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: NHibernate 2.1.2GA Exception
PostPosted: Sat Mar 06, 2010 1:17 pm 
Newbie

Joined: Thu Mar 30, 2006 2:10 pm
Posts: 14
Hello,

I'm receiving the following exception with 2.1.2GA when saving my class:

Exception:
Code:
Invalid index 21 for this SqlParameterCollection with Count=21.


Class:
Code:
   [Class(NameType = typeof(Course), Table = "Course")]
   public class Course
   {
      #region Public Properties

      /// <summary>
      /// Gets the Id.
      /// </summary>
      [Id(0, Column = "CourseId", Name = "Id")]
         [Generator(1, Class = "guid")]
      public virtual Guid Id { get; internal set; }

      /// <summary>
      /// Gets and sets Department.
      /// </summary>
      [ManyToOne(Column = "DepartmentId", ClassType = typeof(Department), Cascade = "none")]
      public virtual IDepartment Department { get; set; }

      /// <summary>
      /// Gets and sets DepartmentId.
      /// </summary>
      public virtual Guid DepartmentId { get; set; }

      /// <summary>
      /// Gets and sets Name.
      /// </summary>
      [Property()]
      public virtual string Name { get; set; }

      /// <summary>
      /// Gets and sets Status.
      /// </summary>
      [Property()]
      public virtual string Status { get; set; }

      /// <summary>
      /// Gets and sets Description.
      /// </summary>
      [Property()]
      public virtual string Description { get; set; }

      /// <summary>
      /// Gets and sets Additional.
      /// </summary>
      [Property()]
      public virtual string Additional { get; set; }

      /// <summary>
      /// Gets and sets Days.
      /// </summary>
      [Property()]
      public virtual int Days { get; set; }
      
      /// <summary>
      /// Gets and sets CancellationDays.
      /// </summary>
      [Property()]
      public virtual int CancellationDays { get; set; }

      /// <summary>
      /// Gets and sets CapacityMaximum.
      /// </summary>
      [Property()]
      public virtual int CapacityMaximum { get; set; }

      /// <summary>
      /// Gets and sets CapacityMinimum.
      /// </summary>
      [Property()]
      public virtual int CapacityMinimum { get; set; }

      /// <summary>
      /// Gets and sets EffectiveMonths.
      /// </summary>
      [Property()]
      public virtual int EffectiveMonths { get; set; }

      /// <summary>
      /// Gets and sets MinimumDays.
      /// </summary>
      [Property()]
      public virtual int MinimumDays { get; set; }

      /// <summary>
      /// Gets and sets Cost.
      /// </summary>
      [Property()]
      public virtual decimal Cost { get; set; }

      /// <summary>
      /// Gets and sets CostCancellation.
      /// </summary>
      [Property()]
      public virtual decimal CostCancellation { get; set; }

      /// <summary>
      /// Gets and sets CostNoShow.
      /// </summary>
      [Property()]
      public virtual decimal CostNoShow { get; set; }

      /// <summary>
      /// Gets and sets IsMandatory.
      /// </summary>
      [Property()]
      public virtual bool IsMandatory { get; set; }

      /// <summary>
      /// Gets and sets IsMandatoryForHire.
      /// </summary>
      [Property()]
      public virtual bool IsMandatoryForHire { get; set; }

      /// <summary>
      /// Gets and sets IsRepeatable.
      /// </summary>
      [Property()]
      public virtual bool IsRepeatable { get; set; }

      /// <summary>
      /// Gets and sets IsRequireApproval.
      /// </summary>
      [Property()]
      public virtual bool IsRequireApproval { get; set; }

      /// <summary>
      /// Gets and sets IsSupervisorOnly.
      /// </summary>
      [Property()]
      public virtual bool IsSupervisorOnly { get; set; }

      #endregion  // Public Properties
   }


