-->
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.  [ 4 posts ] 
Author Message
 Post subject: map Frectangle
PostPosted: Thu May 19, 2005 8:02 am 
Hi i'm new in hibernate,

i have this class:

public abstract class CategoryObject {
protected bool _visible = true;
protected RectangleF _boundingBox;
protected string _id = "";
.....

My problem is:
which is the best way to map RectangleF ?
What type can i put in the mapping file for RectangleF and in the db table?

Thanks


Top
  
 
 Post subject:
PostPosted: Thu May 19, 2005 10:46 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
RectangleF can be another entity (=> mapped as <one-to-one> and saved in another table).
It can also be a <component> if its fields are in CategoryObject's table.

Read NHibernate Reference for more informations about this mapping.

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 12:47 pm 
Sorry but i'm a newbie and i haven't understand very well (also after documentatio reading :()
Where can i find an example?
Because i have created a new table 'RECTANGLE' but my problem is :
Have i to link the 'RECTANGLE' table with 'CATEGORY' table with an external references?
if i had a basic type (like float for example) when i map the object in an table i create a field float in my table. Now if i have an object like FRectangle i can't create a table with a field Frectangle, so what kind of field have i to create ? A blob type? Or a field id that link the RECTANGLE table?

Thanks
Franco


Top
  
 
 Post subject:
PostPosted: Fri May 20, 2005 1:01 am 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
In my opinion, RectangleF data (points) wouldn't be shared across Categories so save yourself the join and place the RectangleF data directly in the Caregory Table.

Code:
T_CATEGORY
  CategoryID (PK)
  IsVisible
  CategoryName
  X1Y1
  X2Y2


Then in your mapping file, use a Component as KPixels suggests:

Code:
<class "CategoryObject">
  <id name="id" column="CategoryID" unsaved-value="-1">
    <generator class="identity" />
  </id>

  <property name="isVisible" column="IsVisible" />
  <property name="name" column="CategoryName" />

  <component name="RectangleF" class="RectangleF">
    <property name="x1y1" column="X1Y1" />
    <property name="x2y2" column="X2Y2" />
  </component>

</class>


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