ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guoyou Jiang <guoyou.ji...@jsvest.com>
Subject some bugs about migration tools
Date Thu, 13 Aug 2009 14:46:32 GMT
when i use migration tools, i find some bugs about it:

1态bootstrap.sql and scripts sql file not support i18n file, so when sql
contains chinese language code, it will print error and insert illegal value
to database.
      i have change command code like this:
      runner.runScript(new MigrationReader(new InputStreamReader(new
FileInputStream(bootstrap), "utf-8"), false, environmentProperties()));
      that's seems ok, so is it possible to add a property value to
environments property file for indicate what charset  the .sql file used?

2. another problem is about changelog table, because i run on windows xp, so
the uppercase column name like 'ID' is auto change to 'id',  so the
change.get("ID") always return null, cause nullpoint error like:
Exception in thread "main" java.lang.NullPointerException
        at java.math.BigDecimal.<init>(BigDecimal.java:647)
        at
org.apache.ibatis.migration.commands.BaseCommand.getChangelog(BaseCom
mand.java:65)
        at
org.apache.ibatis.migration.commands.StatusCommand.execute(StatusComm
and.java:20)
        at
org.apache.ibatis.migration.CommandLine.runCommand(CommandLine.java:7
7)
        at
org.apache.ibatis.migration.CommandLine.execute(CommandLine.java:56)
        at org.apache.ibatis.migration.Migrator.main(Migrator.java:6)

so i change code like this:
      List<Map<String, Object>> changelog = runner.selectAll("select ID,
APPLIED_AT, DESCRIPTION from " + changelogTable() + " order by id");
      List<Change> changes = new ArrayList<Change>();
      for (Map<String, Object> change : changelog) {
        if(change.get("ID") != null) {
            //out.println("change: " + change.get("ID") + " " +
change.get("APPLIED_AT") + " " + change.get("DESCRIPTION"));
            String id = change.get("ID") == null ? null :
change.get("ID").toString();
            String appliedAt = change.get("APPLIED_AT") == null ? null :
change.get("APPLIED_AT").toString();
            String description = change.get("DESCRIPTION") == null ? null :
change.get("DESCRIPTION").toString();
            changes.add(new Change(new BigDecimal(id), appliedAt,
description));
        } else {
            //out.println("change: " + change.get("id") + " " +
change.get("applied_at") + " " + change.get("description"));
            String id = change.get("id") == null ? null :
change.get("id").toString();
            String appliedAt = change.get("applied_at") == null ? null :
change.get("applied_at").toString();
            String description = change.get("description") == null ? null :
change.get("description").toString();
            changes.add(new Change(new BigDecimal(id), appliedAt,
description));
        }
      }

that's ok now.

Mime
View raw message