Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unknown entity error in Hibernate during session.saveOrUpdate()

 
achsu subra
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.




Thanks a lot in advance..
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shouldn't the package be 'com.pnd.data'?
 
achsu subra
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouter Oet wrote:Shouldn't the package be 'com.pnd.data'?


Hi Wouter,

Thanks for your reply.
Sorry, the package is 'com.pnd.data', I had mistyped it. The same error is still thrown.
Please let me know in case of any suggestions.
 
Waswani Naresh
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you included/mentioned the hbm mapping file in the hibernate config file (hibernate.cfg.xml).

Something like this :

<mapping resource="com/pnd/data/Market.hbm.xml" />

Regards,
Naresh Waswani
 
Andrew Kessel
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use JPA entities, you must mention your entity in "hibernate.cfg.xml" that way:
<hibernate-configuration>
<session-factory>
...
<mapping class="com.pnd.data.Market" />
</session-factory>
</hibernate-configuration>


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic