Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » ID of referenced Entity is not updated with CascadeType.ALL
ID of referenced Entity is not updated with CascadeType.ALL [message #757999] Thu, 17 November 2011 10:51
Christoph Laeubrich is currently offline Christoph LaeubrichFriend
Messages: 12
Registered: September 2011
Junior Member
I have the following setup

Class A:
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
long id;
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
--> Set<B> bset;

Class B:
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
long id;



What I do is:
EntityTransaction transaction = manager.getTransaction();
transaction.begin();
A a = new A();
a.bset.add(new B());
manager.persist(a);
transaction.commit();

What happens is, that the id field of B is not updates (it is stored in the DB correctly).

When I use:
EntityTransaction transaction = manager.getTransaction();
transaction.begin();
A a = new A();
B b = new B();
a.bset.add(b);
manager.persist(b);
manager.persist(a);
transaction.commit();
It works as expected and the id field is updated.

My Question is: Is this a bug or is it "to be expected" by the JPA spec?
Previous Topic:EclipseLink Maven repository missing
Next Topic:Must static-weaving be set in the persistence.xml file if static weaving has been performed
Goto Forum:
  


Current Time: Thu Mar 28 13:13:35 GMT 2024

Powered by FUDForum. Page generated in 0.06538 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top