Hello All!
I'm trying to work with OpenJPA and Firebird database. The actual environment is: Apache ODE BPEL engine under Apache Tomcat 5.5 which uses OpenJPA with Firebird database. After some investigations everything works, but with many limitations. These limitations I wish to talk about.

1. OpenJPA doesn't work with latest Firebird JDBC drivers. Only very old one, from year 2005 version "1.5.6" can be used. But even this is not enough, version "1.5.6" which can be downloaded from http://www.firebirdsql.org/index.php?op=files&id=jaybird doesn't have "jaybird.dll" compiled, so for embedded mode I needed "jaybird.dll" from pre-"1.5.6" release. The reason why it cannot be used is the following exception:
org.firebirdsql.jdbc.FBSQLException: The result set is closed
at org.firebirdsql.jdbc.AbstractResultSet.checkCursorMove(AbstractResultSet.java:217) at org.firebirdsql.jdbc.AbstractResultSet.next(AbstractResultSet.java:249) at org.apache.openjpa.lib.jdbc.DelegatingResultSet.next(DelegatingResultSet.java:106) at org.apache.openjpa.jdbc.sql.ResultSetResult.nextInternal(ResultSetResult.java:222) at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.nextInternal(SelectImpl.java:2285) at org.apache.openjpa.jdbc.sql.AbstractResult.next(AbstractResult.java:169) at org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.load(StoreCollectionFieldStrategy.java:476) at org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:802) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:520)
       ... 14 more

I think the reason of this exception is discussed here: http://tracker.firebirdsql.org/browse/JDBC-91

2. Firebird sequences which are new in Firebird 2.x are not implemented in Firebird dictionary. Even Firebird 1.5.x has sequences, but their name was "Generators". Although I use pretty old JDBC drivers, Firebird database version is 2.1.0. So I use following temporary solution:

import org.apache.openjpa.jdbc.schema.Sequence;
import org.apache.openjpa.jdbc.sql.FirebirdDictionary;

public class Firebird2Dictionary extends FirebirdDictionary {

   public Firebird2Dictionary() {
       super();

       nextSequenceQuery = "SELECT NEXT VALUE FOR {0} FROM RDB$DATABASE";
   }

   @Override
   public String[] getCreateSequenceSQL(Sequence seq) {
       StringBuffer buf = new StringBuffer();
       buf.append("CREATE SEQUENCE ");
       buf.append(getFullName(seq));
       return new String[]{ buf.toString() };
   }

}

3. Native queries cannot be executed in resulting environment. Although all named jpql queries executed successfully, native queries throw the following exception:

<openjpa-1.1.0-r422266:657916 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: You cannot set value of an non-existing parameter.
org.apache.openjpa.jdbc.sql.SQLExceptions.narrow(SQLExceptions.java:146)
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4150)
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88)
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64)
org.apache.openjpa.jdbc.kernel.SQLStoreQuery$SQLExecutor.executeUpdate(SQLStoreQuery.java:237)
org.apache.openjpa.kernel.QueryImpl.update(QueryImpl.java:1038)
org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:808)
org.apache.openjpa.kernel.QueryImpl.updateAll(QueryImpl.java:883)
org.apache.openjpa.kernel.DelegatingQuery.updateAll(DelegatingQuery.java:573)
org.apache.openjpa.persistence.QueryImpl.executeUpdate(QueryImpl.java:319)

...
org.firebirdsql.jdbc.FBSQLException: You cannot set value of an non-existing parameter.
org.firebirdsql.jdbc.FBProcedureCall$NullParam.setValue(FBProcedureCall.java:325)
org.firebirdsql.jdbc.AbstractCallableStatement.setLong(AbstractCallableStatement.java:1042)
org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.setLong(DelegatingPreparedStatement.java:120)
org.apache.ode.utils.LoggingStatementWrapper.setLong(LoggingStatementWrapper.java:495)
org.apache.openjpa.lib.jdbc.DelegatingCallableStatement.setLong(DelegatingCallableStatement.java:299)
org.apache.openjpa.jdbc.sql.DBDictionary.setLong(DBDictionary.java:998)
org.apache.openjpa.jdbc.sql.DBDictionary.setUnknown(DBDictionary.java:1283)
org.apache.openjpa.jdbc.sql.SQLBuffer.setParameters(SQLBuffer.java:568)
org.apache.openjpa.jdbc.kernel.SQLStoreQuery$SQLExecutor.executeUpdate(SQLStoreQuery.java:231)
org.apache.openjpa.kernel.QueryImpl.update(QueryImpl.java:1038)
org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:808)
org.apache.openjpa.kernel.QueryImpl.updateAll(QueryImpl.java:883)
org.apache.openjpa.kernel.DelegatingQuery.updateAll(DelegatingQuery.java:573)
org.apache.openjpa.persistence.QueryImpl.executeUpdate(QueryImpl.java:319)
com.comped.TE.db.openjpa.DbQueryJpa.executeUpdate(DbQueryJpa.java:22)

The statement is:
insert into ANAGRAFICHE (COD_TITOLARE, NOME, CODICE_FISCALE, DATA_NASCITA) values (?, ?, ?, ?) This happens because query parameters are not parsed, and Firebird thinks query doesn't have parameters.

So finally this worths of 3 bug reports. Should I write them, or Firebird support is something no one need, so it is dropped by OpenJPA team? The actual blocker is third case above. I don't know if this bug is inside Firebird JDBC drivers or in OpenJPA, because I cannot upgrade to fresh JDBC driver. What do you think, how can I fix this issue?

Best regards,
Alexey Ousov

Reply via email to