Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forums@NamedQuery "DELETE FROM"
https://www.eclipse.org/forums/index.php/mv/msg/151914/478235/#msg_478235
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]]>Enrico2009-08-06T09:00:45-00:00Re: @NamedQuery "DELETE FROM"
https://www.eclipse.org/forums/index.php/mv/msg/151914/478817/#msg_478817
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.
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]]>Thomas Haskes2009-08-07T06:38:31-00:00