Wednesday, April 8, 2009

JPA OneToMany using FetchType.EAGER

Scenario: Want to insert multiple address to basket header with a unique basketId.

BasketHeader.java @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinColumn(name = "basketId", nullable = false) public Set getBasketBillTos() { return basketBillTos; }
By specifying @JoinColumn basketId is set as the foreign key column name for the relationship. Otherwise a default name will be given for the foreign key column. If you are mapping to an existing database schema you will typically require setting the @JoinColumn, otherwise the defaults are probably fine. Implementation on action
Set basketBillToSet = new HashSet(); basketBillToSet.add(basketBillTo); basketHeader.setBasketBillTos(basketBillToSet);

1 Comment:

Anonymous said...

Download Casino tyuueooru
Online Casino Games
So, it is vital to be able to find a right online casino website for you if you don't want your online gambling experience to be annoying and regretting.
[url=http://www.nhgaa.org/]Online Casinos Free[/url]

No matter it's an absolutely free online casino or real money requiring online gambling, the true gambling pleasure can only be expected if the website you choose to enter is good enough to offer you exactly what you're looking for.
http://www.nhgaa.org/ - Web Casino
So, it is vital to be able to find a right online casino website for you if you don't want your online gambling experience to be annoying and regretting.