java.lang.NullPointerException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • A many-to-many collection (User-Role) is mapped the following way: user side: <set name="roles" lazy="false" inverse="true" table="user_roles" cascade="save-update"> <key column="user_name" property-ref="username"/> <many-to-many class="ch.orange.ras.model.Role" column="role_name"/> </set> role side: <set name="users" lazy="true" table="user_roles"> <key column="role_name"/> <many-to-many class="ch.orange.ras.model.User" column="user_name"/> </set> saving a detached User object with a valid set of Roles throws the following exception: java.lang.NullPointerException at org.hibernate.engine.EntityEntry.getLoadedValue(EntityEntry.java:141) at org.hibernate.type.CollectionType.getKeyOfOwner(CollectionType.java:302) at org.hibernate.engine.Collections.processReachableCollection(Collections.java:137) at org.hibernate.event.def.FlushVisitor.processCollection(FlushVisitor.java:37) at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:104) at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:64) at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:58) at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:198) at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:190) at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:70) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86) [...] removing the property-ref attribute from User's mapping makes it work, so I believe the bug is related to that new feature.
    via by Kristof Jozsa,
  • A many-to-many collection (User-Role) is mapped the following way: user side: <set name="roles" lazy="false" inverse="true" table="user_roles" cascade="save-update"> <key column="user_name" property-ref="username"/> <many-to-many class="ch.orange.ras.model.Role" column="role_name"/> </set> role side: <set name="users" lazy="true" table="user_roles"> <key column="role_name"/> <many-to-many class="ch.orange.ras.model.User" column="user_name"/> </set> saving a detached User object with a valid set of Roles throws the following exception: java.lang.NullPointerException at org.hibernate.engine.EntityEntry.getLoadedValue(EntityEntry.java:141) at org.hibernate.type.CollectionType.getKeyOfOwner(CollectionType.java:302) at org.hibernate.engine.Collections.processReachableCollection(Collections.java:137) at org.hibernate.event.def.FlushVisitor.processCollection(FlushVisitor.java:37) at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:104) at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:64) at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:58) at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:198) at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:190) at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:70) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86) [...] removing the property-ref attribute from User's mapping makes it work, so I believe the bug is related to that new feature.
    via by Kristof Jozsa,
  • Delete many-to-one using hibernate
    via Stack Overflow by Timothy Vogel
    ,
    • java.lang.NullPointerException at org.hibernate.engine.EntityEntry.getLoadedValue(EntityEntry.java:141) at org.hibernate.type.CollectionType.getKeyOfOwner(CollectionType.java:302) at org.hibernate.engine.Collections.processReachableCollection(Collections.java:137) at org.hibernate.event.def.FlushVisitor.processCollection(FlushVisitor.java:37) at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:104) at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:64) at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:58) at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:198) at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:190) at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:70) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
    No Bugmate found.