Hi,
I'm having problems with excluding a property from the automatic version increment. In the below stack-trace the tree_version property has optimistic-lock set to false. I guess whats happening is that the hibernate engine expects to find a sql-query that reads:
update rnode set tree_version=? where node_id=? and version=?
but only finds:
update rnode set tree_version=? where node_id=?
What I'm trying to accomplish is to have the automatic versioning only reflect changes made to the actual node properties and use the tree_version property to record movements of nodes in the tree. When I select a node in the gui I need to be able to spot if only the properties have changed or the node itself has been moved.
Code:
2005-12-08 09:55:50,986 DEBUG org.hibernate.event.def.AbstractFlushingEventListener - executing flush
2005-12-08 09:55:50,986 DEBUG org.hibernate.persister.entity.BasicEntityPersister - Updating entity: [se.elanders.repository.model.RNode#1]
2005-12-08 09:55:50,986 DEBUG org.hibernate.persister.entity.BasicEntityPersister - Existing version: 0 -> New version: 0
2005-12-08 09:55:50,986 DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2005-12-08 09:55:50,986 DEBUG org.hibernate.SQL - update rnode set tree_version=? where node_id=?
Hibernate: update rnode set tree_version=? where node_id=?
2005-12-08 09:55:50,986 DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
2005-12-08 09:55:50,986 DEBUG org.hibernate.persister.entity.BasicEntityPersister - Dehydrating entity: [se.elanders.repository.model.RNode#1]
2005-12-08 09:55:50,986 DEBUG org.hibernate.type.LongType - binding '1' to parameter: 1
2005-12-08 09:55:50,986 DEBUG org.hibernate.type.LongType - binding '1' to parameter: 2
2005-12-08 09:55:50,986 DEBUG org.hibernate.type.LongType - binding '0' to parameter: 3
2005-12-08 09:55:50,986 DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-12-08 09:55:50,986 DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
2005-12-08 09:55:50,986 DEBUG org.hibernate.util.JDBCExceptionReporter - could not update: [se.elanders.repository.model.RNode#1] [update rnode set tree_version=? where node_id=?]
java.sql.SQLException: Parameter index out of bounds. 3 is not between valid values of 1 and 2
The mapping is as follows...
Code:
<hibernate-mapping package="se.elanders.repository.model">
<class name="RNode" lazy="false" table="rnode" dynamic-update="true" dynamic-insert="true">
<id name="nodeId" type="long" unsaved-value="null">
<column name="node_id" not-null="true" unique="true"/>
<generator class="native"/>
</id>
<version name="version" type="long" column="version"/>
<property name="lft" type="long" column="lft" optimistic-lock="false"/>
<property name="rgt" type="long" column="rgt" optimistic-lock="false"/>
<property name="treeVersion" type="long" column="tree_version" optimistic-lock="false"/>
<many-to-one name="parent" entity-name="se.elanders.repository.model.RNode" cascade="none" foreign-key="RNode_nodeId" lazy="true">
<column name="parent_node_id"/>
</many-to-one>
<many-to-one name="object" entity-name="se.elanders.repository.model.RObject" cascade="none" foreign-key="RNode_RObject_objectId" lazy="true">
<column name="object_id"/>
</many-to-one>
</class>
</hibernate-mapping>