0

Grails 2.1.0 と Oracle 11 を使用しています。

Oracle データベースのテーブルに接続しようとしているドメイン クラスがあります。list() メソッドを移入するために SQL が生成されると、ORA-00918: column ambiguously defined が発生します。このエラーは、テーブルの主キーが同じエイリアスで 2 回要求されるために発生します。生成された SQL は次のとおりです。

select * from ( select this_.BENCHMARK_CUSIP as BENCHMARK1_4_0_, this_.acronym as acronym4_0_, this_.as_of_date as as3_4_0_, this_.ask_price as ask4_4_0_, this_.ask_yield as ask5_4_0_, this_.benchmark_cusip as benchmark1_4_0_, this_.bid_price as bid6_4_0_, this_.bid_yield as bid7_4_0_, this_.coupon as coupon4_0_, this_.coupon_frequency as coupon9_4_0_, this_.is_on_the_run as is10_4_0_, this_.last_update_time as last11_4_0_, this_.last_update_user as last12_4_0_, this_.maturity as maturity4_0_, this_.name as name4_0_, this_.price as price4_0_, this_.source as source4_0_, this_.yield as yield4_0_ from BENCHMARK this_ ) where rownum <= ?

this_.benchmark_cusip を見るとわかるように、benchmark1_4_0 が 2 回表示されます。

これが私のドメインクラスです

class Benchmark {
    String benchmarkCusip
    String acronym
    String name
    Double coupon
    java.math.BigDecimal couponFrequency
    Date maturity
    String isOnTheRun
    Date asOfDate
    Double bidYield
    Double yield
    Double askYield
    Double bidPrice
    Double price
    Double askPrice
    String source
    String lastUpdateUser
    Date lastUpdateTime

static mapping = {
    table 'BENCHMARK'        
    version false
   columns{id column:'BENCHMARK_CUSIP', generated:'assigned'}

}

コントローラーは、def scaffold = true として定義されているだけです。

何か設定が間違っていると思いますが、私の人生では、オフィスからアクセスできる限られた数のサイトでそれを見つけることができません。

4

1 に答える 1

1

通常、私はこれを行います:

class Benchmark {
  ...

  static mapping = {
    table 'benchmark'
    id column: 'benchmark_cusip', name: 'benchmarkCusip'
  }

}
于 2012-09-13T19:10:08.143 に答える