I'm using hibernate3, with Oracle 10G and am getting a duplicate column error on insert. I'm at a loss as to what I'm doing wrong. Any help would be greatly appreciated.
I have two objects with a one-to-many relationship - A notification filter can have many filter rules. My mapping files are:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="com.worldchain.platform.dataobject.NotificationFilter"
table="t_evt_notification_filter"
lazy="false"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
>
<id
name="id"
column="notification_filter_seq"
type="long"
unsaved-value="0"
>
<generator class="sequence">
<param name="sequence">S_EVT_NOTIFICATION_FILTER</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-NotificationFilter.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<many-to-one
name="eventType"
class="com.worldchain.platform.dataobject.EventType"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="EVENT_TYPE_SEQ"
not-null="true"
/>
<property
name="description"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="description"
length="220"
/>
<property
name="endEffectiveDate"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="END_EFFECT_DT"
/>
<property
name="name"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="name"
length="30"
/>
<property
name="beginEffectiveDate"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="BEG_EFFECT_DT"
/>
<set
name="notificationFilterPersons"
lazy="false"
inverse="false"
cascade="none"
sort="unsorted"
>
<key
column="notification_filter_seq"
>
</key>
<one-to-many
class="com.worldchain.platform.dataobject.NotificationFilterPerson"
/>
</set>
<set
name="notificationDeliveryMethods"
lazy="false"
inverse="false"
cascade="none"
sort="unsorted"
>
<key
column="notification_filter_seq"
>
</key>
<one-to-many
class="com.worldchain.platform.dataobject.NotificationDeliveryMethod"
/>
</set>
<set
name="notificationFilterRoles"
lazy="false"
inverse="false"
cascade="none"
sort="unsorted"
>
<key
column="notification_filter_seq"
>
</key>
<one-to-many
class="com.worldchain.platform.dataobject.NotificationFilterRole"
/>
</set>
<set
name="filterRules"
lazy="false"
inverse="false"
cascade="none"
sort="unsorted"
>
<key
column="notification_filter_seq"
>
</key>
<one-to-many
class="com.worldchain.platform.dataobject.FilterRule"
/>
</set>
<property
name="createdBy"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="CREATED_BY"
length="15"
not-null="true"
/>
<property
name="createdDate"
type="java.sql.Timestamp"
update="true"
insert="true"
access="property"
column="CREATED_DT"
not-null="true"
/>
<property
name="updatedBy"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="UPDATED_BY"
length="15"
not-null="true"
/>
<property
name="updatedDate"
type="java.sql.Timestamp"
update="true"
insert="true"
access="property"
column="UPDATED_DT"
not-null="true"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-NotificationFilter.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
and
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="com.worldchain.platform.dataobject.FilterRule"
table="t_evt_filter_rule"
lazy="false"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
>
<id
name="id"
column="notification_filter_seq"
type="long"
unsaved-value="0"
>
<generator class="sequence">
<param name="sequence">s_evt_filter_rule</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-FilterRule.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="or"
type="boolean"
update="true"
insert="true"
access="property"
column="OR_FLG"
not-null="true"
/>
<property
name="regex"
type="boolean"
update="true"
insert="true"
access="property"
column="REGEX_FLG"
not-null="true"
/>
<property
name="ruleLine"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="rule_line"
length="20"
not-null="true"
/>
<property
name="ruleOperator"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="rule_operator"
length="20"
/>
<many-to-one
name="ruleType"
class="com.worldchain.platform.dataobject.RuleType"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="RULE_TYPE_SEQ"
not-null="true"
/>
<many-to-one
name="notificationFilter"
class="com.worldchain.platform.dataobject.NotificationFilter"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="NOTIFICATION_FILTER_SEQ"
not-null="true"
/>
<property
name="createdBy"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="CREATED_BY"
length="15"
not-null="true"
/>
<property
name="createdDate"
type="java.sql.Timestamp"
update="true"
insert="true"
access="property"
column="CREATED_DT"
not-null="true"
/>
<property
name="updatedBy"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="UPDATED_BY"
length="15"
not-null="true"
/>
<property
name="updatedDate"
type="java.sql.Timestamp"
update="true"
insert="true"
access="property"
column="UPDATED_DT"
not-null="true"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-FilterRule.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
I am creating a new filter rule with the following code:
Code:
FilterRule filterRule = new FilterRule();
filterRule.setNotificationFilter(notificationFilter); filterRule.setOr(false);
filterRule.setRegex(false);
filterRule.setRuleLine("0");
filterRule.setRuleOperator("=");
filterRule.setRuleType(disabledRuleType);
filterRule.setRuleValue("DISABLED");
save(filterRule);
The generated SQL (showsql=yes) is:
Code:
Hibernate: select s_evt_filter_rule.nextval from dual
Hibernate: insert into t_evt_filter_rule (OR_FLG, REGEX_FLG, rule_line, rule_operator, RULE_TYPE_SEQ, NOTIFICATION_FILTER_SEQ, CREATED_BY, CREATED_DT, UPDATED_BY, UPDATED_DT, notification_filter_seq) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
- SQL Error: 957, SQLState: 42000
- ORA-00957: duplicate column name
Stack trace is:
Code:
- Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:155)
at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.impl.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:255)
at org.hibernate.event.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:814)
at com.worldchain.core.orm.hibernate.dao.ObjectDAO.save(ObjectDAO.java:636)
at com.worldchain.platform.dao.impl.NotificationFilterDAO.disable(NotificationFilterDAO.java:341)
at com.worldchain.platform.dao.impl.PlatformDAOImpl.disableNotificationFilter(PlatformDAOImpl.java:977)
at com.worldchain.core.dao.DaoTest.testNotifications(DaoTest.java:234)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at org.jmock.core.VerifyingTestCase.runBare(Unknown Source)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: java.sql.BatchUpdateException: ORA-00957: duplicate column name
at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:459)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:4133)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:53)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:148)
... 24 more