[hibernate-announce] NonUniqueObjectException

Heber Lazcano heber at tralix.com
Tue May 29 18:41:12 EDT 2007


I have the next exception:

org.hibernate.NonUniqueObjectException: a different object with the same
identifier value was already associated with the session

I work with tomcat 5 and hibernate 3.2

I have a  ThreadLocal<Session> threadLocal where put the session and get
it, but each called to tomcat open new session of hibernate...
because the session in threadLocal is null

private static Session getSession() throws HibernateException {
        Session session = threadLocal.get();
        if (session == null || !session.isOpen()) {
            if (sessionFactory == null) {
                rebuildSessionFactory();
            }
            session = (sessionFactory != null) ?
sessionFactory.openSession() : null;
            threadLocal.set(session);
        }
        return session;
}
 
any idea ? what happen this?
Thank you very much.
-- 

*Heber Lazcano*
*/Daemons Developer/*/ /
*Tralix - Everything happens on email.*
/Office:  +52 (442) 2620304/
/Mobile: +52 (442) 1569756/
*/heber at tralix.com <mailto:heber at tralix.com>/*


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-announce/attachments/20070529/aafafc42/attachment.html 


More information about the hibernate-announce mailing list