Issue Type: Bug Bug
Assignee: Unassigned
Components: core
Created: 28/Nov/12 3:50 AM
Description:

The org.hibernate.ogm.jdbc.NoopConnection methods return null, false, etc. values and the void methods are no-ops. Returning null references can cause problems when trying to use them later without null checks.

Specifically, the NoopConnection.createStatement() methods also return null, so when trying to create an EntityManagerFactory, the PersistentTableBulkIdStrategy.exportTableDefinitions() method in hibernate-core is called and throwing a NullPointerException on line 164 when trying to close the statement.

Either null checks should be included in PersistentTableBulkIdStrategy in hibernate-core or NOOP objects should be returned by NoopConnection hibernate-ogm-core, e.g. NoopStatement.

The call causing the NPE:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("ogmsample");

Stack trace:
javax.persistence.PersistenceException: Unable to build EntityManagerFactory
at org.hibernate.ogm.jpa.HibernateOgmPersistence.createEntityManagerFactory(HibernateOgmPersistence.java:110)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at com.example.HibernateOgmTester.main(HibernateOgmTester.java:42)
Caused by: java.lang.NullPointerException
at org.hibernate.hql.spi.PersistentTableBulkIdStrategy.exportTableDefinitions(PersistentTableBulkIdStrategy.java:164)
at org.hibernate.hql.spi.PersistentTableBulkIdStrategy.prepare(PersistentTableBulkIdStrategy.java:102)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:488)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1750)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at org.hibernate.ogm.jpa.HibernateOgmPersistence.createEntityManagerFactory(HibernateOgmPersistence.java:92)
... 3 more

persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="ogmjtasample" transaction-type="JTA">
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<properties>
<property name="hibernate.transaction.jta.platform"
value="org.hibernate.service.jta.platform.spi.JtaPlatform" />
<property name="hibernate.ogm.datastore.provider"
value="infinispan" />
<property name="hibernate.ogm.infinispan.configuration_resourcename"
value="META-INF/ispn-config.xml"/>
</properties>
</persistence-unit>
</persistence>

Maven dependencies:
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-core</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-infinispan</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.8.Final</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.1.8.Final</version>
</dependency>

Environment: hibernate-core 4.1.8.Final, hibernate-entitymanager 4.1.8.Final, hibernate-ogm-core 4.0.0-SNAPSHOT, hibernate-ogm-infinispan 4.0.0-SNAPSHOT
Project: Hibernate OGM
Priority: Critical Critical
Reporter: Patrik Varga
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira