I have a prent object peron.
This object is mapped as a onetomany with two sets of children.
The children objects are phonenumber and address.
They are mapped as a list and manytoone, so the relationship is bidirectional.
The cascade is all.
If I run the following code in a SLSB the behavior is very add.
Person person = new Person ("joe", "smith");
person.getAddresses().add(new Address("1111", "test"));
person.getAddresses().add(new Address("2222", "test"));
person.getAddresses().add(new Address("3333", "test"));
person.getPhoneNumbers().add(new PhoneNumber("111", "1234567"));
System.out.println("Addresses Count : " + person.getAddresses().size());
System.out.println("Phone Number Count : " + person.getPhoneNumbers().size());
entityManager.persist(person);
entityManager.flush();
entityManager.refresh(person);
System.out.println("Addresses Count After : " + person.getAddresses().size());
System.out.println("Phone Number Count After : " +
person.getPhoneNumbers().size());
Now when this is run the logs show :
Addresses Count : 3
Phone Number Count : 1
Addresses Count After : 3
Phone Number Count After : 3
Whatever the number of records in the address list it creates the same number
in the phonenumber list by duplicating the first phonenumber object over and
over until it matches the size of the address list.
If I make one phonenumber and two addresses, jboss persists two address, but
copies the phone number twice.
I am sure this is a bug as the counts are right before I call persist, but
change after jboss returns control.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3934393#3934393
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3934393
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user