NPE when trying to create EntityManagerFactory
----------------------------------------------
Key: HHH-7101
URL:
https://hibernate.onjira.com/browse/HHH-7101
Project: Hibernate ORM
Issue Type: Bug
Components: core
Affects Versions: 4.1.0
Environment: hibernate-jpa-2.0-api:1.0.1-Final; hibernate-core:4.1.0.Final;
hibernate-entitymanager:4.1.0.Final
Reporter: Michael Nascimento Santos
Attachments: npe4cacheable.zip
A NPE is thrown for a simple pure JPA entity annotated with @Cacheable as follows:
@Entity
@Cacheable
public class SampleEntity {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
}
When Persistence.createEntityManagerFactory(String) is called and such entity is part of
the persistence unit, this produces:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
at
org.hibernate.annotations.CacheConcurrencyStrategy.fromAccessType(CacheConcurrencyStrategy.java:52)
at
org.hibernate.cfg.AnnotationBinder.determineCacheConcurrencyStrategy(AnnotationBinder.java:1044)
at org.hibernate.cfg.AnnotationBinder.buildCacheMock(AnnotationBinder.java:1011)
at org.hibernate.cfg.AnnotationBinder.determineCacheSettings(AnnotationBinder.java:968)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:577)
at
org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3431)
at
org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3385)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1337)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1727)
at
org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:88)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
at
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at org.hibernate.test.npe4cacheable.SampleEntity.main(SampleEntity.java:18)
... 6 more
Hibernate should either choose some sensible default strategy or produce a clear message
indicating the need to set one manually.
Attached is a Maven-powered sample with Derby that can be executed with exec:java .
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira