-->
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.  [ 9 posts ] 
Author Message
 Post subject: What did I do wrong ? - [AssertionFailure]: null id in entry
PostPosted: Fri Apr 28, 2006 5:57 pm 
Newbie

Joined: Thu Apr 27, 2006 7:01 pm
Posts: 8
Hibernate version:
1.0.2

Mapping documents:
Code:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="RecEngineLib.Domain.RuleSets.RuleSetInvocation, RecEngineLib" table="RuleSetInvocation" >
      <id name="ID"  column="RuleSetInvocationID" unsaved-value="0">
         <generator class="identity" />
      </id>
      <property name="RuleSetName" />
      <property name="RuleSetVersion" />
      <property name="Timestamp" column="CreateDate"/>

      <set name="Facts">
         <key column="RuleSetInvocationID"/>
         <one-to-many class="RecEngineLib.Domain.RuleSets.RecEngineFact, RecEngineLib"/>
      </set>
   </class>
</hibernate-mapping>



Code:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="RecEngineLib.Domain.RuleSets.RecEngineFact, RecEngineLib" table="EngineFact" >
      <id name="ID"  column="EngineFactID" unsaved-value="0">
         <generator class="identity" />
      </id>
      <discriminator column="Type"/>
      
      <property name="Label" />
      <property name="Name" />
      
      <primitive-array name="Values" table="EngineFactValue">
         <key column="EngineFactID"/>
         <index column="EngineFactValueID"/>
         <element column="value" type="String(255)" />
      </primitive-array>
      
   </class>
</hibernate-mapping>


Code :
Code:
using System;
using System.Collections.Generic;
using NHibernate.Generics;

namespace RecEngineLib.Domain.RuleSets
{
    public class RuleSetInvocation : DomainObject<int>
    {
        #region Private Members
        private string m_ruleSetName;
        private int m_ruleSetVersion;
        private DateTime m_timestamp = new DateTime();

        // NHibernate.Generics members must be named in the following format:  _camelCase
        private IList<RecEngineFact> _facts = new EntityList<RecEngineFact>();
        #endregion

        #region Properties
        public string RuleSetName
        {
            get { return m_ruleSetName; }
            set { m_ruleSetName = value; }
        }
        public int RuleSetVersion
        {
            get { return m_ruleSetVersion; }
            set { m_ruleSetVersion = value; }
        }
        public IList<RecEngineFact> Facts
        {
            get { return _facts; }
        }
        public DateTime Timestamp
        {
            get { return m_timestamp; }
            set { m_timestamp = value; }
        }

        #endregion

        #region Constructors
        public RuleSetInvocation() { }
        public RuleSetInvocation(IRuleSet p_ruleSet, RecEngineFact[] p_facts)
        {
            this.m_ruleSetName = p_ruleSet.Name;
            this.m_ruleSetVersion = p_ruleSet.Version;
            foreach (RecEngineFact l_fact in p_facts)
                this._facts.Add(l_fact);
        }
        #endregion

    }

}


Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using org.nxbre.ie;
using org.nxbre.ie.rule;
using org.nxbre.ie.predicates;

namespace RecEngineLib.Domain.RuleSets
{
    [Serializable]
    public class RecEngineFact
    {
        private string m_relationName, m_label;
        private string[] m_values;
        private int m_id;

        public RecEngineFact()
        {
        }

        public RecEngineFact(string p_label, string p_relationName, string[] p_value)
        {
            this.m_label = p_label;
            this.m_relationName = p_relationName;
            this.m_values = p_value;
        }

        public string Name
        {
            get { return m_relationName; }
            set { m_relationName = value; }
        }

        public int ID
        {
            get { return m_id; }
            set { m_id = value; }
        }

        public string Label
        {
            get { return m_label; }
            set { m_label = value; }
        }

        public string[] Values
        {
            get { return m_values; }
            set { m_values = value; }
        }

        public Fact ToNxBREFact()
        {
            IPredicate[] l_predicates = new Individual[this.m_values.Length];
            for (int i = 0; i < this.m_values.Length; i++)
            {
                float l_valueAsNumber;
                if (float.TryParse(this.m_values[i], out l_valueAsNumber))
                {
                    l_predicates[i] = new Individual(l_valueAsNumber);
                }
                else
                {
                    l_predicates[i] = new Individual(this.m_values[i]);
                }
            }
            return new Fact(this.Label, this.Name, l_predicates);
        }

        public static RecEngineFact FromNxBREFact(Fact p_fact)
        {
            string[] l_values = new string[p_fact.PredicateValues.Length];
            for (int i = 0; i < p_fact.PredicateValues.Length; i++)
                l_values[i] = p_fact.PredicateValues[i].ToString();
            return new RecEngineFact(p_fact.Label, p_fact.Type, l_values);
        }

        public override string ToString()
        {
            string l_result = "";
           
            if (this.Label != null && !this.Label.Equals(""))
                l_result += this.Label + ": ";

            l_result += this.Name;
            l_result += "(";
            bool l_first = true;
            foreach (string l_value in this.Values)
            {
                if (l_first)
                    l_first = false;
                else
                    l_result += ",";
                l_result += l_value;
            }
            l_result += ")";
            return l_result;
        }

