-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: could not synchronize
PostPosted: Fri Feb 09, 2007 6:40 pm 
Newbie

Joined: Fri Jan 26, 2007 3:51 pm
Posts: 16
Hi there,

I'm testing a small app while trying to learn Java Persistence . Just a newbie at this...

In my first unit of work I create and persist a ScheduledCourse object like so:

EntityManagerFactory emf = Persistence.createEntityManagerFactory("scholastic");

//First Unit of work
EntityManager em1 = emf.createEntityManager();
EntityTransaction tx1 = em1.getTransaction();
tx1.begin();
...
ScheduledCourse scheduled_course = new ScheduledCourse(...);
...
em1.persist(scheduled_course);
...
tx1.commit();
em1.close();
emf.close();

Up to this point everything is fine.
In my second unit of work I try to remove the instance of that object from the database:

EntityManagerFactory emf2 = Persistence.createEntityManagerFactory("scholastic");
EntityManager em2 = emf2.createEntityManager();
EntityTransaction tx2 = em2.getTransaction();
tx2.begin();
...
//Retrieve the entity instance from the dbase and make it persistent again
ScheduledCourse sc = em2.find(ScheduledCourse.class, new Long(1));
...
em2.remove(sc);
...
tx2.commit();
em2.close();
emf2.close();

When the delete is attempted, I get this error message:

[java] Could not synchronize database state with session
[java] org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update

Could someone please explain what I may have done wrong? Why isn't the deletion occurring properly?

Alan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 6:31 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you do not provide enough information, also there is no need to create several time the emf, it should be cached somewhere

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.