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.  [ 3 posts ] 
Author Message
 Post subject: One-To-Many relationship breaks on SaveOrUpdate sometimes..
PostPosted: Thu Feb 28, 2008 9:35 pm 
Newbie

Joined: Tue Jun 07, 2005 4:39 pm
Posts: 10
This has been driving me batty for 2 days. I have a class with a one-to-many child class. If I only set the parent for the child class, both save to the database. But if I set the parent for the child and then add the child to the parent's children, then I get this error: System.Data.OleDb.OleDbException: No value given for one or more required parameters.

The other thing that's really annoying about this is that I have another parent-child class relationship where both cases work just fine and I can't see any different in how the classes are structured, mapped, or the tables implemented in the db. Obviously something has to be different but I don't understand why one works and one doesn't.

This code works (sorry for the ugly class/variable names):

Code:
ProjectBudgetInputProgramArea pbipa = new ProjectBudgetInputProgramArea();
pbipa.ScheduleType = 27;
pbipa.ScheduleTitle = "Test Program Area " + now;               

ProjectBudgetInputProgramAreaElement pbipaElement = new ProjectBudgetInputProgramAreaElement();
pbipaElement.PlantingType = "Some Test Program Area Type " + now;
pbipaElement.CostPerTree = 1.9;
pbipaElement.NumberOfTrees = 150;
pbipaElement.CalculateAndSetTotal();
pbipaElement.ProgramArea = pbipa;
               

objects.Add(pbipaElement);
objects.Add(pbipa);

mgr.Store(objects);


But this doesn't:

Code:
ProjectBudgetInputProgramArea pbipa = new ProjectBudgetInputProgramArea();
pbipa.ScheduleType = 27;
pbipa.ScheduleTitle = "Test Program Area " + now;               

ProjectBudgetInputProgramAreaElement pbipaElement = new ProjectBudgetInputProgramAreaElement();
pbipaElement.PlantingType = "Some Test Program Area Type " + now;
pbipaElement.CostPerTree = 1.9;
pbipaElement.NumberOfTrees = 150;
pbipaElement.CalculateAndSetTotal();
pbipaElement.ProgramArea = pbipa;
               
pbipa.ProgramAreaElements.Add(pbipaElement);

objects.Add(pbipaElement);
objects.Add(pbipa);

mgr.Store(objects);


Hibernate version:

1.2.1

Mapping documents:

Parent:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="STS" assembly="STS">
  <class name="ProjectBudgetInputProgramArea" table="PROJECTBUDPROGAREA">
    <id name="Id" unsaved-value="0">
      <column name="id" sql-type="Int32" not-null="true" />
      <generator class="increment" />
    </id>
    <property name="ScheduleType" column="scheduleType" type="Int32" />
    <property name="ScheduleTitle" column="scheduleTitle" type="String" />
    <bag name="ProgramAreaElements" cascade="all" lazy="false" inverse="false">
      <key column="projectBudgetInputProgramAreaId" />
      <one-to-many class="ProjectBudgetInputProgramAreaElement" />
    </bag>
    <many-to-one name="ProjectBudgetInput" column="projectBudgetInputId" class="ProjectBudgetInput" cascade="none" />
  </class>
</hibernate-mapping>


Child:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="STS" assembly="STS">
  <class name="ProjectBudgetInputProgramAreaElement" table="PROJECTBUDPROGAREAEL">
    <id name="Id" unsaved-value="0">
      <column name="id" sql-type="Int32" not-null="true" />
      <generator class="increment" />
    </id>
    <property name="Species" column="species" type="String" />
    <property name="PlantingType" column="plantingType" type="String" />
    <property name="Floor" column="floor" type="Double" />
    <property name="Ceiling" column="ceiling" type="Double" />
    <property name="CostPerTree" column="costPerTree" type="Double" />
    <property name="NumberOfTrees" column="numberOfTrees" type="Int32" />
    <property name="Total" column="totalCost" type="Double" />
    <many-to-one name="ProgramArea" column="projProgId" class="ProjectBudgetInputProgramArea" cascade="none" />
  </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

The mgr variable is a class that calls this on the list of objects:

