-->
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: Problems using hibernate
PostPosted: Tue Jun 01, 2004 4:17 pm 
Newbie

Joined: Tue Jun 01, 2004 4:07 pm
Posts: 2
Hi folks! I'm using last Hibernate and HibernateSync (eclipse plugin) last stable releases and Eclipse 2.1 last stable release.
To try hibernate, a created a simple Email table on database with two primary key attributes: Email and Username.
Then i got correct access to data base using Hibernate features with the following code:

...
_RootDAO.initialize();
EmailDAO dao = new EmailDAO();
Email email = new Email();
email.setEmailEmail("teste");
email.setUserUsername("rocha");
...

After that I tried to change the email set parameters by using variables like user and email. So, the code looked like this:

...
_RootDAO.initialize();
EmailDAO dao = new EmailDAO();
Email email = new Email();
email.setEmailEmail(email);
email.setUserUsername(user);
...

Then, when I executed this code, I got the following exception error:
exception

javax.servlet.ServletException: identifier of an instance of socManager.hibernate.Email altered from socManager.hibernate.Email@18ef117 to socManager.hibernate.Email@18ef117
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


root cause

net.sf.hibernate.HibernateException: identifier of an instance of socManager.hibernate.Email altered from socManager.hibernate.Email@18ef117 to socManager.hibernate.Email@18ef117
net.sf.hibernate.impl.SessionImpl.checkId(SessionImpl.java:2631)
net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2454)
net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2447)
net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2249)
net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2228)
net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
socManager.hibernate.vo._BaseRootDAO.commitTransaction(_BaseRootDAO.java:151)
socManager.hibernate.vo._BaseRootDAO.save(_BaseRootDAO.java:541)
socManager.hibernate.vo.BaseEmailDAO.save(BaseEmailDAO.java:50)
socManager.action.RegisterAction.execute(RegisterAction.java:76)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


Thanks for the help!
JRocha


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 5:59 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You cannot alter the id of an instance attached to a session.

_________________
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.