-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Bi-directional causing NOT NULL constraint violation on chld
PostPosted: Tue Sep 16, 2008 9:12 pm 
Newbie

Joined: Sat Jul 19, 2008 9:33 am
Posts: 3
Location: US
Hibernate 3.2.5
===========================
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping package="com.famc.los.model" schema="dbo">
<class catalog="WorkFlow" name="WorkflowWorkerLoanOfficerAssociation"
schema="dbo" table="WorkerLOAssoc">
<id name="id" type="java.lang.Integer">
<column name="id"/>
<generator class="native"/>
</id>
<many-to-one class="WorkflowWorker" fetch="select" name="worker">
<column name="queue_id" not-null="true"/>
<column length="3" name="employ_id" not-null="true"/>
</many-to-one>
<many-to-one name="loanOfficer" class="WorkflowLoanOfficer" insert="false" update="false" fetch="select">
<column name="queue_id" not-null="true" />
<column name="lo_rep" not-null="true"/>
</many-to-one>
<many-to-one class="WorkflowQueue" fetch="select" insert="false" name="queue" update="false">
<column name="queue_id" not-null="true"/>
</many-to-one>
<property generated="never" lazy="false" name="order" type="java.lang.Integer">
<column name="[Order]" not-null="true"/>
</property>
<property generated="never" lazy="false" name="ismandatory" >
<column name="ismandatory" not-null="true"/>
</property>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping package="com.famc.los.model" schema="dbo">
<class catalog="WorkFlow" name="WorkflowLoanOfficer" schema="dbo"
table="LO" lazy="false" >
<composite-id class="WorkflowLoanOfficerId" mapped="false"
name="id" unsaved-value="undefined" >
<key-many-to-one class="WorkflowQueue" lazy="false" name="queue">
<column name="Queue_ID" />
</key-many-to-one>
<key-property name="loanOfficerId"
type="java.lang.String">
<column length="3" name="lo_rep" />
</key-property>
</composite-id>
<set name="workflowWorkerLoanOfficerAssociations"
sort="unsorted" lazy="false" cascade="all-delete-orphan" inverse="true" >
<key>
<column name="queue_id" not-null="true" />
<column length="3" name="lo_rep" not-null="true" />
</key>
<one-to-many class="WorkflowWorkerLoanOfficerAssociation" />
</set>
<many-to-one name="user" column="lo_rep" insert="false"
update="false" lazy="false" >
</many-to-one>

