-->
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.  [ 1 post ] 
Author Message
 Post subject: Sample code to prevent NonUniqueObjectException
PostPosted: Fri Oct 13, 2006 12:38 pm 
Beginner
Beginner

Joined: Thu Jul 06, 2006 11:09 pm
Posts: 25
Guys (especially from Hibernate team),


Can you please insert some code to prevent the NonUniqueObjectExcpetion? I've been trying to use the following but without any luck:

Scenario 1:

// get entity from DB.

// change values.

// update() -> throws NonUniqueObjectException


Scenario 2:

// get entity from DB.
// evict() entity.

// put to HttpSession for later editing.
// get entity from HttpSession and assign new values.

// merge() with Session -> looks like nothing happens here.
// update() or delete() throws NonUniqueObjectException


I forgot most of my trials, but every time I test it, it always throws the same exception.

I have to use the session.update() to separate it from session.save() base on my application logic. This adds validation for new and old persisted objects.

My Application architecture:

Hibernate (Generic DAO Layer)
EJB (Session Facade)
Remote EJBs
JNDI
ServiceLocator
Struts (Controller)
JSP (View)

I'm using Hibernate 3.2 cr5 and Annotations 3.2.0 CR3

_________________
Don't forget to rate.


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

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.