嵌套的异常是org.hibernate.HibernateException:GORM中缺少多对多映射的列

时间:2018-09-10 06:32:53

标签: hibernate grails gorm

该表已经在数据库中使用其他软件创建,我需要使用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

请注意,我无法修改列名或键或表名

0 个答案:

没有答案