> void reset(){
> q = em.createNamedQuery("deleteAll").executeQuery();
> em.clear();
> em.flush();
> }
One observations:
You should use executeUpdate() instead of executeQuery() to execute the
query
glassfish_at_javadesktop.org wrote:
> inserting...
>
> simple case below:
>
> @Stateful
> public class MyBean {
> @NamedQuery(name="deleteAll", query="delete from MyObj m");
>
> public void init(){
> MyObj o=new MyObj(1); // where MyObj is a class annotated with @Entity with a single value that is the primary key
> em.persist(o); // ***
> }
>
> public void myFunc(){
> // do something
> }
>
> void reset(){
> em.createNamedQuery("deleteAll").executeQuery();
> em.clear();
> em.flush();
> }
> }
>
>
>
> i then have an external app (some junit tests) that do this repeatedly.
>
> init();
> myFunc();
> reset();
>
>
> On the second pass it fails at the em. persist() with EntityExistsException even though the record isn't in the database, but is obviously still cached...
> [Message sent by forum member 'jsl123' (jsl123)]
>
> http://forums.java.net/jive/thread.jspa?messageID=220593
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>