|
Re: @NamedQuery "DELETE FROM" [message #478817 is a reply to message #478235] |
Fri, 07 August 2009 06:38 |
Thomas Haskes Messages: 147 Registered: July 2009 |
Senior Member |
|
|
In which Environment are you running EL. If you are in a Java ee and run
you session beans container managed, the the EE container should handle
transactions for you. If you are in a JavaSE environment, you need to
deal with transactions yourself. This is why EL is complaining that
there is no transaction active. The select query is only reading, and
reading access does not require a transaction.
Try the following:
You need to encapsulate all your writing queries with a transaction.
em.getTransaction().begin();
em.createNamedQuery("YourDeletingNamedQuery").executeUpdate();
em.getTransaction().commit();
HTH
Tom
P.S. If you are running container managed transactions on an
Applicationserver (e.g. JBoss), i think there is a configuration
problem, because the container should handle the transactions for you.
Enrico schrieb:
> Hi all,
>
> I have a @NamedQuery that should delete fomr DB rows basing on my
> conditions.
> When I try to run the query, the following error occour:
>
> JAVA.LANG.ILLEGALSTATEEXCEPTION: EXCEPTION DESCRIPTION: NO TRANSACTION
> IS CURRENTLY ACTIVE
>
> Note:
> 1. i have no problem with the "SELECT" @NamedQuery
> 2. if I try to run the SQL of the created @NamedQuery from outside, the
> rows are correctly removed.
>
> What can be the problem?I need to set somethink on persistece.xml
> configuration?There is additional task to do for delete query?
>
> BR,
> Enrico
|
|
|
Powered by
FUDForum. Page generated in 0.03436 seconds