Here is what my log file says when updating the Course:
Code:
2010-03-06 12:05:52,328 [5] DEBUG NHibernate.Transaction.AdoTransaction [(null)] - Start Commit
2010-03-06 12:05:52,337 [5] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - flushing session
2010-03-06 12:05:52,339 [5] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - processing flush-time cascades
2010-03-06 12:05:52,349 [5] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - dirty checking collections
2010-03-06 12:05:52,353 [5] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - Flushing entities and processing referenced collections
2010-03-06 12:05:52,382 [5] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister [(null)] - Suite.Entity.Impl.Course.Name is dirty
2010-03-06 12:05:52,388 [5] DEBUG NHibernate.Event.Default.DefaultFlushEntityEventListener [(null)] - Updating entity: [Suite.Entity.Impl.Course#cb0465e2-89b4-4c25-b7b4-e994d0b391b6]
2010-03-06 12:05:52,406 [5] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - Processing unreferenced collections
2010-03-06 12:05:52,406 [5] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - Scheduling collection removes/(re)creates/updates
2010-03-06 12:05:52,407 [5] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects
2010-03-06 12:05:52,407 [5] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2010-03-06 12:05:52,409 [5] DEBUG NHibernate.Impl.Printer [(null)] - listing entities:
2010-03-06 12:05:52,420 [5] DEBUG NHibernate.Impl.Printer [(null)] - Suite.Entity.Impl.Course{'Id'='cb0465e2-89b4-4c25-b7b4-e994d0b391b6', 'DepartmentId'='47468e81-0a8e-448f-b602-de9c36b3ae91', 'Name'='Hello World', 'Status'='Active', 'Description'=null, 'Additional'=null, 'Days'='25', 'CancellationDays'='0', 'CapacityMaximum'='0', 'CapacityMinimum'='0', 'EffectiveMonths'='0', 'MinimumDays'='0', 'Cost'='0.0000', 'CostCancellation'='0.0000', 'CostNoShow'='0.0000', 'IsMandatory'='False', 'IsMandatoryForHire'='False', 'IsRepeatable'='False', 'IsRequireApproval'='False', 'IsSupervisorOnly'='False', 'Deleted'='False', 'Department'='Suite.Entity.Impl.Department#47468e81-0a8e-448f-b602-de9c36b3ae91'}
2010-03-06 12:05:52,422 [5] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - executing flush
2010-03-06 12:05:52,422 [5] DEBUG NHibernate.AdoNet.ConnectionManager [(null)] - registering flush begin
2010-03-06 12:05:52,452 [5] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister [(null)] - Updating entity: [Suite.Entity.Impl.Course#cb0465e2-89b4-4c25-b7b4-e994d0b391b6]
2010-03-06 12:05:52,455 [5] DEBUG NHibernate.AdoNet.AbstractBatcher [(null)] - Opened new IDbCommand, open IDbCommands: 1
2010-03-06 12:05:52,455 [5] DEBUG NHibernate.AdoNet.AbstractBatcher [(null)] - Building an IDbCommand object for the SqlString: UPDATE Course SET Name = ?, Status = ?, Description = ?, Additional = ?, Days = ?, CancellationDays = ?, CapacityMaximum = ?, CapacityMinimum = ?, EffectiveMonths = ?, MinimumDays = ?, Cost = ?, CostCancellation = ?, CostNoShow = ?, IsMandatory = ?, IsMandatoryForHire = ?, IsRepeatable = ?, IsRequireApproval = ?, IsSupervisorOnly = ?, Deleted = ?, DepartmentId = ? WHERE CourseId = ?
2010-03-06 12:05:52,457 [5] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister [(null)] - Dehydrating entity: [Suite.Entity.Impl.Course#cb0465e2-89b4-4c25-b7b4-e994d0b391b6]
2010-03-06 12:05:52,457 [5] DEBUG NHibernate.Type.GuidType [(null)] - binding '47468e81-0a8e-448f-b602-de9c36b3ae91' to parameter: 0
2010-03-06 12:05:52,458 [5] DEBUG NHibernate.Type.StringType [(null)] - binding 'Hello World' to parameter: 1
2010-03-06 12:05:52,458 [5] DEBUG NHibernate.Type.StringType [(null)] - binding 'Active' to parameter: 2
2010-03-06 12:05:52,458 [5] DEBUG NHibernate.Type.StringType [(null)] - binding null to parameter: 3
2010-03-06 12:05:52,459 [5] DEBUG NHibernate.Type.StringType [(null)] - binding null to parameter: 4
2010-03-06 12:05:52,459 [5] DEBUG NHibernate.Type.Int32Type [(null)] - binding '25' to parameter: 5
2010-03-06 12:05:52,459 [5] DEBUG NHibernate.Type.Int32Type [(null)] - binding '0' to parameter: 6
2010-03-06 12:05:52,459 [5] DEBUG NHibernate.Type.Int32Type [(null)] - binding '0' to parameter: 7
2010-03-06 12:05:52,459 [5] DEBUG NHibernate.Type.Int32Type [(null)] - binding '0' to parameter: 8
2010-03-06 12:05:52,459 [5] DEBUG NHibernate.Type.Int32Type [(null)] - binding '0' to parameter: 9
2010-03-06 12:05:52,459 [5] DEBUG NHibernate.Type.Int32Type [(null)] - binding '0' to parameter: 10
2010-03-06 12:05:52,459 [5] DEBUG NHibernate.Type.DecimalType [(null)] - binding '0.0000' to parameter: 11
2010-03-06 12:05:52,459 [5] DEBUG NHibernate.Type.DecimalType [(null)] - binding '0.0000' to parameter: 12
2010-03-06 12:05:52,460 [5] DEBUG NHibernate.Type.DecimalType [(null)] - binding '0.0000' to parameter: 13
2010-03-06 12:05:52,460 [5] DEBUG NHibernate.Type.BooleanType [(null)] - binding 'False' to parameter: 14
2010-03-06 12:05:52,460 [5] DEBUG NHibernate.Type.BooleanType [(null)] - binding 'False' to parameter: 15
2010-03-06 12:05:52,460 [5] DEBUG NHibernate.Type.BooleanType [(null)] - binding 'False' to parameter: 16
2010-03-06 12:05:52,460 [5] DEBUG NHibernate.Type.BooleanType [(null)] - binding 'False' to parameter: 17
2010-03-06 12:05:52,460 [5] DEBUG NHibernate.Type.BooleanType [(null)] - binding 'False' to parameter: 18
2010-03-06 12:05:52,460 [5] DEBUG NHibernate.Type.BooleanType [(null)] - binding 'False' to parameter: 19
2010-03-06 12:05:52,465 [5] DEBUG NHibernate.Type.GuidType [(null)] - binding '47468e81-0a8e-448f-b602-de9c36b3ae91' to parameter: 20
2010-03-06 12:05:52,465 [5] DEBUG NHibernate.Type.GuidType [(null)] - binding 'cb0465e2-89b4-4c25-b7b4-e994d0b391b6' to parameter: 21
2010-03-06 12:05:52,468 [5] DEBUG NHibernate.AdoNet.AbstractBatcher [(null)] - Closed IDbCommand, open IDbCommands: 0
2010-03-06 12:05:52,468 [5] DEBUG NHibernate.AdoNet.ConnectionManager [(null)] - registering flush end
2010-03-06 12:05:52,470 [5] DEBUG NHibernate.Transaction.AdoTransaction [(null)] - Rollback
2010-03-06 12:05:52,470 [5] DEBUG NHibernate.Transaction.AdoTransaction [(null)] - IDbTransaction RolledBack
2010-03-06 12:05:52,470 [5] DEBUG NHibernate.Transaction.AdoTransaction [(null)] - IDbTransaction disposed.


I would like to use the DepartmentId field so I don't need to load the Department object all the time.

Suggestions?

Cheers,
Timothy Grant Vogelsang


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.