Menu

Fixed bug in manager with 2 columns pk?

Help
jelvira
2007-11-23
2013-04-25
  • jelvira

    jelvira - 2007-11-23

    Hi.

    Generating the classes for a small database (10g), I've found 3 problems;

    The first one was an error in a template, (an else without {}) that was solved by getting the last CVS version.

    The second, the tables where not extracted from the database... solved by creating the same schema in 9i, and re-generating.

    The third, in a n-m table (pk is fks from other two tables) the loadByPrimaryKey() method was wrong: the generated code was:
    StringBuffer sql = new StringBuffer("SELECT " + ALL_FIELDS + " FROM CONFIGURACION WHERE CFG_CATEGORIA=?CFG_PARAM=?");
    Where it should be:
    StringBuffer sql = new StringBuffer("SELECT " + ALL_FIELDS + " FROM CONFIGURACION WHERE CFG_CATEGORIA=? AND CFG_PARAM=?");
    I've fixed it by changing the manager template (the one in java5) manager.java.vm (line 133)
    #set ( $sql = "$sql$pk.getName()=?" )
    With:
    #if ( $sql == "" )
    #set( $sql = "$pk.getName()=?" )
    #else
    #set( $sql = "$sql AND $pk.getName()=?" )
    #end

    I don't know if we are doing something wrong (we've been using sql2java, previous versions, since long time ago, with no critical problems, with Oracle, MySQL... ) or these are real bugs... Someone faced the same problems?

    Thanks.

     
    • Alain Fagot Béarez

      Thanks for reporting the bug in the loadByPrimaryKey.  I am quite ashamed because it was corrected in the delete method a few lines below...

      As for your second bug...  I don't have any installation of Oracle 10g at hand to make tests.

      Could you explore a bit more as about the expected values for the parameters to the DatabaseMetaData.getTables() method for that database engine?  Were the previous versions of sql2java generating correctly for your 10g database?

      Your patch for the manager.java.vm has been committed to the repository.

      Alain.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.