You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by mt...@apache.org on 2011/07/07 21:15:42 UTC
svn commit: r1143985 - in /openjpa/trunk:
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/FirebirdDictionary.java
openjpa-project/src/doc/manual/supported_databases.xml
Author: mtylenda
Date: Thu Jul 7 19:15:42 2011
New Revision: 1143985
URL: http://svn.apache.org/viewvc?rev=1143985&view=rev
Log:
OPENJPA-487: After simplifying SQL generation for LOCATE function, the function works on Firebird 2.1 (wow!).
Modified:
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/FirebirdDictionary.java
openjpa/trunk/openjpa-project/src/doc/manual/supported_databases.xml
Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/FirebirdDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/FirebirdDictionary.java?rev=1143985&r1=1143984&r2=1143985&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/FirebirdDictionary.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/FirebirdDictionary.java Thu Jul 7 19:15:42 2011
@@ -384,16 +384,26 @@ public class FirebirdDictionary
}
/**
- * Throw {@link UnsupportedException}. Firebird in version earlier than 2.1
- * has no suitable function. Firebird 2.1 has the <code>POSITION</code>
- * function but using it here results in errors like "data type unknown" or
- * "expression evaluation not supported".
+ * On Firebird 2.1 return <code>POSITION(<find>, <str> [, <start>])<code>.
+ * On older versions throw {@link UnsupportedException} - no suitable function exists.
*/
@Override
public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find,
FilterValue start) {
- throw new UnsupportedException(_loc.get("function-not-supported",
- getClass(), "LOCATE"));
+ if (firebirdVersion < FB_VERSION_21) {
+ throw new UnsupportedException(_loc.get("function-not-supported", getClass(), "LOCATE"));
+ }
+ buf.append("POSITION(");
+ find.appendTo(buf);
+ buf.append(", ");
+ str.appendTo(buf);
+ if (start != null) {
+ buf.append(", ");
+ buf.append("CAST(");
+ start.appendTo(buf);
+ buf.append(" AS INTEGER)");
+ }
+ buf.append(")");
}
/**
Modified: openjpa/trunk/openjpa-project/src/doc/manual/supported_databases.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-project/src/doc/manual/supported_databases.xml?rev=1143985&r1=1143984&r2=1143985&view=diff
==============================================================================
--- openjpa/trunk/openjpa-project/src/doc/manual/supported_databases.xml (original)
+++ openjpa/trunk/openjpa-project/src/doc/manual/supported_databases.xml Thu Jul 7 19:15:42 2011
@@ -848,11 +848,6 @@ In order to use many of JPQL functions w
have to be available in the database.
</para>
</listitem>
- <listitem>
- <para>
-<literal>LOCATE</literal> JPQL function is not supported.
- </para>
- </listitem>
</itemizedlist>
</section>
</section>