From ed3889ff690ee3bc974c5efad6a59b09f767da3e Mon Sep 17 00:00:00 2001 From: Catalina Wei Date: Fri, 6 Feb 2009 21:43:53 +0000 Subject: [PATCH] OPENJPA-703 fix TestOptimizeForClause testcase git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@741745 13f79535-47bb-0310-9956-ffa450edef68 --- .../jdbc/TestOptimizeForClause.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java index e2493caa9..0867fda5f 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java @@ -43,20 +43,22 @@ public class TestOptimizeForClause OpenJPAEntityManagerSPI em = emf.createEntityManager(); DBDictionary dict = ((JDBCConfiguration) em.getConfiguration()) .getDBDictionaryInstance(); + + em.getTransaction().begin(); + AllFieldTypes a = new AllFieldTypes(); + a.setIntField(123); + em.persist(a); + em.getTransaction().commit(); + em.clear(); sql.clear(); + Object result = em.createQuery + ("select o from AllFieldTypes o where o.intField = 123"). + getSingleResult(); - try { - Object result = em.createQuery - ("select o from AllFieldTypes o where o.intField = 0"). - getSingleResult(); - - assertNull(result); - if (dict instanceof DB2Dictionary ) { - assertContainsSQL(" optimize for 1 row"); - } - } catch (NoResultException pe) { - ; + assertNotNull(result); + if (dict instanceof DB2Dictionary ) { + assertContainsSQL(" optimize for 1 row"); } em.close(); }