0
當Hibernate創建DB模式我有這樣的輸出:休眠有2個線程,一個得到錯誤
21:22:25,518 INFO [stdout] (ServerService Thread Pool -- 13) Hibernate:
21:22:25,518 INFO [stdout] (ServerService Thread Pool -- 13) alter table Contacto
21:22:25,518 INFO [stdout] (ServerService Thread Pool -- 13) drop
21:22:25,518 INFO [stdout] (ServerService Thread Pool -- 13) foreign key FK_5jh2jf636mhuh77q4hwl1i2w0
21:22:25,519 INFO [stdout] (ServerService Thread Pool -- 50) Hibernate:
21:22:25,519 INFO [stdout] (ServerService Thread Pool -- 50) alter table Contacto
21:22:25,519 INFO [stdout] (ServerService Thread Pool -- 50) drop
21:22:25,519 INFO [stdout] (ServerService Thread Pool -- 50) foreign key FK_5jh2jf636mhuh77q4hwl1i2w0
21:22:25,587 INFO [stdout] (ServerService Thread Pool -- 13) Hibernate:
21:22:25,587 INFO [stdout] (ServerService Thread Pool -- 13) drop table if exists Contacto
21:22:25,596 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000389: Unsuccessful: alter table Contacto drop foreign key FK_5jh2jf636mhuh77q4hwl1i2w0
21:22:25,596 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) Can't DROP 'FK_5jh2jf636mhuh77q4hwl1i2w0'; check that column/key exists
21:22:25,597 INFO [stdout] (ServerService Thread Pool -- 50) Hibernate:
21:22:25,597 INFO [stdout] (ServerService Thread Pool -- 50) drop table if exists Contacto
21:22:25,600 INFO [stdout] (ServerService Thread Pool -- 13) Hibernate:
21:22:25,600 INFO [stdout] (ServerService Thread Pool -- 13) drop table if exists Usuario
21:22:25,600 INFO [stdout] (ServerService Thread Pool -- 50) Hibernate:
21:22:25,601 INFO [stdout] (ServerService Thread Pool -- 50) drop table if exists Usuario
21:22:25,604 INFO [stdout] (ServerService Thread Pool -- 13) Hibernate:
21:22:25,604 INFO [stdout] (ServerService Thread Pool -- 13) create table Contacto (
21:22:25,604 INFO [stdout] (ServerService Thread Pool -- 13) id integer not null,
21:22:25,605 INFO [stdout] (ServerService Thread Pool -- 13) email varchar(255),
21:22:25,605 INFO [stdout] (ServerService Thread Pool -- 13) nombre varchar(255),
21:22:25,605 INFO [stdout] (ServerService Thread Pool -- 13) telefono varchar(255),
21:22:25,605 INFO [stdout] (ServerService Thread Pool -- 13) usuario_cuenta varchar(255),
21:22:25,605 INFO [stdout] (ServerService Thread Pool -- 13) primary key (id)
21:22:25,605 INFO [stdout] (ServerService Thread Pool -- 13) )
21:22:25,606 INFO [stdout] (ServerService Thread Pool -- 50) Hibernate:
21:22:25,606 INFO [stdout] (ServerService Thread Pool -- 50) create table Contacto (
21:22:25,606 INFO [stdout] (ServerService Thread Pool -- 50) id integer not null,
21:22:25,606 INFO [stdout] (ServerService Thread Pool -- 50) email varchar(255),
21:22:25,606 INFO [stdout] (ServerService Thread Pool -- 50) nombre varchar(255),
21:22:25,606 INFO [stdout] (ServerService Thread Pool -- 50) telefono varchar(255),
21:22:25,607 INFO [stdout] (ServerService Thread Pool -- 50) usuario_cuenta varchar(255),
21:22:25,607 INFO [stdout] (ServerService Thread Pool -- 50) primary key (id)
21:22:25,607 INFO [stdout] (ServerService Thread Pool -- 50) )
21:22:25,625 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000389: Unsuccessful: create table Contacto (id integer not null, email varchar(255), nombre varchar(255), telefono varchar(255), usuario_cuenta varchar(255), primary key (id))
21:22:25,625 INFO [stdout] (ServerService Thread Pool -- 13) Hibernate:
21:22:25,625 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) Table 'contacto' already exists
21:22:25,626 INFO [stdout] (ServerService Thread Pool -- 13) create table Usuario (
21:22:25,626 INFO [stdout] (ServerService Thread Pool -- 13) cuenta varchar(255) not null,
21:22:25,626 INFO [stdout] (ServerService Thread Pool -- 13) apellidos varchar(255),
21:22:25,627 INFO [stdout] (ServerService Thread Pool -- 13) email varchar(255),
21:22:25,627 INFO [stdout] (ServerService Thread Pool -- 13) nombre varchar(255),
21:22:25,627 INFO [stdout] (ServerService Thread Pool -- 13) password varchar(255),
21:22:25,628 INFO [stdout] (ServerService Thread Pool -- 13) primary key (cuenta)
21:22:25,628 INFO [stdout] (ServerService Thread Pool -- 13) )
21:22:25,628 INFO [stdout] (ServerService Thread Pool -- 50) Hibernate:
21:22:25,629 INFO [stdout] (ServerService Thread Pool -- 50) create table Usuario (
21:22:25,629 INFO [stdout] (ServerService Thread Pool -- 50) cuenta varchar(255) not null,
21:22:25,629 INFO [stdout] (ServerService Thread Pool -- 50) apellidos varchar(255),
21:22:25,629 INFO [stdout] (ServerService Thread Pool -- 50) email varchar(255),
21:22:25,630 INFO [stdout] (ServerService Thread Pool -- 50) nombre varchar(255),
21:22:25,630 INFO [stdout] (ServerService Thread Pool -- 50) password varchar(255),
21:22:25,630 INFO [stdout] (ServerService Thread Pool -- 50) primary key (cuenta)
21:22:25,630 INFO [stdout] (ServerService Thread Pool -- 50) )
21:22:25,639 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000389: Unsuccessful: create table Usuario (cuenta varchar(255) not null, apellidos varchar(255), email varchar(255), nombre varchar(255), password varchar(255), primary key (cuenta))
21:22:25,639 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) Table 'usuario' already exists
21:22:25,640 INFO [stdout] (ServerService Thread Pool -- 50) Hibernate:
21:22:25,640 INFO [stdout] (ServerService Thread Pool -- 50) alter table Contacto
21:22:25,640 INFO [stdout] (ServerService Thread Pool -- 50) add constraint FK_5jh2jf636mhuh77q4hwl1i2w0
21:22:25,641 INFO [stdout] (ServerService Thread Pool -- 50) foreign key (usuario_cuenta)
21:22:25,641 INFO [stdout] (ServerService Thread Pool -- 50) references Usuario (cuenta)
21:22:25,641 INFO [stdout] (ServerService Thread Pool -- 13) Hibernate:
21:22:25,641 INFO [stdout] (ServerService Thread Pool -- 13) alter table Contacto
21:22:25,642 INFO [stdout] (ServerService Thread Pool -- 13) add constraint FK_5jh2jf636mhuh77q4hwl1i2w0
21:22:25,642 INFO [stdout] (ServerService Thread Pool -- 13) foreign key (usuario_cuenta)
21:22:25,642 INFO [stdout] (ServerService Thread Pool -- 13) references Usuario (cuenta)
21:22:25,657 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000230: Schema export complete
21:22:25,664 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 13) HHH000389: Unsuccessful: alter table Contacto add constraint FK_5jh2jf636mhuh77q4hwl1i2w0 foreign key (usuario_cuenta) references Usuario (cuenta)
21:22:25,665 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 13) Can't write; duplicate key in table '#sql-2f4_20'
它看起來像應用程序有2個線程休眠的,並且這些線程正在同一SQL語句(如創建相同的表格等)
發生了什麼事?
在此先感謝
很難說什麼,直到我們看看你的一些代碼。 – hagrawal