-->
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: Is it possible to map relation property as Guid not Class?
PostPosted: Wed Jul 11, 2007 4:42 am 
Newbie

Joined: Tue Jul 10, 2007 12:05 pm
Posts: 1
Hibernate version:
1.2.0 GA

Question:
Hi!
Is it possible to Map User to Logo by LogoID as Guid property instead of Logo property but to have delete-orphan enabled.
I want to map it as Nullable Guid however i need associated Logo to be deleted if LogoID==null.

In the same time i don't want to use lazy loading or mapping property as Logo class type


Mapping documents:
Code:
<class name="User" table="P_USER">
    <id name="_id" access="field" column="ID_USER" unsaved-value="00000000-0000-0000-0000-000000000000">
      <generator  class="guid" />
    </id>
    <property name="Name" type="String" column="USER_NAME" not-null="true"/>
    <property name="LogoID" type="Guid" column="ID_LOGO" /> <!-- nullable-->
  </class>
  <class name="Logo" table="P_LOGO">
    <id name="_id" access="field" column="ID_LOGO" unsaved-value="00000000-0000-0000-0000-000000000000">
      <generator class="guid" />
    </id>
    <property name="ImageFileID" type="Guid" column="FILE_ID" not-null="true" unique="true" />
    <property name="ImageFileChecksum" type="String" column="FILE_CHECKSUM" not-null="true" />
  </class>



Top
 Profile  
 
 Post subject: Re: Is it possible to map relation property as Guid not Clas
PostPosted: Wed Jul 11, 2007 8:15 am 
Senior
Senior

Joined: Thu Feb 09, 2006 1:30 pm
Posts: 172
Ubadan wrote:
In the same time i don't want to use lazy loading or mapping property as Logo class type


Why don't you want to map it as the Logo class type? If the logo is a proxy by default only the ID will be loaded anyway, so there won't be a performance hit. This would give you the desired behavior until you try to access properties of the Logo class (besides the ID) which you obviously are stating you wouldn't do.

Additionally you could always write HQL queries that return just the properties you need, so if there is a case where you are populating a grid for example, you wouldn't need all of the logo classes, you could have accomplished the ID portion via an HQL query.

Maybe there are some other options besides what you state that will work for you? Give us some more information, and maybe we can come up with some other alternatives as well.


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.