]
Alfio commented on HHH-6813:
----------------------------
Attempting to provide better test cases I found out new info about this bug.
1 - using JTA (hiberjta.zip) a NPE is thrown when em.createQuery().getResultList() method
is invoked (select test);
2 - using JTA a StackOverflowException is thrown when em.find() method is invoked (find
test);
3 - using RESOURCE_LOCAL (hiberlocal.zip) no errors are thrown if only select test or find
test is executed;
4 - using RESOURCE_LOCAL an exception in thrown if both select test and find test are
executed together. The type of error (NPE or SOE) depends on which method is executed
before (Junit does not guarantee the execution order);
@Id @OneToOne cause NullPointerException during query
-----------------------------------------------------
Key: HHH-6813
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6813
Project: Hibernate Core
Issue Type: Bug
Components: core, entity-manager
Affects Versions: 3.6.8, 4.0.0.CR5
Environment: Hibernate 4.0.0.CR5, PostgreSQL 9.1.1, Glassfish 3.1.1
Reporter: Alfio
Labels: jpa2
Attachments: hiberjta.zip, hiberlocal.zip, hibertest.war, hibertest.zip
I've two entities, Person and PersonInfo, with a one-to-one relation:
{code:title=Person.java}
@Entity
public class Person {
@Id
private Integer id;
@Basic
private String name;
@OneToOne( mappedBy = "id" )
private PersonInfo personInfo;
...getters&setters...
}
{code}
{code:title=PersonInfo.java}
@Entity
public class PersonInfo {
@Id
@OneToOne
private Person id;
@Basic
private String info;
...getters&setters...
}
{code}
Hibernate correctly creates two tables but a NPE occours during a simple select query
(only if tables have one or more records)
em.createQuery("SELECT p FROM Person p").getResultList();
...
java.lang.NullPointerException
at
org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:2202)
at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:661)
at org.hibernate.type.EntityType.resolve(EntityType.java:441)
at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:150)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1006)
at org.hibernate.loader.Loader.doQuery(Loader.java:883)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
at org.hibernate.loader.Loader.doList(Loader.java:2463)
at org.hibernate.loader.Loader.doList(Loader.java:2449)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2279)
at org.hibernate.loader.Loader.list(Loader.java:2274)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470)
at
org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1118)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:252)
at
com.sun.enterprise.container.common.impl.QueryWrapper.getResultList(QueryWrapper.java:195)
at nogroup.hibertest.Bean.execute(Bean.java:23)
at
nogroup.hibertest.org$jboss$weld$bean-hibertest-1$0-SNAPSHOT-ManagedBean-class_nogroup$hibertest$Bean_$$_WeldClientProxy.execute(org$jboss$weld$bean-hibertest-1$0-SNAPSHOT-ManagedBean-class_nogroup$hibertest$Bean_$$_WeldClientProxy.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:737)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:467)
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:254)
at com.sun.el.parser.AstValue.invoke(AstValue.java:228)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
at
org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
... 33 more
--
This message is automatically generated by JIRA.
For more information on JIRA, see: