1) What is Hibernate? Hibernate is a powerful, high performance object/relational persistence and query service. This lets the users to develop persistent classes following object-oriented principles such as association, inheritance, polymorphism, composition, and collections. Hibernate eliminates developers to spend more time on writing the native SQL queries and understand the complete underlying database persistence mechanism. [...]
Archive | Database RSS feed for this section
How to solve QuerySyntaxException (table is not mapped) in hibetnate?
December 1, 2008
The following exception is very common if you are the beginner for hibernate. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: book is not mapped [from book] at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:158) at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87) at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70) at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:255) at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056) [...]
Pagination using Hibernate and JSP
October 3, 2008
If the result set is large, then having the entire result set in memory will not be feasible. With large result sets, you cannot afford to have them in memory. In such case, you have to fetch a chunk of data at a time (query based paging). The down side of using query based paging, [...]
Many-to-One Relationship in Hibernate Mappings – Example
September 28, 2008
This example program demonstrates how to write the many-to-one accociations using the hibernate mapping files. Book.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 package hibernate; import java.io.Serializable; public class Book implements Serializable{ [...]
Difference between hibernate’s save,update and saveOrUpdate() methods
September 27, 2008
Difference between hibernate’s save,update and saveOrUpdate() methods Hibetnate has set of methods for saving and updating the values in the database. The methods look like same and difficult to differentiate between them if you are not understanding them clearly. If you understand the hibernate mechanism clearly, it doesn’t execute the SQL statements directly to manipulate [...]
Configure MySql database with Hibernate mappings
July 29, 2008
Configure MySql database Configuring MySql database with hibernate is the same as with other databasses.The only difference will be connection url and the database dialect to be specified in the configuration file. This tips provides a basic example configuration file for configuaring the MySql with hibernate. But it doesn’t explain you installing the MySql database. [...]
Collection Mapping in Hibernate : one-to-many
July 26, 2008
one-to-many class mapping This article explains how to map two classes in collection mapping. In this example one Author object has the list of Book objects. Both the classes are mapped and will be inserted together into the database. Here this example uses Bag as the collection type. Other collection types available are Set,List,Array. Look [...]
Comparison operators in Hibernate
July 26, 2008
Comparison operators HQL supports all the operators used in the SQL language. But, Criteria API doesn’t support the arithmetic expressions. Apart from that, it is easy to use other operators in the Criteria API itself. This tips provides few basic example programs on using the operators. JavaBeatHibernateExample.java 1 2 3 4 5 6 7 8 [...]
NULL and NOT NULL comparison in the Hibernate API
July 26, 2008
null and not null check While checking for the null and not null values in the Hibernate API, we have to be careful and there is chance for misunderstanding. This tips explains how to compare the null values in the Hibernate query. In Java language, if object==null will return the proper value if it is [...]
How to use named parameters and named query in Hibernate?
July 26, 2008
Named Parameters in Hibernate Query There is two types of query parameters binding in the Hibernate Query. One is positioned parameter and another one is named parameter. But, hibernate recommend to use the named parameters since it is more flexible and powerful compare to the positioned parameter. Here we will look into the named parameter [...]







February 13, 2009
10 Comments