It’s making a mistake when I try to do the ORM

Asked

Viewed 83 times

0

I created a table but when I run the application more than once it gives this problem. Why does this happen?

environments {
  development{
    dataSource {
        dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
        url = "jdbc:jtds:sqlserver://localhost:1433/G2017;instance=SQLEXPRESS";
        username = "sa"
        password = "G2017"
        loggingSql = false
    }
}




Error |
2015-12-29 20:06:21,141 [localhost-startStop-1] ERROR       hbm2ddl.SchemaUpdate  - HHH000388: Unsuccessful: alter table   MATERIAL_CONSULTA add MCO_ANE_in_id  bigint not null
Error |
2015-12-29 20:06:21,156 [localhost-startStop-1] ERROR  hbm2ddl.SchemaUpdate  - Column names in each table must be unique. Column  name 'MCO_ANE_in_id' in table 'MATERIAL_CONSULTA' is specified more than once.
Error |
2015-12-29 20:06:21,177 [localhost-startStop-1] ERROR hbm2ddl.SchemaUpdate  - HHH000388: Unsuccessful: alter table MATERIAL_CONSULTA add constraint FK_3u9950vreiqdafld873700mg5 foreign key (MCO_ANE_in_id ) references ANEXO
Error |
2015-12-29 20:06:21,177 [localhost-startStop-1] ERROR   hbm2ddl.SchemaUpdate  - There is already an object named 'FK_3u9950vreiqdafld873700mg5' in the database.
  • What version of Grails? You can post your Datasource.groovy?

  • 2.5.1 version of the grails

  • Column name 'Mco_ane_in_id' in table 'MATERIAL_CONSULTA' is specified more than Once.

  • You could post your Datasource.groovy?

  • This application has many classes but when I created this gave this problem that I do not know how to solve :(

  • The error is very clear: GORM is trying to create the Mco_ane_in_id field in the MATERIAL_CONSULTA table, but it already exists. The same happens when trying to create the foreign key. Anyway, GORM is not identifying that these items already exist in the BD. Tried to create a bank from scratch to see if everything works?

  • I already erased the bank and created again and I did everything again but it gives the same problem... What I do??????????

  • Friend? I changed the name of the field and it worked.

Show 3 more comments

1 answer

0

Grails (through Hibernate) is trying to create the Mco_ane_in_id column, but it already exists in your database. Please post the code of your Materialquery class to verify that this column is not mapped twice in the bank. If that’s the case, it’ll be wrong anyway.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.