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
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…
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. 😀
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.
Finally, there’s another very important peculiarity of what does Cialis that brings it so high above its alternatives. It is the only med that is available in two versions – one intended for use on as-needed basis and one intended for daily use. As you might know, Viagra and Levitra only come in the latter of these two forms and should be consumed shortly before expected sexual activity to ensure best effect. Daily Cialis, in its turn, contains low doses of Tadalafil, which allows to build its concentration up in your system gradually over time and maintain it on acceptable levels, which, consequently, makes it possible for you to enjoy sex at any moment without having to time it.