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.  [ 2 posts ] 
Author Message
 Post subject: Simple JoinedSubClass Error
PostPosted: Thu Feb 14, 2008 11:38 am 
Beginner
Beginner

Joined: Sun Aug 12, 2007 11:22 am
Posts: 44
Location: Sweden
I can't get the JoinedSubClass mapping to work. This is what I got so far.

Code:
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using NHibernate.Mapping.Attributes;

namespace Hairless.Entities.Presentation
{
    [Class(Table = "Presentations")]
    public abstract class Presentation
    {
        private int id;

        [Id(Name = "Id", Column = "PresentationId")]
        [Generator(1, Class = "identity")]
        public virtual int Id
        {
            get { return id; }
            set { id = value; }
        }

    }
}


Code:
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using NHibernate.Mapping.Attributes;

namespace Hairless.Entities.Presentation
{
    //[Class( Table = "BrandPresentation" )]
    [JoinedSubclass( Table = "BrandPresentation" , NameType = typeof(BrandPresentation), ExtendsType = typeof(Presentation))]
    public class BrandPresentation : Presentation
    {
        private String promotionImage;

        [Property]
        public String PromotionImage
        {
            get { return promotionImage; }
            set { promotionImage = value; }
        }


       
       

    }
}


Error

Code:
System.TypeInitializationException: The type initializer for 'Hairless.Persistence.PersistenceHelper' threw an exception. ---> NHibernate.MappingException: (29,6): XML validation error: The element 'joined-subclass' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'property' in namespace 'urn:nhibernate-mapping-2.2'. List of possible elements expected: 'urn:nhibernate-mapping-2.2:meta urn:nhibernate-mapping-2.2:key'. ---> System.Xml.Schema.XmlSchemaValidationException: The element 'joined-subclass' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'property' in namespace 'urn:nhibernate-mapping-2.2'. List of possible elements expected: 'urn:nhibernate-mapping-2.2:meta urn:nhibernate-mapping-2.2:key'.
   --- End of inner exception stack trace ---
   at NHibernate.Cfg.Configuration.LogAndThrow(MappingException me)
   at NHibernate.Cfg.Configuration.ValidationHandler(Object o, ValidationEventArgs args)
   at System.Xml.Schema.XmlSchemaValidator.SendValidationEvent(ValidationEventHandler eventHandler, Object sender, XmlSchemaValidationException e, XmlSeverityType severity)
   at System.Xml.Schema.XmlSchemaValidator.ElementValidationError(XmlQualifiedName name, ValidationState context, ValidationEventHandler eventHandler, Object sender, String sourceUri, Int32 lineNo, Int32 linePos, Boolean getParticles)
   at System.Xml.Schema.XsdValidator.ValidateChildElement()
   at System.Xml.Schema.XsdValidator.ValidateElement()
   at System.Xml.Schema.XsdValidator.Validate()
   at System.Xml.XmlValidatingReaderImpl.ProcessCoreReaderEvent()
   at System.Xml.XmlValidatingReaderImpl.Read()
   at System.Xml.XmlValidatingReader.Read()
   at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
   at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at NHibernate.Cfg.Configuration.LoadMappingDocument(XmlTextReader hbmReader, String name)
   at NHibernate.Cfg.Configuration.AddXmlReader(XmlTextReader hbmReader, String name)
   at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name)
   at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream)
   at Hairless.Persistence.PersistenceHelper..cctor() in D:\Boardstore\Hairless\Hairless\Persistence\PersistenceHelper.cs:line 33
   --- End of inner exception stack trace ---
   at Hairless.Persistence.PersistenceHelper.GetCurrentSession()
   at Hairless.Service1.HelloWorld() in D:\Boardstore\Hairless\Hairless\Service1.asmx.cs:line 47


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 15, 2008 2:08 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
I'm not too experienced with <joined-subclass> or NHMA, but it would seem that JoinedSubclass attribute would have to have a property for defining the key column of the subclass table. It appears that leaving that null is causing NHMA to define an invalid mapping XML (without <key> being the first element after <joined-subclass>). Check the attribute definition for such a property.


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