-->
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.  [ 1 post ] 
Author Message
 Post subject: @MapKey - how to set mapkey from nested entity property?
PostPosted: Sat Apr 12, 2008 12:49 pm 
Newbie

Joined: Fri Dec 28, 2007 6:39 am
Posts: 2
ok, googled this forum but didn't found a final answer... maybe someone can help.

what's the recommended way to set a mapkey from a nested entity property?

We have 3 domain objects.

- Facility
- FacilityEntry
- Property - primary key is the attribute propertyId (a long value)

A Facility has several FacilityEntries:
Code:
   @OneToMany(mappedBy = "facility", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
   @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
   @org.hibernate.annotations.MapKey(columns = { @Column(name = "propertyId") })
   public Map<Property, FacilityEntry> getFacilityEntries() {
      return facilityEntries;
   }


Each FacilityEntry object has one Property object.

I would like to set the primary key of the property object (a long) as MapKey.

How can I archive this?

Is it the recommended way to use @org.hibernate.annotations.MapKey as shown above or do you recommend to use a @Formula (and hence create a new dummy property) in the FacilityEntry class and map that property?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.