Could not instantiate persister org.hibernate.persister.entity.SingleTableEntityPersister
-----------------------------------------------------------------------------------------
Key: HHH-7196
URL:
https://hibernate.onjira.com/browse/HHH-7196
Project: Hibernate ORM
Issue Type: Bug
Components: core
Affects Versions: 4.1.1
Environment: 4.1.1, Windows XP, In Memory HSQLDB 2.2.8
Reporter: stanislav bashkirtsev
While mapping the OTO, I've an NPE. I'm not strong in annotations and it's
possible that the mapping is wrong, but anyway I'd assume that the exception should be
more explanatory:
{code}23-Mar-2012 14:40:16 org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
23-Mar-2012 14:40:16 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.1}
23-Mar-2012 14:40:16 org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
23-Mar-2012 14:40:16 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
23-Mar-2012 14:40:16
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
23-Mar-2012 14:40:16
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
configure
INFO: HHH000115: Hibernate connection pool size: 20
23-Mar-2012 14:40:16
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
configure
INFO: HHH000006: Autocommit mode: false
23-Mar-2012 14:40:16
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
configure
INFO: HHH000401: using driver [org.hsqldb.jdbcDriver] at URL [jdbc:hsqldb:mem:testdb]
23-Mar-2012 14:40:16
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
configure
INFO: HHH000046: Connection properties: {user=sa, password=****}
23-Mar-2012 14:40:16 org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect
23-Mar-2012 14:40:16 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator
initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
23-Mar-2012 14:40:16 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory
<init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
Exception in thread "main" org.hibernate.MappingException: Could not instantiate
persister org.hibernate.persister.entity.SingleTableEntityPersister
at
org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:174)
at
org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:148)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:820)
at
org.hibernate.metamodel.source.internal.SessionFactoryBuilderImpl.buildSessionFactory(SessionFactoryBuilderImpl.java:65)
at
org.hibernate.metamodel.source.internal.MetadataImpl.buildSessionFactory(MetadataImpl.java:340)
at poc.hibernate.Main.main(Main.java:37)
Caused by: java.lang.NullPointerException
at org.hibernate.tuple.PropertyFactory.buildStandardProperty(PropertyFactory.java:288)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:442)
at
org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:791)
at
org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:460)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163){code}
Test Case:
{code}@Entity
@Table(name = "AUTHOR")
public class Author {
@Id
@GeneratedValue
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}{code}
The original exceptions is thrown in _PropertyFactory_ on the line 288 when it appears
that type variable is _null_.
{code}@Entity
@Table(name = "BOOK")
public class Book {
@Id
@GeneratedValue
private Long id;
@OneToOne
private Author author;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Author getAuthor() {
return author;
}
public void setAuthor(Author author) {
this.author = author;
}
}{code}
{code}public class Main {
public static void main(String[] args) {
Configuration configuration = new Configuration()
.setProperty("hibernate.archive.autodetection",
"class")
.setProperty("hibernate.connection.driver_class",
"org.hsqldb.jdbcDriver")
.setProperty("hibernate.dialect",
"org.hibernate.dialect.HSQLDialect")
.setProperty("hibernate.hbm2ddl.auto", "create")
.setProperty("hibernate.connection.url",
"jdbc:hsqldb:mem:testdb")
.setProperty("hibernate.connection.username", "sa")
.setProperty("hibernate.connection.password", "")
.setProperty("connection.pool_size", "2");
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder()
.applySettings(configuration.getProperties())
.buildServiceRegistry();
MetadataSources metadataSources = new MetadataSources(serviceRegistry);
metadataSources
.addAnnotatedClass(Author.class)
.addAnnotatedClass(Book.class);
SessionFactory sessionFactory =
metadataSources.buildMetadata().buildSessionFactory();
}
}{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira