I'm having a problem with a one-to-many association and the exception noted in the subject:
PropertyValueException: not-null property references a null or transient value: com.allureglobal.harvey.model.RotatorAnimationContentAssignment._contentAssignmentsBackref
Having done some searching, I've got a general grasp on where this kind of problem comes from, but I don't see my situation fitting into any of the scenarios that I've seen yet.
I have class RotatorSlotAssignment (RSA) that contains a List collection of RotatorContentAssignment (RCA). RCA is an abstract class with RotatorImageContentAssignment and RotatorAnimationContentAssignment extending it. RCA is the class that holds the parent RSA.
When I try to add a single RotatorAnimationContentAssignment object to the List and save the RSA, I get that exception. I've provided the relevant parts of my annotated code below. If anyone can help me figure this out, I'd appreciate it.
Dave
Hibernate version:3.2.6GA
RotatorSlotAssignment:
Code:
@OneToMany(cascade=CascadeType.ALL)
@IndexColumn(name="content_order",base=1)
@JoinColumn(name="rotator_slot_assignment_id", nullable=false)
private List<RotatorContentAssignment> contentAssignments = new ArrayList<RotatorContentAssignment>();
RotatorContentAssignment:
Code:
@ManyToOne
@JoinColumn(name="rotator_slot_assignment_id", nullable=true, insertable=false, updatable=false)
private RotatorSlotAssignment rotatorSlotAssignment;
Part of the stacktrace - which only really tells us where the Exception was throw out of Spring.
Code:
org.springframework.orm.jpa.JpaSystemException: org.hibernate.PropertyValueException: not-null property references a null or transient value: com.allureglobal.harvey.model.RotatorAnimationContentAssignment._contentAssignmentsBackref; nested exception is javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property references a null or transient value: com.allureglobal.harvey.model.RotatorAnimationContentAssignment._contentAssignmentsBackref
org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:215)
org.springframework.orm.jpa.DefaultJpaDialect.translateExceptionIfPossible(DefaultJpaDialect.java:113)
org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:212)
org.springframework.orm.jpa.JpaAccessor.translateIfNecessary(JpaAccessor.java:152)
org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:196)
org.springframework.orm.jpa.JpaTemplate.persist(JpaTemplate.java:261)
org.crank.crud.GenericDaoJpa.store(GenericDaoJpa.java:83)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:299)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:172)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
$Proxy29.store(Unknown Source)
com.allureglobal.harvey.controller.mediaBoard.assign.RotatorAssignmentController.addAnimationContent(RotatorAssignmentController.java:144)
com.allureglobal.harvey.controller.mediaBoard.assign.RotatorAssignmentController.createRotatorContent(RotatorAssignmentController.java:82)