Ropardo Sowftware development company

Experience software development with ROPARDO S.R.L.

RSS Feed
RSS Feed
  • Home
  • About ROPARDO S.R.L
  • Our websites

Hibernate MappingException error

When using Hibernate in a project, correct configuration of the service is a must, otherwise errors won’t let you alone :) Following the basic steps of configuration, I found myself facing an error, of which cause made no sense on the moment because I thought my configuration were correct.

In the hibernate.cfg.xml file, sessionFactory was created, with the necessary details to connect to the database and I had the mapping details for mapping the domain objects to the database tables.
After creating all the hbm.xml files needed, previously declared in the configuration file, I just had to run the project in tomcat and see the result of the logic implemented in controller.
This is the error that appeared:


DEBUG DefaultSaveOrUpdateEventListener(entityIsDetached:205) - updating detached instance
ERROR StandardWrapperValve(invoke:260) - Servlet.service() for servlet TestServlet threw exception
org.hibernate.MappingException: Unknown entity: domain.ro.test.TestServlet
org.hibernate.impl.SessionFactoryImpl.getEntityPersister
(SessionFactoryImpl.java:550)
org.hibernate.impl.SessionImpl.getEntityPersister
(SessionImpl.java:1338)
org.hibernate.event.def.AbstractSaveEventListener.
saveWithGeneratedId(AbstractSaveEvent
.........

Debuging the application and displaying in the console of Eclipse Hibernate details, I saw that it recognized at initialization about the hbm.xml files, but when having to commit data, so using them in particular, it did not recognized them anymore, throwing the error above…

”org.hibernate.MappingException”

An example from an hbm.file:

class name=”test.domain.TestConfig” table=”test_config” entity-name=”TestConfig”

At first glance, the code looked correct to me, thus I couldn’t understood the error. After documenting about this error, I found that a possible problem was setting the entity-name of a annotation class in hbm.xml file. Which in my case deleting the entity-name from the xml file was the sollution. :D

The element simply maps the object with the coresponding database table. Creates a tie between the elements from your object and the fields from the database table. The Class element has some properties the programmer cand choose to make use of, or not. More details HERE.

Entity-name should be used when you have a class and want to map it to more than one table. For instance, there are two tables that have fields in common. Instead of creating two different persistence classes, you use only one, with help from the “entity-name” property you can distinguish which fields are from which table.

entity-name=”TestConfig1″
…
entity-name=”TestConfig2″

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Get Shareaholic
Tags: entity-name Hibernate Java MappingException

 Posted in: Java
September 18, 2009 | Gabriela Radu | No Comments

Leave a Reply

 


  • « Previous post
  • Next post »
  • Recent Posts

    • Installing PyGraphviz on Windows
    • Convert python object to XML representation
    • Liferay Portlet Development
    • Norway Road Show 2011 private meeting invitation
    • Oracle OpenWorld 2011
  • Ropardo is Hiring

  • Subscribe

    • Add to Google Reader or Homepage Add to netvibes TopOfBlogs
  • Recent Comments

    • Rajkumar Pomaji on Bluetooth PC Remote Control
    • Stelian Morariu on GWT 2.1 – Uploading a file using the RPC mechanism
    • Sergio on GWT 2.1 – Uploading a file using the RPC mechanism
    • Artem on Liferay: Deployment will start in a few seconds… and how to realy start
    • rkd80 on GWT 2.1 – Uploading a file using the RPC mechanism
  • Archives

    • November 2011 (1)
    • September 2011 (4)
    • July 2011 (3)
    • June 2011 (2)
    • May 2011 (4)
    • April 2011 (4)
    • March 2011 (3)
    • February 2011 (2)
    • January 2011 (2)
    • December 2010 (1)
    • November 2010 (4)
    • October 2010 (4)
    • August 2010 (3)
    • July 2010 (3)
    • June 2010 (6)
    • May 2010 (8)
    • April 2010 (7)
    • March 2010 (9)
    • February 2010 (6)
    • January 2010 (5)
    • December 2009 (7)
    • November 2009 (9)
    • October 2009 (10)
    • September 2009 (14)
    • August 2009 (10)
    • July 2009 (1)
    • June 2009 (1)
    • May 2009 (1)
    • April 2009 (1)
    • March 2009 (1)
    • October 2008 (3)
    • October 2007 (3)
    • July 2007 (4)
    • June 2007 (1)
    • May 2007 (3)
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
  • Categories

    • News (15)
    • Ropardo Team (8)
    • Ropardo Products (6)
      • File Tracking Client (4)
      • iManagement (2)
    • Software Development (83)
      • Microsoft.NET (22)
      • Java (40)
      • Oracle (8)
      • Power Builder (3)
      • Liferay (5)
      • Lotus Notes (9)
      • xWiki (4)
    • System Adminstration (13)
      • Linux (10)
      • Windows (3)
    • Programming (1)
    • Uncategorized (3)
    • Databases (10)
      • MSSQL (5)
      • PostgreeSQL (3)
    • Microsoft.NET (1)
    • Web Development (28)
      • ASP/ASPX (3)
      • Content Management Systems (1)
      • HTML/CSS (5)
      • Javascrip/AJAX (8)
      • PHP (7)
    • Oracle E Business Suite (6)
  • Tags

    .NET ajax blog C# certification client CMS control css database Debugging django Domino Eclipse extension file tracking filter fun gentoo google Hibernate how to html image iManagement import Java javascript jQuery liferay Linux Lotus Notes lotus script Oracle Oracle BI Publisher 11g PHP portal PostgreSQL powerbuilder Python SQL Telerik velocity xml Xwiki

© 2010 ROPARDO s.r.l..

Powered by WordPress. Styled by Ropardo