Code:
private void StoreIList(IList list)
        {
            log.Info("Storing list of " + list.Count + " objects");

            ISession session = NHibernateFactoryProvider.GetInstance().GetFactoryInstance().OpenSession();
            ITransaction transaction = session.BeginTransaction();

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] != null)
                {
                    session.SaveOrUpdate(list[i]);
                }
                else
                {
                    log.Warn("Object with index " + i + " in list was null; unable to store");
                }

                //log.Info("Successfully stored object with index=" + i + ", type=" + list[i].GetType().ToString());
            }

            transaction.Commit();
           
            session.Flush();
            session.Close();
        }


Full stack trace of any exception that occurs:

DEBUG 2008-02-28 16:29:03,403 8500ms ADOExceptionReporter LogExceptions - could not insert collection: [STS.ProjectBudgetInputProgramArea.ProgramAreaElements#1]
System.Data.OleDb.OleDbException: No value given for one or more required parameters.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at NHibernate.JetDriver.JetDbCommand.ExecuteNonQuery()
at NHibernate.Impl.NonBatchingBatcher.AddToBatch(IExpectation expectation)
at NHibernate.Persister.Collection.AbstractCollectionPersister.Recreate(IPersistentCollection collection, Object id, ISessionImplementor session)
WARN 2008-02-28 16:29:03,419 8515ms ADOExceptionReporter LogExceptions - System.Data.OleDb.OleDbException: No value given for one or more required parameters.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at NHibernate.JetDriver.JetDbCommand.ExecuteNonQuery()
at NHibernate.Impl.NonBatchingBatcher.AddToBatch(IExpectation expectation)
at NHibernate.Persister.Collection.AbstractCollectionPersister.Recreate(IPersistentCollection collection, Object id, ISessionImplementor session)
ERROR 2008-02-28 16:29:03,419 8515ms ADOExceptionReporter LogExceptions - No value given for one or more required parameters.
ERROR 2008-02-28 16:29:03,419 8515ms SessionImpl Execute - could not synchronize database state with session
NHibernate.ADOException: could not insert collection: [STS.ProjectBudgetInputProgramArea.ProgramAreaElements#1] ---> System.Data.OleDb.OleDbException: No value given for one or more required parameters.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at NHibernate.JetDriver.JetDbCommand.ExecuteNonQuery()
at NHibernate.Impl.NonBatchingBatcher.AddToBatch(IExpectation expectation)
at NHibernate.Persister.Collection.AbstractCollectionPersister.Recreate(IPersistentCollection collection, Object id, ISessionImplementor session)
--- End of inner exception stack trace ---
at NHibernate.Persister.Collection.AbstractCollectionPersister.Recreate(IPersistentCollection collection, Object id, ISessionImplementor session)
at NHibernate.Impl.ScheduledCollectionRecreate.Execute()
at NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
at NHibernate.Impl.SessionImpl.ExecuteAll(IList list)
at NHibernate.Impl.SessionImpl.Execute()
DEBUG 2008-02-28 16:29:03,419 8515ms ConnectionManager Execute - registering flush end
ERROR 2008-02-28 16:29:03,419 8515ms Logger Error - Error creating and storing test model objects
NHibernate.ADOException: could not insert collection: [STS.ProjectBudgetInputProgramArea.ProgramAreaElements#1] ---> System.Data.OleDb.OleDbException: No value given for one or more required parameters.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at NHibernate.JetDriver.JetDbCommand.ExecuteNonQuery()
at NHibernate.Impl.NonBatchingBatcher.AddToBatch(IExpectation expectation)
at NHibernate.Persister.Collection.AbstractCollectionPersister.Recreate(IPersistentCollection collection, Object id, ISessionImplementor session)
--- End of inner exception stack trace ---
at NHibernate.Persister.Collection.AbstractCollectionPersister.Recreate(IPersistentCollection collection, Object id, ISessionImplementor session)
at NHibernate.Impl.ScheduledCollectionRecreate.Execute()
at NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
at NHibernate.Impl.SessionImpl.ExecuteAll(IList list)
at NHibernate.Impl.SessionImpl.Execute()
at NHibernate.Impl.SessionImpl.Flush()
at NHibernate.Transaction.AdoTransaction.Commit()
at STS.Core.ModelManager.StoreIList(IList list) in C:\Documents and Settings\Dale.DEVINECO\My Documents\Visual Studio 2005\Projects\STS\STS\Core\ModelManager.cs:line 109
at STS.Core.ModelManager.Store(Object o) in C:\Documents and Settings\Dale.DEVINECO\My Documents\Visual Studio 2005\Projects\STS\STS\Core\ModelManager.cs:line 39
at STS.UserInterface.MainForm.testBudgetInputSavingToolStripMenuItem_Click(Object sender, EventArgs e) in C:\Documents and Settings\Dale.DEVINECO\My Documents\Visual Studio 2005\Projects\STS\STS\UserInterface\MainForm.cs:line 1021


Name and version of the database you are using:

MS Access 2003

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

INFO 2008-02-28 16:29:03,044 8140ms Logger Info - Storing list of 2 objects
DEBUG 2008-02-28 16:29:03,059 8156ms SessionImpl .ctor - opened session
DEBUG 2008-02-28 16:29:03,059 8156ms AdoTransaction Begin - begin
DEBUG 2008-02-28 16:29:03,059 8156ms iverConnectionProvider GetConnection - Obtaining IDbConnection from Driver
DEBUG 2008-02-28 16:29:03,138 8234ms Cascades IsUnsaved - unsaved-value: 0
DEBUG 2008-02-28 16:29:03,138 8234ms SessionImpl SaveOrUpdate - SaveOrUpdate() unsaved instance
DEBUG 2008-02-28 16:29:03,169 8265ms IncrementGenerator getNext - fetching initial value: select max(id) from PROJECTBUDPROGAREAEL
DEBUG 2008-02-28 16:29:03,169 8265ms iverConnectionProvider GetConnection - Obtaining IDbConnection from Driver
DEBUG 2008-02-28 16:29:03,200 8296ms IncrementGenerator getNext - first free id: 1
DEBUG 2008-02-28 16:29:03,200 8296ms ConnectionProvider CloseConnection - Closing connection
DEBUG 2008-02-28 16:29:03,200 8296ms SessionImpl eneratedIdentifier - generated identifier: 1
DEBUG 2008-02-28 16:29:03,200 8296ms SessionImpl DoSave - saving [STS.ProjectBudgetInputProgramAreaElement#1]
DEBUG 2008-02-28 16:29:03,231 8328ms Cascades IsUnsaved - unsaved-value: 0
DEBUG 2008-02-28 16:29:03,231 8328ms Cascades IsUnsaved - unsaved-value: 0
DEBUG 2008-02-28 16:29:03,231 8328ms SessionImpl SaveOrUpdate - SaveOrUpdate() unsaved instance
DEBUG 2008-02-28 16:29:03,231 8328ms IncrementGenerator getNext - fetching initial value: select max(id) from PROJECTBUDPROGAREA
DEBUG 2008-02-28 16:29:03,231 8328ms iverConnectionProvider GetConnection - Obtaining IDbConnection from Driver
DEBUG 2008-02-28 16:29:03,231 8328ms IncrementGenerator getNext - first free id: 1
DEBUG 2008-02-28 16:29:03,231 8328ms ConnectionProvider CloseConnection - Closing connection
DEBUG 2008-02-28 16:29:03,231 8328ms SessionImpl eneratedIdentifier - generated identifier: 1
DEBUG 2008-02-28 16:29:03,231 8328ms SessionImpl DoSave - saving [STS.ProjectBudgetInputProgramArea#1]
DEBUG 2008-02-28 16:29:03,231 8328ms Cascades Cascade - processing cascades for: STS.ProjectBudgetInputProgramArea
DEBUG 2008-02-28 16:29:03,231 8328ms Cascades Cascade - done processing cascades for: STS.ProjectBudgetInputProgramArea
DEBUG 2008-02-28 16:29:03,247 8343ms WrapVisitor rayOrNewCollection - Wrapped collection in role: STS.ProjectBudgetInputProgramArea.ProgramAreaElements
DEBUG 2008-02-28 16:29:03,247 8343ms Cascades Cascade - processing cascades for: STS.ProjectBudgetInputProgramArea
DEBUG 2008-02-28 16:29:03,247 8343ms Cascades CascadeCollection - cascading to collection: STS.ProjectBudgetInputProgramArea.ProgramAreaElements
DEBUG 2008-02-28 16:29:03,263 8359ms Cascades Cascade - cascading to SaveOrUpdate()
DEBUG 2008-02-28 16:29:03,263 8359ms SessionImpl SaveOrUpdate - SaveOrUpdate() persistent instance
DEBUG 2008-02-28 16:29:03,263 8359ms Cascades Cascade - done processing cascades for: STS.ProjectBudgetInputProgramArea
DEBUG 2008-02-28 16:29:03,263 8359ms AdoTransaction Commit - commit
DEBUG 2008-02-28 16:29:03,263 8359ms SessionImpl FlushEverything - flushing session
DEBUG 2008-02-28 16:29:03,263 8359ms Cascades Cascade - processing cascades for: STS.ProjectBudgetInputProgramArea
DEBUG 2008-02-28 16:29:03,263 8359ms Cascades CascadeCollection - cascading to collection: STS.ProjectBudgetInputProgramArea.ProgramAreaElements
DEBUG 2008-02-28 16:29:03,263 8359ms Cascades Cascade - cascading to SaveOrUpdate()
DEBUG 2008-02-28 16:29:03,263 8359ms SessionImpl SaveOrUpdate - SaveOrUpdate() persistent instance
DEBUG 2008-02-28 16:29:03,263 8359ms Cascades Cascade - done processing cascades for: STS.ProjectBudgetInputProgramArea
DEBUG 2008-02-28 16:29:03,278 8375ms SessionImpl FlushEntities - Flushing entities and processing referenced collections
DEBUG 2008-02-28 16:29:03,278 8375ms bstractEntityPersister LogDirtyProperties - STS.ProjectBudgetInputProgramAreaElement.ProgramArea is dirty
DEBUG 2008-02-28 16:29:03,278 8375ms SessionImpl FlushEntity - Updating entity: [STS.ProjectBudgetInputProgramAreaElement#1]
DEBUG 2008-02-28 16:29:03,294 8390ms AbstractVisitor ProcessCollection - Processing collection for role STS.ProjectBudgetInputProgramArea.ProgramAreaElements
DEBUG 2008-02-28 16:29:03,294 8390ms SessionImpl eachableCollection - Collection found: [STS.ProjectBudgetInputProgramArea.ProgramAreaElements#1], was: [<unreferenced>]
DEBUG 2008-02-28 16:29:03,294 8390ms SessionImpl FlushCollections - Processing unreferenced collections
DEBUG 2008-02-28 16:29:03,294 8390ms SessionImpl FlushCollections - scheduling collection removes/(re)creates/updates
DEBUG 2008-02-28 16:29:03,294 8390ms SessionImpl FlushEverything - Flushed: 2 insertions, 1 updates, 0 deletions to 2 objects
DEBUG 2008-02-28 16:29:03,294 8390ms SessionImpl FlushEverything - Flushed: 1 (re)creations, 0 updates, 0 removals to 1 collections
DEBUG 2008-02-28 16:29:03,294 8390ms Printer ToString - listing entities:
DEBUG 2008-02-28 16:29:03,309 8406ms Printer ToString - STS.ProjectBudgetInputProgramAreaElement{NumberOfTrees=150, Ceiling=0, Total=285, PlantingType=Some Test Program Area Type 4:29 PM, Species=null, Id=1, ProgramArea=ProjectBudgetInputProgramArea#1, CostPerTree=1.9, Floor=0}
DEBUG 2008-02-28 16:29:03,309 8406ms Printer ToString - STS.ProjectBudgetInputProgramArea{ProgramAreaElements=[ProjectBudgetInputProgramAreaElement#1], ProjectBudgetInput=null, ScheduleType=27, Id=1, ScheduleTitle=Test Program Area 4:29 PM}
DEBUG 2008-02-28 16:29:03,309 8406ms SessionImpl Execute - executing flush
DEBUG 2008-02-28 16:29:03,309 8406ms ConnectionManager Execute - registering flush begin
DEBUG 2008-02-28 16:29:03,309 8406ms bstractEntityPersister Insert - Inserting entity: [STS.ProjectBudgetInputProgramAreaElement#1]
DEBUG 2008-02-28 16:29:03,325 8421ms BatcherImpl penPreparedCommand - Opened new IDbCommand, open IDbCommands: 1
DEBUG 2008-02-28 16:29:03,325 8421ms BatcherImpl Generate - Building an IDbCommand object for the SqlString: INSERT INTO PROJECTBUDPROGAREAEL (species, plantingType, floor, ceiling, costPerTree, numberOfTrees, totalCost, projProgId, id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
DEBUG 2008-02-28 16:29:03,325 8421ms bstractEntityPersister Dehydrate - Dehydrating entity: [STS.ProjectBudgetInputProgramAreaElement#1]
DEBUG 2008-02-28 16:29:03,325 8421ms StringType NullSafeSet - binding null to parameter: 0
DEBUG 2008-02-28 16:29:03,325 8421ms StringType NullSafeSet - binding 'Some Test Program Area Type 4:29 PM' to parameter: 1
DEBUG 2008-02-28 16:29:03,325 8421ms DoubleType NullSafeSet - binding '0' to parameter: 2
DEBUG 2008-02-28 16:29:03,325 8421ms DoubleType NullSafeSet - binding '0' to parameter: 3
DEBUG 2008-02-28 16:29:03,325 8421ms DoubleType NullSafeSet - binding '1.9' to parameter: 4
DEBUG 2008-02-28 16:29:03,325 8421ms Int32Type NullSafeSet - binding '150' to parameter: 5
DEBUG 2008-02-28 16:29:03,325 8421ms DoubleType NullSafeSet - binding '285' to parameter: 6
DEBUG 2008-02-28 16:29:03,325 8421ms Int32Type NullSafeSet - binding null to parameter: 7
DEBUG 2008-02-28 16:29:03,325 8421ms Int32Type NullSafeSet - binding '1' to parameter: 8
DEBUG 2008-02-28 16:29:03,356 8453ms SQL LogCommand - INSERT INTO PROJECTBUDPROGAREAEL (species, plantingType, floor, ceiling, costPerTree, numberOfTrees, totalCost, projProgId, id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?); @p0 = '', @p1 = 'Some Test Program Area Type 4:29 PM', @p2 = '0', @p3 = '0', @p4 = '1.9', @p5 = '150', @p6 = '285', @p7 = '', @p8 = '1'
DEBUG 2008-02-28 16:29:03,356 8453ms bstractEntityPersister Insert - Inserting entity: [STS.ProjectBudgetInputProgramArea#1]
DEBUG 2008-02-28 16:29:03,372 8468ms BatcherImpl osePreparedCommand - Closed IDbCommand, open IDbCommands: 0
DEBUG 2008-02-28 16:29:03,372 8468ms BatcherImpl penPreparedCommand - Opened new IDbCommand, open IDbCommands: 1
DEBUG 2008-02-28 16:29:03,372 8468ms BatcherImpl Generate - Building an IDbCommand object for the SqlString: INSERT INTO PROJECTBUDPROGAREA (scheduleType, scheduleTitle, projectBudgetInputId, id) VALUES (?, ?, ?, ?)
DEBUG 2008-02-28 16:29:03,372 8468ms bstractEntityPersister Dehydrate - Dehydrating entity: [STS.ProjectBudgetInputProgramArea#1]
DEBUG 2008-02-28 16:29:03,372 8468ms Int32Type NullSafeSet - binding '27' to parameter: 0
DEBUG 2008-02-28 16:29:03,372 8468ms StringType NullSafeSet - binding 'Test Program Area 4:29 PM' to parameter: 1
DEBUG 2008-02-28 16:29:03,372 8468ms Int32Type NullSafeSet - binding null to parameter: 2
DEBUG 2008-02-28 16:29:03,372 8468ms Int32Type NullSafeSet - binding '1' to parameter: 3
DEBUG 2008-02-28 16:29:03,372 8468ms SQL LogCommand - INSERT INTO PROJECTBUDPROGAREA (scheduleType, scheduleTitle, projectBudgetInputId, id) VALUES (?, ?, ?, ?); @p0 = '27', @p1 = 'Test Program Area 4:29 PM', @p2 = '', @p3 = '1'
DEBUG 2008-02-28 16:29:03,372 8468ms BatcherImpl osePreparedCommand - Closed IDbCommand, open IDbCommands: 0
DEBUG 2008-02-28 16:29:03,388 8484ms bstractEntityPersister Update - Updating entity: [STS.ProjectBudgetInputProgramAreaElement#1]
DEBUG 2008-02-28 16:29:03,388 8484ms BatcherImpl penPreparedCommand - Opened new IDbCommand, open IDbCommands: 1
DEBUG 2008-02-28 16:29:03,388 8484ms BatcherImpl Generate - Building an IDbCommand object for the SqlString: UPDATE PROJECTBUDPROGAREAEL SET species = ?, plantingType = ?, floor = ?, ceiling = ?, costPerTree = ?, numberOfTrees = ?, totalCost = ?, projProgId = ? WHERE id = ?
DEBUG 2008-02-28 16:29:03,388 8484ms bstractEntityPersister Dehydrate - Dehydrating entity: [STS.ProjectBudgetInputProgramAreaElement#1]
DEBUG 2008-02-28 16:29:03,388 8484ms StringType NullSafeSet - binding null to parameter: 0
DEBUG 2008-02-28 16:29:03,388 8484ms StringType NullSafeSet - binding 'Some Test Program Area Type 4:29 PM' to parameter: 1
DEBUG 2008-02-28 16:29:03,388 8484ms DoubleType NullSafeSet - binding '0' to parameter: 2
DEBUG 2008-02-28 16:29:03,388 8484ms DoubleType NullSafeSet - binding '0' to parameter: 3
DEBUG 2008-02-28 16:29:03,388 8484ms DoubleType NullSafeSet - binding '1.9' to parameter: 4
DEBUG 2008-02-28 16:29:03,388 8484ms Int32Type NullSafeSet - binding '150' to parameter: 5
DEBUG 2008-02-28 16:29:03,388 8484ms DoubleType NullSafeSet - binding '285' to parameter: 6
DEBUG 2008-02-28 16:29:03,388 8484ms Int32Type NullSafeSet - binding '1' to parameter: 7
DEBUG 2008-02-28 16:29:03,388 8484ms Int32Type NullSafeSet - binding '1' to parameter: 8
DEBUG 2008-02-28 16:29:03,388 8484ms SQL LogCommand - UPDATE PROJECTBUDPROGAREAEL SET species = ?, plantingType = ?, floor = ?, ceiling = ?, costPerTree = ?, numberOfTrees = ?, totalCost = ?, projProgId = ? WHERE id = ?; @p0 = '', @p1 = 'Some Test Program Area Type 4:29 PM', @p2 = '0', @p3 = '0', @p4 = '1.9', @p5 = '150', @p6 = '285', @p7 = '1', @p8 = '1'
DEBUG 2008-02-28 16:29:03,388 8484ms BatcherImpl osePreparedCommand - Closed IDbCommand, open IDbCommands: 0
DEBUG 2008-02-28 16:29:03,403 8500ms ICollectionPersister Recreate - Inserting collection: [STS.ProjectBudgetInputProgramArea.ProgramAreaElements#1]
DEBUG 2008-02-28 16:29:03,403 8500ms BatcherImpl penPreparedCommand - Opened new IDbCommand, open IDbCommands: 1
DEBUG 2008-02-28 16:29:03,403 8500ms BatcherImpl Generate - Building an IDbCommand object for the SqlString: UPDATE PROJECTBUDPROGAREAEL SET projectBudgetInputProgramAreaId = ? WHERE id = ?
DEBUG 2008-02-28 16:29:03,403 8500ms Int32Type NullSafeSet - binding '1' to parameter: 0
DEBUG 2008-02-28 16:29:03,403 8500ms Int32Type NullSafeSet - binding '1' to parameter: 1
DEBUG 2008-02-28 16:29:03,403 8500ms SQL LogCommand - UPDATE PROJECTBUDPROGAREAEL SET projectBudgetInputProgramAreaId = ? WHERE id = ?; @p0 = '1', @p1 = '1'
DEBUG 2008-02-28 16:29:03,403 8500ms BatcherImpl osePreparedCommand - Closed IDbCommand, open IDbCommands: 0
DEBUG 2008-02-28 16:29:03,403 8500ms ADOExceptionReporter LogExceptions - could not insert collection: [STS.ProjectBudgetInputProgramArea.ProgramAreaElements#1]


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 01, 2008 9:55 am 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
I am not sure if this is your problem; when there is a bidirectional many-to-one, the non-inverse side must be the "one" side. Try changing the <bag> to 'inverse="true"'.

_________________
Karl Chu


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 11, 2008 7:11 pm 
Newbie

Joined: Tue Jun 07, 2005 4:39 pm
Posts: 10
karlchu wrote:
I am not sure if this is your problem; when there is a bidirectional many-to-one, the non-inverse side must be the "one" side. Try changing the <bag> to 'inverse="true"'.


Thanks! You were right about this (though you probably already knew that :) ).

Changing inverse to "true" didn't fix it right off the bat but it was also because I had the wrong key column name in the bag tag of the parent mapping xml (d'oh). But after fixing that and changing inverse to "true" it works just fine.


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

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.