인프런 커뮤니티 질문&답변

황규혁님의 프로필 이미지
황규혁

작성한 질문수

자바 ORM 표준 JPA 프로그래밍 - 기본편

테이블 드랍이 안됩니다..

작성

·

321

0

실전 예제 4를 하고 있는데 create로 설정하면 메인메서드 실행할 때마다 테이블 드랍되고 실행되어야하는데 아래와 같은 오류가 자꾸 발생하면서 실행이 안되는데 왜그럴까요 ㅠㅠ 수동으로 데이터베이스에서 드랍하고 실행하거나 update 등으로만 설정해야 잘 작동되는데 왜그럴까요...

 

스크린샷 2023-08-08 오후 10.42.56.png /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin/java -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=49362:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Users/hwang-gyuhyeog/Desktop/JPA/1.자바 ORM 표준 JPA 프로그래밍-기본편/jpashop/target/classes:/Users/hwang-gyuhyeog/.m2/repository/org/hibernate/hibernate-entitymanager/5.3.10.Final/hibernate-entitymanager-5.3.10.Final.jar:/Users/hwang-gyuhyeog/.m2/repository/org/jboss/logging/jboss-logging/3.3.2.Final/jboss-logging-3.3.2.Final.jar:/Users/hwang-gyuhyeog/.m2/repository/org/hibernate/hibernate-core/5.3.10.Final/hibernate-core-5.3.10.Final.jar:/Users/hwang-gyuhyeog/.m2/repository/org/javassist/javassist/3.23.2-GA/javassist-3.23.2-GA.jar:/Users/hwang-gyuhyeog/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/hwang-gyuhyeog/.m2/repository/org/jboss/jandex/2.0.5.Final/jandex-2.0.5.Final.jar:/Users/hwang-gyuhyeog/.m2/repository/com/fasterxml/classmate/1.3.4/classmate-1.3.4.jar:/Users/hwang-gyuhyeog/.m2/repository/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar:/Users/hwang-gyuhyeog/.m2/repository/org/dom4j/dom4j/2.1.1/dom4j-2.1.1.jar:/Users/hwang-gyuhyeog/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.0.4.Final/hibernate-commons-annotations-5.0.4.Final.jar:/Users/hwang-gyuhyeog/.m2/repository/javax/persistence/javax.persistence-api/2.2/javax.persistence-api-2.2.jar:/Users/hwang-gyuhyeog/.m2/repository/net/bytebuddy/byte-buddy/1.9.5/byte-buddy-1.9.5.jar:/Users/hwang-gyuhyeog/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.1.1.Final/jboss-transaction-api_1.2_spec-1.1.1.Final.jar:/Users/hwang-gyuhyeog/.m2/repository/com/h2database/h2/1.4.200/h2-1.4.200.jar:/Users/hwang-gyuhyeog/.m2/repository/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar jpabook.jpashop.JpaMain

8월 08, 2023 10:39:56 오후 org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation

INFO: HHH000204: Processing PersistenceUnitInfo [

name: hello

...]

8월 08, 2023 10:39:56 오후 org.hibernate.Version logVersion

INFO: HHH000412: Hibernate Core {5.3.10.Final}

8월 08, 2023 10:39:56 오후 org.hibernate.cfg.Environment <clinit>

INFO: HHH000206: hibernate.properties not found

8월 08, 2023 10:39:57 오후 org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>

INFO: HCANN000001: Hibernate Commons Annotations {5.0.4.Final}

8월 08, 2023 10:39:57 오후 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)

8월 08, 2023 10:39:57 오후 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator

INFO: HHH10001005: using driver [org.h2.Driver] at URL [jdbc:h2:tcp://localhost/~/jpashop]

8월 08, 2023 10:39:57 오후 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator

INFO: HHH10001001: Connection properties: {user=sa}

8월 08, 2023 10:39:57 오후 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator

INFO: HHH10001003: Autocommit mode: false

8월 08, 2023 10:39:57 오후 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections <init>

INFO: HHH000115: Hibernate connection pool size: 20 (min=1)

8월 08, 2023 10:39:57 오후 org.hibernate.dialect.Dialect <init>

INFO: HHH000400: Using dialect: org.hibernate.dialect.H2Dialect

Hibernate:

drop table Category if exists

Hibernate:

drop table CATEGORY_ITEM if exists

Hibernate:

drop table Delivery if exists

Hibernate:

drop table Item if exists

Hibernate:

drop table Member if exists

Hibernate:

drop table OrderItem if exists

Hibernate:

drop table ORDERS if exists

Hibernate:

drop sequence if exists hibernate_sequence

Hibernate: create sequence hibernate_sequence start with 1 increment by 1

8월 08, 2023 10:39:57 오후 org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection

INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@7f5b9db] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.

