openSession and getCurrentSession Difference in Hibernate

hibernate-thumbnail

When you get a session from the session factory object in hibernate, either you can use openSession or getCurrentSession. If you are using the openSession method, it opens a new session freshly. If you use getCurrentSession, it gets the current session from the existing thread context instead of opening a new session. You should have […]

Hibernate Dependency Library Exception (JTA) : javax/transaction/SystemException

hibernate-thumbnail

If you are developing hibernate application, you would encounter the following exception if you have not added the jta-1.1.jar in your libraries. This JAR file is used in the hibernate transaction development.¬†However, when you run the configuration itself will throw the exception if the JAR file is not found. Lets see how you can get […]

Hibernate Dependency Library Exception (JPA) : javax/persistence/SharedCacheMode

hibernate-thumbnail

If you are developing hibernate application, you would encounter the following exception if you have not added the hibernate-jpa-2.1-api-1.0.0.Final.jar in your libraries. Lets see how you can get this JAR file. Exception Trace

Why Jandex and Classmate Libraries Used in Hibernate 4.2 Core

hibernate-thumbnail

Hibernate uses various third part dependencies internally to resolve the various problems. One of the dependency is Jandex (jandex-1.1.0.Final.jar) and Classmate (classmate-1.0.0) libraries which are not required for the hibernate’s core functionality. If you don’t add them to the libraries, you would get the below exceptions. Jandex and Classmate are not required for the main […]

Hibernate Dependency Library Exception (Commons Annotations) : org/hibernate/annotations/common/reflection/MetadataProvider

hibernate-thumbnail

If you miss the Hibernate commons annotations library hibernate-commons-annotations-4.0.4.Final.jar, then you would get java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider exception. Exception Trace

Hibernate Dependency Library Exception (JBoss Logging) : org/jboss/logging/BasicLogger

hibernate-thumbnail

If you are developing hibernate application, it is internally using the JBoss logging framework. You have to add the jboss-logging-3.1.4.GA.jar to resolve the dependency. Also you can get JAR files from the maven repository. If the JAR is not in the libraries, you would get the following exception. Exception Trace

Hibernate Configuration Resource Loading Problems

hibernate-thumbnail

It is one of the very common exception thrown when you start setting up the environment for hibernate application. hibernate.cfg.xml is the default configuration file for defining the hibernate database configurations and mappings. This file has to be copied in the classpath directory. In this scenario, you always keep this file under the “src” folder […]

Hibernate ORM 4.3.0 Released

hibernate-thumbnail

Hibernate got its own website. If you look at the website, hibernate is grown big from just a ORM framework couple of years back. Last week hibernate has released its latest version 4.3.0. The main theme for this release is the support for JPA 2.1 (JSR 338) specification. The following are some of the notable […]

Polymorphic Association Mapping with Any Relationship in Hibernate

hibernate_icon

Polymorphic association, supported by Hibernate, is the solution of such mapping requirement as an instance of entity needs to be associated with one of multiple possible entities. This can be implemented with Any relationship. In this relationship, the table holding the relationship would have two columns for relationship management. One to identify the primary key […]

Implicit Polymorphism in Hibernate

hibernate_orm

Implicit polymorphism in Hibernate is one of the inheritance strategies supported in Hibernate. Implicit polymorphism means if a class or interface is used in HQL, criteria or named queries, hibernate fetches the records from the table mapped to the used class along with all the tables mapped to its subclasses, at any hierarchy level. This […]