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.  [ 7 posts ] 
Author Message
 Post subject: abstract="true" in mapping?
PostPosted: Fri Oct 03, 2008 6:03 am 
Newbie

Joined: Fri Oct 03, 2008 5:55 am
Posts: 3
Location: Groningen, The Netherlands
Hi,

Does anyone know what is wrong with this mapping as NHibernate is complaining about invalid XML because the "abstract" attribute is not definded/declared:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="HPPTCMS.LOGIC.Classes.Article, HPPTCMS.LOGIC" table="HPPTCMS_Article" lazy="true" abstract="true">

    <id name="ID" column="id" type="Int64">
      <generator class="native" />
    </id>

    <discriminator column="articlediscriminatorid" type="String"/>

    <subclass name="HPPTCMS.LOGIC.Classes.ProjectItem, HPPTCMS.LOGIC" discriminator-value="20">
    </subclass>
    <subclass name="HPPTCMS.LOGIC.Classes.BlogItem, HPPTCMS.LOGIC" discriminator-value="30">
    </subclass>

etc etc.


  </class>
</hibernate-mapping>




Thanks!
Bouwe


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 03, 2008 6:53 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Which version do you use ? I think that attribute was introduced with NH 2.0.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 03, 2008 8:00 am 
Newbie

Joined: Fri Oct 03, 2008 5:55 am
Posts: 3
Location: Groningen, The Netherlands
Oops, yes that would make sense... :)

I used 1.2 and now upgraded to 2.0, which causes some other problems, which I will post on a new subject... :|

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 03, 2008 9:16 am 
Newbie

Joined: Fri Oct 03, 2008 5:55 am
Posts: 3
Location: Groningen, The Netherlands
After upgrading to NHibernate 2.0 and fixing some issues, I'm getting an SystemOutOfRangeException because System.Collections.ListDictionaryInternal is empty and it propably wants to find something in this list?

I don't what this ListDictionaryInternal is and what is wrong with my mapping file... :(

I assume it still has something to do with the fact i want to use an abstract class with subclasses and a dsicriminator.

This is my mapping file:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="HPPTCMS.LOGIC.Classes.Article, HPPTCMS.LOGIC" table="HPPTCMS_Article" lazy="true" abstract="true">

    <id name="ID" column="id" type="Int64">
      <generator class="native" />
    </id>

    <discriminator column="articlediscriminatorid" type="String"/>

    <property name="Title" column="title" type="String" length="255"/>

    <subclass name="HPPTCMS.LOGIC.Classes.ProjectItem, HPPTCMS.LOGIC" discriminator-value="20">
      <property name="Excerpt" column="excerpt" type="String" length="255"/>
    </subclass>
    <subclass name="HPPTCMS.LOGIC.Classes.BlogItem, HPPTCMS.LOGIC" discriminator-value="30">
      <property name="Body" column="body" type="String" length="255"/>
    </subclass>

  </class>
</hibernate-mapping>


This is the stack trace:

