Таблица уже создана внутри базы данных с использованием другого программного обеспечения, мне нужно преобразовать отображение с помощью GORM, поэтому имя и тип столбца уже созданы.
Class Customer{
static hasMany = [ reservationClienti:ReservationSource]
static mapping = {
sort("id")
table name: 'clienti'//, schema: 'public'
id generator: 'sequence', params: [sequence: 'clienti_seq']
id column: "id", sqlType: "int4"
reservationClienti joinTable: [name: "clienti_reservation_source",
column: "id_cliente_reservation", key: "id_cliente_res"] , sqlType:
"int4"
}
}
class ReservationSource{
static hasMany = [clienteReservation: Customer ]
static belongsTo = [Customer ]
static mapping = {
table name: "fonti_commissioni"//, schema: "public"
id column: "id", sqlType: "int4"
id generator: 'sequence', params: [sequence: 'fonti_commissioni_seq']
clienteReservation joinTable: [name: "clienti_reservation_source",
column: "id_cliente_res", key: "id_cliente_reservation"] , sqlType:
"int4"
}
}
При запуске проекта я получаю это исключение
2018-09-10 11:42:36,021 [localhost-startStop-1] ERROR
context.GrailsContextLoaderListener - Error initializing the
application: 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.HibernateException: Missing
column: id_cliente in public.clienti_reservation_source
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.HibernateException: Missing column: id_cliente in
public.clienti_reservation_source
Обратите внимание: я не могу изменить имя столбца, ключ или имя таблицы