hibernate

Nico Heid's picture

Using an EntityManagerFactory with JPA, Hibernate and Wicket

If you read the previous article "@OneToMany Relationship with Java, Hibernate and Annotations" you might have noticed some
imperfections in the persistence layer. On the code side we have been
lazy by just using FetchType.EAGER. This of course puts extra stress on
the database, because in our example, for each BlogPost all Comments are
fetched, even though they might not be displayed.


Maybe you played around with the example
version 0.1.1(download tarball).
You might have noticed that if you switch to FetchType.LAZY you will
most likely get a no session or session was closed on certain operations.
Read more

Nico Heid's picture

Java persistence with Hibernate and Annotations

Hibernate is a well known object-relational mapping library (ORM) for Java. It allows you to map entries in your relational database to objects in your Java classes.
Usually this is done by a mapping file written in XML. As this approach is a bit more expensive we will use annotations to map a class to the relating database table.
Based on the Maven tutorial by my colleague Phillip, we will begin with a quickstart archetype and include Hibernate and a MySQL connection. Then we will write a simple data access object (DAO) which maps to the database table we will create. After that we use a class to set up the connection and fill the database with some of our objects.

Note: This is just a superficial glance at Hibernate to get in touch with the framework.
Read more

Syndicate content