-->
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: Mapping transient properties
PostPosted: Tue Apr 12, 2005 4:26 pm 
Newbie

Joined: Tue Apr 12, 2005 4:13 pm
Posts: 3
Howdy,

I'm using Hibernate 2.1.8, JDK 1.4.2 and Oracle9i.

I've been scouring the documentation, tutorials and hibernate action book and can't find a way to do the following. Any suggestions would be appreciated.

Let's say I have the following two persistant classes which I can map to the database. With the exception of the companyName field in User.

Class: Company
- id
- name

Class: User
- id
- name
- companyId
- companyName (not a column in the database, just a convenience method)

I want to populate the companyName when I retrieve a list of Users based on the companyId stored for that user. Can this be done and how? Or do I just create a one to one mapping? I was hoping to keep the number of objects retrieved low.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 12, 2005 4:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Sure, use a formula property mapping (instead of the column-based mapping). Note that these are read-only.

Note that it would have to use a correlated subselect, which may be less performant than mapping the association and using a join.


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.