8월 08, 2023 10:39:57 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException

WARN: GenerationTarget encountered exception accepting command : Error executing DDL "

drop table Category if exists" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "

drop table Category if exists" via JDBC Statement

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:375)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:359)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:241)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:154)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:126)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:112)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:144)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)

at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310)

at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939)

at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)

at jpabook.jpashop.JpaMain.main(JpaMain.java:14)

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Cannot drop "CATEGORY" because "FKJIP0OR3VEMIXCCL6VX0KLUJ03" depends on it; SQL statement:

drop table Category if e [90107-214]

at org.h2.message.DbException.getJdbcSQLException(DbException.java:632)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)

at org.h2.message.DbException.get(DbException.java:223)

at org.h2.command.ddl.DropTable.prepareDrop(DropTable.java:97)

at org.h2.command.ddl.DropTable.update(DropTable.java:121)

at org.h2.command.CommandContainer.update(CommandContainer.java:169)

at org.h2.command.Command.executeUpdate(Command.java:252)

at org.h2.server.TcpServerThread.process(TcpServerThread.java:408)

at org.h2.server.TcpServerThread.run(TcpServerThread.java:191)

at java.base/java.lang.Thread.run(Thread.java:834)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:576)

at org.h2.engine.SessionRemote.done(SessionRemote.java:611)

at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237)

at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228)

at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)

... 15 more

8월 08, 2023 10:39:57 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException

WARN: GenerationTarget encountered exception accepting command : Error executing DDL "

drop table Delivery if exists" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "

drop table Delivery if exists" via JDBC Statement

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:375)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:359)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:241)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:154)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:126)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:112)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:144)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)

at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310)

at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939)

at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)

at jpabook.jpashop.JpaMain.main(JpaMain.java:14)

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Cannot drop "DELIVERY" because "FKDBS21F1YI0COXY9Y0KXW4G9JF" depends on it; SQL statement:

drop table Delivery if e [90107-214]

at org.h2.message.DbException.getJdbcSQLException(DbException.java:632)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)

at org.h2.message.DbException.get(DbException.java:223)

at org.h2.command.ddl.DropTable.prepareDrop(DropTable.java:97)

at org.h2.command.ddl.DropTable.update(DropTable.java:121)

at org.h2.command.CommandContainer.update(CommandContainer.java:169)

at org.h2.command.Command.executeUpdate(Command.java:252)

at org.h2.server.TcpServerThread.process(TcpServerThread.java:408)

at org.h2.server.TcpServerThread.run(TcpServerThread.java:191)

at java.base/java.lang.Thread.run(Thread.java:834)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:576)

at org.h2.engine.SessionRemote.done(SessionRemote.java:611)

at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237)

at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228)

at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)

... 15 more

8월 08, 2023 10:39:57 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException

WARN: GenerationTarget encountered exception accepting command : Error executing DDL "

drop table Item if exists" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "

drop table Item if exists" via JDBC Statement

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:375)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:359)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:241)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:154)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:126)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:112)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:144)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)

at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310)

at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939)

at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)

at jpabook.jpashop.JpaMain.main(JpaMain.java:14)

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Cannot drop "ITEM" because "FK75MRPPRV8OIGH00Y92TIBW7ID, FK2SRBE8WJBANR4VTKRSB8ATQ7O, FKQQWSWM36Y8UQOH9EMTORUOXCV, FKABGE9EQALSPCEJIJ53RAT7PJH" depends on it; SQL statement:

drop table Item if e [90107-214]

at org.h2.message.DbException.getJdbcSQLException(DbException.java:632)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)

at org.h2.message.DbException.get(DbException.java:223)

at org.h2.command.ddl.DropTable.prepareDrop(DropTable.java:97)

at org.h2.command.ddl.DropTable.update(DropTable.java:121)

at org.h2.command.CommandContainer.update(CommandContainer.java:169)

at org.h2.command.Command.executeUpdate(Command.java:252)

at org.h2.server.TcpServerThread.process(TcpServerThread.java:408)

at org.h2.server.TcpServerThread.run(TcpServerThread.java:191)

at java.base/java.lang.Thread.run(Thread.java:834)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:576)

at org.h2.engine.SessionRemote.done(SessionRemote.java:611)

at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237)

at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228)

at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)

... 15 more

8월 08, 2023 10:39:57 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException

WARN: GenerationTarget encountered exception accepting command : Error executing DDL "

drop table Member if exists" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "

drop table Member if exists" via JDBC Statement

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:375)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:359)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:241)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:154)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:126)