        public override bool Equals(object obj)
        {
            if (obj == null)
                return false;
            if (!(obj is RecEngineFact))
                return false;
            RecEngineFact l_fact = (RecEngineFact)obj;
            if (!l_fact.Name.Equals(this.Name))
                return false;
            if (l_fact.Values.Length != this.Values.Length)
                return false;
            for (int i = 0; i < this.Values.Length; i++)
            {
                string l_value1 = this.Values[i], l_value2 = l_fact.Values[i];

                double l_numValue1, l_numValue2;
                if (double.TryParse(l_value1, out l_numValue1) && double.TryParse(l_value2, out l_numValue2))
                {
                    // Try to compare them as numbers if they are both valid numbers.
                    if (l_numValue1 != l_numValue2)
                        return false;
                }
                else
                {
                    // Otherwise just compare them as strings.
                    if (!this.Values[i].Equals(l_fact.Values[i]))
                        return false;
                }
            }
            return true;
        }
    }
}


Full stack trace of any exception that occurs:
Code:
[AssertionFailure]: null id in entry (don't flush the Session after an exception
occurs)
   at NHibernate.Impl.SessionImpl.CheckId(Object obj, IClassPersister persister,
Object id)
   at NHibernate.Impl.SessionImpl.FlushEntity(Object obj, EntityEntry entry)
   at NHibernate.Impl.SessionImpl.FlushEntities()
   at NHibernate.Impl.SessionImpl.FlushEverything()
   at NHibernate.Impl.SessionImpl.Flush()
   at NHibernate.Transaction.AdoTransaction.Commit()
   at RecEngineLib.DataImpl.NHibernateSessionManager.CommitTransaction() in C:\R
ecEngineDotNet\RecEngineLib\DataImpl\NHibernateSessionManager.cs:line 148
   at NHibernateSessionModule.CommitAndCloseSession(Object sender, EventArgs e)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplicati
on.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& compl
etedSynchronously)
-->
--.
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClie
ntMessage message, WebResponse response, Stream responseStream, Boolean asyncCal
l)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodN
ame, Object[] parameters)
   at RecEngineTest.RecEngineServer.CIQRecEngineService.ApplyRules(String p_rule
SetName, Int32 p_ruleSetVersion, RecEngineFact[] p_facts) in C:\RecEngineDotNet\
recenginetest\Web References\RecEngineServer\Reference.cs:line 108
   at RecEngineTest.Program.Main(String[] args) in C:\RecEngineDotNet\recenginet
est\Program.cs:line 40


Name and version of the database you are using:
SQL Server 2000 SP4

Table Schema:

Code:
CREATE TABLE RuleSetInvocation(
   RuleSetInvocationID INT IDENTITY(1,1) NOT NULL,
   RuleSetName VARCHAR(255) NOT NULL,
   RuleSetVersion INT NOT NULL,
   CreateDate DATETIME NOT NULL)
go

CREATE TABLE EngineFact(
   EngineFactID INT IDENTITY(1,1) NOT NULL,
   RuleSetInvocationID INT NOT NULL,
   Type   INT NOT NULL,
   Label VARCHAR(255) NOT NULL,
   Name VARCHAR(255) NOT NULL)

CREATE TABLE EngineFactValue(
   EngineFactValueID INT  NOT NULL,
   EngineFactID INT NOT NULL,
   Value   VARCHAR(255) NOT NULL)


