Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Object Relational Mapping
Joined: Aug 05, 2011
Nov 30, 2012 02:50:59
i was try to generate the org.hibernate.NonUniqueObjectException exception , but there is not exception generated . there is follwing code
User user1 = new User(); user1.setId(9); user1.setLoginName("HardeepSingh"); session.saveOrUpdate(user1); session.evict(user1); User user = (User) session.get(User.class, 9); user.setLoginName("singhHardeep0013"); user.setPassword("paswd"); user.setName("Hardeep Singh"); user.setEmailAddress("Hardeepsingh.email@example.com"); user.setVerified(true); user.setLassAccess(new Date()); user.setRegestrationTime(new GregorianCalendar());
With Regards :-
Joined: Mar 07, 2010
Dec 12, 2012 19:08:22
You cannot have 2 objects with the same persistent id in the context at the same time or you get this exception. In your example this does not happen.
Here is a blog that explains it a bit
How To Ask Questions
Read before you PM me
I agree. Here's the link:
Problem in Adding Attributes to TLD file
Test duplication on db with exception...am I on the right track?
how to refactor this method ?
Doubt in an Object instance while using evict() method
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013