ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fischer Christian (JIRA)" <ibatis-...@incubator.apache.org>
Subject [jira] Created: (IBATIS-285) ABATOR SQL map generator creates incorrect XML maps using Sybase and Oracle
Date Thu, 06 Apr 2006 07:13:47 GMT
ABATOR SQL map generator creates incorrect XML maps using Sybase and Oracle

         Key: IBATIS-285
         URL: http://issues.apache.org/jira/browse/IBATIS-285
     Project: iBatis for Java
        Type: Bug

  Components: DAO  
    Versions: 2.1.7    
 Environment: IBATIS 2.1.7, Abator 0.6.1, Sybase or Oracle DB 9.i, JAVA
    Reporter: Fischer Christian

I generated SQL maps and DAO classes using the ABATOR generator and the Eclipse plugin. The
datasoruce is either Sybase or an Oracle 9.i DB. 

The problem is the generated SQL maps are not correct! In general all definitions which starts
with 'abatorgenerated_' are missing the
prefix containing [schema]_[tablename]. 

Because they are referenced in the same XML map file and also from IBATIS classes using
the prefix you get errors like:
com.ibatis.common.exception.NestedRuntimeException: Could not find SQL statement to include
with refid 'schema_tablename.abatorgenerated_Example_Where_Clause'

There is an include in the map file like:
<include refid="schema_tablename.abatorgenerated_Example_Where_Clause"/>

But the definition is:
<sql id="abatorgenerated_Example_Where_Clause">

So the problem is fixed either by removing the prefix in the include or appending it in the

I checked the ABATOR source code and found the problem immediately in SqlMapGeneratorDefaultImpl.java.

The code to generate above refid attributes is:

addAttribute(xml, "refid", getSqlMapNamespace(tableConfiguration.getTable()) + "." + getExampleWhereClauseId());

whereas the code to generate e.g. above  <sql id="abatorgenerated ... tags is:

protected String getExampleWhereClauseId() {
        return "abatorgenerated_Example_Where_Clause";

My quick solution was to remove the getSqlMapNamespace(tableConfiguration.getTable()) + "."
in the code where the
refid attributs are generated. But unfortunately the XML map is also accessed directly by
the IBATIS classes which also
appends the prefix. This affects all methods like:

public String getInsertStatementId()
public String getSelectByExampleStatementId()

So I think the solution should be to change all these getXXXId() methods to append the schema
+ tablename
prefix at he start of the return string. But this requires access to the tableConfiguration
object which is not a class member variable.

I got the same problems using Sybase and Oracle DB. No idea how that should work using DB/2?

Best regards

Christian Fischer

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message