1

列名に特殊文字が含まれるテーブルのHibernate上でgrailsにマッピングを実装しようとしています。すなわち「-」

ドメインクラスでのマッピング

//properties
    Boolean  h00_02

//mapping
    static mapping = {
     h00_02 column : 'h00-02'
     }

例外スタックトレース:

   2011-01-14 09:47:01,492 [http-8080-2] ERROR util.JDBCExceptionReporter  - Unknown column 'this_.h00' in 'field list'
2011-01-14 09:47:01,532 [http-8080-2] ERROR errors.GrailsExceptionResolver  - Exception occurred when processing request: [GET] /Dailyreport/dates/list
Stacktrace follows:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'this_.h00' in 'field list'
 at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
 at com.mysql.jdbc.Util.getInstance(Util.java:381)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
 at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
 at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
 at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
 at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
 at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
 at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
 at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
 at dailyreport.DatesController$_closure2.doCall(DatesController.groovy:13)
 at dailyreport.DatesController$_closure2.doCall(DatesController.groovy)
 at java.lang.Thread.run(Thread.java:662)

クエリ:何か考えがありますか、前述の問題をどのように解決できますか?それを逃れるのに苦労しましたが、それも機能しません。既存のデータベースでUIを開発しようとしているため、前述の列名を使用する必要があります。

前もって感謝します !

4

1 に答える 1

3

これは機能しますか?

static mapping = {
  h00_02 column : '`h00-02`'
}

(それとも、「逃げようとした」とはどういう意味ですか?)

于 2011-01-14T09:24:13.610 に答える