Hibernate Tips and Solutions

Hibernate tips and tricks
==================

This is just my past compilations of some tips and solutions to common errors in using Hibernate.


1. org/slf4j/impl/StaticLoggerBinder error

If you happen to receive this error...

Replace the slf4j-api-1.5.3.jar(hibernate-distribution-3.3.1.GA) to the following files and it should work...

slf4j-nop-1.5.6.jar
slf4j-api-1.5.6.jar

You can download these files at http://www.slf4j.org/download.html

2. QuerySyntaxException: (simply means "table is not mapped properly").

The first thing you need to do is check your Hibernate mapping in your xml file.




your database contains a table called "hibernatetable" which you must define in your xml file.

Of course you need to create your hibernateTableClass

Example of the hibernateTableClass (only one attribute = id)




Then just make sure you call the correct Object in your query...




3. Another Big Problem is how to deal with complicated joins.

One thing I noticed when your query becomes complicated is that the program starts to crawl and well harder to read. Good thing there is the native SQL query!



Some examples:



コメント

人気の投稿