Debug level Hibernate log excerpt:
Code:
14:57:01.132 [3608] DEBUG NHibernate.Transaction.AdoTransaction - commit
14:57:01.132 [3608] DEBUG NHibernate.Impl.SessionImpl - flushing session
14:57:01.132 [3608] DEBUG NHibernate.Impl.SessionImpl - Flushing entities and processing referenced collections
14:57:01.132 [3608] ERROR NHibernate.AssertionFailure - An AssertionFailure occured - this may indicate a bug in NHibernate
NHibernate.AssertionFailure: null id in entry (don't flush the Session after an exception occurs)
14:57:01.132 [3608] DEBUG NHibernate.Impl.SessionImpl - closing session
14:57:01.132 [3608] DEBUG NHibernate.Impl.SessionImpl - disconnecting session
14:57:01.148 [3608] DEBUG NHibernate.Connection.ConnectionProvider - Closing connection



So I am not sure what is going on, newbie here... I've been struggling for a few days on my first Nhibernate project

Last point, I have a "Type" for descriminator that I don't use yet,
it will be to have 2x _facts (InputFacts and OutputFact) but I don't know yet how to do this.
Thanks!

Christian


Top
 Profile  
 
 Post subject: Adding the DEBUG Log
PostPosted: Fri Apr 28, 2006 6:32 pm 
Newbie

Joined: Thu Apr 27, 2006 7:01 pm
Posts: 8
Code:
5:32:46.986 [3564] DEBUG NHibernate.Impl.SessionImpl - saving [RecEngineLib.Domain.RuleSets.RuleSetInvocation#<null>]
15:32:46.986 [3564] DEBUG NHibernate.Impl.SessionImpl - executing insertions
15:32:47.002 [3564] DEBUG NHibernate.Util.ADOExceptionReporter - Could not save object
System.InvalidCastException: Unable to cast object of type 'NHibernate.Generics.EntityList`1[RecEngineLib.Domain.RuleSets.RecEngineFact]' to type 'Iesi.Collections.ISet'.
   at NHibernate.Type.SetType.Wrap(ISessionImplementor session, Object collection)
   at NHibernate.Impl.WrapVisitor.ProcessArrayOrNewCollection(Object collection, PersistentCollectionType collectionType)
   at NHibernate.Impl.WrapVisitor.ProcessCollection(Object collection, PersistentCollectionType collectionType)
   at NHibernate.Impl.AbstractVisitor.ProcessValue(Object value, IType type)
   at NHibernate.Impl.WrapVisitor.ProcessValues(Object[] values, IType[] types)
   at NHibernate.Impl.SessionImpl.DoSave(Object theObj, Key key, IClassPersister persister, Boolean replicate, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
   at NHibernate.Impl.SessionImpl.DoSave(Object obj, Object id, IClassPersister persister, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
   at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything)
15:32:47.017 [3564] WARN  NHibernate.Util.ADOExceptionReporter - System.InvalidCastException: Unable to cast object of type 'NHibernate.Generics.EntityList`1[RecEngineLib.Domain.RuleSets.RecEngineFact]' to type 'Iesi.Collections.ISet'.
   at NHibernate.Type.SetType.Wrap(ISessionImplementor session, Object collection)
   at NHibernate.Impl.WrapVisitor.ProcessArrayOrNewCollection(Object collection, PersistentCollectionType collectionType)
   at NHibernate.Impl.WrapVisitor.ProcessCollection(Object collection, PersistentCollectionType collectionType)
   at NHibernate.Impl.AbstractVisitor.ProcessValue(Object value, IType type)
   at NHibernate.Impl.WrapVisitor.ProcessValues(Object[] values, IType[] types)
   at NHibernate.Impl.SessionImpl.DoSave(Object theObj, Key key, IClassPersister persister, Boolean replicate, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
   at NHibernate.Impl.SessionImpl.DoSave(Object obj, Object id, IClassPersister persister, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
   at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything)
15:32:47.017 [3564] ERROR NHibernate.Util.ADOExceptionReporter - Unable to cast object of type 'NHibernate.Generics.EntityList`1[RecEngineLib.Domain.RuleSets.RecEngineFact]' to type 'Iesi.Collections.ISet'.
15:32:47.142 [3564] DEBUG NHibernate.Transaction.AdoTransaction - commit
15:32:47.142 [3564] DEBUG NHibernate.Impl.SessionImpl - flushing session
15:32:47.142 [3564] DEBUG NHibernate.Impl.SessionImpl - Flushing entities and processing referenced collections
15:32:47.142 [3564] ERROR NHibernate.AssertionFailure - An AssertionFailure occured - this may indicate a bug in NHibernate
NHibernate.AssertionFailure: null id in entry (don't flush the Session after an exception occurs)
15:32:47.142 [3564] DEBUG NHibernate.Impl.SessionImpl - closing session
15:32:47.142 [3564] DEBUG NHibernate.Impl.SessionImpl - disconnecting session
15:32:47.142 [3564] DEBUG NHibernate.Connection.ConnectionProvider - Closing connection


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 29, 2006 7:32 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Looks like you're misusing NHibernate.Generics, maybe Ayende will be able to help you with that, if he sees this message. You're probably using IList and mapping it as <set> or something like that.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 29, 2006 12:28 pm 
Newbie

Joined: Thu Apr 27, 2006 7:01 pm
Posts: 8
sergey wrote:
Looks like you're misusing NHibernate.Generics, maybe Ayende will be able to help you with that, if he sees this message. You're probably using IList and mapping it as <set> or something like that.


Yes I am using IList and mapping to a Set, Shouldn't I ?
If not, which collection should I use ? Map, set, bag idbag ?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 29, 2006 2:55 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
ILists can only be mapped as <list>, <bag> or <idbag>.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 01, 2006 11:21 am 
Newbie

Joined: Thu Apr 27, 2006 7:01 pm
Posts: 8
thanks, let me try that.
Christian


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 01, 2006 6:28 pm 
Newbie

Joined: Thu Apr 27, 2006 7:01 pm
Posts: 8
crenninger wrote:
thanks, let me try that.
Christian


Still not sucessful, does anyone has some sample on how to map a set ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 8:53 am 
Beginner
Beginner

Joined: Thu Oct 20, 2005 9:26 am
Posts: 27
Location: Barcelona
I got the same problem now.
Did you find a solution?

It's definately not the mapping, since I haven't changed that for a while, and it's been working fine until now.
Besides that, the site is running on my local machine fine, but this error came on my hosting provider.

/David


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 11:09 am 
Newbie

Joined: Thu Apr 27, 2006 7:01 pm
Posts: 8
yes it has been solved , has far as I remember, it was a problem with the mapping where I had forgotten to define a parent/child relationship.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.