mirror of https://github.com/apache/openjpa.git
OPENJPA-703 add testcase for getSingleResult
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@741737 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6bbbb786c2
commit
72fa143e53
|
@ -18,12 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.openjpa.persistence.jdbc;
|
package org.apache.openjpa.persistence.jdbc;
|
||||||
|
|
||||||
|
import javax.persistence.NoResultException;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
|
|
||||||
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
|
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
|
||||||
import org.apache.openjpa.persistence.simple.AllFieldTypes;
|
import org.apache.openjpa.persistence.simple.AllFieldTypes;
|
||||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
|
||||||
import org.apache.openjpa.persistence.OpenJPAQuery;
|
import org.apache.openjpa.persistence.OpenJPAQuery;
|
||||||
import org.apache.openjpa.persistence.InvalidStateException;
|
import org.apache.openjpa.persistence.InvalidStateException;
|
||||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
|
import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
|
||||||
|
@ -39,17 +39,39 @@ public class TestOptimizeForClause
|
||||||
setUp(AllFieldTypes.class);
|
setUp(AllFieldTypes.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testOptimizeForClauseViaGetSingleResult() {
|
||||||
|
OpenJPAEntityManagerSPI em = emf.createEntityManager();
|
||||||
|
DBDictionary dict = ((JDBCConfiguration) em.getConfiguration())
|
||||||
|
.getDBDictionaryInstance();
|
||||||
|
|
||||||
|
sql.clear();
|
||||||
|
|
||||||
|
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) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
em.close();
|
||||||
|
}
|
||||||
|
|
||||||
public void testOptimizeForClauseViaHint() {
|
public void testOptimizeForClauseViaHint() {
|
||||||
testOptimizeForClause(true,false,false);
|
tstOptimizeForClause(true,false,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOptimizeForClauseViaFind() {
|
public void testOptimizeForClauseViaFind() {
|
||||||
testOptimizeForClause(false,true,false);
|
tstOptimizeForClause(false,true,false);
|
||||||
}
|
}
|
||||||
public void testOptimizeForClauseViaQueryHint() {
|
public void testOptimizeForClauseViaQueryHint() {
|
||||||
testOptimizeForClause(false,true,true);
|
tstOptimizeForClause(false,true,true);
|
||||||
}
|
}
|
||||||
public void testOptimizeForClause(boolean hint,
|
public void tstOptimizeForClause(boolean hint,
|
||||||
boolean find, boolean queryHint) {
|
boolean find, boolean queryHint) {
|
||||||
OpenJPAEntityManagerSPI em = emf.createEntityManager();
|
OpenJPAEntityManagerSPI em = emf.createEntityManager();
|
||||||
DBDictionary dict = ((JDBCConfiguration) em.getConfiguration())
|
DBDictionary dict = ((JDBCConfiguration) em.getConfiguration())
|
||||||
|
|
Loading…
Reference in New Issue