2 Replies Latest reply on May 30, 2013 5:09 AM by skiabox

    Revision_field_name column is not updated

    skiabox

      I have created a spring application using Hibernate Envers but when I am trying to save an updated entity, the revision_field_name column is not advancing and Hibernate is trying to insert again the same number in the column.

      So instead of 2 it tries to insert 1 again and that produces a database error.

       

      See more details below.

       

      spring-config.xml :

      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
             xmlns:jpa="http://www.springframework.org/schema/data/jpa"
             xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
          <context:annotation-config />
          <context:component-scan base-package="foo.bar.service.springjpa"/>
      
      
          <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
              <property name="driverClassName">
                  <value>${jdbc.driverClassName}</value>
              </property>
              <property name="url">
                  <value>${jdbc.url}</value>
              </property>
              <property name="username">
                  <value>${jdbc.username}</value>
              </property>
              <property name="password">
                  <value>${jdbc.password}</value>
              </property>
          </bean>
      
          <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
              <property name="entityManagerFactory" ref="emf"/>
          </bean>
      
          <tx:annotation-driven transaction-manager="transactionManager"/>
      
          <bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
              <property name="dataSource" ref="dataSource"/>
              <property name="jpaVendorAdapter">
                  <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
              </property>
              <property name="packagesToScan" value="foo.bar.domain"/>
              <property name="jpaProperties">
                  <props>
                      <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                      <prop key="hibernate.max_fetch_depth">3</prop>
                      <prop key="hibernate.jdbc.fetch_size">50</prop>
                      <prop key="hibernate.jdbc.batch_size">10</prop>
                      <prop key="hibernate.show_sql">true</prop>
      
                      <!-- Properties for Hibernate Envers -->
                      <prop key="org.hibernate.envers.audit_table_suffix">_H</prop>
                      <prop key="org.hibernate.envers.revision_field_name">AUDIT_REVISION</prop>
                      <prop key="org.hibernate.envers.revision_type_field_name">ACTION_TYPE</prop>
                      <prop key="org.hibernate.envers.audit_strategy">org.hibernate.envers.strategy.ValidityAuditStrategy</prop>
                      <prop key="org.hibernate.envers.audit_strategy_validity_end_rev_field_name">AUDIT_REVISION_END</prop>
                      <prop key="org.hibernate.envers.audit_strategy_validity_store_revend_timestamp">True</prop>
                      <prop key="org.hibernate.envers.audit_strategy_validity_revend_timestamp_field_name">AUDIT_REVISION_END_TS</prop>
                  </props>
              </property>
          </bean>
      
      
          <context:property-placeholder location="jdbc.properties"/>
      
          <jpa:repositories base-package="foo.bar.repository"
                            entity-manager-factory-ref="emf"
                            transaction-manager-ref="transactionManager"/>
      
          <jpa:auditing auditor-aware-ref="auditorAwareBean"/>
      
          <bean id="auditorAwareBean" class="foo.bar.springjpa.auditor.AuditorAwareBean"/>
      </beans>

       

      ContactAudit.java :

      package foo.bar.domain;
      
      import org.hibernate.annotations.Type;
      import org.hibernate.envers.Audited;
      import org.hibernate.envers.NotAudited;
      import org.joda.time.DateTime;
      import org.springframework.data.domain.Auditable;
      
      import javax.persistence.*;
      import java.io.Serializable;
      import java.util.Date;
      import java.util.HashSet;
      import java.util.Set;
      
      import static javax.persistence.GenerationType.IDENTITY;
      
      
      @Audited
      @Table(name = "CONTACT_AUDIT")
      @Entity
      public class ContactAudit implements Auditable<String, Long>, Serializable{
          private Long id;
          private String firstName;
          private String lastName;
          private Date birthDate;
          private int version;
      
          private Set<Hobby> hobbies = new HashSet<Hobby>();
          private Set<ContactTelDetail> contactTelDetails = new HashSet<ContactTelDetail>();
      
          //Audit fields
          private String createdBy;
          private DateTime createdDate;
          private String lastModifiedBy;
          private DateTime lastModifiedDate;
      
          //constructors
          public ContactAudit() {
          }
      
          public ContactAudit(String firstName, String lastName) {
              this.firstName = firstName;
              this.lastName = lastName;
          }
      
          public ContactAudit(String firstName, String lastName, Date birthDate, Set<Hobby> hobbies, Set<ContactTelDetail> contactTelDetails) {
              this.firstName = firstName;
              this.lastName = lastName;
              this.birthDate = birthDate;
              this.hobbies = hobbies;
              this.contactTelDetails = contactTelDetails;
          }
      
          @Column(name = "ID")
          @Id
          @GeneratedValue(strategy = IDENTITY)
          public Long getId() {
              return id;
          }
      
          @Override
          @Transient
          public boolean isNew() {
              if (id == null)
                  return true;
              else
                  return false;
          }
      
          public void setId(Long id) {
              this.id = id;
          }
      
          @Column(name = "FIRST_NAME")
          public String getFirstName() {
              return firstName;
          }
      
          public void setFirstName(String firstName) {
              this.firstName = firstName;
          }
      
          @Column(name = "LAST_NAME")
          public String getLastName() {
              return lastName;
          }
      
          public void setLastName(String lastName) {
              this.lastName = lastName;
          }
      
          @Column(name = "BIRTH_DATE")
          @Temporal(TemporalType.DATE)
          public Date getBirthDate() {
              return birthDate;
          }
      
          public void setBirthDate(Date birthDate) {
              this.birthDate = birthDate;
          }
      
          @Column(name = "VERSION")
          @Version
          public int getVersion() {
              return version;
          }
      
          public void setVersion(int version) {
              this.version = version;
          }
      
          @ManyToMany
          @NotAudited
          @JoinTable(name = "contact_hobby_detail",
                  joinColumns = @JoinColumn(name = "CONTACT_ID"),
                  inverseJoinColumns = @JoinColumn(name = "HOBBY_ID"))
          public Set<Hobby> getHobbies() {
              return hobbies;
          }
      
          public void setHobbies(Set<Hobby> hobbies) {
              this.hobbies = hobbies;
          }
      
          @OneToMany(mappedBy = "contact", cascade = CascadeType.ALL, orphanRemoval = true)
          @NotAudited
          public Set<ContactTelDetail> getContactTelDetails() {
              return contactTelDetails;
          }
      
          public void setContactTelDetails(Set<ContactTelDetail> contactTelDetails) {
              this.contactTelDetails = contactTelDetails;
          }
      
          @Column(name = "CREATED_BY")
          public String getCreatedBy() {
              return createdBy;
          }
      
          public void setCreatedBy(String createdBy) {
              this.createdBy = createdBy;
          }
      
          @Column(name = "CREATED_DATE")
          @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
          public DateTime getCreatedDate() {
              return createdDate;
          }
      
          public void setCreatedDate(DateTime createdDate) {
              this.createdDate = createdDate;
          }
      
          @Column(name = "LAST_MODIFIED_BY")
          public String getLastModifiedBy() {
              return lastModifiedBy;
          }
      
          public void setLastModifiedBy(String lastModifiedBy) {
              this.lastModifiedBy = lastModifiedBy;
          }
      
          @Column(name = "LAST_MODIFIED_DATE")
          @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
          public DateTime getLastModifiedDate() {
              return lastModifiedDate;
          }
      
          public void setLastModifiedDate(DateTime lastModifiedDate) {
              this.lastModifiedDate = lastModifiedDate;
          }
      
          //other methods
          public String toString()
          {
              return "Contact - Id: " + id + ", First name: " + firstName + ", Last name: " + lastName + ", Birthday: " + birthDate
                      + ", Create by: " + createdBy + ", Create date: " + createdDate + ", Modified by: " + lastModifiedBy + ", Modifed date: " + lastModifiedDate;
      
          }
      
      }

       

       

      ContactAuditServiceImpl.java :

      package foo.bar.service.springjpa;
      
      import com.google.common.collect.Lists;
      import foo.bar.domain.ContactAudit;
      import foo.bar.repository.ContactAuditRepository;
      import foo.bar.service.ContactAuditService;
      import org.hibernate.envers.AuditReader;
      import org.hibernate.envers.AuditReaderFactory;
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.stereotype.Repository;
      import org.springframework.stereotype.Service;
      import org.springframework.transaction.annotation.Transactional;
      
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      import java.util.List;
      
      
      @Service("contactAuditService")
      @Repository
      @Transactional
      public class ContactAuditServiceImpl implements ContactAuditService{
      
          @Autowired
          private ContactAuditRepository contactAuditRepository;
      
          @PersistenceContext
          private EntityManager entityManager;
      
          @Override
          @Transactional(readOnly = true)
          public List<ContactAudit> findAll() {
              return Lists.newArrayList(contactAuditRepository.findAll());
          }
      
          @Override
          @Transactional(readOnly = true)
          public ContactAudit findById(Long id) {
              return contactAuditRepository.findOne(id);
          }
      
          @Override
          public ContactAudit save(ContactAudit contact) {
              return contactAuditRepository.save(contact);
          }
      
          @Override
          @Transactional(readOnly = true)
          public ContactAudit findAuditByRevision(Long id, int revision) {
              AuditReader auditReader = AuditReaderFactory.get(entityManager);
              return auditReader.find(ContactAudit.class, id, revision);
          }
      }

       

      AuditorAwareBean.java

      package foo.bar.springjpa.auditor;
      
      import org.springframework.data.domain.AuditorAware;
      
      public class AuditorAwareBean implements AuditorAware<String>{
          @Override
          public String getCurrentAuditor() {
              return "prospring3";
          }
      }

       

      SpringJpaAuditSample.java :

      package foo.bar;
      
      import foo.bar.domain.ContactAudit;
      import foo.bar.service.ContactAuditService;
      import org.springframework.context.support.GenericXmlApplicationContext;
      
      import java.util.Date;
      import java.util.List;
      
      
      public class SpringJpaAuditSample {
      
          public static void main(String[] args) {
              GenericXmlApplicationContext ctx = new GenericXmlApplicationContext("spring-config.xml");
      
              ContactAuditService contactService = ctx.getBean("contactAuditService", ContactAuditService.class);
      
              List<ContactAudit> contacts = contactService.findAll();
              listContacts(contacts);
      
              //Add new contact
              System.out.println("Add new contact");
              ContactAudit contact = new ContactAudit();
              contact.setFirstName("Michael");
              contact.setLastName("Jackson");
              contact.setBirthDate(new Date());
              contactService.save(contact);
              contacts = contactService.findAll();
              listContacts(contacts);
      
              //Update contact
              System.out.println("Update contact");
              contact.setFirstName("Tom");
              contactService.save(contact);
              contacts = contactService.findAll();
              listContacts(contacts);
      
              //Find audit record by revision
              ContactAudit oldContact = contactService.findAuditByRevision(1L, 1);
              System.out.println("");
              System.out.println("Old Contact with id 1 and rev 1:" + oldContact);;
              System.out.println("");
              oldContact = contactService.findAuditByRevision(1L, 2);
              System.out.println("");
              System.out.println("Old Contact with id 1 and rev 2:" + oldContact);
              System.out.println("");
          }
      
          private static void listContacts(List<ContactAudit> contacts)
          {
              System.out.println("");
              System.out.println("Listing contacts without details:");
              for(ContactAudit contact: contacts)
              {
                  System.out.println(contact);
                  System.out.println();
              }
          }
      }

       

      Database table script

       

      CREATE TABLE CONTACT_AUDIT_H (
             ID INT NOT NULL
           , FIRST_NAME VARCHAR(60) NOT NULL
           , LAST_NAME VARCHAR(40) NOT NULL
           , BIRTH_DATE DATE
           , VERSION INT NOT NULL DEFAULT 0
           , CREATED_BY VARCHAR(20)
           , CREATED_DATE TIMESTAMP
           , LAST_MODIFIED_BY VARCHAR(20)
           , LAST_MODIFIED_DATE TIMESTAMP
           , AUDIT_REVISION INT NOT NULL
           , ACTION_TYPE INT
           , AUDIT_REVISION_END INT
           , AUDIT_REVISION_END_TS TIMESTAMP
           , UNIQUE UQ_CONTACT_AUDIT_H_1 (FIRST_NAME, LAST_NAME)
           , PRIMARY KEY (ID, AUDIT_REVISION)
      );

       

      pom.xml :

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
          <modelVersion>4.0.0</modelVersion>
          <groupId>foo.bar</groupId>
          <artifactId>SimpleProject25</artifactId>
          <packaging>jar</packaging>
          <version>1.0-SNAPSHOT</version>
          <name>SimpleProject25</name>
          <url>http://maven.apache.org</url>
      
          <properties>
              <spring.version>3.2.2.RELEASE</spring.version>
          </properties>
      
          <dependencies>
              <dependency>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-core</artifactId>
                  <version>${spring.version}</version>
              </dependency>
      
              <dependency>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-context</artifactId>
                  <version>${spring.version}</version>
              </dependency>
      
              <dependency>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-aspects</artifactId>
                  <version>${spring.version}</version>
              </dependency>
      
              <dependency>
                  <groupId>junit</groupId>
                  <artifactId>junit</artifactId>
                  <version>4.8.2</version>
                  <scope>test</scope>
              </dependency>
              <dependency>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-test</artifactId>
                  <version>${spring.version}</version>
                  <scope>test</scope>
              </dependency>
              <dependency>
                  <groupId>org.slf4j</groupId>
                  <artifactId>slf4j-log4j12</artifactId>
                  <version>1.7.2</version>
              </dependency>
      
              <dependency>
                  <groupId>mysql</groupId>
                  <artifactId>mysql-connector-java</artifactId>
                  <version>5.1.25</version>
              </dependency>
      
              <dependency>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-jdbc</artifactId>
                  <version>${spring.version}</version>
              </dependency>
      
              <dependency>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-orm</artifactId>
                  <version>${spring.version}</version>
              </dependency>
      
              <dependency>
                  <groupId>commons-dbcp</groupId>
                  <artifactId>commons-dbcp</artifactId>
                  <version>1.4</version>
              </dependency>
      
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-entitymanager</artifactId>
                  <version>4.2.1.Final</version>
              </dependency>
      
              <dependency>
                  <groupId>javax.validation</groupId>
                  <artifactId>validation-api</artifactId>
                  <version>1.1.0.Final</version>
              </dependency>
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-validator</artifactId>
                  <version>5.0.1.Final</version>
              </dependency>
              <dependency>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-context-support</artifactId>
                  <version>${spring.version}</version>
              </dependency>
              <dependency>
                  <groupId>org.springframework.data</groupId>
                  <artifactId>spring-data-jpa</artifactId>
                  <version>1.3.2.RELEASE</version>
              </dependency>
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-envers</artifactId>
                  <version>4.2.1.Final</version>
              </dependency>
      
              <dependency>
                  <groupId>org.hibernate.javax.persistence</groupId>
                  <artifactId>hibernate-jpa-2.0-api</artifactId>
                  <version>1.0.1.Final</version>
              </dependency>
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-jpamodelgen</artifactId>
                  <version>1.2.0.Final</version>
              </dependency>
      
              <dependency>
                  <groupId>joda-time</groupId>
                  <artifactId>joda-time</artifactId>
                  <version>2.2</version>
              </dependency>
              <dependency>
                  <groupId>joda-time</groupId>
                  <artifactId>joda-time-hibernate</artifactId>
                  <version>1.3</version>
              </dependency>
              <dependency>
                  <groupId>com.google.guava</groupId>
                  <artifactId>guava</artifactId>
                  <version>14.0.1</version>
              </dependency>
      
              <dependency>
                  <groupId>org.jadira.usertype</groupId>
                  <artifactId>usertype.core</artifactId>
                  <version>3.1.0.CR6</version>
              </dependency>
          </dependencies>
      
          <build>
              <finalName>SpringApp</finalName>
              <plugins>
                  <plugin>
                      <artifactId>maven-compiler-plugin</artifactId>
                      <configuration>
                          <source>1.6</source>
                          <target>1.6</target>
                          <compilerArguments>
                              <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
                          </compilerArguments>
                      </configuration>
                  </plugin>
                  <plugin>
                      <artifactId>maven-surefire-plugin</artifactId>
                      <configuration>
                          <includes>
                              <include>**/*Tests.java</include>
                          </includes>
                      </configuration>
                  </plugin>
              </plugins>
          </build>
      </project>

        • 1. Re: Revision_field_name column is not updated
          skiabox

          Any ideas guys on this one?

          • 2. Re: Revision_field_name column is not updated
            skiabox

            Here is the code that gets to the mysql server from the application :

            Query,"/* mysql-connector-java-5.1.25 ( Revision: ${bzr.revision-id} ) */SHOW VARIABLES WHERE Variable_name ='language' OR Variable_name = 'net_write_timeout' OR Variable_name = 'interactive_timeout' OR Variable_name = 'wait_timeout' OR Variable_name = 'character_set_client' OR Variable_name = 'character_set_connection' OR Variable_name = 'character_set' OR Variable_name = 'character_set_server' OR Variable_name = 'tx_isolation' OR Variable_name = 'transaction_isolation' OR Variable_name = 'character_set_results' OR Variable_name = 'timezone' OR Variable_name = 'time_zone' OR Variable_name = 'system_time_zone' OR Variable_name = 'lower_case_table_names' OR Variable_name = 'max_allowed_packet' OR Variable_name = 'net_buffer_length' OR Variable_name = 'sql_mode' OR Variable_name = 'query_cache_type' OR Variable_name = 'query_cache_size' OR Variable_name = 'init_connect'"
            Query,"/* mysql-connector-java-5.1.25 ( Revision: ${bzr.revision-id} ) */SELECT @@session.auto_increment_increment"
            Query,"SHOW COLLATION"
            Query,"SET NAMES latin1"
            Query,"SET character_set_results = NULL"
            Query,"SET autocommit=1"
            Query,"SET sql_mode='STRICT_TRANS_TABLES'"
            Query,"SET autocommit=0"
            Query,"select contactaud0_.ID as ID1_0_, contactaud0_.BIRTH_DATE as BIRTH2_0_, contactaud0_.CREATED_BY as CREATED3_0_, contactaud0_.CREATED_DATE as CREATED4_0_, contactaud0_.FIRST_NAME as FIRST5_0_, contactaud0_.LAST_MODIFIED_BY as LAST6_0_, contactaud0_.LAST_MODIFIED_DATE as LAST7_0_, contactaud0_.LAST_NAME as LAST8_0_, contactaud0_.VERSION as VERSION9_0_ from CONTACT_AUDIT contactaud0_"
            Query,commit
            Query,"SET autocommit=1"
            Query,"SET autocommit=0"
            Query,"insert into CONTACT_AUDIT (BIRTH_DATE, CREATED_BY, CREATED_DATE, FIRST_NAME, LAST_MODIFIED_BY, LAST_MODIFIED_DATE, LAST_NAME, VERSION) values ('2013-05-28', 'prospring3', '2013-05-28 12:40:44', 'Michael', 'prospring3', '2013-05-28 12:40:44', 'Jackson', 0)"
            Query,"insert into REVINFO (REVTSTMP) values (1369744844762)"
            Query,"insert into CONTACT_AUDIT_H (ACTION_TYPE, AUDIT_REVISION_END, AUDIT_REVISION_END_TS, BIRTH_DATE, CREATED_BY, CREATED_DATE, FIRST_NAME, LAST_MODIFIED_BY, LAST_MODIFIED_DATE, LAST_NAME, ID, AUDIT_REVISION) values (0, null, null, '2013-05-28', 'prospring3', '2013-05-28 12:40:44', 'Michael', 'prospring3', '2013-05-28 12:40:44', 'Jackson', 1, 1)"
            Query,commit
            Query,"SET autocommit=1"
            Query,"SET autocommit=0"
            Query,"select contactaud0_.ID as ID1_0_, contactaud0_.BIRTH_DATE as BIRTH2_0_, contactaud0_.CREATED_BY as CREATED3_0_, contactaud0_.CREATED_DATE as CREATED4_0_, contactaud0_.FIRST_NAME as FIRST5_0_, contactaud0_.LAST_MODIFIED_BY as LAST6_0_, contactaud0_.LAST_MODIFIED_DATE as LAST7_0_, contactaud0_.LAST_NAME as LAST8_0_, contactaud0_.VERSION as VERSION9_0_ from CONTACT_AUDIT contactaud0_"
            Query,commit
            Query,"SET autocommit=1"
            Query,"SET autocommit=0"
            Query,"select contactaud0_.ID as ID1_0_1_, contactaud0_.BIRTH_DATE as BIRTH2_0_1_, contactaud0_.CREATED_BY as CREATED3_0_1_, contactaud0_.CREATED_DATE as CREATED4_0_1_, contactaud0_.FIRST_NAME as FIRST5_0_1_, contactaud0_.LAST_MODIFIED_BY as LAST6_0_1_, contactaud0_.LAST_MODIFIED_DATE as LAST7_0_1_, contactaud0_.LAST_NAME as LAST8_0_1_, contactaud0_.VERSION as VERSION9_0_1_, contacttel1_.CONTACT_ID as CONTACT5_0_3_, contacttel1_.ID as ID1_5_3_, contacttel1_.ID as ID1_5_0_, contacttel1_.CONTACT_ID as CONTACT5_5_0_, contacttel1_.TEL_NUMBER as TEL2_5_0_, contacttel1_.TEL_TYPE as TEL3_5_0_, contacttel1_.VERSION as VERSION4_5_0_ from CONTACT_AUDIT contactaud0_ left outer join contact_tel_detail contacttel1_ on contactaud0_.ID=contacttel1_.CONTACT_ID where contactaud0_.ID=1"
            Query,"select contact0_.ID as ID1_3_1_, contact0_.BIRTH_DATE as BIRTH2_3_1_, contact0_.FIRST_NAME as FIRST3_3_1_, contact0_.LAST_NAME as LAST4_3_1_, contact0_.VERSION as VERSION5_3_1_, contacttel1_.CONTACT_ID as CONTACT5_3_3_, contacttel1_.ID as ID1_5_3_, contacttel1_.ID as ID1_5_0_, contacttel1_.CONTACT_ID as CONTACT5_5_0_, contacttel1_.TEL_NUMBER as TEL2_5_0_, contacttel1_.TEL_TYPE as TEL3_5_0_, contacttel1_.VERSION as VERSION4_5_0_ from contact contact0_ left outer join contact_tel_detail contacttel1_ on contact0_.ID=contacttel1_.CONTACT_ID where contact0_.ID=1"
            Query,"select hobbies0_.CONTACT_ID as CONTACT2_0_1_, hobbies0_.HOBBY_ID as HOBBY1_4_1_, hobby1_.HOBBY_ID as HOBBY1_6_0_ from contact_hobby_detail hobbies0_ inner join hobby hobby1_ on hobbies0_.HOBBY_ID=hobby1_.HOBBY_ID where hobbies0_.CONTACT_ID=1"
            Query,"update CONTACT_AUDIT set BIRTH_DATE='2013-05-28', CREATED_BY='prospring3', CREATED_DATE='2013-05-28 12:40:44', FIRST_NAME='Tom', LAST_MODIFIED_BY='prospring3', LAST_MODIFIED_DATE='2013-05-28 12:40:44', LAST_NAME='Jackson', VERSION=1 where ID=1 and VERSION=0"
            Query,"insert into REVINFO (REVTSTMP) values (1369744844980)"
            Query,"insert into CONTACT_AUDIT_H (ACTION_TYPE, AUDIT_REVISION_END, AUDIT_REVISION_END_TS, BIRTH_DATE, CREATED_BY, CREATED_DATE, FIRST_NAME, LAST_MODIFIED_BY, LAST_MODIFIED_DATE, LAST_NAME, ID, AUDIT_REVISION) values (1, null, null, '2013-05-28', 'prospring3', '2013-05-28 12:40:44', 'Tom', 'prospring3', '2013-05-28 12:40:44', 'Jackson', 1, 1)"
            Query,rollback
            Query,"SET autocommit=1"