org.hibernate.PropertyValueException

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.

  • {code:java} @Entity // Other annotations public class RelatedEntities { // ... other mappings @ManyToOne( fetch = FetchType.LAZY ) @JoinColumn( name = "entity1__id", updatable = true, columnDefinition = "int(10)" , nullable = false ) private Entity1 entity1; @ManyToOne( fetch = FetchType.LAZY ) @JoinColumn( name = "entity2__id", updatable = true, columnDefinition = "int(10)" , nullable = true ) private Entity2 entity2; @ManyToOne( fetch = FetchType.LAZY ) @JoinColumn( name = "entity3__id", updatable = true, columnDefinition = "int(10)" , nullable = true ) private Entity3 entity3; } @Entity // Other annotations public class Entity1 { // ... other mappings @OneToMany( mappedBy = "entity1", fetch = FetchType.LAZY ) @BatchSize( size = 1024 ) private Set<RelatedEntities> relatedEntities = new HashSet<>(); } @Entity // Other annotations public class Entity2 { // ... other mappings @OneToMany( mappedBy = "entity2", fetch = FetchType.LAZY ) @BatchSize( size = 1024 ) private Set<RelatedEntities> relatedEntities = new HashSet<>(); } @Entity // Other annotations public class Entity3 { // ... other mappings @OneToMany( mappedBy = "entity3", fetch = FetchType.LAZY ) @BatchSize( size = 1024 ) private Set<RelatedEntities> relatedEntities = new HashSet<>(); } {code} When trying to persist an object of RelatedEntities with null value for entity2, hibernate throws following exception: {code:java} org.hibernate.PropertyValueException: not-null property references a null or transient value : example.RelatedEntities.entity2 at org.hibernate.engine.internal.Nullability.checkNullability(Nullability.java:92) at org.hibernate.action.internal.AbstractEntityInsertAction.nullifyTransientReferencesIfNotAlready(AbstractEntityInsertAction.java:115) at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:69) at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:597) at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:232) at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:213) at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:256) at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:318) at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:275) at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:182) at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:113) at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:189) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:132) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:58) at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:778) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:751) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:756) {code} Similarly when trying to persist an object of RelatedEntities with null value for entity3, hibernate throws same exception for example.RelatedEntities.entity3: {code:java} org.hibernate.PropertyValueException: not-null property references a null or transient value : example.RelatedEntities.entity3 {code} Above piece of code works perfectly with hibernate version 4.3.8.Final
    via by Amar Laddha,
  • {code:java} @Entity // Other annotations public class RelatedEntities { // ... other mappings @ManyToOne( fetch = FetchType.LAZY ) @JoinColumn( name = "entity1__id", updatable = true, columnDefinition = "int(10)" , nullable = false ) private Entity1 entity1; @ManyToOne( fetch = FetchType.LAZY ) @JoinColumn( name = "entity2__id", updatable = true, columnDefinition = "int(10)" , nullable = true ) private Entity2 entity2; @ManyToOne( fetch = FetchType.LAZY ) @JoinColumn( name = "entity3__id", updatable = true, columnDefinition = "int(10)" , nullable = true ) private Entity3 entity3; } @Entity // Other annotations public class Entity1 { // ... other mappings @OneToMany( mappedBy = "entity1", fetch = FetchType.LAZY ) @BatchSize( size = 1024 ) private Set<RelatedEntities> relatedEntities = new HashSet<>(); } @Entity // Other annotations public class Entity2 { // ... other mappings @OneToMany( mappedBy = "entity2", fetch = FetchType.LAZY ) @BatchSize( size = 1024 ) private Set<RelatedEntities> relatedEntities = new HashSet<>(); } @Entity // Other annotations public class Entity3 { // ... other mappings @OneToMany( mappedBy = "entity3", fetch = FetchType.LAZY ) @BatchSize( size = 1024 ) private Set<RelatedEntities> relatedEntities = new HashSet<>(); } {code} When trying to persist an object of RelatedEntities with null value for entity2, hibernate throws following exception: {code:java} org.hibernate.PropertyValueException: not-null property references a null or transient value : example.RelatedEntities.entity2 at org.hibernate.engine.internal.Nullability.checkNullability(Nullability.java:92) at org.hibernate.action.internal.AbstractEntityInsertAction.nullifyTransientReferencesIfNotAlready(AbstractEntityInsertAction.java:115) at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:69) at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:597) at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:232) at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:213) at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:256) at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:318) at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:275) at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:182) at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:113) at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:189) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:132) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:58) at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:778) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:751) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:756) {code} Similarly when trying to persist an object of RelatedEntities with null value for entity3, hibernate throws same exception for example.RelatedEntities.entity3: {code:java} org.hibernate.PropertyValueException: not-null property references a null or transient value : example.RelatedEntities.entity3 {code} Above piece of code works perfectly with hibernate version 4.3.8.Final
    via by Amar Laddha,
  • Checksum checker errors out: https://www.irccloud.com/pastebin/r67glKqq/ Code is/was: https://github.com/DSpace/DSpace/blob/master/dspace-api/src/main/java/org/dspace/content/dao/impl/BitstreamDAOImpl.java#L68 Criteria criteria = createCriteria(context, Bitstream.class).add(Subqueries.propertyNotIn("id", DetachedCriteria.forClass(MostRecentChecksum.class))); I've changed that to: DetachedCriteria d = DetachedCriteria.forClass(MostRecentChecksum.class, "mrc"); d.setProjection(Projections.projectionList().add(Projections.property("mrc.bitstream"))); Criteria criteria = createCriteria(context, Bitstream.class, "b") .add(Subqueries.propertyNotIn("b.id", d)); And that doesn't error out. (PR coming, once I get it all successful). However, I get another error, that I don't have a solution to yet: /dspace/bin/dspace checker -v Exception: not-null property references a null or transient value: org.dspace.checker.MostRecentChecksum.checksumAlgorithm org.hibernate.PropertyValueException: not-null property references a null or transient value: org.dspace.checker.MostRecentChecksum.checksumAlgorithm at org.hibernate.engine.internal.Nullability.checkNullability(Nullability.java:103) at org.hibernate.action.internal.AbstractEntityInsertAction.nullifyTransientReferencesIfNotAlready(AbstractEntityInsertAction.java:132) at org.hibernate.action.internal.AbstractEntityInsertAction.makeEntityManaged(AbstractEntityInsertAction.java:141) at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:235) at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:209) at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:152) at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:329) at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:286) at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:192) at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:135) at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:208) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:151) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:78) at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:772) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:746) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:750) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.hibernate.context.internal.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:352) at com.sun.proxy.$Proxy37.persist(Unknown Source) at org.dspace.core.AbstractHibernateDAO.create(AbstractHibernateDAO.java:30) at org.dspace.checker.MostRecentChecksumServiceImpl.updateMissingBitstreams(MostRecentChecksumServiceImpl.java:110) at org.dspace.checker.CheckerCommand.process(CheckerCommand.java:123) at org.dspace.app.checker.ChecksumChecker.main(ChecksumChecker.java:231) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.dspace.app.launcher.ScriptLauncher.runOneCommand(ScriptLauncher.java:226) at org.dspace.app.launcher.ScriptLauncher.main(ScriptLauncher.java:78)
    via by Peter Dietz,
  • Checksum checker errors out: https://www.irccloud.com/pastebin/r67glKqq/ Code is/was: https://github.com/DSpace/DSpace/blob/master/dspace-api/src/main/java/org/dspace/content/dao/impl/BitstreamDAOImpl.java#L68 Criteria criteria = createCriteria(context, Bitstream.class).add(Subqueries.propertyNotIn("id", DetachedCriteria.forClass(MostRecentChecksum.class))); I've changed that to: DetachedCriteria d = DetachedCriteria.forClass(MostRecentChecksum.class, "mrc"); d.setProjection(Projections.projectionList().add(Projections.property("mrc.bitstream"))); Criteria criteria = createCriteria(context, Bitstream.class, "b") .add(Subqueries.propertyNotIn("b.id", d)); And that doesn't error out. (PR coming, once I get it all successful). However, I get another error, that I don't have a solution to yet: /dspace/bin/dspace checker -v Exception: not-null property references a null or transient value: org.dspace.checker.MostRecentChecksum.checksumAlgorithm org.hibernate.PropertyValueException: not-null property references a null or transient value: org.dspace.checker.MostRecentChecksum.checksumAlgorithm at org.hibernate.engine.internal.Nullability.checkNullability(Nullability.java:103) at org.hibernate.action.internal.AbstractEntityInsertAction.nullifyTransientReferencesIfNotAlready(AbstractEntityInsertAction.java:132) at org.hibernate.action.internal.AbstractEntityInsertAction.makeEntityManaged(AbstractEntityInsertAction.java:141) at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:235) at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:209) at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:152) at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:329) at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:286) at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:192) at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:135) at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:208) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:151) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:78) at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:772) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:746) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:750) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.hibernate.context.internal.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:352) at com.sun.proxy.$Proxy37.persist(Unknown Source) at org.dspace.core.AbstractHibernateDAO.create(AbstractHibernateDAO.java:30) at org.dspace.checker.MostRecentChecksumServiceImpl.updateMissingBitstreams(MostRecentChecksumServiceImpl.java:110) at org.dspace.checker.CheckerCommand.process(CheckerCommand.java:123) at org.dspace.app.checker.ChecksumChecker.main(ChecksumChecker.java:231) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.dspace.app.launcher.ScriptLauncher.runOneCommand(ScriptLauncher.java:226) at org.dspace.app.launcher.ScriptLauncher.main(ScriptLauncher.java:78)
    via by Peter Dietz,
  • ERROR with filmography
    via GitHub by jluc2808
    ,
    • org.hibernate.PropertyValueException: not-null property references a null or transient value : example.RelatedEntities.entity2 at org.hibernate.engine.internal.Nullability.checkNullability(Nullability.java:92) at org.hibernate.action.internal.AbstractEntityInsertAction.nullifyTransientReferencesIfNotAlready(AbstractEntityInsertAction.java:115) at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:69) at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:597) at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:232) at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:213) at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:256) at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:318) at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:275) at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:182) at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:113) at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:189) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:132) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:58) at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:778) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:751) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:756)

    Users with the same issue

    Pilleo
    6 times, last one,
    Victor_IT
    1 times, last one,
    serious2monkeys
    79 times, last one,
    davidvanlaatum
    6 times, last one,
    Unknown visitor1 times, last one,