-->
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.  [ 3 posts ] 
Author Message
 Post subject: Unable to Persist Data
PostPosted: Fri Mar 28, 2008 6:16 pm 
Beginner
Beginner

Joined: Thu Dec 08, 2005 12:18 pm
Posts: 21
Location: Birmingham, Alabama
Okay, first let me apologize for such a basic question.....

What I have done is created a MYSQL database. I have used MyEclipse to reverse engineer the source code for Hibernate and Spring (DAOs). I pass the Spring errors and now I am unable to get pass the Hibernate errors.



Hibernate version: 3.1

Mapping documents:
Code:
<?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">

<hibernate-mapping>
    <class name="jtdi.metadata.orm.JtdiDocument" table="jtdi_document" catalog="jtdi_metadata_db">
        <id name="jtdiDocumentId" type="java.lang.Integer">
            <column name="jtdi_document_id" />
            <generator class="guid" />
        </id>
        <property name="storagePath" type="java.lang.String">
            <column name="storage_path" length="256" />
        </property>
        <property name="storageHostName" type="java.lang.String">
            <column name="storage_host_name" length="50" />
        </property>
        <property name="docFileSize" type="java.lang.Long">
            <column name="doc_file_size" />
        </property>
        <property name="docFileName" type="java.lang.String">
            <column name="doc_file_name" length="50" />
        </property>
        <property name="docDescription" type="java.lang.String">
            <column name="doc_description" length="65535" />
        </property>
        <property name="docType" type="java.lang.String">
            <column name="doc_type" length="50" />
        </property>
        <property name="docCreationDate" type="java.util.Date">
            <column name="doc_creation_date" length="0" />
        </property>
        <property name="docUpdateDate" type="java.util.Date">
            <column name="doc_update_date" length="0" />
        </property>
        <property name="docTitle" type="java.lang.String">
            <column name="doc_title" length="256" />
        </property>
        <property name="docExpirationDate" type="java.util.Date">
            <column name="doc_expiration_date" length="0" />
        </property>
        <property name="docOsDate" type="java.util.Date">
            <column name="doc_os_date" length="0" />
        </property>

        <set name="operationMaintenances" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.OperationMaintenance" />
        </set>
        <set name="engrDrawings" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.EngrDrawing" />
        </set>
        <set name="metadataDocuments" inverse="true">
            <key><column name="fk_jtdi_document_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.MetadataDocument" />
        </set>
        <set name="technicalDirectiveBulletins" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.TechnicalDirectiveBulletin" />
        </set>
        <set name="supplySupports" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.SupplySupport" />
        </set>
        <set name="techDirectiveChanges" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.TechDirectiveChange" />
        </set>
        <set name="techManuals" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.TechManual" />
        </set>
        <set name="distribStmts" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.DistribStmt" />
        </set>
        <set name="safetyMessages" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.SafetyMessage" />
        </set>
        <set name="programMngDocuments" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.ProgramMngDocument" />
        </set>
        <set name="iracs" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.Irac" />
        </set>
        <set name="trainings" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.Training" />
        </set>
        <set name="instructions" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.Instruction" />
        </set>
        <set name="techPubDeficiencyRpts" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.TechPubDeficiencyRpt" />
        </set>
        <set name="configManagements" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.ConfigManagement" />
        </set>
        <set name="hazardousMaterials" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.HazardousMaterial" />
        </set>
        <set name="securityClassifications" inverse="true">
            <key><column name="fk_jtdi_doc_id" not-null="true" /></key>
            <one-to-many class="jtdi.metadata.orm.SecurityClassification" />
        </set>
    </class>
</hibernate-mapping>



Full stack trace of any exception that occurs:

