Permalink
Browse files

HHH-7356 add failure expected test

  • Loading branch information...
1 parent 51aa114 commit 32d36f6ea984a8dabf8655352244be1510e03081 @stliu stliu committed May 29, 2012
@@ -426,7 +426,7 @@ private static Integer getTimeout(String queryName, QueryHint[] hints) {
if ( timeout != null ) {
// convert milliseconds to seconds
- timeout = new Integer ((int)Math.round(timeout.doubleValue() / 1000.0 ) );
+ timeout = (int)Math.round(timeout.doubleValue() / 1000.0 );
}
else {
// timeout is already in seconds
@@ -29,6 +29,8 @@
import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.ejb.AvailableSettings;
import org.hibernate.ejb.test.BaseEntityManagerFunctionalTestCase;
+import org.hibernate.internal.AbstractSessionImpl;
+import org.hibernate.internal.QueryImpl;
import org.hibernate.testing.*;
import org.jboss.logging.Logger;
import org.junit.Test;
@@ -51,6 +53,17 @@
private static final Logger log = Logger.getLogger( LockTest.class );
@Test
+ @FailureExpected( jiraKey = "HHH-7356")
+ public void testLockTimeoutASNamedQueryHint(){
+ EntityManager em = getOrCreateEntityManager();
+ em.getTransaction().begin();
+ Query query = em.createNamedQuery( "getAll" );
+ query.setLockMode( LockModeType.PESSIMISTIC_READ );
+ int timeout = ((QueryImpl)(((org.hibernate.ejb.QueryImpl)query).getHibernateQuery())).getLockOptions().getTimeOut();
+ assertEquals( 3, timeout );
+ }
+
+ @Test
public void testFindWithTimeoutHint() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
@@ -3,11 +3,15 @@
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import javax.persistence.NamedQuery;
+import javax.persistence.QueryHint;
/**
* @author Emmanuel Bernard
*/
@Entity
+@NamedQuery(name = "getAll", query = "select u from UnversionedLock u",
+hints = @QueryHint( name = "javax.persistence.lock.timeout", value = "3000"))
public class UnversionedLock {
@Id
@GeneratedValue

0 comments on commit 32d36f6

Please sign in to comment.