OpenJPA

Cookbook

To log SQL statements from OpenJPA, you could use a value for openjpa.Log similar to the folllowing:

DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE

Hibernate

Testing

Cookbook

To log the value of bind variables in SQL statements:

log4j.logger.org.hibernate.type=DEBUG

OpenJPA to Hibernate migration

Areas to look at:

  • Implicit joins in HQL/JPQL statements - the resulting JOIN type generated by the underlying JPA framework differs between OpenJPA and Hibernate
  • LazyInitializationExceptions, caused by different default fetch types (lazy vs eager) between the two JPA frameworks
  • Differences between the handling of primitives vs object types as parameters to queries - OpenJPA allows primitives but Hibernate does not
  • Multiple fields mapped to the same column using @Column annotations. OpenJPA allows this, but Hibernate does not (will throw HibernateMappingException: Repeated column in mapping for entity)