at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:112)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:144)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)

at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310)

at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939)

at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)

at jpabook.jpashop.JpaMain.main(JpaMain.java:14)

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Cannot drop "MEMBER" because "FKH0DB7KQR88ED8HQTCQW3JKCIA" depends on it; SQL statement:

drop table Member if e [90107-214]

at org.h2.message.DbException.getJdbcSQLException(DbException.java:632)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)

at org.h2.message.DbException.get(DbException.java:223)

at org.h2.command.ddl.DropTable.prepareDrop(DropTable.java:97)

at org.h2.command.ddl.DropTable.update(DropTable.java:121)

at org.h2.command.CommandContainer.update(CommandContainer.java:169)

at org.h2.command.Command.executeUpdate(Command.java:252)

at org.h2.server.TcpServerThread.process(TcpServerThread.java:408)

at org.h2.server.TcpServerThread.run(TcpServerThread.java:191)

at java.base/java.lang.Thread.run(Thread.java:834)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:576)

at org.h2.engine.SessionRemote.done(SessionRemote.java:611)

at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237)

at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228)

at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)

... 15 more

8월 08, 2023 10:39:57 오후 org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection

INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@5c723f2d] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.

8월 08, 2023 10:39:57 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException

WARN: GenerationTarget encountered exception accepting command : Error executing DDL "

create table Category (

id bigint not null,

name varchar(255),

PARENT_ID bigint,

primary key (id)

)" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "

create table Category (

id bigint not null,

name varchar(255),

PARENT_ID bigint,

primary key (id)

)" via JDBC Statement

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:315)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)

at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310)

at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939)

at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)

at jpabook.jpashop.JpaMain.main(JpaMain.java:14)

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "CATEGORY" already exists; SQL statement:

create table Category (

id bigint not null,

name varchar(255),

PARENT_ID bigint,

primary key (id)

[42101-214]

at org.h2.message.DbException.getJdbcSQLException(DbException.java:502)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)

at org.h2.message.DbException.get(DbException.java:223)

at org.h2.message.DbException.get(DbException.java:199)

at org.h2.command.ddl.CreateTable.update(CreateTable.java:91)

at org.h2.command.CommandContainer.update(CommandContainer.java:169)

at org.h2.command.Command.executeUpdate(Command.java:252)

at org.h2.server.TcpServerThread.process(TcpServerThread.java:408)

at org.h2.server.TcpServerThread.run(TcpServerThread.java:191)

at java.base/java.lang.Thread.run(Thread.java:834)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:453)

at org.h2.engine.SessionRemote.done(SessionRemote.java:611)

at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237)

at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228)

at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)

... 15 more

8월 08, 2023 10:39:57 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException

WARN: GenerationTarget encountered exception accepting command : Error executing DDL "

create table Delivery (

id bigint not null,

city varchar(255),

deliveryStatus integer,

street varchar(255),

zipcode varchar(255),

primary key (id)

)" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "

create table Delivery (

id bigint not null,

city varchar(255),

deliveryStatus integer,

street varchar(255),

zipcode varchar(255),

primary key (id)

)" via JDBC Statement

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:315)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)

at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310)

at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939)

at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)

at jpabook.jpashop.JpaMain.main(JpaMain.java:14)

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "DELIVERY" already exists; SQL statement:

create table Delivery (

id bigint not null,

city varchar(255),

deliveryStatus integer,

street varchar(255),

zipcode varchar(255),

primary key (id)

[42101-214]

at org.h2.message.DbException.getJdbcSQLException(DbException.java:502)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)

at org.h2.message.DbException.get(DbException.java:223)

at org.h2.message.DbException.get(DbException.java:199)

at org.h2.command.ddl.CreateTable.update(CreateTable.java:91)

at org.h2.command.CommandContainer.update(CommandContainer.java:169)

at org.h2.command.Command.executeUpdate(Command.java:252)

at org.h2.server.TcpServerThread.process(TcpServerThread.java:408)

at org.h2.server.TcpServerThread.run(TcpServerThread.java:191)

at java.base/java.lang.Thread.run(Thread.java:834)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:453)

at org.h2.engine.SessionRemote.done(SessionRemote.java:611)

at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237)

at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228)

at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)

... 15 more

8월 08, 2023 10:39:57 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException

WARN: GenerationTarget encountered exception accepting command : Error executing DDL "

create table Item (

DTYPE varchar(31) not null,

ITEM_ID bigint not null,

name varchar(255),

price integer not null,

stockQuantity integer not null,

actor varchar(255),

director varchar(255),

author varchar(255),

isbn varchar(255),

artist varchar(255),

etc varchar(255),

primary key (ITEM_ID)

)" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "

