i am trying to insert a Employee entity into the database. I am using JPA and the database is mysql. When I try to insert the entity, it gives me tables must be created I assume that I dont have to create the table. Entity will automatically create the table with the annotated name. Please find the exception and code below.
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'gsq.articles' doesn't exist
Error Code: 1146
Call: CREATE TABLE articles (id INTEGER AUTO_INCREMENT NOT NULL, libelle VARCHAR(255), ENTREPRISE_id INTEGER, PRIMARY KEY (id))
Query: DataModifyQuery(sql="CREATE TABLE articles (id INTEGER AUTO_INCREMENT NOT NULL, libelle VARCHAR(255), ENTREPRISE_id INTEGER, PRIMARY KEY (id))")
[EL Fine]: 2017-11-12 20:57:29.914--ServerSession(162116790)--Connection(578752466)--CREATE TABLE entreprise (id INTEGER AUTO_INCREMENT NOT NULL, libelle VARCHAR(255) UNIQUE, PRIMARY KEY (id))
[EL Fine]: 2017-11-12 20:57:29.919--ServerSession(162116790)--SELECT 1
[EL Warning]: 2017-11-12 20:57:29.921--ServerSession(162116790)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'gsq.entreprise' doesn't exist
Error Code: 1146
Call: CREATE TABLE entreprise (id INTEGER AUTO_INCREMENT NOT NULL, libelle VARCHAR(255) UNIQUE, PRIMARY KEY (id))
Query: DataModifyQuery(sql="CREATE TABLE entreprise (id INTEGER AUTO_INCREMENT NOT NULL, libelle VARCHAR(255) UNIQUE, PRIMARY KEY (id))")
[EL Fine]: 2017-11-12 20:57:29.922--ServerSession(162116790)--Connection(578752466)--CREATE TABLE users (ID BIGINT AUTO_INCREMENT NOT NULL, password VARCHAR(255), type VARCHAR(255), username VARCHAR(255) UNIQUE, PRIMARY KEY (ID))
[EL Fine]: 2017-11-12 20:57:29.927--ServerSession(162116790)--SELECT 1
[EL Warning]: 2017-11-12 20:57:29.929--ServerSession(162116790)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'gsq.users' doesn't exist
Error Code: 1146
Call: CREATE TABLE users (ID BIGINT AUTO_INCREMENT NOT NULL, password VARCHAR(255), type VARCHAR(255), username VARCHAR(255) UNIQUE, PRIMARY KEY (ID))
Query: DataModifyQuery(sql="CREATE TABLE users (ID BIGINT AUTO_INCREMENT NOT NULL, password VARCHAR(255), type VARCHAR(255), username VARCHAR(255) UNIQUE, PRIMARY KEY (ID))")
[EL Fine]: 2017-11-12 20:57:29.93--ServerSession(162116790)--Connection(578752466)--ALTER TABLE articles ADD CONSTRAINT FK_articles_ENTREPRISE_id FOREIGN KEY (ENTREPRISE_id) REFERENCES entreprise (id)
[EL Fine]: 2017-11-12 20:57:29.935--ServerSession(162116790)--SELECT 1
[EL Warning]: 2017-11-12 20:57:29.936--ServerSession(162116790)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'gsq.articles' doesn't exist
Error Code: 1146
Call: ALTER TABLE articles ADD CONSTRAINT FK_articles_ENTREPRISE_id FOREIGN KEY (ENTREPRISE_id) REFERENCES entreprise (id)
Query: DataModifyQuery(sql="ALTER TABLE articles ADD CONSTRAINT FK_articles_ENTREPRISE_id FOREIGN KEY (ENTREPRISE_id) REFERENCES entreprise (id)")
[EL Fine]: 2017-11-12 20:57:30.035--ServerSession(162116790)--Connection(578752466)--SELECT id, libelle FROM entreprise
[EL Fine]: 2017-11-12 20:57:30.035--ServerSession(162116790)--SELECT 1
[EL Warning]: 2017-11-12 20:57:30.035--UnitOfWork(1734860123)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'gsq.entreprise' doesn't exist
Error Code: 1146
Call: SELECT id, libelle FROM entreprise
Query: ReadAllQuery(referenceClass=Entreprise sql="SELECT id, libelle FROM entreprise")
Exception in thread "AWT-EventQueue-0" javax.persistence.RollbackException: Transaction rolled back because transaction was set to RollbackOnly.
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:92)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
at controlleur.Executerequest.closeEntityManager(Executerequest.java:73)
at frame.ArticlesFram.MajComBox(ArticlesFram.java:385)
at frame.ArticlesFram.<init>(ArticlesFram.java:53)
at frame.ArticlesFram$13.run(ArticlesFram.java:501)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="GSQPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>entities.Articles</class>
<class>entities.Entreprise</class>
<class>entities.Users</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/gsq"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="eclipselink.logging.level.sql" value="FINE"/>
<property name="eclipselink.logging.parameters" value="true"/>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
Artcile entity
#Entity
#Table(name = "articles")
#XmlRootElement
#NamedQueries({
#NamedQuery(name = "Articles.findAll", query = "SELECT a FROM Articles a"),
#NamedQuery(name = "Articles.findById", query = "SELECT a FROM Articles a WHERE a.id = :id"),
#NamedQuery(name = "Articles.findByLibelle", query = "SELECT a FROM Articles a WHERE a.libelle = :libelle")})
public class Articles implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
#Basic(optional = false)
#Column(name = "id")
private Integer id;
#Column(name = "libelle")
private String libelle;
#ManyToOne
private Entreprise entreprise;
public Articles() {
}
public Articles(Integer id) {
this.id = id;
}
}
I haven't work with eclipselink, but checking a few example and can see that all have mentioned below 4 properties each time:
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.create-ddl-jdbc-file-name" value="createDDL_ddlGeneration.jdbc"/>
<property name="eclipselink.drop-ddl-jdbc-file-name" value="dropDDL_ddlGeneration.jdbc"/>
<property name="eclipselink.ddl-generation.output-mode" value="both"/>
might be the cause ?
the problem was at the database level and not with jpa I solved it by connecting to another database thx
Related
We are upgrading Mysql-5.7 to Mysql-8.0.28 with Mysql-8.0.28 Connector.
Here the issue is, Hibernate trying to recreate all tables even if all tables are exists using hbm2ddl.auto as update.
Software Version Details :
Hibernate-5.3.17,
Mysql Database-8.0.28,
Mysql Connector-8.0.28.
hibernate.cfg.xml
<session-factory>
<property name="show_sql">false</property>
<property name="dialect">org.hibernate.dialect.MySQL8Dialect</property>
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory
</property>
<property name="hibernate.cache.provider_configuration_file_resource_path">ehcache.xml</property>
<property name="cacheManagerName">ehcache-agora</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="c3p0.timeout">3000</property>
<property name="c3p0.idle_test_period">300</property>
Logs information :
[11 Jul 2022 15:42:32 IST][INFO] HHH000130: Instantiating explicit connection provider: org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl
[11 Jul 2022 15:42:32 IST][WARN] GenerationTarget encountered exception accepting command : Error executing DDL "create table ALERT (ID bigint not null, NAME varchar(255), DATA longtext, TYPE varchar(255), USER_ID bigint, CREATED_DATE datetime(6), primary key (ID)) engine=InnoDB" via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create table ALERT (ID bigint not null, NAME varchar(255), DATA longtext, TYPE varchar(255), USER_ID bigint, CREATED_DATE datetime(6), primary key (ID)) engine=InnoDB" via JDBC Statement
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:559)
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:504)
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.createTable(AbstractSchemaMigrator.java:277)
at org.hibernate.tool.schema.internal.GroupedSchemaMigratorImpl.performTablesMigration(GroupedSchemaMigratorImpl.java:71)
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:207)
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:183)
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.cfg.Configuration.buildSessionFactory(Configuration.java:708)
at com.sathya.sdp.server.ThreadSession.<clinit>(ThreadSession.java:88)
at com.sathya.sdp.server.presentation.PlatformBuilder.initialize(PlatformBuilder.java:66)
at com.sathya.sdp.server.presentation.PlatformServlet.initialize(PlatformServlet.java:320)
at com.sathya.sdp.server.presentation.PlatformServlet.init(PlatformServlet.java:49)
at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
Caused by: java.sql.SQLSyntaxErrorException: Table 'ALERT' already exists
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:763)
at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:648)
at com.mysql.cj.jdbc.StatementWrapper.execute(StatementWrapper.java:529)
at org.jboss.jca.adapters.jdbc.WrappedStatement.execute(WrappedStatement.java:198)
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)
... 40 more
Thanks in Advance,
P.Sathya
I have a JPA project that uses Hibernate and H2. The following is the maven pom dependency list:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.181</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.6.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.6.Final</version>
</dependency>
The following is the project structure:
The following is the content of blood_donor_create.sql:
CREATE TABLE IF NOT EXISTS `blood_type` (
`id` integer NOT NULL,
`blood_type` char(3) NOT NULL,
PRIMARY KEY (`id`)
)
CREATE TABLE IF NOT EXISTS `donation` (
`id` bigint NOT NULL auto_increment,
`date` date NOT NULL,
`location` varchar(150) NOT NULL,
`donor_id` bigint NOT NULL,
PRIMARY KEY (`id`),
KEY `donation_donor` (`donor_id`),
CONSTRAINT `donation_donor` FOREIGN KEY (`donor_id`) REFERENCES `donor` (`id`)
)
CREATE TABLE IF NOT EXISTS `donor` (
`id` bigint NOT NULL auto_increment,
`name` varchar(50) NOT NULL,
`myanmar_name` varchar(100) NOT NULL,
`email` varchar(50) NOT NULL,
`facebook` varchar(50) NOT NULL,
`phone` integer NOT NULL,
`blood_type_id` integer NOT NULL,
PRIMARY KEY (`id`),
KEY `donor_blood_type` (`blood_type_id`),
CONSTRAINT `donor_blood_type` FOREIGN KEY (`blood_type_id`) REFERENCES `blood_type` (`id`)
)
And the following is the content of blood_donor_load.sql:
INSERT INTO `blood_type` (`id`, `blood_type`) VALUES
(1, 'A+'),
(2, 'A-'),
(3, 'B+'),
(4, 'B-'),
(5, 'O+'),
(6, 'O-'),
(7, 'AB+'),
(8, 'AB-');
The following is the content of persistence.xml:
<persistence-unit name="BloodDonorPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:h2:file:~/blooddonor"/>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
<property name="javax.persistence.schema-generation.create-source" value="script"/>
<property name="javax.persistence.schema-generation.create-script-source" value="sql/blood_donor_load.sql"/>
<property name="javax.persistence.sql-load-script-source" value="sql/blood_donor_load.sql"/>
</properties>
</persistence-unit>
Running the program causes the following exceptions:
Exception in thread "main" javax.persistence.PersistenceException: Unable to execute JPA schema generation create command [INSERT INTO `blood_type` (`id`, `blood_type`) VALUES]
at org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase.acceptCreateCommands(GenerationTargetToDatabase.java:64)
at org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator.doGeneration(JpaSchemaGenerator.java:507)
at org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator.access$300(JpaSchemaGenerator.java:69)
at org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator$Generation.execute(JpaSchemaGenerator.java:184)
at org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator.performGeneration(JpaSchemaGenerator.java:76)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:843)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:842)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:75)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
at org.bitbucket.infovillavendor.blooddonor.Launcher.main(Launcher.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: org.h2.jdbc.JdbcSQLException: Table "BLOOD_TYPE" not found; SQL statement:
INSERT INTO `blood_type` (`id`, `blood_type`) VALUES [42102-181]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.command.Parser.readTableOrView(Parser.java:5227)
at org.h2.command.Parser.readTableOrView(Parser.java:5204)
at org.h2.command.Parser.parseInsert(Parser.java:1025)
at org.h2.command.Parser.parsePrepared(Parser.java:401)
at org.h2.command.Parser.parse(Parser.java:305)
at org.h2.command.Parser.parse(Parser.java:277)
at org.h2.command.Parser.prepareCommand(Parser.java:242)
at org.h2.engine.Session.prepareLocal(Session.java:446)
at org.h2.engine.Session.prepareCommand(Session.java:388)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1189)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:171)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:159)
at org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase.acceptCreateCommands(GenerationTargetToDatabase.java:61)
... 18 more
What might be wrong here?
I don't think you need the quotes in the table name in the creation or insertion.
The best thing to do is to install the H2 database, which has a front-end, onto your computer and paste the create and load statements into the console so it can highlight the errors and give you meaningful messages.
I am trying to insert a Employee entity into the database. I am using JPA and the database is mysql.
When I try to insert the entity, it gives me test.employee does not exist. I assume that I dont have to create
the table. Entity will automatically create the table with the annotated name.
Please find the exception and code below.
Exception in thread "main" javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test.employee' doesn't exist
Error Code: 1146
Call: INSERT INTO employee (FIRST_NAME, LAST_NAME) VALUES (?, ?)
bind => [abc,def]
Query: InsertObjectQuery(com.example.entities.Employee#ee1ede)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:157)
at com.example.dao.BaseDao.commitAndClose(BaseDao.java:41)
at com.example..dao.BaseDao.persist(BaseDao.java:29)
at com.example..dao.EmployeeDao.createEmployee(EmployeeDao.java:29)
at com.example.Main.main(KITMain.java:27)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test.employee' doesn't exist
Error Code: 1146
Call: INSERT INTO employee (FIRST_NAME, LAST_NAME) VALUES (?, ?)
bind => [ram, mohan]
Query: InsertObjectQuerycom.example.entities.Employee#ee1ede)
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:331)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:900)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:962)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:631)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:558)
at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1991)
at org.eclipse.persistence.sessions.server.ClientSession.executeCall(ClientSession.java:298)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:242)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.insertObject(DatasourceCallQueryMechanism.java:377)
at org.eclipse.persistence.internal.queries.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:165)
at org.eclipse.persistence.internal.queries.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:180)
at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:489)
at org.eclipse.persistence.queries.InsertObjectQuery.executeCommit(InsertObjectQuery.java:80)
at org.eclipse.persistence.queries.InsertObjectQuery.executeCommitWithChangeSet(InsertObjectQuery.java:90)
at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:301)
at org.eclipse.persistence.queries.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:58)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:798)
at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:108)
at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:85)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1793)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1775)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1726)
at org.eclipse.persistence.internal.sessions.CommitManager.commitNewObjectsForClassWithChangeSet(CommitManager.java:226)
at org.eclipse.persistence.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:125)
at org.eclipse.persistence.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:4196)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1441)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1531)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:277)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1169)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:132)
... 4 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test.employee' doesn't exist
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.Util.getInstance(Util.java:384)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4232)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4164)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2838)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2334)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2262)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2246)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:890)
persistence.xml
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<class>com.example.entities.Employee</class>
<properties>
<!-- derby -->
<!-- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"
/> <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"
/> <property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/test"
/> <property name="javax.persistence.jdbc.user" value="app" /> <property
name="javax.persistence.jdbc.password" value="admin" /> -->
<!-- mysql -->
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/test" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="" />
<!-- EclipseLink should create the database schema automatically -->
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.ddl-generation.output-mode"
value="database" />
<!-- Configure simple SQL logging for demonstration. -->
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.logging.thread" value="false" />
<property name="eclipselink.logging.session" value="false" />
<property name="eclipselink.logging.exceptions" value="false" />
<property name="eclipselink.logging.timestamp" value="false" />
</properties>
</persistence-unit>
package com.example.entities;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
*
* #author ddd
*/
#Entity
#Table(name = "employee")
public class Employee implements Serializable {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
#Column(name = "EMP_ID")
private String employeeId;
#Column(name = "FIRST_NAME")
private String firstName;
#Column(name = "LAST_NAME")
private String lastName ;
public String getEmployeeId() {
return employeeId;
}
public void setEmployeeId(String employeeId) {
this.employeeId = employeeId;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
[EL Config]: metadata: The access type for the persistent class [class de.allianz.kit.server.persistence.entities.Employee] is set to [FIELD].
[EL Config]: metadata: The alias name for the entity class [class de.allianz.kit.server.persistence.entities.Employee] is being defaulted to: Employee.
[EL Info]: EclipseLink, version: Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5
[EL Fine]: connection: Detected database platform: org.eclipse.persistence.platform.database.MySQLPlatform
[EL Config]: connection: Connection(3278348)--connecting(DatabaseLogin(
platform=>MySQLPlatform
user name=> "root"
datasource URL=> "jdbc:mysql://localhost:3306/test"
))
[EL Config]: connection: Connection(5863106)--Connected: jdbc:mysql://localhost:3306/test
User: root#localhost
Database: MySQL Version: 5.6.17
Driver: MySQL Connector Java Version: mysql-connector-java-5.1.30 ( Revision: alexander.soklakov#oracle.com-20140310090514-8xt1yoht5ksg2e7c )
[EL Info]: connection: file:/C:/myworkspace/kit_ws/com.example.server.persistence/classes/_kit login successful
[EL Fine]: sql: Connection(5863106)--DROP TABLE employee
[EL Fine]: sql: SELECT 1
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown table 'test.employee'
Error Code: 1051
Call: DROP TABLE employee
Query: DataModifyQuery(sql="DROP TABLE employee")
[EL Fine]: sql: Connection(5863106)--DROP TABLE employee
[EL Fine]: sql: SELECT 1
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown table 'test.employee'
Error Code: 1051
Call: DROP TABLE employee
Query: DataModifyQuery(sql="DROP TABLE employee")
[EL Fine]: sql: Connection(5863106)--DROP TABLE employee
[EL Fine]: sql: SELECT 1
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown table 'test.employee'
Error Code: 1051
Call: DROP TABLE employee
Query: DataModifyQuery(sql="DROP TABLE employee")
[EL Fine]: sql: Connection(5863106)--DROP TABLE employee
[EL Fine]: sql: SELECT 1
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown table 'test.employee'
Error Code: 1051
Call: DROP TABLE employee
Query: DataModifyQuery(sql="DROP TABLE employee")
[EL Fine]: sql: Connection(5863106)--DROP TABLE employee
[EL Fine]: sql: SELECT 1
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown table 'test.employee'
Error Code: 1051
Call: DROP TABLE employee
Query: DataModifyQuery(sql="DROP TABLE employee")
[EL Fine]: sql: Connection(5863106)--CREATE TABLE employee (EMP_ID VARCHAR(255) AUTO_INCREMENT NOT NULL, FIRST_NAME VARCHAR(255), LAST_NAME VARCHAR(255), PRIMARY KEY (EMP_ID))
[EL Fine]: sql: SELECT 1
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Incorrect column specifier for column 'EMP_ID'
Error Code: 1063
Call: CREATE TABLE employee (EMP_ID VARCHAR(255) AUTO_INCREMENT NOT NULL, FIRST_NAME VARCHAR(255), LAST_NAME VARCHAR(255), PRIMARY KEY (EMP_ID))
Query: DataModifyQuery(sql="CREATE TABLE employee (EMP_ID VARCHAR(255) AUTO_INCREMENT NOT NULL, FIRST_NAME VARCHAR(255), LAST_NAME VARCHAR(255), PRIMARY KEY (EMP_ID))")
[EL Fine]: sql: Connection(5863106)--INSERT INTO employee (FIRST_NAME, LAST_NAME) VALUES (?, ?)
bind => [ram, mohan]
[EL Fine]: sql: SELECT 1
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test.employee' doesn't exist
Error Code: 1146
You will need extra configuration if you want an auto generated varchar.
The generation of DDL is translating to:
CREATE TABLE employee (EMP_ID VARCHAR(255) AUTO_INCREMENT NOT NULL, FIRST_NAME VARCHAR(255), LAST_NAME VARCHAR(255), PRIMARY KEY (EMP_ID))
and the log is saying:
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Incorrect column specifier for column 'EMP_ID'
Error Code: 1063
MySql is rejecting EMP_ID becuase it cant have AUTO_INCREMENT with varchar, and you need to specify the auto generation for it. Probably Derby has this feature, and it works different for MySql.
You might wanna look in this answer.
Or just change the type of EMP_ID to an integer number if you dont mind the type or for a quick test.
Could be you mysql data is corrupted.
Go to Mysql home directory and delete all .frm extension. and restart Msysql server.
Solved.
Please have a look on my create script.
My goal is to controll the creation of the schema by script and let the dropping be handled by the metadata stuff.
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.target-database" value="DERBY" />
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver" />
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create" />
<property name="javax.persistence.schema-generation.script.action" value="create" />
<property name="javax.persistence.schema-generation.create-source" value="script" />
<property name="javax.persistence.schema-generation.create-script-source"
value="file:/home/kevin/workspace_pluginDev/zvagent/src/main/resources/META-INF/sql/create_tables.ddl" />
<property name="javax.persistence.sql-load-script-source"
value="file:/home/kevin/workspace_pluginDev/zvagent/src/main/resources/META-INF/sql/load_stammdaten.sql" />
The create script will be executed but fails on the end of the first line. It seems like the create script is executed line wise and not statement by statement:
The create script
I tested this script successfully on the same DB connection inside Eclipse using a SQL-Scrapbook editor.
CREATE TABLE TABELLENNAME (
"BESCHREIBUNG" VARCHAR(255),
"ID" BIGINT NOT NULL PRIMARY KEY,
"LASTUPDATE" BIGINT,
"SONSTIGES" VARCHAR(255),
);
But when called from JPA this happens:
Log/Error messages from the DB
[EL Fine]: sql: 2014-03-09 13:45:44.167--ServerSession(194685468)--Connection(1337157493)--Thread(Thread[main,5,main])--CREATE TABLE TABELLENNAME (
[EL Fine]: sql: 2014-03-09 13:45:44.17--ServerSession(194685468)--Thread(Thread[main,5,main])--VALUES(1)
[EL Warning]: 2014-03-09 13:45:44.172--ServerSession(194685468)--Thread(Thread[main,5,main])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Syntaxfehler: Encountered "<EOF>" at line 1, column 27.
Error Code: 0
Call: CREATE TABLE TABELLENNAME (
Query: DataModifyQuery(sql="CREATE TABLE TABELLENNAME (")
[EL Fine]: sql: 2014-03-09 13:45:44.172--ServerSession(194685468)--Connection(1337157493)--Thread(Thread[main,5,main])--"BESCHREIBUNG" VARCHAR(255),
[EL Fine]: sql: 2014-03-09 13:45:44.179--ServerSession(194685468)--Thread(Thread[main,5,main])--VALUES(1)
[EL Warning]: 2014-03-09 13:45:44.181--ServerSession(194685468)--Thread(Thread[main,5,main])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Syntaxfehler: Encountered "\"BESCHREIBUNG\"" at line 1, column 1.
Error Code: 0
Call: "BESCHREIBUNG" VARCHAR(255),
Query: DataModifyQuery(sql=""BESCHREIBUNG" VARCHAR(255),")
[EL Fine]: sql: 2014-03-09 13:45:44.182--ServerSession(194685468)--Connection(1337157493)--Thread(Thread[main,5,main])--"ID" BIGINT NOT NULL PRIMARY KEY,
[EL Fine]: sql: 2014-03-09 13:45:44.184--ServerSession(194685468)--Thread(Thread[main,5,main])--VALUES(1)
[EL Warning]: 2014-03-09 13:45:44.186--ServerSession(194685468)--Thread(Thread[main,5,main])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Syntaxfehler: Encountered "\"ID\"" at line 1, column 1.
Error Code: 0
Call: "ID" BIGINT NOT NULL PRIMARY KEY,
Query: DataModifyQuery(sql=""ID" BIGINT NOT NULL PRIMARY KEY,")
[EL Fine]: sql: 2014-03-09 13:45:44.193--ServerSession(194685468)--Connection(1337157493)--Thread(Thread[main,5,main])--"LASTUPDATE" BIGINT,
[EL Fine]: sql: 2014-03-09 13:45:44.196--ServerSession(194685468)--Thread(Thread[main,5,main])--VALUES(1)
[EL Warning]: 2014-03-09 13:45:44.198--ServerSession(194685468)--Thread(Thread[main,5,main])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Syntaxfehler: Encountered "\"LASTUPDATE\"" at line 1, column 1.
Error Code: 0
Call: "LASTUPDATE" BIGINT,
Query: DataModifyQuery(sql=""LASTUPDATE" BIGINT,")
[EL Fine]: sql: 2014-03-09 13:45:44.198--ServerSession(194685468)--Connection(1337157493)--Thread(Thread[main,5,main])--"SONSTIGES" VARCHAR(255),
[EL Fine]: sql: 2014-03-09 13:45:44.202--ServerSession(194685468)--Thread(Thread[main,5,main])--VALUES(1)
[EL Warning]: 2014-03-09 13:45:44.203--ServerSession(194685468)--Thread(Thread[main,5,main])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Syntaxfehler: Encountered "\"SONSTIGES\"" at line 1, column 1.
Error Code: 0
Call: "SONSTIGES" VARCHAR(255),
Query: DataModifyQuery(sql=""SONSTIGES" VARCHAR(255),")
[EL Fine]: sql: 2014-03-09 13:45:44.204--ServerSession(194685468)--Connection(1337157493)--Thread(Thread[main,5,main])--);
[EL Fine]: sql: 2014-03-09 13:45:44.206--ServerSession(194685468)--Thread(Thread[main,5,main])--VALUES(1)
[EL Warning]: 2014-03-09 13:45:44.208--ServerSession(194685468)--Thread(Thread[main,5,main])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Syntaxfehler: Encountered ")" at line 1, column 1.
Error Code: 0
Call: );
Query: DataModifyQuery(sql=");")
Q: Is there a way to format the create scripts human readable but at the same time executable as create script?
I use hibernate in my application. At once I want to write tests. I take database with data. Before test database should be clear. I thought if I write
<prop key="hibernate.hbm2ddl.auto">create-drop</prop>
In my configuration - it helps me. But hibernate try drop all tables in random order.
And I see following log:
INFO ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext#432a0f6c: startup date [Fri Sep 20 15:16:06 MSK 2013]; root of context hierarchy
INFO XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [test/BeanConfig.xml]
INFO XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [test/data.xml]
INFO DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#75be16f5: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,candidateDao,eventDaoImpl,eventStatusDao,eventTypeDao,noteDao,skillDao,userDao,vacancyDao,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,transactionManager,dataSource,sessionFactory,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy
INFO DriverManagerDataSource - Loaded JDBC driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
INFO Version - HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
INFO Version - HHH000412: Hibernate Core {4.2.1.Final}
INFO Environment - HHH000206: hibernate.properties not found
INFO Environment - HHH000021: Bytecode provider name : javassist
INFO Configuration - HHH000044: Configuring from URL: file:/C:/Users/Nikolay_Tkachev/workspace/HHSystem/Core/target/classes/test/hibernate.cfg.xml
INFO Configuration - HHH000041: Configured SessionFactory: null
INFO Dialect - HHH000400: Using dialect: org.hibernate.dialect.SQLServerDialect
INFO TransactionFactoryInitiator - HHH000399: Using default transaction strategy (direct JDBC transactions)
INFO ASTQueryTranslatorFactory - HHH000397: Using ASTQueryTranslatorFactory
INFO Version - HV000001: Hibernate Validator 4.3.1.Final
INFO SchemaExport - HHH000227: Running hbm2ddl schema export
Hibernate: alter table candidate drop constraint FK_0a095d3c05344292b630736d577
ERROR SchemaExport - HHH000389: Unsuccessful: alter table candidate drop constraint FK_0a095d3c05344292b630736d577
ERROR SchemaExport - FK_0a095d3c05344292b630736d577 не является ограничением.
Hibernate: alter table candidate_skill drop constraint FK_f487e8a130cb44478cf45d2bed6
ERROR SchemaExport - HHH000389: Unsuccessful: alter table candidate_skill drop constraint FK_f487e8a130cb44478cf45d2bed6
ERROR SchemaExport - FK_f487e8a130cb44478cf45d2bed6 не является ограничением.
Hibernate: alter table candidate_skill drop constraint FK_d5e271d145df45948a4928ef92f
ERROR SchemaExport - HHH000389: Unsuccessful: alter table candidate_skill drop constraint FK_d5e271d145df45948a4928ef92f
ERROR SchemaExport - FK_d5e271d145df45948a4928ef92f не является ограничением.
Hibernate: alter table candidate_status drop constraint FK_26a9279492b14ebd9068df09af9
ERROR SchemaExport - HHH000389: Unsuccessful: alter table candidate_status drop constraint FK_26a9279492b14ebd9068df09af9
ERROR SchemaExport - FK_26a9279492b14ebd9068df09af9 не является ограничением.
Hibernate: alter table candidate_status drop constraint FK_d6fda5bc80c140bb8053a15595b
ERROR SchemaExport - HHH000389: Unsuccessful: alter table candidate_status drop constraint FK_d6fda5bc80c140bb8053a15595b
ERROR SchemaExport - FK_d6fda5bc80c140bb8053a15595b не является ограничением.
Hibernate: alter table candidate_status drop constraint FK_04345df148d644c2a458c48aa7a
ERROR SchemaExport - HHH000389: Unsuccessful: alter table candidate_status drop constraint FK_04345df148d644c2a458c48aa7a
ERROR SchemaExport - FK_04345df148d644c2a458c48aa7a не является ограничением.
Hibernate: alter table event drop constraint FK_3221e14f1a5546aea264084277b
ERROR SchemaExport - HHH000389: Unsuccessful: alter table event drop constraint FK_3221e14f1a5546aea264084277b
ERROR SchemaExport - FK_3221e14f1a5546aea264084277b не является ограничением.
Hibernate: alter table event drop constraint FK_1e065236f2aa41a886818431a74
ERROR SchemaExport - HHH000389: Unsuccessful: alter table event drop constraint FK_1e065236f2aa41a886818431a74
ERROR SchemaExport - FK_1e065236f2aa41a886818431a74 не является ограничением.
Hibernate: alter table event drop constraint FK_8cd8c0859ba8443e9f6ec783473
ERROR SchemaExport - HHH000389: Unsuccessful: alter table event drop constraint FK_8cd8c0859ba8443e9f6ec783473
ERROR SchemaExport - FK_8cd8c0859ba8443e9f6ec783473 не является ограничением.
Hibernate: alter table event_candidate drop constraint FK_04a181b9bf6842ce808631f5b26
ERROR SchemaExport - HHH000389: Unsuccessful: alter table event_candidate drop constraint FK_04a181b9bf6842ce808631f5b26
ERROR SchemaExport - FK_04a181b9bf6842ce808631f5b26 не является ограничением.
Hibernate: alter table event_candidate drop constraint FK_60493ff24dc343bf9edd017b5f1
ERROR SchemaExport - HHH000389: Unsuccessful: alter table event_candidate drop constraint FK_60493ff24dc343bf9edd017b5f1
ERROR SchemaExport - FK_60493ff24dc343bf9edd017b5f1 не является ограничением.
Hibernate: alter table event_vacancy drop constraint FK_87e5ee2c1ed24cabb2a0e8472e8
ERROR SchemaExport - HHH000389: Unsuccessful: alter table event_vacancy drop constraint FK_87e5ee2c1ed24cabb2a0e8472e8
ERROR SchemaExport - FK_87e5ee2c1ed24cabb2a0e8472e8 не является ограничением.
Hibernate: alter table event_vacancy drop constraint FK_99ca9c03c1a34a0d8c4c0e62a5b
ERROR SchemaExport - HHH000389: Unsuccessful: alter table event_vacancy drop constraint FK_99ca9c03c1a34a0d8c4c0e62a5b
ERROR SchemaExport - FK_99ca9c03c1a34a0d8c4c0e62a5b не является ограничением.
Hibernate: alter table note drop constraint FK_a30769362d244864aea0d90fa53
ERROR SchemaExport - HHH000389: Unsuccessful: alter table note drop constraint FK_a30769362d244864aea0d90fa53
ERROR SchemaExport - FK_a30769362d244864aea0d90fa53 не является ограничением.
Hibernate: alter table note drop constraint FK_9ea4fdfb6a4249cd8fc4365b08e
ERROR SchemaExport - HHH000389: Unsuccessful: alter table note drop constraint FK_9ea4fdfb6a4249cd8fc4365b08e
ERROR SchemaExport - FK_9ea4fdfb6a4249cd8fc4365b08e не является ограничением.
Hibernate: alter table note drop constraint FK_ef76fe39f36e41439347bbe0d50
ERROR SchemaExport - HHH000389: Unsuccessful: alter table note drop constraint FK_ef76fe39f36e41439347bbe0d50
ERROR SchemaExport - FK_ef76fe39f36e41439347bbe0d50 не является ограничением.
Hibernate: alter table vacancy drop constraint FK_78a4a7e3d0484999aedab350f6c
ERROR SchemaExport - HHH000389: Unsuccessful: alter table vacancy drop constraint FK_78a4a7e3d0484999aedab350f6c
ERROR SchemaExport - FK_78a4a7e3d0484999aedab350f6c не является ограничением.
Hibernate: alter table vacancy_candidate drop constraint FK_70b128e5e6a24a78b7b500feeb0
ERROR SchemaExport - HHH000389: Unsuccessful: alter table vacancy_candidate drop constraint FK_70b128e5e6a24a78b7b500feeb0
ERROR SchemaExport - FK_70b128e5e6a24a78b7b500feeb0 не является ограничением.
Hibernate: alter table vacancy_candidate drop constraint FK_c9145cfab1c4417ba935cea8ca5
ERROR SchemaExport - HHH000389: Unsuccessful: alter table vacancy_candidate drop constraint FK_c9145cfab1c4417ba935cea8ca5
ERROR SchemaExport - FK_c9145cfab1c4417ba935cea8ca5 не является ограничением.
Hibernate: alter table vacancy_skill drop constraint FK_66c9f60532da40249fe0286747d
ERROR SchemaExport - HHH000389: Unsuccessful: alter table vacancy_skill drop constraint FK_66c9f60532da40249fe0286747d
ERROR SchemaExport - FK_66c9f60532da40249fe0286747d не является ограничением.
Hibernate: alter table vacancy_skill drop constraint FK_3e3cb30e74ca45f786bf86ad790
ERROR SchemaExport - HHH000389: Unsuccessful: alter table vacancy_skill drop constraint FK_3e3cb30e74ca45f786bf86ad790
ERROR SchemaExport - FK_3e3cb30e74ca45f786bf86ad790 не является ограничением.
Hibernate: alter table vacancy_status drop constraint FK_f867af57b4374eb892c86b76076
ERROR SchemaExport - HHH000389: Unsuccessful: alter table vacancy_status drop constraint FK_f867af57b4374eb892c86b76076
ERROR SchemaExport - FK_f867af57b4374eb892c86b76076 не является ограничением.
Hibernate: alter table vacancy_status drop constraint FK_da55313052974e3bafeb61dc55a
ERROR SchemaExport - HHH000389: Unsuccessful: alter table vacancy_status drop constraint FK_da55313052974e3bafeb61dc55a
ERROR SchemaExport - FK_da55313052974e3bafeb61dc55a не является ограничением.
Hibernate: alter table vacancy_status drop constraint FK_958985ec3e7d43fcb8b01b12b0d
ERROR SchemaExport - HHH000389: Unsuccessful: alter table vacancy_status drop constraint FK_958985ec3e7d43fcb8b01b12b0d
ERROR SchemaExport - FK_958985ec3e7d43fcb8b01b12b0d не является ограничением.
Hibernate: drop table author
ERROR SchemaExport - HHH000389: Unsuccessful: drop table author
ERROR SchemaExport - Невозможно удалить объект "author", так как на него ссылается ограничение FOREIGN KEY.
Hibernate: drop table candidate
ERROR SchemaExport - HHH000389: Unsuccessful: drop table candidate
ERROR SchemaExport - Невозможно удалить объект "candidate", так как на него ссылается ограничение FOREIGN KEY.
Hibernate: drop table candidate_skill
Hibernate: drop table candidate_status
Hibernate: drop table event
ERROR SchemaExport - HHH000389: Unsuccessful: drop table event
ERROR SchemaExport - Невозможно удалить объект "event", так как на него ссылается ограничение FOREIGN KEY.
Hibernate: drop table event_candidate
Hibernate: drop table event_status
ERROR SchemaExport - HHH000389: Unsuccessful: drop table event_status
ERROR SchemaExport - Невозможно удалить объект "event_status", так как на него ссылается ограничение FOREIGN KEY.
Hibernate: drop table event_type
ERROR SchemaExport - HHH000389: Unsuccessful: drop table event_type
ERROR SchemaExport - Невозможно удалить объект "event_type", так как на него ссылается ограничение FOREIGN KEY.
Hibernate: drop table event_vacancy
Hibernate: drop table note
Hibernate: drop table skill
ERROR SchemaExport - HHH000389: Unsuccessful: drop table skill
ERROR SchemaExport - Невозможно удалить объект "skill", так как на него ссылается ограничение FOREIGN KEY.
Hibernate: drop table status_for_candidate
Hibernate: drop table status_for_vacancy
ERROR SchemaExport - HHH000389: Unsuccessful: drop table status_for_vacancy
ERROR SchemaExport - Невозможно удалить объект "status_for_vacancy", так как на него ссылается ограничение FOREIGN KEY.
Hibernate: drop table vacancy
ERROR SchemaExport - HHH000389: Unsuccessful: drop table vacancy
ERROR SchemaExport - Невозможно удалить объект "vacancy", так как на него ссылается ограничение FOREIGN KEY.
Hibernate: drop table vacancy_candidate
Hibernate: drop table vacancy_skill
Hibernate: drop table vacancy_status
Hibernate: create table author (id int identity not null, name varchar(255), surname varchar(255), login varchar(255) not null, password varchar(255), primary key (id))
ERROR SchemaExport - HHH000389: Unsuccessful: create table author (id int identity not null, name varchar(255), surname varchar(255), login varchar(255) not null, password varchar(255), primary key (id))
ERROR SchemaExport - В базе данных уже существует объект с именем "author".
Hibernate: create table candidate (id int identity not null, name varchar(255), surname varchar(255), creation_date datetime, phone varchar(12), cv_url varchar(100), author_id int, primary key (id))
ERROR SchemaExport - HHH000389: Unsuccessful: create table candidate (id int identity not null, name varchar(255), surname varchar(255), creation_date datetime, phone varchar(12), cv_url varchar(100), author_id int, primary key (id))
ERROR SchemaExport - В базе данных уже существует объект с именем "candidate".
Hibernate: create table candidate_skill (candidate_id int not null, skills_id int not null, primary key (candidate_id, skills_id))
Hibernate: create table candidate_status (id int identity not null, creation_date datetime, author_id int, candidate_id int, status_for_candidate_id int, primary key (id))
Hibernate: create table event (id int identity not null, creation_date datetime not null, description TEXT, event_date datetime not null, name varchar(255), author_id int, event_status_id int, event_type_id int, primary key (id))
ERROR SchemaExport - HHH000389: Unsuccessful: create table event (id int identity not null, creation_date datetime not null, description TEXT, event_date datetime not null, name varchar(255), author_id int, event_status_id int, event_type_id int, primary key (id))
ERROR SchemaExport - В базе данных уже существует объект с именем "event".
Hibernate: create table event_candidate (events_id int not null, candidates_id int not null, primary key (events_id, candidates_id))
Hibernate: create table event_status (id int identity not null, name varchar(255) not null, primary key (id))
ERROR SchemaExport - HHH000389: Unsuccessful: create table event_status (id int identity not null, name varchar(255) not null, primary key (id))
ERROR SchemaExport - В базе данных уже существует объект с именем "event_status".
Hibernate: create table event_type (id int identity not null, name varchar(255) not null, primary key (id))
ERROR SchemaExport - HHH000389: Unsuccessful: create table event_type (id int identity not null, name varchar(255) not null, primary key (id))
ERROR SchemaExport - В базе данных уже существует объект с именем "event_type".
Hibernate: create table event_vacancy (events_id int not null, vacancies_id int not null, primary key (events_id, vacancies_id))
Hibernate: create table note (id int identity not null, creation_date datetime, text TEXT not null, author_id int, candidate_id int, vacancy_id int, primary key (id))
Hibernate: create table skill (id int identity not null, name varchar(255) not null, primary key (id))
ERROR SchemaExport - HHH000389: Unsuccessful: create table skill (id int identity not null, name varchar(255) not null, primary key (id))
ERROR SchemaExport - В базе данных уже существует объект с именем "skill".
Hibernate: create table status_for_candidate (id int identity not null, name varchar(255) not null, primary key (id))
Hibernate: create table status_for_vacancy (id int identity not null, name varchar(255) not null, primary key (id))
ERROR SchemaExport - HHH000389: Unsuccessful: create table status_for_vacancy (id int identity not null, name varchar(255) not null, primary key (id))
ERROR SchemaExport - В базе данных уже существует объект с именем "status_for_vacancy".
Hibernate: create table vacancy (id int identity not null, creation_date datetime not null, description TEXT, name varchar(30) not null, author_id int, primary key (id))
ERROR SchemaExport - HHH000389: Unsuccessful: create table vacancy (id int identity not null, creation_date datetime not null, description TEXT, name varchar(30) not null, author_id int, primary key (id))
ERROR SchemaExport - В базе данных уже существует объект с именем "vacancy".
Hibernate: create table vacancy_candidate (vacancy_id int not null, candidate_id int not null, primary key (vacancy_id, candidate_id))
Hibernate: create table vacancy_skill (vacancy_id int not null, skill_id int not null, primary key (vacancy_id, skill_id))
Hibernate: create table vacancy_status (id int identity not null, creation_date datetime, author_id int, status_for_vacancy_id int, vacancy_id int, primary key (id))
Hibernate: alter table candidate add constraint FK_0a095d3c05344292b630736d577 foreign key (author_id) references author
Hibernate: alter table candidate_skill add constraint FK_f487e8a130cb44478cf45d2bed6 foreign key (skills_id) references skill
Hibernate: alter table candidate_skill add constraint FK_d5e271d145df45948a4928ef92f foreign key (candidate_id) references candidate
Hibernate: alter table candidate_status add constraint FK_26a9279492b14ebd9068df09af9 foreign key (author_id) references author
Hibernate: alter table candidate_status add constraint FK_d6fda5bc80c140bb8053a15595b foreign key (candidate_id) references candidate
Hibernate: alter table candidate_status add constraint FK_04345df148d644c2a458c48aa7a foreign key (status_for_candidate_id) references status_for_candidate
Hibernate: alter table event add constraint FK_3221e14f1a5546aea264084277b foreign key (author_id) references author
Hibernate: alter table event add constraint FK_1e065236f2aa41a886818431a74 foreign key (event_status_id) references event_status
Hibernate: alter table event add constraint FK_8cd8c0859ba8443e9f6ec783473 foreign key (event_type_id) references event_type
Hibernate: alter table event_candidate add constraint FK_04a181b9bf6842ce808631f5b26 foreign key (candidates_id) references candidate
Hibernate: alter table event_candidate add constraint FK_60493ff24dc343bf9edd017b5f1 foreign key (events_id) references event
Hibernate: alter table event_vacancy add constraint FK_87e5ee2c1ed24cabb2a0e8472e8 foreign key (vacancies_id) references vacancy
Hibernate: alter table event_vacancy add constraint FK_99ca9c03c1a34a0d8c4c0e62a5b foreign key (events_id) references event
Hibernate: alter table note add constraint FK_a30769362d244864aea0d90fa53 foreign key (author_id) references author
Hibernate: alter table note add constraint FK_9ea4fdfb6a4249cd8fc4365b08e foreign key (candidate_id) references candidate
Hibernate: alter table note add constraint FK_ef76fe39f36e41439347bbe0d50 foreign key (vacancy_id) references vacancy
Hibernate: alter table vacancy add constraint FK_78a4a7e3d0484999aedab350f6c foreign key (author_id) references author
Hibernate: alter table vacancy_candidate add constraint FK_70b128e5e6a24a78b7b500feeb0 foreign key (candidate_id) references candidate
Hibernate: alter table vacancy_candidate add constraint FK_c9145cfab1c4417ba935cea8ca5 foreign key (vacancy_id) references vacancy
Hibernate: alter table vacancy_skill add constraint FK_66c9f60532da40249fe0286747d foreign key (skill_id) references skill
Hibernate: alter table vacancy_skill add constraint FK_3e3cb30e74ca45f786bf86ad790 foreign key (vacancy_id) references vacancy
Hibernate: alter table vacancy_status add constraint FK_f867af57b4374eb892c86b76076 foreign key (author_id) references author
Hibernate: alter table vacancy_status add constraint FK_da55313052974e3bafeb61dc55a foreign key (status_for_vacancy_id) references status_for_vacancy
Hibernate: alter table vacancy_status add constraint FK_958985ec3e7d43fcb8b01b12b0d foreign key (vacancy_id) references vacancy
INFO SchemaExport - HHH000230: Schema export complete
any messages - on my native language. These messages return jdbc driver. Gist of these messsages is that, table is has constraints with another table.
Can you help me to find way for clear my database ?