http://openjpa.apache.org/entity-enhancement.html
-Donald On 5/25/10 9:15 PM, Trenton D. Adams wrote: > Build time enhancement? > > ----- "C N Davies" <[email protected]> wrote: > >> From: "C N Davies" <[email protected]> >> To: [email protected] >> Sent: Tuesday, May 25, 2010 7:32:11 PM GMT -07:00 US/Canada Mountain >> Subject: RE: Inappropriate error message >> >> I raised this point about a year ago, this seems to be a catch all >> error because I would also get it on null fields intermittently when >> there was no DB constraint in effect. This was fixed by build time >> enhancement, but if you have a DB constraint then it doesn't seen to >> fix it as you have reported. It doesn't appear to happen in 2.0. >> >> Chris >> >> >> >> -----Original Message----- >> From: Trenton D. Adams [mailto:[email protected]] >> Sent: Wednesday, 26 May 2010 10:10 AM >> To: [email protected] >> Subject: Inappropriate error message >> >> I was getting the following error with openjpa 1.2.1... >> <openjpa-1.2.1-r752877:753278 fatal user error> >> org.apache.openjpa.persistence.InvalidStateException: Encountered >> unmanaged object in persistent field >> "org.adamsbros.rmi.ledger.journal.JournalEntry.journalType" during >> flush. However, this field does not allow cascade persist. Set the >> cascade attribute for this field to CascadeType.PERSIST or >> CascadeType.ALL (JPA annotations) or "persist" or "all" (JPA orm.xml), >> or enable cascade-persist globally, or manually persist the related >> field value prior to flushing. You cannot flush unmanaged objects or >> graphs that have persistent associations to unmanaged objects. >> >> >> JournalEntry.journalType defined as... >> @ManyToOne >> @JoinColumn(name = "journal_type", referencedColumnName = >> "journal_type", >> nullable = false, table = "journal") >> >> JournalType constructor was like this... >> @Id >> @Column(name = "journal_type") >> private String journalType; >> >> @Column(name = "description") >> private String description; >> >> public JournalType() >> { >> } >> // empty as you can see >> public JournalType(final String journalType) >> { >> } >> >> Keep in mind that I do not want cascading to occur with the >> journalType in JournalEntry, as I will manage them separately. >> >> As a result, creating a new JournalType would always result in empty >> instance variables. I would have expected something like this from >> the postgresql db... >> open_accounting=> INSERT INTO journal_types VALUES(null, null); >> ERROR: null value in column "journal_type" violates not-null >> constraint >> >> But instead I get the obscure error about unmanaged objects. >> >> Not sure if something similar would happen in openjpa 2, as openejb is >> not yet configured to use it. But, if it does do the same thing, I >> would highly recommend changing something. This took me about 20-30 >> minutes to see, maybe longer. I was trying to compare my entities >> with other entities that were doing the exact same thing, and couldn't >> see any problems. It just seemed so odd. And it was all because my >> constructor was not doing it's proper initialization of the instance >> variables, from the values passed in. >> >> Would you like me to post a bug report? >
