Archive for the \'Hibernate\' Category

Hibernate Data View Objects Annotations

In my last article Hibernate Data View Objects I showed some basic ideas, of how filling up view objects can be done with the help of hibernate in a more or less automatic way.
Meanwhile I created some little API classes, that can be used to annotate view objects.

Hibernate DataViewObjects

When working with Hibernate and nested domain object models, it can be a performance problem when trying to display several (including nested) properties in a view. Usually for such cases the use of view objects is practical.
This is the first scetch of my idea to automate population of view objects with hibernate.

Hibernate Deeper OrderBy

Hibernate unterstützt in der Criteria API bei der Angabe von Properties für Criterions oder auch Sortierungen lediglich die Angabe von Properties der Tiefe 1.
Beispielsweise ist criteria.addOrder(Order.asc("id")) möglich, jedoch criteria.addOrder(Order.asc("parent.id")) oder gar criteria.addOrder(Order.asc("parent.parent.id")) nicht möglich.
Um diese Abbilden zu können, muss man sich einiger Joins oder Aliase bedienen.
Im folgenden wird dies anhand der Sortierung gelöst.

Spring Hibernate Snipplets

Few snipplets making the usage of hibernate with annotations within spring easier.

Hibernate Criteria to SQL Translation

Some time ago I posted a helper-class to transform HQL to SQL for debugging purposes. Meanwhile I found out how also to transform Criterias to SQL.

Hibernate Statistics JSP Reloaded

Some time ago I posted a JSP-Page for displaying Hibernate-Statistics within an application. Meanwhile I also posted some Code to translate HQL queries to SQL. Now I merged both together to a new version of the Hibernate Statistics page that also displays SQL statements, and it’s still not a code-beauty 😉

Hibernate HQL to SQL Translation

For debugging purposes using hibernate it’s often usefull to have the generated SQL query to an appropriate HQL query.
But setting the hibernate configuration hibernate.show_sql to true leads to logging any query made within an application (which can be a lot in some applications). With the following class the hibernate API is used to generate the correct SQL query from a given HQL query and can be used anywhere to log the generated query.

Hibernate and Spring DAO Templates

Häufig genutzt, einmal notiert: Interface und abstrakte Implementierung von DAOs zur Benutzung mit Spring und Hibernate.