create table Item (

DTYPE varchar(31) not null,

ITEM_ID bigint not null,

name varchar(255),

price integer not null,

stockQuantity integer not null,

actor varchar(255),

director varchar(255),

author varchar(255),

isbn varchar(255),

artist varchar(255),

etc varchar(255),

primary key (ITEM_ID)

)" via JDBC Statement

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:315)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)

at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310)

at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939)

at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)

at jpabook.jpashop.JpaMain.main(JpaMain.java:14)

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" already exists; SQL statement:

create table Item (

DTYPE varchar(31) not null,

ITEM_ID bigint not null,

name varchar(255),

price integer not null,

stockQuantity integer not null,

actor varchar(255),

director varchar(255),

author varchar(255),

isbn varchar(255),

artist varchar(255),

etc varchar(255),

primary key (ITEM_ID)

[42101-214]

at org.h2.message.DbException.getJdbcSQLException(DbException.java:502)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)

at org.h2.message.DbException.get(DbException.java:223)

at org.h2.message.DbException.get(DbException.java:199)

at org.h2.command.ddl.CreateTable.update(CreateTable.java:91)

at org.h2.command.CommandContainer.update(CommandContainer.java:169)

at org.h2.command.Command.executeUpdate(Command.java:252)

at org.h2.server.TcpServerThread.process(TcpServerThread.java:408)

at org.h2.server.TcpServerThread.run(TcpServerThread.java:191)

at java.base/java.lang.Thread.run(Thread.java:834)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:453)

at org.h2.engine.SessionRemote.done(SessionRemote.java:611)

at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237)

at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228)

at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)

... 15 more

8월 08, 2023 10:39:57 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException

WARN: GenerationTarget encountered exception accepting command : Error executing DDL "

create table Member (

MEMBER_ID bigint not null,

city varchar(255),

name varchar(255),

street varchar(255),

zipcode varchar(255),

primary key (MEMBER_ID)

)" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "

create table Member (

MEMBER_ID bigint not null,

city varchar(255),

name varchar(255),

street varchar(255),

zipcode varchar(255),

primary key (MEMBER_ID)

)" via JDBC Statement

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:315)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)

at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310)

at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939)

at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)

at jpabook.jpashop.JpaMain.main(JpaMain.java:14)

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "MEMBER" already exists; SQL statement:

create table Member (

MEMBER_ID bigint not null,

city varchar(255),

name varchar(255),

street varchar(255),

zipcode varchar(255),

primary key (MEMBER_ID)

[42101-214]

at org.h2.message.DbException.getJdbcSQLException(DbException.java:502)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)

at org.h2.message.DbException.get(DbException.java:223)

at org.h2.message.DbException.get(DbException.java:199)

at org.h2.command.ddl.CreateTable.update(CreateTable.java:91)

at org.h2.command.CommandContainer.update(CommandContainer.java:169)

at org.h2.command.Command.executeUpdate(Command.java:252)

at org.h2.server.TcpServerThread.process(TcpServerThread.java:408)

at org.h2.server.TcpServerThread.run(TcpServerThread.java:191)

at java.base/java.lang.Thread.run(Thread.java:834)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:453)

at org.h2.engine.SessionRemote.done(SessionRemote.java:611)

at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237)

at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228)

at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)

... 15 more

8월 08, 2023 10:39:57 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException

WARN: GenerationTarget encountered exception accepting command : Error executing DDL "

alter table Category

add constraint FK8tepc1qkmluodspg6tnliwhit

foreign key (PARENT_ID)

references Category" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "

alter table Category

add constraint FK8tepc1qkmluodspg6tnliwhit

foreign key (PARENT_ID)

references Category" via JDBC Statement

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:375)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135)

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155)

at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)

at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310)

at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939)

at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)

at jpabook.jpashop.JpaMain.main(JpaMain.java:14)

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Constraint "FK8TEPC1QKMLUODSPG6TNLIWHIT" already exists; SQL statement:

alter table Category

add constraint FK8tepc1qkmluodspg6tnliwhit

foreign key (PARENT_ID)

references Cat [90045-214]

at org.h2.message.DbException.getJdbcSQLException(DbException.java:632)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)

at org.h2.message.DbException.get(DbException.java:223)

at org.h2.message.DbException.get(DbException.java:199)

at org.h2.command.ddl.AlterTableAddConstraint.tryUpdate(AlterTableAddConstraint.java:109)

at org.h2.command.ddl.AlterTableAddConstraint.update(AlterTableAddConstraint.java:72)

at org.h2.command.ddl.AlterTable.update(AlterTable.java:46)

