-->
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.  [ 4 posts ] 
Author Message
 Post subject: timestamp StaleObjectStateException dom4j import
PostPosted: Wed Apr 27, 2005 1:09 pm 
Newbie

Joined: Mon Mar 14, 2005 11:50 am
Posts: 9
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.2

Mapping documents:<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.eko.cims.model.dict" >

<class entity-name="category" name="Category" table="EventCategories"
rowid="rowid" node="category" >

<id name="id" type="long" column="category_id"
access="field" node="@id" >
<generator class="sequence">
<param name="sequence" >eventCategorySeq</param>
</generator>
</id>

<timestamp column="chg_ts" name="changeTimestamp"
unsaved-value="null" node="@version" />
<property name="changeUserId" type="string"
column="chg_user_id" not-null="true"
access="field" node="@changeuserid" />
<property name="description" type="string"
column="desc_txt" not-null="true" access="field" node="@description" />

<many-to-one name="parent"
column="parent_id"
access="field" node="." entity-name="category" />

<bag name="events" table="EventCategoryMap" access="field" node="event" >
<key column="category_id"/>
<many-to-many column="event_id" class="Event" node="event/@id" entity-name="event" />
</bag>

<bag name="children" table="CategoryChildren" access="field" node="." >
<key column="category_id"/>
<many-to-many column="child_cat_id"
class="Category" node="category" entity-name="category" />
</bag>

</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():tx = session.beginTransaction();

SAXReader reader = new SAXReader();
Document document = reader.read(new File("src/test-data/inova_pospinal_menu.xml").toURL());

TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(
new StreamSource( "src/test-data/menu_template.xsl" )
);

// now lets style the given document
DocumentSource source = new DocumentSource( document );
DocumentResult result = new DocumentResult();
transformer.transform( source, result );

// return the transformed document
Document transformedDoc = result.getDocument();

OutputFormat format = OutputFormat.createPrettyPrint();
XMLWriter writer = new XMLWriter( System.out, format );
writer.write( transformedDoc );

List categories = transformedDoc.selectNodes("//category");
for (int i=0; i < 1; i++) {
Element node = (Element)categories.get(i);
dom4jSession.persist(node);
//dom4jSession.replicate(node, ReplicationMode.IGNORE);
}

dom4jSession.flush();
tx.commit();

XML output from translation is:
<?xml version="1.0" encoding="UTF-8"?>

<categories>
<category changeuserid="system" description="Additional Adjuncts"></category>
<category changeuserid="system" description="Adult Neuraxial Opiod Orders">
<event description="Comorbidities" eventcode="34019300"/>
</category>
<category changeuserid="system" description="Allergies"></category>
<category changeuserid="system" description="Antibiotic Allergies"></category>
<category changeuserid="system" description="Free text Physician"></category>
<category changeuserid="system" description="Height and Weight"></category>
<category changeuserid="system" description="Narcotic Adjuncts"></category>
<category changeuserid="system" description="Narcotic Allergies"></category>
<category changeuserid="system" description="Patient"></category>
<category changeuserid="system" description="Physician and Signatures">
<event description="Physician Signature" eventcode="00900260"/>
<event description="Verbal Order" eventcode="00900250"/>
</category>
<category changeuserid="system" description="Treatment of Side Effects"></category>
</categories>


Full stack trace of any exception that occurs:Hibernate: select eventCategorySeq.nextval from dual
2005-04-27 13:40:23,688 DEBUG - - SessionProxy - onSave, entity: org.dom4j.tree.DefaultElement
2005-04-27 13:40:23,763 DEBUG - - SessionProxy - onFlushDirty, entity: org.dom4j.tree.DefaultElement
Hibernate: insert into dev_EventCategories (chg_ts, chg_user_id, desc_txt, parent_id, category_id) values (?, ?, ?, ?, ?)
Hibernate: update dev_EventCategories set chg_ts=?, chg_user_id=?, desc_txt=?, parent_id=? where category_id=? and chg_ts=?
2005-04-27 13:40:23,884 ERROR - - AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [category#1069]
at org.hibernate.persister.entity.BasicEntityPersister.check(BasicEntityPersister.java:1431)
at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:1976)
at org.hibernate.persister.entity.BasicEntityPersister.updateOrInsert(BasicEntityPersister.java:1899)
at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:2139)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:75)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:678)
at com.eko.cims.model.dict.XmlExportTest.testImportXML(XmlExportTest.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)

Name and version of the database you are using:Oracle 8i

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:DEBUG


Top
 Profile  
 
 Post subject: Ooops :(
PostPosted: Wed Apr 27, 2005 1:13 pm 
Newbie

Joined: Mon Mar 14, 2005 11:50 am
Posts: 9
Forgot to actually say anything. I meant to say that I am having trouble figuring out how to make my importation of xml using the new XML mappings work. I have been able to make it work correctly when I take out the timestamp property in my hbm, or when I have specified a value of "21" or something else in the generated xml that I am importing . I basically need hibernate to either see the version attribute and think it is null and not attached or ..umm..something else?

Whine whine whine!!

BTW this feature is fuck$%# awesome. I just keep loving this product more and more. now fix my problem because it's the most important thing in the world right now... ;)

jesse.


Top
 Profile  
 
 Post subject: Fixed
PostPosted: Wed Apr 27, 2005 3:42 pm 
Newbie

Joined: Mon Mar 14, 2005 11:50 am
Posts: 9
Ok sorry, the ClassCastException was the result of a bad node-mapping in a different mapping file. I would only say that perhaps better exception/line tracing might be in order...I don't know, add a try {} catch around some of the property accessor blocks and add the Entity name you got any exceptions on into your HibernateException? Hah..I know this is all new, and since I do'nt plan on contributing anything i'll just stfu.. :)


Top
 Profile  
 
 Post subject: G$%d damnit
PostPosted: Wed Apr 27, 2005 3:45 pm 
Newbie

Joined: Mon Mar 14, 2005 11:50 am
Posts: 9
F me....I posted a problem solved response to something that was completely unrelated...Damnit..

ok..So my timestamps still aren't working yet...But since I don't REALLY REALYL need them for a while I'll just ignore it until someone sees my sea of inner-monologue here.


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