[jboss-jira] [JBoss JIRA] Closed: (HIBERNATE-115) Bug in AbstractEntityPersister for generated version properties
Steve Ebersole (JIRA)
jira-events at lists.jboss.org
Mon Jun 22 10:48:57 EDT 2009
[ https://jira.jboss.org/jira/browse/HIBERNATE-115?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Steve Ebersole closed HIBERNATE-115.
------------------------------------
Resolution: Rejected
This is not true. The version field should be updated on any state change.
> Bug in AbstractEntityPersister for generated version properties
> ---------------------------------------------------------------
>
> Key: HIBERNATE-115
> URL: https://jira.jboss.org/jira/browse/HIBERNATE-115
> Project: Hibernate
> Issue Type: Bug
> Environment: Jboss 4.2.3 GA, Hibernate 3.3.1, MSSQL Server 2005, actual Merlia DB Driver 7.0.5
> Reporter: Juergen W
> Assignee: Steve Ebersole
>
> Following problem:
> we're using following configuration for our entities (dynamic-update="true" , dynamic-insert="true" , select-before-update="true", the version property is generated by the database and is read-only )
> <?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="de.xxx.xxx.Angebot"
> table="ANGeBot"
> dynamic-update="true"
> dynamic-insert="true"
> select-before-update="true">
>
> <id name="angbId" type="java.lang.Integer" column="ANGB_ID" unsaved-value="0">
> <generator class="identity"/>
> </id>
> <version name="Timestamp" type="binary" column="ANGB_Timestamp" generated="always" insert="false" unsaved-value="undefined"/>
> <property name="Aenderungsdatum" column="ANGB_Aenderungsdatum" type="java.util.Date" length="23"/>
> <property name="Aenderungsperson" column="ANGB_Aenderungsperson" type="java.lang.String" length="30"/>
> <property name="AnbieterAnsprechpartner" column="ANGB_Anbieter_Ansprechpartner" type="java.lang.String" length="100"/>
> ... additional props...
> </class>
> </hibernate-mapping>
> If we made some changes to a row, hibernate should update only the "dirty fields" and NOT the version field. But hibernate tries to update the version property too, and thus we got the db exception, the version column is not updateable.
> Hibernate generates following updatestatement, if we change the field ANGB_ANBIETER_ANSPRECHPARTNER
> UPDATE
> V_AMVW_ANGEBOT
> SET
> ANGB_TIMESTAMP=?, <---- THATs WRONG
> ANGB_ANBIETER_ANSPRECHPARTNER=?
> WHERE
> ANGB_ID=?
> AND ANGB_TIMESTAMP=?
> I think, in the org.hibernate.persister.entity.AbstractEntityPersister in the method getPropertiesToUpdate() following "if statement" is missing if the version property is generated:
> if ( isVersioned()) {
> propsToUpdate[ getVersionProperty() ] =
> Versioning.isVersionIncrementRequired( dirtyProperties, hasDirtyCollection, getPropertyVersionability() );
> }
> If I change the "if" statement to following:
> if ( isVersioned() && !isVersionPropertyGenerated()) {
> propsToUpdate[ getVersionProperty() ] =
> Versioning.isVersionIncrementRequired( dirtyProperties, hasDirtyCollection, getPropertyVersionability() );
> }
> than it is working
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list