File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Persisting second identical object causes ConstraintViolationException? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "Persisting second identical object causes ConstraintViolationException?" Watch "Persisting second identical object causes ConstraintViolationException?" New topic
Author

Persisting second identical object causes ConstraintViolationException?

Andre Brandt
Greenhorn

Joined: Feb 28, 2009
Posts: 1
Hi Forum,

first - I'm new to javaee and ejb3 ;)

I've created a new entity bean which has successfully be deployed on my jboss 5.0.0GA. Persisting new objects does work. (via em.persist(object)) So I wrote a little test to find out, if my unique constraint also work - well, it doesn't seem to/it works too good ...

When adding a second, identical object to my database, I get an ConstraintViolationException. Can someone tell me, where my mistake is?

I thought, that, when catching EntityExistsException that should not happen...

best regard,
Dellerium



entity bean:


Dao bean:




Alok Kushwah
Ranch Hand

Joined: Jul 10, 2007
Posts: 31
Looks like program is trying to insert rows with same id. You can see "Unique Key Voilation" error in thread. Query the database table and you can find out row exist or not.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Persisting second identical object causes ConstraintViolationException?
 
Similar Threads
Could not synchronize database state with session
Problem in persisting Entity with Composite Key
jboss4.0.5.GA ejb3 error while persisiting one to one entity
EJB3:->Connection error occured
Can't commit because the transaction is in aborted state