-->
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: Inner class?
PostPosted: Mon Jan 05, 2009 7:18 am 
Beginner
Beginner

Joined: Mon Jan 05, 2009 7:08 am
Posts: 24
hello

Trying to find an example to do "inner/nested-class" (Not inheritance) - I looked at the doc (http://www.hibernate.org/hib_docs/nhibe ... pping.html ) didn't find an example. Anyone?

I suspect you probably need to do this, am I right?
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
    <class name="nhRegistration.Person, nhRegistration" table="people">
      <id name="Id" column="personid" type="Int32">
         <generator class="assigned" />
      </id>
      <property name="Name" column="Name"
             type="String(50)"/>

                <!-- This is inheritance, not INNER class -->
      <subclass name="nhRegistration.Student, nhRegistration"
             discriminator-value="student">
         <property name="SSN" column="identifier"
             type="String"/>

                         [b]<!-- INNER/nested class here! is this right? -->[/b]
                         <property name="IPhone" type="Universe.Gadget.iPhone" />

      </subclass>
   </class>
</hibernate-mapping>


[url]
Example adapted from http://www.theserverside.net/tt/article ... NHibernate
[/url]

Thanks!


Top
 Profile  
 
 Post subject: Basically this is what I need to do...
PostPosted: Mon Jan 05, 2009 10:17 pm 
Beginner
Beginner

Joined: Mon Jan 05, 2009 7:08 am
Posts: 24
hello

guys, anyone know how to do mapping file for this? For example:


<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">

<class name="ThinkFundamentals.Util.Security.Person, ThinkFundamentals.Util.Security" table="Person">
<id name="Id" column="Id" type="Int64" unsaved-value="0">
<generator class="native" />
</id>
<property name="FirstName" column="FirstName" type="String(50)" />
<property name="MiddleName" column="MiddleName" type="String(50)" />
...

<!-- how to map this to ObjProperties table? -->
<property name="ObjProperties" type="Util.Object" ??? />
</class>
</hibernate-mapping>

There's a table named "ObjProperties", schema for example:

Id int
PersonId int /* references Person.id */
PropertyName varchar(50),
PropertyValue varchar(50)
...

And class "Util.Object.ObjProperties" is NOT a collection class, but it contains one.

class ObjectProperties
{
... other properties ...
Hashtable _properties = new HashTable(); &lt;&lt; See, that's the property collection.
...
}

I got a feeling this setup is not very nHibernate-friendly?

Thanks!


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.