mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 00:24:57 +00:00
HHH-5275 - Criteria.setLockMode does not work correctly
This commit is contained in:
parent
35ce5bfef7
commit
a41efe37d5
@ -36,7 +36,7 @@
|
||||
@Entity
|
||||
@Table( name = "T_LOCK_A" )
|
||||
public class A {
|
||||
private Integer id;
|
||||
private Long id;
|
||||
private String value;
|
||||
|
||||
public A() {
|
||||
@ -49,11 +49,11 @@ public A(String value) {
|
||||
@Id
|
||||
@GeneratedValue( generator = "increment" )
|
||||
@GenericGenerator( name = "increment", strategy = "increment" )
|
||||
public Integer getId() {
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
import org.hibernate.testing.async.TimedExecutor;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@ -52,6 +53,8 @@
|
||||
*/
|
||||
@TestForIssue( jiraKey = "HHH-5275")
|
||||
public class LockModeTest extends BaseCoreFunctionalTestCase {
|
||||
private Long id;
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class[] { A.class };
|
||||
@ -61,7 +64,7 @@ protected Class<?>[] getAnnotatedClasses() {
|
||||
public void createData() {
|
||||
Session session = sessionFactory().openSession();
|
||||
session.beginTransaction();
|
||||
session.save( new A( "it" ) );
|
||||
id = (Long) session.save( new A( "it" ) );
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
}
|
||||
@ -82,7 +85,7 @@ public void testLoading() {
|
||||
Session s1 = sessionFactory().openSession();
|
||||
s1.beginTransaction();
|
||||
try {
|
||||
A it = (A) s1.get( A.class, 1, LockMode.PESSIMISTIC_WRITE );
|
||||
A it = (A) s1.get( A.class, id, LockMode.PESSIMISTIC_WRITE );
|
||||
// make sure we got it
|
||||
assertNotNull( it );
|
||||
|
||||
@ -200,7 +203,7 @@ public void execute() {
|
||||
// to write a locked row
|
||||
A it = (A) s.get(
|
||||
A.class,
|
||||
1,
|
||||
id,
|
||||
new LockOptions( LockMode.PESSIMISTIC_WRITE ).setTimeOut( LockOptions.NO_WAIT )
|
||||
);
|
||||
it.setValue( "changed" );
|
||||
|
Loading…
x
Reference in New Issue
Block a user