[jboss-user] [EJB 3.0] - ejb3 - setList(Set<MyObjs> list) - fails to persist.
hanasakijiji
do-not-reply at jboss.com
Sat Mar 10 01:20:45 EST 2007
reload the instance and call getList returns empty list.
|
| @OneToMany(
| cascade= {CascadeType.ALL, CascadeType.ALL}
| fetch=FetchType.EAGER)
| @JoinTable(
| name="myjointable",
| joinColumns={ @JoinColumn(name="owner_fk") }
| inverseJoinColumn=@JoinColumn(name="owned_fk")
| public Set<OwnedItem> getOwnedItems() {
| return(ownedItems);
| }
|
| private Set<OwnedItem> ownedItems = new HashSet<OwnedItem>();
|
////
Q1: the cascade type in OneToMany can either be an array, as above, or a
single item. Both compile. Both are in the hibernate annotations docs;
however I do not find an explanation of the types or when to use an
array and when not to (also how many items to put in the array and their
meaning). Could someone explain this and point to reference docs?
Q2: the above class was instantiated and persisted fine. Now it is
loaded with an Query and the following is done:
myObject.getOwnedItems.add(unsavedNewOwnedItem);
em.flush();
- Does the unsavedNewOwnedItem need to be persisted first?
- what happens if it is not persisted yet?
- what happens if it is already persisted?
I have tried this withe the new owned item instanced already saved and
not yet saved/persisted. The join table appears to be updated; however,
when the class is reloaded, by a call to a new session bean (used by a
subsequent call to a servlet), the Set is empty. It is expected to
contain the item that was added.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4026839#4026839
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4026839
More information about the jboss-user
mailing list