Some minor problems with hibernate

Source: Internet
Author: User

The two tables are a one-to-many mapping relationship, and errors that occur when a foreign key constraint is established in the table. As long as the table when the corresponding foreign key constraints removed it is OK.

Two tables are:

CREATE TABLE Cst_customer (
  cust_id number not NULL,
  cust_name varchar () NOT NULL,
  Cust_source varchar (32) Default NULL,
  cust_industry varchar () default NULL,
  cust_level varchar () default NULL,
  Cust_phone varchar () default NULL,
  cust_mobile varchar () default NULL,
  PRIMARY KEY (cust_id)
);

CREATE TABLE Cst_linkman (
  lkm_id number not NULL,
  lkm_name varchar () DEFAULT NULL,
  lkm_cust_id number (() not NULL,
  lkm_gender varchar2 (1) default NULL,
  lkm_phone varchar2 () default NULL,
  Lkm_mobile VARCHAR2 () default null,
  lkm_email varchar2 ($) default NULL,
  lkm_qq varchar2 () default NULL,
  lkm_ Position varchar2 default NULL,
  Lkm_memo varchar2 ($) default NULL,
  PRIMARY KEY (lkm_id),
  CONSTRAINT fk_cst_linkman_lkm_cust_id FOREIGN KEY (lkm_cust_id) REFERENCES Cst_customer (cust_id)
);




Org.hibernate.tool.schema.spi.SchemaManagementException:Unable to execute schema management to JDBC target [ALTER TABLE Cst_linkman add constraint fkh9yp1nql5227xxcopuxqx2e7q foreign key (lkm_cust_id) references Cst_customer (cust_id)] at or G.hibernate.tool.schema.internal.targetdatabaseimpl.accept (targetdatabaseimpl.java:59)
At Org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlString (schemamigratorimpl.java:431)
At Org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlStrings (schemamigratorimpl.java:420)
At Org.hibernate.tool.schema.internal.SchemaMigratorImpl.applyForeignKeys (schemamigratorimpl.java:386)
At Org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigrationToTargets (schemamigratorimpl.java:214)
At Org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration (schemamigratorimpl.java:60)
At Org.hibernate.tool.hbm2ddl.SchemaUpdate.execute (schemaupdate.java:133)
At Org.hibernate.tool.hbm2ddl.SchemaUpdate.execute (schemaupdate.java:101)
At Org.hibernate.internal.sessionfactoryimpl.<init> (sessionfactoryimpl.java:470)
At Org.hibernate.boot.internal.SessionFactoryBuilderImpl.build (sessionfactorybuilderimpl.java:444)
At Org.hibernate.cfg.Configuration.buildSessionFactory (configuration.java:708)
At Org.hibernate.cfg.Configuration.buildSessionFactory (configuration.java:724)
At Com.hibernate.tes.DayOne.test1 (dayone.java:15)
At Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method)
At Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:57)
At Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:43)
At Java.lang.reflect.Method.invoke (method.java:606)
At Org.junit.runners.model.frameworkmethod$1.runreflectivecall (frameworkmethod.java:44)
At Org.junit.internal.runners.model.ReflectiveCallable.run (reflectivecallable.java:15)
At org.junit.runners.model.FrameworkMethod.invokeExplosively (frameworkmethod.java:41)
At Org.junit.internal.runners.statements.InvokeMethod.evaluate (invokemethod.java:20)
At Org.junit.runners.BlockJUnit4ClassRunner.runChild (blockjunit4classrunner.java:76)
At Org.junit.runners.BlockJUnit4ClassRunner.runChild (blockjunit4classrunner.java:50)
At Org.junit.runners.parentrunner$3.run (parentrunner.java:193)
At Org.junit.runners.parentrunner$1.schedule (parentrunner.java:52)
At Org.junit.runners.ParentRunner.runChildren (parentrunner.java:191)
At org.junit.runners.parentrunner.access$000 (parentrunner.java:42)
At Org.junit.runners.parentrunner$2.evaluate (parentrunner.java:184)
At Org.junit.runners.ParentRunner.run (parentrunner.java:236)
At Org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (junit4testreference.java:86)
At Org.eclipse.jdt.internal.junit.runner.TestExecution.run (testexecution.java:38)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:459)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:675)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (remotetestrunner.java:382)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (remotetestrunner.java:192)
Caused by:java.sql.sqlexception:ora-02275: Such a reference constraint already exists in this table


At Oracle.jdbc.driver.DatabaseError.throwSqlException (databaseerror.java:112)
At Oracle.jdbc.driver.T4CTTIoer.processError (t4cttioer.java:331)
At Oracle.jdbc.driver.T4CTTIoer.processError (t4cttioer.java:288)
At Oracle.jdbc.driver.T4C8Oall.receive (t4c8oall.java:745)
At Oracle.jdbc.driver.T4CStatement.doOall8 (t4cstatement.java:210)
At Oracle.jdbc.driver.T4CStatement.executeForRows (t4cstatement.java:961)
At Oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout (oraclestatement.java:1190)
At Oracle.jdbc.driver.OracleStatement.executeUpdateInternal (oraclestatement.java:1657)
At Oracle.jdbc.driver.OracleStatement.executeUpdate (oraclestatement.java:1626)
At Com.mchange.v2.c3p0.impl.NewProxyStatement.executeUpdate (newproxystatement.java:208)
At Org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept (targetdatabaseimpl.java:56)
... More

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.