3 Replies Latest reply on Dec 1, 2010 1:03 PM by Adam Warski

    Getting javax.persistence.NonUniqueResultException

    Rodrigo Uchoa Novice

      Hey guys,

       

      I'm getting a "javax.persistence.NonUniqueResultException" when doing a very simple query. My query goes something like this:

       

      {code}

      AuditQuery query = queryCreator.forRevisionsOfEntity(entity.getClass(), false, true);

      query.add(AuditEntity.id().eq(entity.getId()));

      query.getResultList();

      {code}

       

      Nothing fancy about it. Still, I'm getting the following exception. The stack trace suggests it has something to do with the @OneToOne mappings:

       

      javax.persistence.NonUniqueResultException

      at org.hibernate.envers.query.impl.AbstractAuditQuery.getSingleResult(AbstractAuditQuery.java:111)

      at org.hibernate.envers.entities.mapper.relation.OneToOneNotOwningMapper.mapToEntityFromMap(OneToOneNotOwningMapper.java:74)

      at org.hibernate.envers.entities.mapper.MultiPropertyMapper.mapToEntityFromMap(MultiPropertyMapper.java:118)

      at org.hibernate.envers.entities.EntityInstantiator.createInstanceFromVersionsEntity(EntityInstantiator.java:93)

      at org.hibernate.envers.query.impl.RevisionsOfEntityQuery.list(RevisionsOfEntityQuery.java:126)

      at org.hibernate.envers.query.impl.AbstractAuditQuery.getResultList(AbstractAuditQuery.java:100)

       

       

       

      Does anyone have a clue?