-->
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: invalid index X for this sqlparametercollection with count X
PostPosted: Tue Jul 26, 2011 5:41 pm 
Newbie

Joined: Tue Jul 26, 2011 5:22 pm
Posts: 2
I know this is probably asked all the time, but this is more of "I can't see it".
Me and another developer have sat down and tried to figure out why this one particular enum value causes this issue. With the enum i get this error, without it it succeeds.

I am using fluent nhibernate for my mappings and conventions.
I supplied all relevant information regarding this issue.

Code:
    public class Listing : Entity
    {
        public virtual bool Active { get; set; }
        public virtual bool Archived { get; set; }
        public virtual bool AutoAccept { get; set; }
        public virtual bool Completed { get; set; }
        public virtual bool Deleted { get; set; }
        public virtual bool DeliveryInside { get; set; }
        public virtual bool MatchComplete { get; set; }
        public virtual bool PickupInside { get; set; }
        public virtual DateTime? AuctionEndDate { get; set; }
        public virtual DateTime? DateCreated { get; set; }
        public virtual DateTime? DateUpdated { get; set; }
        public virtual DateTime? ExpiresOn { get; set; }
        public virtual DateTime? TimeframeEarliestDelivery { get; set; }
        public virtual DateTime? TimeframeEarliestPickup { get; set; }
        public virtual DateTime? TimeframeLatestDelivery { get; set; }
        public virtual DateTime? TimeframeLatestPickup { get; set; }
        public virtual decimal Mileage { get; set; }
        public virtual decimal TotalWeight { get; set; }
        public virtual int AffiliateID { get; set; }
        public virtual int BidTypeID { get; set; }
        public virtual int CategoryID { get; set; }
        public virtual int Commodity2ID { get; set; }
        public virtual int ControlVersion { get; set; }
        public virtual int GeneratedId { get; set; }
        public virtual int ListingDuration { get; set; }
        public virtual int OriginalPackageTypeID { get; set; }
        public virtual int PackageTypeID { get; set; }
        public virtual int PackageVersion { get; set; }
        public virtual int SubcategoryID { get; set; }
        public virtual int Views { get; set; }
        public virtual int PickupAddressTypeID { get; set; }
        public virtual int DropoffAddressTypeID { get; set; }
        public virtual string AuctionBuyerID { get; set; }
        public virtual string AuctionImageURL { get; set; }
        public virtual string AuctionItemID { get; set; }
        public virtual string CurrentStatus { get; set; }
        public virtual string Description { get; set; }
        public virtual string image1FileName { get; set; }
        public virtual string PreviousStatus { get; set; }
        public virtual string RecipientName { get; set; }
        public virtual string RecipientPhone1 { get; set; }
        public virtual string SenderName { get; set; }
        public virtual string SenderPhone1 { get; set; }
        public virtual string Title { get; set; }

        public virtual TimeFrameType DeliveryTimeFrameTypeId { get; set; } // This causes the error

        public virtual IList<ListingQuestion> Questions { get; protected set; }

        public virtual bool IsBrokered()
        {
            return false;
        }

        public virtual ListingQuestion GetRootQuestion(int questionID)
        {
            return null;
        }

        public virtual IEnumerable<ListingQuestion> GetQuestionThread(int questionID)
        {
            return null;
        }
       
        public virtual IEnumerable<ListingQuestion> GetUnansweredQuestions()
        {
            return null;
        }
    }


Code:
    public class ListingOverride : IAutoMappingOverride<Listing>
    {
        public void Override(AutoMapping<Listing> mapping)
        {
            mapping.Id(x => x.Id, "PackageID");
            mapping.Map(x => x.Completed, "MatchComplete");
            mapping.Map(x => x.ExpiresOn, "ExpirationDate");
        }
    }


Code:
    public class EnumConvention : IUserTypeConvention
    {
        public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
        {
            criteria.Expect(p => p.Property.PropertyType.IsEnum);
        }

        public void Apply(IPropertyInstance instance)
        {
            instance.CustomType(instance.Property.PropertyType);
        }
    }


Code:
    public class ListingQuestion : Entity
    {
        #region Built-in types
        public virtual bool AnswerReported { get; set; }
        public virtual bool HideQuestion { get; set; }
        public virtual bool QuestionReported { get; set; }
        public virtual DateTime? AnsweredOn { get; set; }
        public virtual DateTime? AskedOn { get; set; }
        public virtual int ParentQuestionID { get; set; }
        public virtual int QuestionFlagStatus { get; set; }
        public virtual int UserID { get; set; }
        public virtual string Answer { get; set; }
        public virtual string Question { get; set; }
        #endregion

        #region Entity types
        public virtual Listing Listing { get; set; }
        #endregion
    }


Code:
    public class ListingQuestionOverride : IAutoMappingOverride<ListingQuestion>
    {
        public void Override(AutoMapping<ListingQuestion> mapping)
        {
            mapping.Id(x => x.Id).Column("QuestionID");
            mapping.Map(x => x.AnsweredOn).Column("DateAnswered");
            mapping.Map(x => x.AskedOn).Column("DateCreated");
            mapping.Map(x => x.HideQuestion).Column("QuestionHide");

            mapping.References(x => x.Listing).Column("PackageID");
        }
    }


Code:
        public IList<ListingQuestion> GetListingQuestions(int userID)
        {
            return Transact<IList<ListingQuestion>>(() =>
                session.QueryOver<ListingQuestion>()
                .Where(q => q.AnsweredOn == null)
                .And(q => q.UserID == 266795)
                .JoinQueryOver<Listing>(q => q.Listing)
                //.Where(l => l.Lister.Id == userID && !l.Completed && !l.Archived)
                //.And(l => l.Active && !l.Deleted && l.ExpiresOn > DateTime.Now)
                .List());
        }


Code:
        protected virtual TResult Transact<TResult>(Func<TResult> func)
        {
            if (!session.Transaction.IsActive)
            {
                TResult result;
                using (var trans = session.BeginTransaction())
                {
                    result = func.Invoke();
                    trans.Commit(); // This is where the error happens.
                }
                return result;
            }
            return func.Invoke();
        }


Top
 Profile  
 
 Post subject: Re: invalid index X for this sqlparametercollection with count X
PostPosted: Mon Aug 01, 2011 4:33 pm 
Newbie

Joined: Tue Jul 26, 2011 5:22 pm
Posts: 2
For anyone who finds this, this is what happens when you either have mapped something more than once, or you have NULLABLE database types being set to NOT NULLABLE types.

Who knows what else this error is thrown for.


Top
 Profile  
 
 Post subject: Re: invalid index X for this sqlparametercollection with count X
PostPosted: Tue Aug 02, 2011 8:02 am 
Newbie

Joined: Tue Aug 02, 2011 7:54 am
Posts: 1
workout - workout plan - workout routines

_________________
workout routines - workout - workout plan


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.