-->
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.  [ 5 posts ] 
Author Message
 Post subject: cannot update/save
PostPosted: Wed Sep 16, 2009 6:48 am 
Newbie

Joined: Mon Aug 03, 2009 3:10 pm
Posts: 7
Hello
i get an error when trying to save/update information into db.
i used debug and traced the problem in hibernateTemplate class:
Code:
..
//create session
      System.out.println("session: " +session);
//begin transaction
      System.out.println("begin transaction...");
      Serializable id = session.save(entity);

      session.getTransaction().commit();
   ...


in Console the last message is "begin transaction..." and then i get this error:
Quote:
org.hibernate.MappingException: Unknown entity: domain.blabla
org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)
org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1338)
org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:98)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
$Proxy0.save(Unknown Source)
hibernate.HibernateTemplate.save(HibernateTemplate.java:84)
services.persistence.hibernate.HibernateServiceImpl.saveX(HibernateServiceImpl.java:41)
services.business.ServiceImplementation.saveX(ServiceImplementation.java:37)
web.MyServlet.save(MyServlet.java:118)
web.MyServlet.doPost(MyServlet.java:283)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)




The data that i want to update the db with exits, but it just not save. The domain.blabla is mapped in hibernate xml config file
Any ideas? thank you


Top
 Profile  
 
 Post subject: Re: cannot update/save
PostPosted: Wed Sep 16, 2009 9:00 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Quote:
org.hibernate.MappingException: Unknown entity: domain.blabla


Looks like a class references this particular class, but it's not included as an added annotated object or in your hibernate mapping file, depending upon the approach your are taking. Can you see where this class is mapped? It might be a case sensitivity problem. I hate to see classes that start with lower class names.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: cannot update/save
PostPosted: Wed Sep 16, 2009 9:16 am 
Newbie

Joined: Mon Aug 03, 2009 3:10 pm
Posts: 7
i have the hbm.xml class created. in hibernate config xml i declare:
Code:
<mapping resource="dfr/test/domain/Machine.hbm.xml" />


in debug i can see that this Machine.hbm.xml is recognized.

And by the way...previous to the err ahead i have this:
Quote:
DEBUG DefaultSaveOrUpdateEventListener(entityIsDetached:205) - updating detached instance
ERROR StandardWrapperValve(invoke:260) - Servlet.service() for servlet MyServlet threw exception
org.hibernate.MappingException: Unknown entity....


I can show data from database, create the session, begin transaction, but when at the commit it breaks.


Top
 Profile  
 
 Post subject: Re: cannot update/save
PostPosted: Fri Sep 18, 2009 8:43 am 
Newbie

Joined: Mon Aug 03, 2009 3:10 pm
Posts: 7
problem solved: had the ..entity-name=".." declare in the hbm.xml class. after i deleted it, it worked.


Top
 Profile  
 
 Post subject: Re: cannot update/save
PostPosted: Fri Sep 18, 2009 7:26 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Sometimes small issues are the toughest ones to find. So glad you got this working!

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.