users@glassfish.java.net

Re: why em.persist() immediately inserts data into database?

From: Sanjeeb Sahoo <Sahoo_at_Sun.COM>
Date: Fri, 25 Jun 2010 22:26:15 +0530

To realise the importance of tx.commit(), add the following line after
em.persist() and test:
throw new Exception();


On Friday 25 June 2010 07:56 PM, glassfish_at_javadesktop.org wrote:
> use hibernate.
> auto commit is off, I checked the hibernate logging.
>
> code is like this:
>
> try{
> tx.begin();
> em.persist(entity);
> tx.commit();
> }catch(Exception ex)
> {
> tx.rollabck();
> }
>
> after em.persist() is executed, the data is in my database! tx.commit() seems to be useless here.
>
> Can anyone help me with that please ?
> [Message sent by forum member 'bobxu']
>
> http://forums.java.net/jive/thread.jspa?messageID=475823
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>