-->
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: Unknown entity error in Hibernate during session.saveOrUpdat
PostPosted: Tue Aug 16, 2011 6:36 pm 
Newbie

Joined: Mon Jan 31, 2011 2:24 pm
Posts: 6
Hi All,

I am trying to save data using session.saveOrUpdate(obj). Here obj is a bean object and is returned by calling a method from a class that is in another jar. The bean class is also defined in this jar file.

For e.g in below Market.hbm.xml file, the Market bean is in the jar file and the package points to the jar. In MktPersistance.java, the below error is thrown at saveOrUpdate(). Looks like Market class is not being identified since its in the jar file. Also, the values in obj object are displaying correctly logger.info("\nEntity to be persisted=" + obj).

14:37:01.345 [pool-1-thread-1] ERROR c.a.f.n.o.s.support.MktPersistence - Unknown entity: com.pnd.data.Market


Please let me know how this can be resolved. Thanks a lot for your time.

Code:
   1. Market.hbm.xml 
   2. <hibernate-mapping package="com.pnd.data.Market"> 
   3.     <class name="Market" table="MRKT"> 
   4.   
   5.   
   6. MktPersistance.java 
   7. // data is a Set of Market bean objects. 
   8. for (Object obj : data) { 
   9.             try { 
  10.                 session = HibernateUtil.getSessionFactory().getCurrentSession(); 
  11.                 session.beginTransaction(); 
  12.                 logger.info("\nEntity to be persisted=" + obj); 
  13.                 logger.info("class = "+obj.getClass()); 
  14.   
  15.                 session.saveOrUpdate(obj); 
  16.                 logger.info("\nAfter Save or Update"); 
  17.   
  18.                 session.flush();                 
  19.                 session.clear(); 
  20.                 logger.info("session clear done"); 
  21.                 session.getTransaction().commit(); 
  22.             }   
  23.             catch(RuntimeException ex){ 
  24.                 ..... 
  25.             } 
  26.            } 


Thanks a lot in advance..


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.