[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6317) Retrieving

Clint Popetz (JIRA) noreply at atlassian.com
Tue Jun 14 14:00:25 EDT 2011


Retrieving 
-----------

                 Key: HHH-6317
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6317
             Project: Hibernate Core
          Issue Type: Bug
          Components: envers
    Affects Versions: 3.6.5
            Reporter: Clint Popetz


For the following mapping:

{code}
public class AnEntity extends HibernatePersistedObject {

	@Id
	@GeneratedValue
	private Long id;
	@OneToOne(optional=false,mappedBy="anEntity")
	private TargetEntity target;

}

public class TargetEntity { 
	@Id
	@GeneratedValue
	private Long id;

        @ManyToOne
        private AnEntity anEntity;

}        
{code}

and the following query:

{code}
AuditReaderFactory.get(em).createQuery().
			forRevisionsOfEntity(AnEntity.class,false,false).
			add(AuditEntity.id().eq(id)).addOrder(AuditEntity.revisionNumber().desc()).
			setMaxResults(1).getSingleResult()
{code}

I get an NPE because the there is no EntityConfiguration for TargetEntity, as it is not audited:

{noformat}
java.lang.NullPointerException
	at org.hibernate.envers.query.impl.EntitiesAtRevisionQuery.list(EntitiesAtRevisionQuery.java:81)
	at org.hibernate.envers.query.impl.AbstractAuditQuery.getSingleResult(AbstractAuditQuery.java:108)
	at org.hibernate.envers.entities.mapper.relation.OneToOneNotOwningMapper.mapToEntityFromMap(OneToOneNotOwningMapper.java:82)
	at org.hibernate.envers.entities.mapper.MultiPropertyMapper.mapToEntityFromMap(MultiPropertyMapper.java:118)
	at org.hibernate.envers.entities.EntityInstantiator.createInstanceFromVersionsEntity(EntityInstantiator.java:100)
	at org.hibernate.envers.query.impl.RevisionsOfEntityQuery.list(RevisionsOfEntityQuery.java:135)
	at org.hibernate.envers.query.impl.AbstractAuditQuery.getSingleResult(AbstractAuditQuery.java:108)
{noformat}


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list