-->
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: Discriminator error
PostPosted: Sun Oct 09, 2005 1:52 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
I'm got the following mapping:

Code:
<?xml version="1.0" encoding="utf-16"?>
<hibernate-mapping xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate-mapping-2.0">
  <class name="Model.Rule, Model" table="Rules" discriminator-value="0"   >
    <id name="Id" access="nosetter.camelcase-underscore" column="RuleId" type="Int32"  unsaved-value="0">
      <generator class="native">
      </generator>
    </id>
    <discriminator column="RuleTypeId" type="String" />
    <property name="Severity" access="property" column="Severity"         />
    <property name="EndDate" access="property" column="EndDate" type="System.DateTime"        />
    <property name="StartDate" access="property" column="StartDate" type="System.DateTime"        />
    <any name="Entity" access="property" id-type="Int32" meta-type="Int32"     >
      <meta-value value="1" class="Model.Board, Model" />
      <column name="RuleEntityType" />
      <column name="RuleEntityId" />
    </any>
    <subclass name="Model.Rules.EmployeeRule, Model"  discriminator-value="-1">
      <property name="_employeeId" access="field" column="RuleParameter1" type="Int32"        />
      <subclass name="Model.Rules.EmployeeSeperation, Model"  discriminator-value="2">
        <property name="_secondWorkerId" access="field" column="RuleParameter2" type="Int32"        />
      </subclass>
    </subclass>
    <subclass name="Model.NumberOfShifts, Model"  discriminator-value="1">
      <property name="Period" access="property" column="RuleParameter1Type"         />
      <property name="ShiftsNumber" access="property" column="RuleParameter1" type="Int32"        />
    </subclass>
  </class>
</hibernate-mapping>


I'm getting this error:

Quote:
TestCase 'Tests.EmployeeScheduleTest.LoadRules' failed: NHibernate.MappingException : Error parsing discriminator value: '2'
----> System.ArgumentException : Item has already been added. Key in dictionary: '2' Key being added: '2'
at NHibernate.Persister.EntityPersister..ctor(PersistentClass model, ISessionFactoryImplementor factory)
at NHibernate.Persister.PersisterFactory.CreateClassPersister(PersistentClass model, ISessionFactoryImplementor factory)
at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, Settings settings)
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at Castle.ActiveRecord.Framework.SessionFactoryHolder.GetSessionFactory(Type type)
at Castle.ActiveRecord.Framework.SessionFactoryHolder.CreateSession(Type type)
at Castle.ActiveRecord.ActiveRecordBase.Save(Object instance)
at Castle.ActiveRecord.ActiveRecordBase.Save()
E:\ssc\Tests\EmployeeScheduleTest.cs(70,0): at Tests.EmployeeScheduleTest.LoadRules()
--MappingException
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at System.Collections.Hashtable.Add(Object key, Object value)
at NHibernate.Persister.EntityPersister..ctor(PersistentClass model, ISessionFactoryImplementor factory)


I've only one 2 as a discriminator. What is going on?


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.