-->
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: Generic Mapping Class in Component Element With Alpha
PostPosted: Sun Sep 24, 2006 9:09 pm 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
Does the alpha Nhibernate support using generics on components? for example, say I have class Range that will implemented as Range<DateTime>


Code:
    public class Range<T> : IRange<T> where T : IComparable<T>
    {
        private readonly T start;
        private readonly T end;

        public Range(T start, T end)
        {
            if (start.CompareTo(end) <= 0)
            {
                this.start = start;
                this.end = end;
            }
            else
            {
                this.start = end;
                this.end = start;
            }
        }

        public T Start
        {
            get { return this.start; }
        }

        public T End
        {
            get { return this.end; }
        }

...


Now my mapping in the class for the component is
Code:
    <component name="PayrollPeriod" class="Cei.eMerge.Common.Range`1[System.DateTime], Cei.eMerge.Common" >
      <property name="Start" access="field.camelcase" column="StartDate"  />
      <property name="End" access="field.camelcase" column="EndDate"/>
    </component>


I am getting the following error from the mapping configuration when i write my sql
Code:
Write Ddl script? (Y/N)  y
Working...

Failed!
EXCEPTION:NHibernate.MappingException
-------------------------------------------------------------------------
MESSAGE:Value cannot be null.
Parameter name: con
-------------------------------------------------------------------------
STACK TRACE:   at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream)
   at NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly, Boolean skipOrdering)
   at NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly)
   at NHibernate.Cfg.Configuration.AddAssembly(String assemblyName)
   at Cei.eMerge.Data.NHibernateSessionManager.GetConfiguration() in C:\Documents and Settings\mnichols\My Documents\Visual Studio 2005\Projects\eMerge\src\app\Cei.eMerge.Data\NHibernate\NHibernateSes
sionManager.cs:line 82
   at Cei.eMerge.Data.NHibernateSessionManager.get_Configuration() in C:\Documents and Settings\mnichols\My Documents\Visual Studio 2005\Projects\eMerge\src\app\Cei.eMerge.Data\NHibernate\NHibernateSe
ssionManager.cs:line 53
   at TestConsole.Program.WriteDdlScript() in C:\Documents and Settings\mnichols\My Documents\Visual Studio 2005\Projects\eMerge\src\app\Cei.eMerge.NHibernateUtil\Program.cs:line 55
   at TestConsole.Program.Main(String[] args) in C:\Documents and Settings\mnichols\My Documents\Visual Studio 2005\Projects\eMerge\src\app\Cei.eMerge.NHibernateUtil\Program.cs:line 24
-------------------------------------------------------------------------



that exception doesn't give me much to go on...am I mapping a generic class correctly? I only find one example for mapping a class in the .Tests

Thanks in advance

_________________
If this helped...please remember to rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 24, 2006 11:39 pm 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
Never mind...I had forgotten a default constructor on my class. I forgot to look in my log file for the stack trace that told me more.
Still the error message is pretty obscure with this.
Once I put the default constructor in, all works as I wanted...awesome job Sergey and team! Generics rock.

_________________
If this helped...please remember to rate it!


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.