-->
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: Mapping question
PostPosted: Mon Oct 24, 2005 2:45 pm 
It is very simple, i have :

Code:
public class Character
{
   private string m_characterName;
   private InventoryComponent m_inventory;
   ...
   // all get and set
}

public class InventoryComponent
{
   private int         m_activeWeapon;
   private int         m_money;
   private IDictionary   m_inventoryItems;  // hashtable of InventoryItem
   ...
   // all get and set
}

public class InventoryItem
{
   private int   m_itemName;
   private int   m_slot;
   ...
   // all get and set
}


I want to do in my code :
Code:
Character char1 = new Character();
...
string char1Name = char1.characterName;
int char1Money = char1.inventory.money;
InventoryItem item = (InventoryItem) char1.inventory.inventoryItems(10);  // get the item in the slot number 10


In my database i have 2 tables, the table Character with fields :

- characterName
- activeWeapon
- money

And the table InventoryItem with :
- characterName
- itemName
- slot

My mapping file look like :

Code:
<class name="DOL.GS.Database.Character, GameServer" table="`Character`">
      <id name="CharacterName" type="String(24)" column="`CharacterName`">
         <generator class="assigned" />
      </id>
      ...
      <component name="Inventory" class="DOL.GS.Database.InventoryComponent, GameServer">
         <property name="ActiveWeapon" not-null="true" column="`ActiveWeapon`"/>
         <property name="Money" not-null="true" column="`Money`"/>
         <map name="InventoryItems" cascade="delete" table="`InventoryItem`">
            <key column="`CharacterName`"/>
            <index column="`SlotPosition`" type="Int"/>
            <one-to-many class="DOL.GS.Database.InventoryItem, GameServer"/>
         </map>
      </component>
</class>


But it does not seems to work, how does i can map that please ? Thx


Top
  
 
 Post subject:
PostPosted: Tue Oct 25, 2005 11:51 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Can you provide details? Are you getting an exception somewhere?

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 25, 2005 2:23 pm 
Ho yes, sorry, i don't remember this post :). In fact it was a error in my mapping file, all work like a charm now.

I was not sure to be allowed to map such this but after reading this and some research in my files a found the bug.

Quote:
The properties of a component may be of any Hibernate type (collections, many-to-one associations, other components, etc). Nested components should not be considered an exotic usage. Hibernate is intended to support a very fine-grained object model.


Source : http://www.hibernate.org/hib_docs/reference/en/html/components.html


Thanks for your help KPixel.


Top
  
 
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.