openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexey Ousov <aou...@gmail.com>
Subject Firebird issues
Date Mon, 17 Nov 2008 10:46:22 GMT
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:

&lt;openjpa-1.1.0-r422266:657916 nonfatal general error> 
org.apache.openjpa.persistence.PersistenceException: You cannot set 
value of an non-existing parameter.&#xd;
org.apache.openjpa.jdbc.sql.SQLExceptions.narrow(SQLExceptions.java:146)&#xd;
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4150)&#xd;
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)&#xd;
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88)&#xd;
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64)&#xd;
org.apache.openjpa.jdbc.kernel.SQLStoreQuery$SQLExecutor.executeUpdate(SQLStoreQuery.java:237)&#xd;
org.apache.openjpa.kernel.QueryImpl.update(QueryImpl.java:1038)&#xd;
org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:808)&#xd;
org.apache.openjpa.kernel.QueryImpl.updateAll(QueryImpl.java:883)&#xd;
org.apache.openjpa.kernel.DelegatingQuery.updateAll(DelegatingQuery.java:573)&#xd;
org.apache.openjpa.persistence.QueryImpl.executeUpdate(QueryImpl.java:319)&#xd;
&#xd;
...&#xd;
org.firebirdsql.jdbc.FBSQLException: You cannot set value of an 
non-existing parameter.&#xd;
org.firebirdsql.jdbc.FBProcedureCall$NullParam.setValue(FBProcedureCall.java:325)&#xd;
org.firebirdsql.jdbc.AbstractCallableStatement.setLong(AbstractCallableStatement.java:1042)&#xd;
org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.setLong(DelegatingPreparedStatement.java:120)&#xd;
org.apache.ode.utils.LoggingStatementWrapper.setLong(LoggingStatementWrapper.java:495)&#xd;
org.apache.openjpa.lib.jdbc.DelegatingCallableStatement.setLong(DelegatingCallableStatement.java:299)&#xd;
org.apache.openjpa.jdbc.sql.DBDictionary.setLong(DBDictionary.java:998)&#xd;
org.apache.openjpa.jdbc.sql.DBDictionary.setUnknown(DBDictionary.java:1283)&#xd;
org.apache.openjpa.jdbc.sql.SQLBuffer.setParameters(SQLBuffer.java:568)&#xd;
org.apache.openjpa.jdbc.kernel.SQLStoreQuery$SQLExecutor.executeUpdate(SQLStoreQuery.java:231)&#xd;
org.apache.openjpa.kernel.QueryImpl.update(QueryImpl.java:1038)&#xd;
org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:808)&#xd;
org.apache.openjpa.kernel.QueryImpl.updateAll(QueryImpl.java:883)&#xd;
org.apache.openjpa.kernel.DelegatingQuery.updateAll(DelegatingQuery.java:573)&#xd;
org.apache.openjpa.persistence.QueryImpl.executeUpdate(QueryImpl.java:319)&#xd;
com.comped.TE.db.openjpa.DbQueryJpa.executeUpdate(DbQueryJpa.java:22)&#xd;

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

Mime
View raw message