On 01/22/2010 07:38 PM, cjdelisle (SVN) wrote:
Author: cjdelisle
Date: 2010-01-22 19:38:30 +0100 (Fri, 22 Jan 2010)
New Revision: 26312
Modified:
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java
Log:
XWIKI-4754 parameterize query in getTranslationList
Modified:
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java
===================================================================
---
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java 2010-01-22
17:49:40 UTC (rev 26311)
+++
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java 2010-01-22
18:38:30 UTC (rev 26312)
@@ -3024,11 +3024,12 @@
public List<String> getTranslationList(XWikiDocument doc, XWikiContext
context) throws XWikiException
{
- String hql =
- "select doc.language from XWikiDocument as doc where doc.space =
'" + Utils.SQLFilter(doc.getSpace())
- + "' and doc.name = '" +
Utils.SQLFilter(doc.getName())
- + "' and (doc.language<> '' or (doc.language is
not null and '' is null))";
- List<String> list = context.getWiki().search(hql, context);
+ String hql = "select doc.language from XWikiDocument as doc where doc.space
= ? and doc.name = ? "
+ + "and (doc.language<> '' or (doc.language
is not null and '' is null))";
doc.space and doc.name are explicitly used for historical reasons (in
the beginning doc.fullName was not stored in the database). For better
performance we could just use doc.fullName = ?.
+ ArrayList<String> params = new
ArrayList<String>();
+ params.add(doc.getSpace());
+ params.add(doc.getName());
+ List<String> list = search(hql, 0, 0, params, context);
return (list == null) ? new ArrayList<String>() : list;
}
--
Sergiu Dumitriu
http://purl.org/net/sergiu/