</class>
</hibernate-mapping>
===========================
for (WorkflowWorkerLoanOfficerAssociation wloa : persistedList) {
log.debug(" persisting wloa:officerId:" + wloa.getLoanOfficer().getId().getLoanOfficerId());
WorkflowLoanOfficer lo = getLoanOfficerDao().getById(wloa.getLoanOfficer().getId());
wloa.setLoanOfficer(lo);
Set<WorkflowWorkerLoanOfficerAssociation> loSet = lo.getWorkflowWorkerLoanOfficerAssociations();
if (loSet.contains(wloa))
loSet.remove(wloa);
loSet.add(wloa);
log.debug(BeanUtil.dumpBean(lo));

getLoanOfficerDao().save(lo);
===========================
Hibernate: /* load com.famc.los.model.WorkflowLoanOfficer */ select workflowlo0_.Queue_ID as Queue1_75_0_, workflowlo0_.lo_rep as lo2_75_0_ from WorkFlow.dbo.LO workflowlo0_ where workflowlo0_.Queue_ID=? and workflowlo0_.lo_rep=?
Hibernate: /* load one-to-many com.famc.los.model.WorkflowLoanOfficer.workflowWorkerLoanOfficerAssociations */ select workflowwo0_.queue_id as queue2_1_, workflowwo0_.lo_rep as lo4_1_, workflowwo0_.id as id1_, workflowwo0_.id as id76_0_, workflowwo0_.queue_id as queue2_76_0_, workflowwo0_.employ_id as employ3_76_0_, workflowwo0_.lo_rep as lo4_76_0_, workflowwo0_.[Order] as Order5_76_0_, workflowwo0_.ismandatory as ismandat6_76_0_ from WorkFlow.dbo.WorkerLOAssoc workflowwo0_ where workflowwo0_.queue_id=? and workflowwo0_.lo_rep=?
Hibernate: /* load com.famc.los.model.WorkflowContext */ select workflowco0_.Context_ID as Context1_73_0_, workflowco0_.Context as Context73_0_, workflowco0_.MoveToWorker as MoveToWo3_73_0_, workflowco0_.AudNum as AudNum73_0_, workflowco0_.LifeCycle as LifeCycle73_0_, workflowco0_.Description as Descript6_73_0_ from Workflow.dbo.Context workflowco0_ where workflowco0_.Context_ID=?
[16718] INFO SimpleProfiler profile -> ********* com.famc.los.model.dao.hibernate.WorkflowLoanOfficerDaoHibernate execution(getById) : 453ms *********
[16718] DEBUG WorkerConfigurationServiceImpl saveWorkerWorkAssignments -> [id:com.famc.los.model.WorkflowLoanOfficerId@15f08][user:[actAccess:1][branchId:2?T][branchMgr:0][branchRestr:0][commPlan:][defDept:UND][displayName:IANNI, ANTHONY][docAccess:3][docPrep:0][dreLicense:][emploansRestr:0][employAddr1:][employAddr2:][employBd:null][employEmail:aianni@franklinamerican.com][employNo:][employSsn:][endDate:null][exclude:false][faxPhone:][faxPhonePre:][fileId:AEP6K][firstName:ANTHONY][funAccess:3][funder:0][genAccess:3][hireDate:2006-05-08 00:00:00.0][homePhone:][homePhonePre:][insAccess:3][insurer:0][lastName:IANNI][licExpires:null][licensedUsr:1][location:17][middleName:][mktAccess:3][notes:][officeRestr:0][password:FAMC0501][phoneExt:253][processor:0][remoteUser:0][reploansRestr:0][retailRep:0][searchInd:loan_num][shipper:0][shpAccess:3][srvAccess:3][sysAccess:3][undAccess:3][underwriter:false][userInfoExtended:[loginName:AIANNI][userInfoExtendedAuditTeamLead:false][userInfoExtendedId:A\Z]][userInfoExtendedAuditTeamLead:false][userInfoId:A\Z][userType:][wholesaleRep:1][workPhone:][workPhonePre:]][workflowWorkerLoanOfficerAssociations:[[id:46][isMandatory:true][loan officer id:A\Z][order:3][worker id:[employId:B2Y][queueId:1]], [id:49][isMandatory:false][loan officer id:A\Z][order:2][worker id:[employId:B9W][queueId:1]], [id:51][isMandatory:true][loan officer id:A\Z][order:4][worker id:[employId:B9W][queueId:1]], [id:35][isMandatory:false][loan officer id:A\Z][order:3][worker id:[employId:B8T][queueId:1]], [id:44][isMandatory:false][loan officer id:A\Z][order:1][worker id:[employId:B2Y][queueId:1]], [id:null][isMandatory:true][loan officer id:A\Z][order:0][worker id:[employId:AXD][queueId:1]], [id:42][isMandatory:false][loan officer id:A\Z][order:2][worker id:[employId:B9T][queueId:1]], [id:34][isMandatory:true][loan officer id:A\Z][order:2][worker id:[employId:B8T][queueId:1]], [id:43][isMandatory:true][loan officer id:A\Z][order:4][worker id:[employId:B9T][queueId:1]]]]
[16718] DEBUG WorkflowLoanOfficerDaoHibernate saveOrUpdate -> saveOrUpdate WorkflowLoanOfficer instance
Hibernate: /* get current state com.famc.los.model.WorkflowLoanOfficer */ select workflowlo_.Queue_ID, workflowlo_.lo_rep from WorkFlow.dbo.LO workflowlo_ where workflowlo_.Queue_ID=? and workflowlo_.lo_rep=?
Hibernate: /* insert com.famc.los.model.WorkflowWorkerLoanOfficerAssociation */ insert into WorkFlow.dbo.WorkerLOAssoc (queue_id, employ_id, [Order], ismandatory) values (?, ?, ?, ?)
[17109] WARN JDBCExceptionReporter logExceptions -> SQL Error: 515, SQLState: 23000
[17109] ERROR JDBCExceptionReporter logExceptions -> Cannot insert the value NULL into column 'lo_rep', table 'WorkFlow.dbo.WorkerLOAssoc'; column does not allow nulls. INSERT fails.
[17124] ERROR WorkflowLoanOfficerDaoHibernate saveOrUpdate -> saveOrUpdate failed
org.springframework.dao.DataIntegrityViolationException: could not insert: [com.famc.los.model.WorkflowWorkerLoanOfficerAssociation]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [com.famc.los.model.WorkflowWorkerLoanOfficerAssociation]
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:622)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:378)
at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:693)
at com.famc.los.model.dao.hibernate.WorkflowLoanOfficerDaoHibernate.saveOrUpdate(WorkflowLoanOfficerDaoHibernate.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:77)
at com.famc.model.spring.SimpleProfiler.profile(SimpleProfiler.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:64)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy75.saveOrUpdate(Unknown Source)
at com.famc.los.service.workflow.configuration.WorkerConfigurationServiceImpl.saveWorkerWorkAssignments(WorkerConfigurationServiceImpl.java:470)
at com.famc.los.service.workflow.configuration.WorkerConfigurationServiceImpl.save(WorkerConfigurationServiceImpl.java:378)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
at $Proxy83.save(Unknown Source)
at com.famc.los.service.workflow.configuration.WorkerConfigurationServiceTest.testSaveWorker(WorkerConfigurationServiceTest.java:206)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.hibernate.exception.ConstraintViolationException: could not insert: [com.famc.los.model.WorkflowWorkerLoanOfficerAssociation]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2158)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2638)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at org.hibernate.engine.Cascade.cascade(Cascade.java:97)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.cascadeOnUpdate(DefaultSaveOrUpdateEventListener.java:357)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:329)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495)
at org.springframework.orm.hibernate3.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:696)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
... 55 more
Caused by: java.sql.SQLException: Cannot insert the value NULL into column 'lo_rep', table 'WorkFlow.dbo.WorkerLOAssoc'; column does not allow nulls. INSERT fails.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:367)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2816)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2254)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:631)
at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:584)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:546)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeUpdate(JtdsPreparedStatement.java:505)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33)
... 88 more
===========================
MSSQL Server 2003
===========================
When I look at the insert statement for the problem child, the WorkflowWorkerLoanOfficerAssoc, it doesn't include the parameter for the loan officer ID.

Big problem is that it is trying to do an insert with only four of the fields and the lo_rep field, which is the loan officer ID, cannot be null nor do I want it to be.

Thanks in advance for any help.


Top
 Profile  
 
 Post subject: The problem
PostPosted: Wed Sep 17, 2008 12:26 pm 
Newbie

Joined: Sat Jul 19, 2008 9:33 am
Posts: 3
Location: US
The problem is that I had to use the queue_id column for two different associations and the lo_rep column being a part of a composit key of one of those associations. Hibernate was forcing the composit key association to be insert="false" update="false" thus leaving the lo_rep out of it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.