openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Trenton D. Adams" <tr...@trentonadams.ca>
Subject openjpa-1.2.1 partial commit problem
Date Thu, 27 May 2010 04:40:45 GMT
Hi Guys,

I am not yet using the build time enhancer, as it currently blows up on one of my objects,
as noted in another message to the list.  So, it's sticking to runtime subclassing.

I'm having the oddest problem.  I am using EJB3, and have a method that REQUIRES_NEW for the
transaction.  It works fine like that, but as soon as I remove that attribute, to get the
default transaction attribute, my records are only partially committed, literally.

So, what I'm trying to do, is 
1. put a journal entry in with the message "pre commit entry" in it's own transaction, to
make sure something is entered in, in case something happens that blows up the rest of the
commit process.  That way someone knows why the serial column has a missing journal number.
2. add some entity objects to the journal entry, as a collection
3. merge the journal entry again with objects in the collection

That's fine, but I decided to remove the REQUIRES_NEW, just to see if my unit tests would
fail.  I found out really quickly that only one item of the collection is being persisted
to the database.

I am effectively going like this (pseudo code)...

--- method with REQUIRES_NEW
            entityManager.persist(journalEntry);
            entityManager.flush();  // if this flush is removed, it works without REQUIRES_NEW,
but not otherwise.

--- method that calls method with REQUIRES_NEW
            journalEntry = new JournalEntry(
                ledgerBroker.getJournalType(), "pre commit entry");
            sessionContext.getBusinessObject(
            RIJournalEntryManager.class).persistMethod(journalEntry);
            journalEntry.addItem(blah);
            journalEntry.addItem(blah);
            entityManager.merge(journalEntry);
            entityManager.flush();

It seems to me that this is a bug in openjpa, but I cannot be certain, as I'm VERY new to
EJB/JPA.

Mime
View raw message