In this example we are going to see how to use Hibernate Query Language (HQL). This the query language created for Hibernate. It’s syntax is very similar to a normal SQL language but instead of tables it deals with classes and instead of columns it deals with properties or class attributes. And that’s what makes it really suitable to use ...
Read More »Home » Archives for Nikos Maravitsas »
Hibernate Connection Pool configuration with C3P0 Example
This is a tutorial on how to use C3P0 connection pool framework with Hibernate. Basically what a connection pool does is to create a number of connections (a pool of connections) with the database server and keep them idle. Every time a query comes up the application picks one of the pooled connections and uses that to interact with the ...
Read More »Hibernate Logging Configuration – SLF4J + Log4j and Logback
In this example we are going to see how to configure Logging in Hibernate. SLF4J (Simple Logging Facade for Java) is a very nice logging framework that Hibernate uses, in order to output your logs using your favorite logging tool ( log4j, JCL, JDK logging, logback) to your preferred location. We are going to use SLF4J along with log4j and Logback. ...
Read More »Hibernate JBoss Tools Installation in Eclipse + Mapping Generation Example
Generating .hbm.cfg files or creating annotated files to map your classes is always a bit boring and it involves writing a lot of boilerplate code. In Eclipse you can use JBoss Hibernatate Tools, with which you can automatically generate all the files you need to work with Hibernate. In this tutorial we are going to see how to install Hibernate ...
Read More »Hibernate Cascade example
In this tutorial we are going to see the use of the cascade feature of relational databases and how it is applied in Hibernate. This tutorial is based on the previous Hibernate One-to-Many Relationship Example (XML Mapping and Annotation). You can download the Eclipse project from there. So these are the tools we are going to use on a Windows 7 ...
Read More »Hibernate Many-to-Many Relationship with Join Table Example
In the previous tutorial, Hibernate Many-to-Many Relationship Example (XML Mapping and Annotation), we saw how use Hibernate in order to work with classes that have many-to-many relationships. I would strongly recommend to read that tutorial before proceeding to this one. For this tutorial we are going to see how to map the classes with Annotations. So these are the tools ...
Read More »Hibernate Many-to-Many Relationship Example (XML Mapping and Annotation)
In this example we are going to see how to map classes to databases tables which have Many-to-Many relationships. We are going to see the mapping both with XML Mapping and with Annotations. So these are the tools we are going to use on a Windows 7 platform: JDK 1.7 Maven 3.0.5 Hibernate 3.6.3.Final MySQL JDBC driver 5.1.9 Eclipse 4.2 ...
Read More »Hibernate One-to-Many Relationship Example (XML Mapping and Annotation)
In this example we are going to see how to map classes to databases tables which have one-to-many relationships. We are going to see the mapping both with XML Mapping and with Annotations. So these are the tools we are going to use on a Windows 7 platform: JDK 1.7 Maven 3.0.5 Hibernate 3.6.3.Final MySQL JDBC driver 5.1.9 Eclipse 4.2 ...
Read More »Hibernate One-to-One Relationship Example (XML Mapping and Annotation)
In this example we are going to see how to map classes to databases tables which have one-to-one relationships. We are going to see the mapping both with XML Mapping and with Annotations. So these are the tools we are going to use on a Windows 7 platform: JDK 1.7 Maven 3.0.5 Hibernate 3.6.3.Final MySQL JDBC driver 5.1.9 Eclipse 4.2 ...
Read More »Hibernate 3 with Maven 3 and MySQL 5 Example (XML Mapping and Annotation)
In this example we are going to see how to create a Java program that uses Hibernate Framework to store a Student tuple in a MySQL database. We are going to use Maven to create and build our project. We are going to see how to work both with XML mapping and Annotations to map the Class to the database table. So ...
Read More »