Hi,
I am new to EJB and hope someone could help me with this.
I am trying to use ejb3 stateless bean with hibernate 3.1.
In the stateless bean I get a SessionFactory by
SessionFactory sf = (SessionFactory) new InitialContext().lookup("java:/hibernate/SessionFactory");
and from there I open a session:
Session session = sf.openSession();
Then I do some work using this session object. After than I close the session by:
session.close();
The problem is that this code can only read from the database. Insert/update/delete are not persisted to the database.
However, If I put the
session.flush() before
session.close(), all CRUD works. I have read some documentations that said it is not necessary to force the flush. Can someone tell me if I should or should not put the flush() everytime before I close the session?
BTW, I have set the persistence.properties with the following:
hibernate.transaction.flush_before_completion=true
hibernate.transaction.auto_close_session=true
thanks!
g