background preloader

JPA

Facebook Twitter

Java - JPA/Hibernate - Default data. Open Session in View. Sessions and transactions is required reading to understand this pattern.

Open Session in View

This page describes Hibernate 3.1.x and code shown here does not work in older versions. The problem A common issue in a typical (web-)application is the rendering of the view, after the main logic of the action has been completed, and therefore, the Hibernate Session has already been closed and the database transaction has ended. If you access detached objects that have been loaded in the Session inside your JSP (or any other view rendering mechanism), you might hit an unloaded collection or a proxy that isn't initialized. The exception you get is: LazyInitializationException: Session has been closed (or a very similar message).

Java Persistence/Inheritance. An example of inheritance.

Java Persistence/Inheritance

SmallProject and LargeProject inherit the properties of their common parent, Project. Inheritance is a fundamental concept of object-oriented programming and Java. Relational databases have no concept of inheritance, so persisting inheritance in a database can be tricky. Because relational databases have no concept of inheritance, there is no standard way of implementing inheritance in database, so the hardest part of persisting inheritance is choosing how to represent the inheritance in the database. JPA defines several inheritance mechanisms, mainly defined though the @Inheritance annotation or the <inheritance> element. FishEye: Annotated - Hibernate/core/patches/hibernate-3.3.2.GA_CP04_JBPAPP-9172/core/src/main/java/org/hibernate/dialect/Oracle10gDialect.java.

Hibernate: Ensuring Initialized Association Paths. Querydsl.