Grails 2.2.1で多対1リレーションシップの埋め込みドメインを使用しようとしています。ここに私がしようとしているものの簡略版があります。GORMコンポジション - 多対1リレーションシップを持つ埋め込みドメインorg.hibernate.MappingException
私は既存のDBテーブルへのマッピングだ: "事件" テーブルにマップ
create table incident (id bigint generated by default as identity, state_id bigint not null, primary key (id));
create table state (id bigint generated by default as identity, name varchar(255) not null, primary key (id));
alter table incident add constraint FK52F44D27499E79E foreign key (state_id) references state;
ドメイン: "状態" テーブルにマップする
class Incident {
Vehicle vehicle
static embedded = ['vehicle']
}
class Vehicle{
State state
static mapping = {
state column: 'state_id'
}
}
がドメイン:
class State {
String name
}
アプリケーションを実行しようとすると、次のエラーが発生します。
Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: test.State, at table: incident, for columns: [org.hibernate.mapping.Column(vehicle_state)]
埋め込みドメイン内で多対1の関連付けが可能ですか?
- 更新 -
私は状態を取得するための回避策を使用して終了。
class Vehicle{
static transients = [ "state" ]
Long stateId
static mapping = {
stateId column: 'state_id'
}
State getState(){
State.get(this.stateId)
}
}
私は...これはGrailsのバグかもしれないと思うし始めているが、HTTPに似たサウンド://jira.grailsを。org/browse/GRAILS-9012 –