-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Insert includes column twice for nested obj w/ composite key
PostPosted: Tue May 29, 2007 6:06 pm 
Newbie

Joined: Fri Feb 02, 2007 8:12 pm
Posts: 3
Location: St. Louis, Missouri, USA
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.