The issue is that I get a unique key constraint thrown on a non unique column, the column is indexed but is not unique, this error is driving me up the wall. In my debuging I droped that specific index, it then just crashed on another one, and when I drop all indecies it works, but as soon as I recreate one it starts all over, any ideas out there.
Hibernate version:
Hibernate 2.1.6
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="com.bayt.hibernate.mapping.cv">
<class name="BytCvIndex" table="byt_cv_index" >
<id
column="CV_ID"
name="Id"
type="long">
<generator class="assigned"/>
</id>
<property
column="DATE_INDEXED"
length="14"
name="DateIndexed"
not-null="false"
type="timestamp"
/>
<property
column="CV_SKILL_PRINT"
length="255"
name="CvSkillPrint"
not-null="false"
type="string"
/>
<property
column="EDU_ISO_TXT"
length="255"
name="EduIsoTxt"
not-null="false"
type="string"
/>
<!-- please tell Joe Hudson that the type 'enum' could not be resolved.. defaulting to java.lang.String -->
<property
column="EMP_STATUS"
length="2"
name="EmpStatus"
not-null="false"
type="java.lang.String"
/>
<property
column="OBJECTIVE_TXT"
name="ObjectiveTxt"
not-null="false"
type="string"
/>
<!-- please tell Joe Hudson that the type 'enum' could not be resolved.. defaulting to java.lang.String -->
<property
column="MARITAL_STATUS"
length="2"
name="MaritalStatus"
not-null="false"
type="java.lang.String"
/>
<property
column="CV_STAGE"
length="1"
name="CvStage"
not-null="true"
type="int"
/>
<property
column="AGE"
length="6"
name="Age"
not-null="false"
type="int"
/>
<!-- please tell Joe Hudson that the type 'set' could not be resolved.. defaulting to java.lang.String -->
<property
column="LANG_SET"
length="40"
name="LangSet"
not-null="false"
type="java.lang.String"
/>
<property
column="EXP_ISO_TXT"
length="255"
name="ExpIsoTxt"
not-null="false"
type="string"
/>
<property
column="NATIONAL_ISO_TXT"
length="255"
name="NationalIsoTxt"
not-null="false"
type="string"
/>
<property
column="EXP_TITLE"
name="ExpTitle"
not-null="false"
type="string"
/>
<!-- please tell Joe Hudson that the type 'enum' could not be resolved.. defaulting to java.lang.String -->
<property
column="LOCALE"
length="3"
name="Locale"
not-null="false"
type="java.lang.String"
/>
<property
column="AFFILIATE_ID"
name="AffiliateId"
not-null="true"
type="int"
/>
<property
column="EDU_DEGREE"
name="EduDegree"
not-null="false"
type="int"
/>
<property
column="RES_LOC_ISO"
length="2"
name="ResLocIso"
not-null="false"
type="string"
/>
<property
column="EXP_EMP"
name="ExpEmp"
not-null="false"
type="string"
/>
<property
column="GENERIC_TXT"
name="GenericTxt"
not-null="false"
type="string"
/>
<property
column="EDU_TXT"
name="EduTxt"
not-null="false"
type="string"
/>
<!-- please tell Joe Hudson that the type 'enum' could not be resolved.. defaulting to java.lang.String -->
<property
column="EMP_TYPE"
length="2"
name="EmpType"
not-null="false"
type="java.lang.String"
/>
<property
column="SALARY_RANGE"
name="SalaryRange"
not-null="false"
type="int"
/>
<property
column="CV_TITLE"
length="255"
name="CvTitle"
not-null="false"
type="string"
/>
<property
column="EXP_DESC"
name="ExpDesc"
not-null="false"
type="string"
/>
<property
column="RES_LOC_ISO_PR_LC"
length="6"
name="ResLocIsoPrLc"
not-null="false"
type="string"
/>
<property
column="NOTICE_PERIOD"
length="6"
name="NoticePeriod"
not-null="false"
type="java.lang.Integer"
/>
<property
column="JB_LOC_TXT"
length="255"
name="JbLocTxt"
not-null="false"
type="string"
/>
<property
column="EXP_YEARS"
length="6"
name="ExpYears"
not-null="false"
type="long"
/>
<!-- please tell Joe Hudson that the type 'enum' could not be resolved.. defaulting to java.lang.String -->
<property
column="GENDER"
length="2"
name="Gender"
not-null="false"
type="java.lang.String"
/>
<property
column="SKILL_TXT"
name="SkillTxt"
not-null="false"
type="string"
/>
<property
column="JB_CAT_TXT"
length="255"
name="JbCatTxt"
not-null="false"
type="string"
/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
ERROR - Duplicate key or integrity constraint violation message from server: "Duplicate entry '0' for key 2"
ERROR - could not insert: [com.bayt.hibernate.mapping.cv.BytCvIndex#1069359]
java.sql.SQLException: Duplicate key or integrity constraint violation message from server: "Duplicate entry '0' for key 2"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2247)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1772)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1619)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:98)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
at com.bayt.hibernate.BaytController.runIndex(BaytController.java:499)
at com.bayt.scheduler.IndexProxy.execute(IndexProxy.java:83)
at org.quartz.core.JobRunShell.run(JobRunShell.java:191)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:516)
ERROR - Could not synchronize database state with session
net.sf.hibernate.JDBCException: could not insert: [com.bayt.hibernate.mapping.cv.BytCvIndex#1069359]
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:478)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
at com.bayt.hibernate.BaytController.runIndex(BaytController.java:499)
at com.bayt.scheduler.IndexProxy.execute(IndexProxy.java:83)
at org.quartz.core.JobRunShell.run(JobRunShell.java:191)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:516)
Caused by: java.sql.SQLException: Duplicate key or integrity constraint violation message from server: "Duplicate entry '0' for key 2"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2247)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1772)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1619)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:98)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)
... 9 more
Name and version of the database you are using:
MySQL 4.1.11 on Sparc Solaris 8
The generated SQL (show_sql=true):
nothing special
Debug level Hibernate log excerpt:
|