openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1692088 - in /openjpa/trunk: openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/ openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/
Date Tue, 21 Jul 2015 11:25:36 GMT
Author: struberg
Date: Tue Jul 21 11:25:35 2015
New Revision: 1692088

URL: http://svn.apache.org/r1692088
Log:
OPENJPA-2601 fix 'hint' element in orm.xml parsing

Txs to Kariem Hussein for the patch!

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/TestXMLPersistenceMetaDataParser.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/orm.xml
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/TestXMLPersistenceMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/TestXMLPersistenceMetaDataParser.java?rev=1692088&r1=1692087&r2=1692088&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/TestXMLPersistenceMetaDataParser.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/TestXMLPersistenceMetaDataParser.java
Tue Jul 21 11:25:35 2015
@@ -23,6 +23,9 @@ import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.openjpa.kernel.QueryHints;
+import org.apache.openjpa.meta.QueryMetaData;
+import org.apache.openjpa.persistence.meta.MetamodelImpl;
 import org.apache.openjpa.persistence.test.SQLListenerTestCase;
 import javax.persistence.*;
 
@@ -161,7 +164,14 @@ public class TestXMLPersistenceMetaDataP
         em.close();
         
     }
-    
+
+    public void testQueryHintOrmXml() {
+        QueryMetaData[] meta = ((MetamodelImpl) emf.getMetamodel()).getRepository().getQueryMetaDatas();
+        assertEquals(1, meta.length);
+        assertEquals("Country1.literal", meta[0].getName());
+        assertEquals(1, meta[0].getHintKeys().length);
+        assertEquals(QueryHints.HINT_USE_LITERAL_IN_SQL, meta[0].getHintKeys()[0]);
+    }
 
     private void printArrayList(ArrayList aList) {
         Iterator itr = aList.iterator();

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/orm.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/orm.xml?rev=1692088&r1=1692087&r2=1692088&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/orm.xml
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/orm.xml
Tue Jul 21 11:25:35 2015
@@ -22,6 +22,10 @@
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
  version="1.0">
     <package>org.apache.openjpa.persistence</package>
+    <named-query name="Country1.literal">
+        <query>Select c from Country1 c where c.name = 'literal'</query>
+        <hint name="openjpa.hint.UseLiteralInSQL" value="true" />
+    </named-query>
     <entity class="Security1">
         <table name="SECURITY1" />
         <attributes>

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java?rev=1692088&r1=1692087&r2=1692088&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
Tue Jul 21 11:25:35 2015
@@ -170,7 +170,7 @@ public class XMLPersistenceMetaDataParse
 
         _elems.put("named-query", QUERY);
         _elems.put("named-native-query", NATIVE_QUERY);
-        _elems.put("query-hint", QUERY_HINT);
+        _elems.put("hint", QUERY_HINT);
         _elems.put("query", QUERY_STRING);
 
         _elems.put("flush-mode", FLUSH_MODE);



Mime
View raw message