dev@glassfish.java.net

Re: TransactionRequiredException for UPDATE query ?

From: Arun Gupta <Arun.Gupta_at_Sun.COM>
Date: Fri, 26 Oct 2007 05:55:16 -0700

>> This is not an issue if I replace updateDescription with another query
>> that uses only SELECT. Do I need special transactions when UPDATE
>> query is invoked ?
> Unlike JDBC which has something like auto-commit, there is no such
> facility in JPA. So, user must begin a transaction before updating the
> database using JPA APIs. In your case, you need to add bracket the
> update by a pair of em.getTransaction().begin() and
> em.getTransaction.commit().
Perfect, this is what I was looking for.

I wish there were simpler "Hello World" samples based on your blog.

Thanks,
-Arun
>
> More described here [1].
>
> Thanks,
> Sahoo
>
> [1]
> http://weblogs.java.net/blog/ss141213/archive/2005/12/entitymanagerpe_1.html
>
>>
>> I could not find any reference in the JavaEE5 tutorial
>> (http://java.sun.com/javaee/5/docs/tutorial/doc/bnbtl.html#bnbud) on
>> this topic.
>>
>> -Arun
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>

-- 
Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta