HHH-6322 upgrade to hibernate-jpa-2.0-api-1.0.1.Final

This commit is contained in:
Strong Liu 2011-06-15 10:55:40 +08:00
parent 5745d7b2a6
commit 5227cc2c10
3 changed files with 100 additions and 1 deletions

View File

@ -526,7 +526,7 @@
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.0.Final</version>
<version>1.0.1.Final</version>
</dependency>
<!-- Set the version of the hibernate-commons-annotations to be used throughout the the project -->
<dependency>

View File

@ -0,0 +1,54 @@
package org.hibernate.test.optlock;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;
@Table(name = "taba")
@Entity
public class A {
private static final long serialVersionUID = 1L;
private int id;
private int version;
private String descr;
public A() {
}
public A(int id, String descr) {
this.id = id;
this.descr = descr;
}
@Id
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Version
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
@Basic
public String getDescr() {
return descr;
}
public void setDescr(String descr) {
this.descr = descr;
}
}

View File

@ -0,0 +1,45 @@
package org.hibernate.test.optlock;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
/**
* @author Strong Liu
*/
public class IssueHibernateTest extends TestCase {
public IssueHibernateTest() {
}
public IssueHibernateTest(String name) {
super( name );
}
public void testCheckDBVersion() {
Session s = openSession();
s.beginTransaction();
A a1 = new A( 1, "test1" );
s.persist( a1 );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
A a=(A)s.get( A.class,1 );
assertEquals( 0,a.getVersion() );
s.clear();
Session s2 = openSession();
s2.beginTransaction();
A a2 = (A)s2.get( A.class,1 );
a2.setDescr( "changed 2" );
s2.merge( a2 );
s2.getTransaction().commit();
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] { A.class };
}
}