Home > Back-end >  Hibernate configuration problem
Hibernate configuration problem

Time:02-05

I installed in the ali cloud mysql version number is 5.7.30=0 ubuntu0. 18.04.1
Then in the hibernate. HBM. XML configuration file configuration & lt; The property name="the dialect" & gt; Org. Hibernate. The dialect. MySQL5InnoDBDialect & lt;/property>
Common MySQL5InnoDBDialect MySQL5Dialect MySQL57Dialect, MySQL57InnoDBDialect have tried, but still exist the following warning, programs can run normally, insert also works as a result,



WARN: GenerationTarget encountered exception has the command: Error executing DDL "alter table product_ add constraint FK5g0v39gl73bdiw9waaha0pkfg foreign key (category) references category_ (id)" via JDBC Statement
Org.hibernate.tool.schema.spi.Com mandAcceptanceException: Error executing DDL "alter table product_ add constraint FK5g0v39gl73bdiw9waaha0pkfg foreign key (category) references category_ (id)" via JDBC Statement

CodePudding user response:

refer to the original poster cloud walker Gorge response:
I installed mysql version number on ali cloud is 5.7.30=0 ubuntu0. 18.04.1
Then in the hibernate. HBM. XML configuration file configuration & lt; The property name="the dialect" & gt; Org. Hibernate. The dialect. MySQL5InnoDBDialect & lt;/property>
Common MySQL5InnoDBDialect MySQL5Dialect MySQL57Dialect, MySQL57InnoDBDialect have tried, but still exist the following warning, programs can run normally, insert also works as a result,



WARN: GenerationTarget encountered exception has the command: Error executing DDL "alter table product_ add constraint FK5g0v39gl73bdiw9waaha0pkfg foreign key (category) references category_ (id)" via JDBC Statement
Org.hibernate.tool.schema.spi.Com mandAcceptanceException: Error executing DDL "alter table product_ add constraint FK5g0v39gl73bdiw9waaha0pkfg foreign key (category) references category_ (id)" via JDBC Statement



Configuration to add try

CodePudding user response:

reference 1st floor qq_39936465 response:
Quote: refer to the original poster cloud walker Gorge response:
I installed mysql version number on ali cloud is 5.7.30=0 ubuntu0. 18.04.1
Then in the hibernate. HBM. XML configuration file configuration & lt; The property name="the dialect" & gt; Org. Hibernate. The dialect. MySQL5InnoDBDialect & lt;/property>
Common MySQL5InnoDBDialect MySQL5Dialect MySQL57Dialect, MySQL57InnoDBDialect have tried, but still exist the following warning, programs can run normally, insert also works as a result,



WARN: GenerationTarget encountered exception has the command: Error executing DDL "alter table product_ add constraint FK5g0v39gl73bdiw9waaha0pkfg foreign key (category) references category_ (id)" via JDBC Statement
Org.hibernate.tool.schema.spi.Com mandAcceptanceException: Error executing DDL "alter table product_ add constraint FK5g0v39gl73bdiw9waaha0pkfg foreign key (category) references category_ (id)" via JDBC Statement



Configuration to add try

, this is added to the configuration

CodePudding user response:

refer to the second floor on the cloud walker Gorge response:
Quote: refer to 1st floor qq_39936465 response:
, this is added to the configuration, no effect


Feel the hibernate configuration should be no problem, it is your SQL statement has a problem! Look stick SQL,

CodePudding user response:

The SQL statement is generated automatically
SessionFactory sf=new Configuration (). The configure () buildSessionFactory ();
The Session s=sf. OpenSession ();
S.b eginTransaction ();
The Category c=new Category ();
//c.s. etId (1);
C.s. etName (" c6 ");
S.s ave (c);
The Product p=(Product) s.g et (Product. Class, 4);
P. etCategory (c);
S.u pdate (p);

S.g etTransaction (), commit ();
S.c lose ();
Sf. The close ();
  • Related