This content has been marked as final. Show 2 replies
Since you're using @Transactional, you're not using EJB3 (SLSB/SFSB).
If you were to convert this JavaBean to a SFSB, for example, the PersistenceContext would be flushed by the EntityManager/container after the persist() method execution.
Not sure how it works with @Transactional and JavaBeans.
When using SMPC, I know you can set the |flushModeType=MANUAL| and flush the PersistenceContext yourself. I'm not sure if this will work or not with JavaBeans, however. This is obviously similar to what you're doing above with session.flush().
You're not calling any setter methods on the event entity instance... I'm assuming your table does not have any not null columns (except maybe for the identity column)?
Does your code work if you convert to EJB3??
Here is an example using a JavaBean with Hibernate from the hibernate Seam example:
public void getBookings()
bookings = bookingDatabase.createQuery("select b from Booking b where b.user.username = :username order by b.checkinDate")
At the moment we're using a simple POJO to do the job.
I think manual flush won't work, since when I called entityManager.flush before using the session, it would end up doing an exception (not possible to flush).