dev@glassfish.java.net

Re: TransactionRequiredException for UPDATE query ?

From: Lance J. Andersen <Lance.Andersen_at_Sun.COM>
Date: Fri, 26 Oct 2007 09:20:22 -0400

i have a couple web based examples that i can tie into a hello world
example and i will post it as a blog

Arun Gupta wrote:
>>> 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
>>
>