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.

  • The entity contains the following field: @ManyToMany(cascade = {CascadeType.PERSIST}) @JoinTable( name = "Apples", joinColumns = {@JoinColumn(name = "storeId", nullable = false)}, inverseJoinColumns = {@JoinColumn(name = "appleId", nullable = false)} ) public Set<Apple> apples = new HashSet<Apple>(); An exception is thrown when saving the entity: java.lang.NullPointerException at org.hibernate.envers.entities.EntitiesConfigurations.getToPropertyNames(EntitiesConfigurations.java:155) at org.hibernate.envers.event.BaseEnversEventListener.addCollectionChangeWorkUnit(BaseEnversEventListener.java:121) at org.hibernate.envers.event.BaseEnversEventListener.generateBidirectionalCollectionChangeWorkUnits(BaseEnversEventListener.java:90) at org.hibernate.envers.event.EnversPostInsertEventListenerImpl.onPostInsert(EnversPostInsertEventListenerImpl.java:60) at org.hibernate.action.internal.EntityIdentityInsertAction.postInsert(EntityIdentityInsertAction.java:149) at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:102) In that particular method: public Set<String> getToPropertyNames(String fromEntityName, String fromPropertyName, String toEntityName) { Set<String> entityAndParentsNames = getEntityAndParentsNames(fromEntityName); Set<String> toPropertyNames = new HashSet<String>(); for (RelationDescription relationDescription : getRelationDescriptions(toEntityName)) { String relToEntityName = relationDescription.getToEntityName(); String mappedByPropertyName = relationDescription.getMappedByPropertyName(); if (entityAndParentsNames.contains(relToEntityName) && mappedByPropertyName.equals(fromPropertyName)) { toPropertyNames.add(relationDescription.getFromPropertyName()); } } return toPropertyNames; } mappedByPropertyName is null since RelationDescription can have null mappedByPropertyName when invoked at: EntityConfiguration public void addToManyMiddleRelation(String fromPropertyName, String toEntityName) { relations.put(fromPropertyName, new RelationDescription(fromPropertyName, RelationType.TO_MANY_MIDDLE, toEntityName, null, null, null, null, true)); }
    via by Clement Pang,
  • The entity contains the following field: @ManyToMany(cascade = {CascadeType.PERSIST}) @JoinTable( name = "Apples", joinColumns = {@JoinColumn(name = "storeId", nullable = false)}, inverseJoinColumns = {@JoinColumn(name = "appleId", nullable = false)} ) public Set<Apple> apples = new HashSet<Apple>(); An exception is thrown when saving the entity: java.lang.NullPointerException at org.hibernate.envers.entities.EntitiesConfigurations.getToPropertyNames(EntitiesConfigurations.java:155) at org.hibernate.envers.event.BaseEnversEventListener.addCollectionChangeWorkUnit(BaseEnversEventListener.java:121) at org.hibernate.envers.event.BaseEnversEventListener.generateBidirectionalCollectionChangeWorkUnits(BaseEnversEventListener.java:90) at org.hibernate.envers.event.EnversPostInsertEventListenerImpl.onPostInsert(EnversPostInsertEventListenerImpl.java:60) at org.hibernate.action.internal.EntityIdentityInsertAction.postInsert(EntityIdentityInsertAction.java:149) at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:102) In that particular method: public Set<String> getToPropertyNames(String fromEntityName, String fromPropertyName, String toEntityName) { Set<String> entityAndParentsNames = getEntityAndParentsNames(fromEntityName); Set<String> toPropertyNames = new HashSet<String>(); for (RelationDescription relationDescription : getRelationDescriptions(toEntityName)) { String relToEntityName = relationDescription.getToEntityName(); String mappedByPropertyName = relationDescription.getMappedByPropertyName(); if (entityAndParentsNames.contains(relToEntityName) && mappedByPropertyName.equals(fromPropertyName)) { toPropertyNames.add(relationDescription.getFromPropertyName()); } } return toPropertyNames; } mappedByPropertyName is null since RelationDescription can have null mappedByPropertyName when invoked at: EntityConfiguration public void addToManyMiddleRelation(String fromPropertyName, String toEntityName) { relations.put(fromPropertyName, new RelationDescription(fromPropertyName, RelationType.TO_MANY_MIDDLE, toEntityName, null, null, null, null, true)); }
    via by Clement Pang,
    • java.lang.NullPointerException at org.hibernate.envers.entities.EntitiesConfigurations.getToPropertyNames(EntitiesConfigurations.java:155) at org.hibernate.envers.event.BaseEnversEventListener.addCollectionChangeWorkUnit(BaseEnversEventListener.java:121) at org.hibernate.envers.event.BaseEnversEventListener.generateBidirectionalCollectionChangeWorkUnits(BaseEnversEventListener.java:90) at org.hibernate.envers.event.EnversPostInsertEventListenerImpl.onPostInsert(EnversPostInsertEventListenerImpl.java:60) at org.hibernate.action.internal.EntityIdentityInsertAction.postInsert(EntityIdentityInsertAction.java:149) at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:102)
    No Bugmate found.