juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ks...@apache.org
Subject svn commit: r746512 - /webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/util/DynamicQuery.java
Date Sat, 21 Feb 2009 13:55:23 GMT
Author: kstam
Date: Sat Feb 21 13:55:22 2009
New Revision: 746512

URL: http://svn.apache.org/viewvc?rev=746512&view=rev
Log:
JUDDI-195, Add a number(#) the questionmarks '?#' 

(http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/manual.html#jpa_overview_query_basic)

for example 

select t.entityKey from Tmodel t where (t.authorizedName = ? and UPPER(t.entityKey) like ?)
should be
select t.entityKey from Tmodel t where (t.authorizedName = ?1 and UPPER(t.entityKey) like
?2) 

Modified:
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/util/DynamicQuery.java

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/util/DynamicQuery.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/util/DynamicQuery.java?rev=746512&r1=746511&r2=746512&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/util/DynamicQuery.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/util/DynamicQuery.java
Sat Feb 21 13:55:22 2009
@@ -17,6 +17,7 @@
 
 package org.apache.juddi.query.util;
 
+import java.util.StringTokenizer;
 import java.util.Vector;
 import java.util.List;
 import javax.persistence.Query;
@@ -180,7 +181,14 @@
 	}
 	
 	public Query buildJPAQuery(EntityManager em) {
-		Query qry = em.createQuery(sql.toString());
+		StringTokenizer tokenizer = new StringTokenizer(sql.toString(),"?");
+		StringBuffer sqlBuffer = new StringBuffer();
+		int numberOfTokens = tokenizer.countTokens();
+		for (int i=1; i<numberOfTokens; i++) {
+			sqlBuffer.append(tokenizer.nextToken() + "?" + i);
+		}
+		if (tokenizer.hasMoreTokens()) sqlBuffer.append(tokenizer.nextToken());
+		Query qry = em.createQuery(sqlBuffer.toString());
 		
 		for (int i = 0; i < values.size(); i++)
 			qry.setParameter(i + 1, values.elementAt(i));



---------------------------------------------------------------------
To unsubscribe, e-mail: juddi-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: juddi-cvs-help@ws.apache.org


Mime
View raw message