[code]
Exception in thread "main" org.springframework.orm.hibernate3.HibernateSystemException: reassociated object has dirty collection reference (or an array); nested exception is org.hibernate.HibernateException: reassociated object has dirty collection reference (or an array)
Caused by: org.hibernate.HibernateException: reassociated object has dirty collection reference (or an array)
at org.hibernate.event.def.OnLockVisitor.processCollection(OnLockVisitor.java:66)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:61)
at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55)
at org.hibernate.event.def.AbstractVisitor.process(AbstractVisitor.java:123)
at org.hibernate.event.def.AbstractReassociateEventListener.reassociate(AbstractReassociateEventListener.java:78)
at org.hibernate.event.def.DefaultLockEventListener.onLock(DefaultLockEventListener.java:59)
at org.hibernate.impl.SessionImpl.fireLock(SessionImpl.java:579)
at org.hibernate.impl.SessionImpl.lock(SessionImpl.java:571)
at org.springframework.orm.hibernate3.HibernateTemplate$10.doInHibernate(HibernateTemplate.java:614)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
at org.springframework.orm.hibernate3.HibernateTemplate.lock(HibernateTemplate.java:612)
at jtdi.metadata.orm.dao.JtdiDocumentDAO.attachClean(JtdiDocumentDAO.java:169)
at jtdi.metadata.persistence.bean.JtdiDocumentBean.addJtdiDocument(JtdiDocumentBean.java:19)
at jtdi.metadata.business.helper.JtdiDocumentBusinessHelper.persistJtdiDocument(JtdiDocumentBusinessHelper.java:59)
at jtdi.metadata.business.helper.JtdiDocumentBusinessHelper.main(JtdiDocumentBusinessHelper.java:114)
[/cde]

Name and version of the database you are using: MySQL 5.0



Here is code from Hibernate's OnLockVisitor


[code]
if ( collection == null ) {
//do nothing
}
else if ( collection instanceof PersistentCollection ) {
....... // Do something
}
else {
* // brand new collection
//TODO: or an array!! we can't lock objects with arrays
now??
throw new HibernateException( "reassociated object has
dirty collection reference (or an array)" );* }
[/code]


As you can see for yourself this situation occurs if your collection is not
PersistentCollection (i.e. if you have replaced collection completely after
obtaining object from DB) or is you use array (not very likely).




Thank you for taking the time to read my post and for any suggetions you can offer.

Russ


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 29, 2008 9:57 pm 
Beginner
Beginner

Joined: Thu Dec 08, 2005 12:18 pm
Posts: 21
Location: Birmingham, Alabama
I have spent most of the day walking through the entity and hibernate configuration files to ensure I have the relationships marked correctly. I have also turned on all the logging I can in an effort to identify my problem.

I am not populating any collections in my test. The only thing I am trying to accomplish is add one record in one table.

Code:
--attach failed

org.springframework.orm.hibernate3.HibernateSystemException: reassociated object has dirty collection reference (or an array); nested exception is org.hibernate.HibernateException: reassociated object has dirty collection reference (or an array)

Caused by:

org.hibernate.HibernateException: reassociated object has dirty collection reference (or an array)

            at org.hibernate.event.def.OnLockVisitor.processCollection(OnLockVisitor.java:66)

            at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101)

            at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:61)

            at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55)

            at org.hibernate.event.def.AbstractVisitor.process(AbstractVisitor.java:123)

            at org.hibernate.event.def.AbstractReassociateEventListener.reassociate(AbstractReassociateEventListener.java:78)

            at org.hibernate.event.def.DefaultLockEventListener.onLock(DefaultLockEventListener.java:59)

            at org.hibernate.impl.SessionImpl.fireLock(SessionImpl.java:579)

            at org.hibernate.impl.SessionImpl.lock(SessionImpl.java:571)

            at org.springframework.orm.hibernate3.HibernateTemplate$10.doInHibernate(HibernateTemplate.java:614)

            at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)

            at org.springframework.orm.hibernate3.HibernateTemplate.lock(HibernateTemplate.java:612)

            at jtdi.metadata.orm.dao.JtdiDocumentDAO.attachClean(JtdiDocumentDAO.java:167)

            at jtdi.metadata.persistence.bean.JtdiDocumentBean.addJtdiDocument(JtdiDocumentBean.java:19)

            at jtdi.metadata.business.helper.JtdiDocumentBusinessHelper.persistJtdiDocument(JtdiDocumentBusinessHelper.java:76)

            at jtdi.metadata.business.helper.JtdiDocumentBusinessHelper.main(JtdiDocumentBusinessHelper.java:131)




Any suggestions would be appreciated.

Russ


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 31, 2008 1:42 pm 
Beginner
Beginner

Joined: Thu Dec 08, 2005 12:18 pm
Posts: 21
Location: Birmingham, Alabama
I found this ina another post:

http://forum.hibernate.org/viewtopic.php?p=2275218&sid=cb11560b9421a85ca4075ab435c6813f

"What happens here is, that hibernate calls the setxx() with an initialized, but empty collection. This is not set so the collection stays as the constructor left it. It may be null in other cases. When re-associating, hibernate sees a collection, which has not been set by it. So it can only conclude, that someone else has called setxxx(), which makes the collection really dirty.

Rule: Only use simple set methods"


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.