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: URGENT : HELP : Mapping Generic class
PostPosted: Mon Jun 22, 2009 12:38 pm 
Newbie

Joined: Fri Mar 13, 2009 10:36 am
Posts: 10
Hi Have the following class.

Can some one pelase provide the mapping file for this please ?

I do not know how to map <T> element.

abstract class AbstractBase<T>
{
public string Name
{
get { return typeof(T).Name; }
}

}

For string I can do the following
<class name="ConsoleApplication1.AbstractBase`1[System.String], ConsoleApplication1" lazy="false" abstract="true" table="test_hibernate">

How do I do it for the <T> Element?


Thanks.


Top
 Profile  
 
 Post subject: Re: URGENT : HELP : Mapping Generic class
PostPosted: Tue Jun 23, 2009 7:52 am 
Newbie

Joined: Fri Mar 13, 2009 10:36 am
Posts: 10
Can some one please tell me if this is possible in Hibernate ? If not is there any way around it other than having user defined base class?


Top
 Profile  
 
 Post subject: Re: URGENT : HELP : Mapping Generic class
PostPosted: Tue Jun 23, 2009 12:38 pm 
Newbie

Joined: Fri Mar 13, 2009 10:36 am
Posts: 10
OK .. After countless hours spent on good and R&D I came up with something that works. But I dont think its the best solution.
If any one has a better way of doign this then please do let me know.

Code:
<?xml version="1.0" encoding="utf-8"?>
<!--Generated from NHibernate.Mapping.Attributes on 2009-06-23 13:44:27Z.-->
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">

<class name="ConsoleApplication1.AbstractPromotion`1[System.Int16], ConsoleApplication1" lazy="false" abstract="true" table="test_hibernate">
     <id name="Id" column="id">
      <generator class="assigned" />
    </id>
    <discriminator column="discriminator" />
    <property name="Name" />
  </class>
 
<class name="ConsoleApplication1.AbstractPromotion`1[System.String], ConsoleApplication1" lazy="false" abstract="true" table="test_hibernate">
     <id name="Id" column="id">
      <generator class="assigned" />
    </id>
    <discriminator column="discriminator" />
    <property name="Name" />
  </class>

<subclass name="ConsoleApplication1.IntPromotion, ConsoleApplication1" lazy="false" extends="ConsoleApplication1.AbstractPromotion`1[System.Int16], ConsoleApplication1" />
<subclass name="ConsoleApplication1.StringPromotion, ConsoleApplication1" lazy="false" extends="ConsoleApplication1.AbstractPromotion`1[System.String], ConsoleApplication1" />

</hibernate-mapping>


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.