Code:
   bij System.Collections.ArrayList.get_Item(Int32 index)
   bij NHibernate.SqlCommand.InFragment.ToFragmentString()
   bij NHibernate.Persister.Entity.SingleTableEntityPersister.DiscriminatorFilterFragment(String alias)
   bij NHibernate.Persister.Entity.SingleTableEntityPersister.FilterFragment(String alias)
   bij NHibernate.Persister.Entity.AbstractEntityPersister.FilterFragment(String alias, IDictionary`2 enabledFilters)
   bij NHibernate.Loader.Entity.EntityJoinWalker..ctor(IOuterJoinLoadable persister, String[] uniqueKey, Int32 batchSize, LockMode lockMode, ISessionFactoryImplementor factory, IDictionary`2 enabledFilters)
   bij NHibernate.Loader.Entity.EntityLoader..ctor(IOuterJoinLoadable persister, String[] uniqueKey, IType uniqueKeyType, Int32 batchSize, LockMode lockMode, ISessionFactoryImplementor factory, IDictionary`2 enabledFilters)
   bij NHibernate.Loader.Entity.EntityLoader..ctor(IOuterJoinLoadable persister, Int32 batchSize, LockMode lockMode, ISessionFactoryImplementor factory, IDictionary`2 enabledFilters)
   bij NHibernate.Loader.Entity.EntityLoader..ctor(IOuterJoinLoadable persister, LockMode lockMode, ISessionFactoryImplementor factory, IDictionary`2 enabledFilters)
   bij NHibernate.Loader.Entity.BatchingEntityLoader.CreateBatchingEntityLoader(IOuterJoinLoadable persister, Int32 maxBatchSize, LockMode lockMode, ISessionFactoryImplementor factory, IDictionary`2 enabledFilters)
   bij NHibernate.Persister.Entity.AbstractEntityPersister.CreateEntityLoader(LockMode lockMode, IDictionary`2 enabledFilters)
   bij NHibernate.Persister.Entity.AbstractEntityPersister.CreateEntityLoader(LockMode lockMode)
   bij NHibernate.Persister.Entity.AbstractEntityPersister.CreateLoaders()
   bij NHibernate.Persister.Entity.AbstractEntityPersister.PostInstantiate()
   bij NHibernate.Persister.Entity.SingleTableEntityPersister.PostInstantiate()
   bij NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)
   bij NHibernate.Cfg.Configuration.BuildSessionFactory()
   bij HPPTCMS.DATA.DAO.NHibernateSessionManager.InitSessionFactory() in C:\Mijn Projecten\HPPTCMS\HPPTCMSPortals\HPPTCMS\HPPTCMS.DATA\DAO\NHibernateSessionManager.cs:regel 53
   bij HPPTCMS.DATA.DAO.NHibernateSessionManager..ctor() in C:\Mijn Projecten\HPPTCMS\HPPTCMSPortals\HPPTCMS\HPPTCMS.DATA\DAO\NHibernateSessionManager.cs:regel 36
   bij HPPTCMS.DATA.DAO.NHibernateSessionManager.Nested..cctor() in C:\Mijn Projecten\HPPTCMS\HPPTCMSPortals\HPPTCMS\HPPTCMS.DATA\DAO\NHibernateSessionManager.cs:regel 45


Top
 Profile  
 
 Post subject: Having The Same problem
PostPosted: Tue Dec 30, 2008 4:57 pm 
Newbie

Joined: Tue Dec 30, 2008 4:53 pm
Posts: 2
I'am having the same problem with nhibernate v 2.0.1.4000
here is my mapping file

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                   assembly="FGalaxy" namespace="FGalaxy">
  <class name="SectorObject" table="SectorObject" discriminator-value="0">
    <id name="ID" column="ObjectId">
      <generator class="guid"/>
    </id>
    <discriminator column="ObjectType" type="System.Int32"/>
    <property name="Name"/>
    <property name="Speed"/>
    <component name="Coords">
      <component name="Galactic">
        <property name="gX" column="glX"/>
        <property name="gY" column="glY"/>
        <property name="gZ" column="glZ"/>
      </component>
    </component>
    <component name="dCoords">
      <component name="Galactic">
        <property name="gX" column="dglX"/>
        <property name="gY" column="dglY"/>
        <property name="gZ" column="dglZ"/>
      </component>
    </component>
    <component name="SystemID">
      <property name="ID" column="SystemId"/>
    </component>
    <subclass name="SystemObject" extends="SectorObject" discriminator-value="1">
      <subclass name="SystemBodyObject" extends="SystemObject" discriminator-value="2">
        <property name="SystemBodyID" column="SystemBodyId"/>
      </subclass>
    </subclass>
  </class>
</hibernate-mapping>


And I'am Getting this exception....
Code:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.Collections.ArrayList.get_Item(Int32 index)
   at NHibernate.SqlCommand.InFragment.ToFragmentString()
   at NHibernate.Persister.Entity.SingleTableEntityPersister.DiscriminatorFilter
Fragment(String alias)
   at NHibernate.Persister.Entity.SingleTableEntityPersister.FilterFragment(Stri
ng alias)
   at NHibernate.Persister.Entity.AbstractEntityPersister.FilterFragment(String
alias, IDictionary`2 enabledFilters)
(...)


Need help!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 31, 2008 3:15 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
When do you get the exception ? Can you post the code ?

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 02, 2009 10:21 am 
Newbie

Joined: Tue Dec 30, 2008 4:53 pm
Posts: 2
Well i solved the problem. It isn't a real problem but its a bug or a miss feature ^^.

I was trying to migrate some old code to nHibernate in this project and the 2 subclasses SystemObject And SystemBodyObject where abstract classes...

I've change my code so the classes aren't abstract anymore and everything is ok now.

The problem is that nHibernate should log and report the problem with the config file.

I've changed other things in the project while trying to make it work so i will make a "test case" for this in the weekend and post it to Jira since i've opened a bug report there.

Thanks

Pedro


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