I have a mapped object that has two properties, Contract (of type Contract) and Season (of type ContractSeason). ContractSeason is mapped with a composite primary key of 3 assigned elements: CNTRT_ID, SEASON_NBR, and VERS_NBR. Since CNTRT_ID is both the primary key of "Contract", and 1/3rd of the PK of "Season", it includes the column twice when I insert my object that has both of these properties.
Is there a better way to do this mapping? Is this something that isn't possible, and I'll need to remodel the database schema? Any input is appreciated.
Please note that I'm an application developer and was not part of creating this data model. Composite, assigned keys? That would only come out of my mouth when explaining what NOT to do. :(
Hibernate version: 1.2.0.3002
Mapping documents:
Code:
<many-to-one name="Contract" column="CNTRT_ID" />
<many-to-one name="Season">
<column name="CNTRT_ID" />
<column name="SEASON_NBR" />
<column name="VERS_NBR" />
</many-to-one>
Full stack trace of any exception that occurs:Code:
[OracleException (0x80131938): ORA-00957: duplicate column name
]
System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle errorHandle, Int32 rc) +167
System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciRowidDescriptor& rowidDescriptor, ArrayList& resultParameterOrdinals) +1719
System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean needRowid, OciRowidDescriptor& rowidDescriptor) +503
System.Data.OracleClient.OracleCommand.ExecuteNonQuery() +125
NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd) +50
NHibernate.Impl.NonBatchingBatcher.AddToBatch(IExpectation expectation) +50
NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session) +669
[ADOException: could not insert: [OurCompanyFramework.LSSS.Domain.ContractElement#17][SQL: INSERT INTO IMR.LSSS_CNTRT_ELEM (VERS_NBR, CNTRT_ID, CNTRT_ID, SEASON_NBR, VERS_NBR, FCLTY_ID, TEAM_ID, LAST_UPDATE_USERID, LAST_UPDATED_TIMESTAMP, CNTRT_ELEM_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]]
NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session) +850
NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Object obj, ISessionImplementor session) +302
NHibernate.Impl.ScheduledInsertion.Execute() +105
NHibernate.Impl.SessionImpl.Execute(IExecutable executable) +169
NHibernate.Impl.SessionImpl.ExecuteAll(IList list) +124
NHibernate.Impl.SessionImpl.Execute() +281
NHibernate.Impl.SessionImpl.Flush() +114
OurCompanyFramework.NHibernateUnitOfWorkAdapter.Flush() +44
OurCompanyFramework.Web.GlobalMediaWebApplication.GlobalMediaWebApplication_EndRequest(Object sender, EventArgs e) +75
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +167
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +117
Name and version of the database you are using: Oracle 10i