-->
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: AssertionFailure on simple joined-subclass
PostPosted: Thu Dec 29, 2005 12:15 pm 
Newbie

Joined: Tue Nov 01, 2005 6:32 pm
Posts: 16
Looks like I'm getting an AssertionFailure on a rather simple mapping. Before escalating this to JIRA or whatever, is there anything obvious I'm doing wrong?

Hibernate version: 1.0

Mapping documents:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="Abcdefg.Budget, Abcdefg.Library" table="customer_budget">
      
      <id name="Id" column="budget_id" unsaved-value="0">
         <generator class="identity"/>
      </id>
      
      <property name="Year" column="budget_year"/>
      
      <joined-subclass name="Abcdefg.CustomerBudget, Abcdefg.Library" table="customer_budget">
      
         <key column="budget_id"/>
         
         
         <many-to-one name="Customer" class="Abcdefg.Customer, Abcdefg.Labels" />
      
      </joined-subclass>
      
      
      
      <joined-subclass name="Abcdefg.MiscBudget, Abcdefg.Library" table="budget_misc">
      
         <key column="budget_id"/>
         
         <property column="Practice" name="Practice" type="String"/>
         <property column="Platform" name="Platform" type="String"/>
      
      </joined-subclass>
   </class>
</hibernate-mapping>


Full stack trace of any exception that occurs:
Code:
  at NHibernate.Mapping.Subclass.CreateForeignKey()
   at NHibernate.Cfg.Binder.BindJoinedSubclass(XmlNode node, Subclass model, Mappings mappings)
   at NHibernate.Cfg.Binder.PropertiesFromXML(XmlNode node, PersistentClass model, Mappings mappings)
   at NHibernate.Cfg.Binder.BindRootClass(XmlNode node, RootClass model, Mappings mappings)
   at NHibernate.Cfg.Binder.BindRoot(XmlDocument doc, Mappings model)
   at NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc)
   at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream)

Debug level Hibernate log excerpt:
Code:
2005-12-29 11:07:34,185 [6056] INFO  NHibernate.Cfg.Configuration - Found mapping documents in assembly: Budget.hbm.xml
2005-12-29 11:07:34,185 [6056] INFO  NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2000Dialect
2005-12-29 11:07:34,185 [6056] INFO  NHibernate.Cfg.Binder - Mapping class: Abcdefg.Budget -> customer_budget
2005-12-29 11:07:34,185 [6056] DEBUG NHibernate.Cfg.Binder - Mapped property: Id -> budget_id, type: Int32
2005-12-29 11:07:34,185 [6056] DEBUG NHibernate.Cfg.Binder - Mapped property: Year -> budget_year, type: Int32
2005-12-29 11:07:34,185 [6056] INFO  NHibernate.Cfg.Binder - Mapping joined-subclass: Abcdefg.CustomerBudget -> customer_budget
2005-12-29 11:07:34,185 [6056] ERROR NHibernate.AssertionFailure - An AssertionFailure occured - this may indicate a bug in NHibernate
NHibernate.AssertionFailure: Not a joined-subclass
2005-12-29 11:07:34,201 [6056] ERROR NHibernate.Cfg.Configuration - Could not configure datastore from input stream
NHibernate.AssertionFailure: Not a joined-subclass
   at NHibernate.Mapping.Subclass.CreateForeignKey()
   at NHibernate.Cfg.Binder.BindJoinedSubclass(XmlNode node, Subclass model, Mappings mappings)
   at NHibernate.Cfg.Binder.PropertiesFromXML(XmlNode node, PersistentClass model, Mappings mappings)
   at NHibernate.Cfg.Binder.BindRootClass(XmlNode node, RootClass model, Mappings mappings)
   at NHibernate.Cfg.Binder.BindRoot(XmlDocument doc, Mappings model)
   at NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc)
   at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 29, 2005 12:17 pm 
Newbie

Joined: Tue Nov 01, 2005 6:32 pm
Posts: 16
And here is an outline of the relevant entity classes....


Code:
public abstract class Budget
   {
      private int m_id;

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

   public class CustomerBudget : Budget
   {
      private Customer m_customer;

      public Customer ParentCustomer
      {
         get { return m_customer; }
         set { m_customer = value; }
      }
   }

   public class MiscBudget : Budget
   {
      private string m_platform;
      private string m_practice;

      public string Platform
      {
         get { return m_platform; }
         set { m_platform = value; }
      }

      public string Practice
      {
         get { return m_practice; }
         set { m_practice = value; }
      }
   }


Note that the abstract base class has no abstract members. Could this be the problem?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 29, 2005 12:30 pm 
Newbie

Joined: Tue Nov 01, 2005 6:32 pm
Posts: 16
Ok, stupid me. After looking at the source for NHibernate.Cfg.Binder and Nhibernate.Mapping.Subclass I discovered that the exception is thrown if Table = RootTable, and then I noticed that I had the wrong table name listed for my root class in the mapping file :)


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.