at org.h2.command.CommandContainer.update(CommandContainer.java:169)

at org.h2.command.Command.executeUpdate(Command.java:252)

at org.h2.server.TcpServerThread.process(TcpServerThread.java:408)

at org.h2.server.TcpServerThread.run(TcpServerThread.java:191)

at java.base/java.lang.Thread.run(Thread.java:834)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:576)

at org.h2.engine.SessionRemote.done(SessionRemote.java:611)

at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237)

at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228)

at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)

... 15 more

Hibernate:

create table Category (

id bigint not null,

name varchar(255),

PARENT_ID bigint,

primary key (id)

)

Hibernate:

create table CATEGORY_ITEM (

CATEGORY_ID bigint not null,

ITEM_ID bigint not null

)

Hibernate:

create table Delivery (

id bigint not null,

city varchar(255),

deliveryStatus integer,

street varchar(255),

zipcode varchar(255),

primary key (id)

)

Hibernate:

create table Item (

DTYPE varchar(31) not null,

ITEM_ID bigint not null,

name varchar(255),

price integer not null,

stockQuantity integer not null,

actor varchar(255),

director varchar(255),

author varchar(255),

isbn varchar(255),

artist varchar(255),

etc varchar(255),

primary key (ITEM_ID)

)

Hibernate:

create table Member (

MEMBER_ID bigint not null,

city varchar(255),

name varchar(255),

street varchar(255),

zipcode varchar(255),

primary key (MEMBER_ID)

)

Hibernate:

create table OrderItem (

ORDER_ITEM_ID bigint not null,

ITEM_ID bigint,

ORDER_ID bigint,

primary key (ORDER_ITEM_ID)

)

Hibernate:

create table ORDERS (

ORDER_ID bigint not null,

orderDate timestamp,

status varchar(255),

DELIVERY_ID bigint,

MEMBER_ID bigint,

primary key (ORDER_ID)

)

Hibernate:

alter table Category

add constraint FK8tepc1qkmluodspg6tnliwhit

foreign key (PARENT_ID)

references Category

Hibernate:

alter table CATEGORY_ITEM

add constraint FKf1uerpnmn49vl1spbbplgxaun

foreign key (ITEM_ID)

references Item

Hibernate:

alter table CATEGORY_ITEM

add constraint FKjip0or3vemixccl6vx0kluj03

foreign key (CATEGORY_ID)

references Category

Hibernate:

alter table OrderItem

add constraint FKabge9eqalspcejij53rat7pjh

foreign key (ITEM_ID)

references Item

Hibernate:

alter table OrderItem

add constraint FKk7lmf97wukpquk6d8blxy5neq

foreign key (ORDER_ID)

references ORDERS

Hibernate:

alter table ORDERS

add constraint FKdbs21f1yi0coxy9y0kxw4g9jf

foreign key (DELIVERY_ID)

references Delivery

Hibernate:

alter table ORDERS

add constraint FKh0db7kqr88ed8hqtcqw3jkcia

foreign key (MEMBER_ID)

references Member

8월 08, 2023 10:39:57 오후 org.hibernate.tool.schema.internal.SchemaCreatorImpl applyImportSources

INFO: HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@30f74e79'

Hibernate:

call next value for hibernate_sequence

Hibernate:

/* insert jpabook.jpashop.domain.Book

*/ insert

into

Item

(name, price, stockQuantity, author, isbn, DTYPE, ITEM_ID)

values

(?, ?, ?, ?, ?, 'Book', ?)

8월 08, 2023 10:39:57 오후 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions

WARN: SQL Error: 23505, SQLState: 23505

8월 08, 2023 10:39:57 오후 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions

ERROR: Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.ITEM(ITEM_ID) ( /* key:1 */ 'Book', CAST(1 AS BIGINT), 'dd', 0, 0, NULL, NULL, 'abc', NULL, NULL, NULL)"; SQL statement:

/* insert jpabook.jpashop.domain.Book */ insert into Item (name, price, stockQuantity, author, isbn, DTYPE, I [23505-200]

8월 08, 2023 10:39:57 오후 org.hibernate.internal.ExceptionMapperStandardImpl mapManagedFlushFailure

ERROR: HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]

8월 08, 2023 10:39:57 오후 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl stop

INFO: HHH10001008: Cleaning up connection pool [jdbc:h2:tcp://localhost/~/jpashop]

Process finished with exit code 0

 

답변 1

0

황규혁님의 프로필 이미지
황규혁
질문자

아 하이버네이트 버전을 바꾸니까 해결됐습니다!

황규혁님의 프로필 이미지
황규혁

작성한 질문수

질문하기