-->
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: [JPA] @MapKey or what?
PostPosted: Sun Feb 22, 2009 10:29 am 
Newbie

Joined: Sun Feb 22, 2009 10:24 am
Posts: 3
I have the field in my class:
Code:
private Map<Test, Float> prices;

Test is my own Java class and Float is Java type of course.
What annotation should I use to map it?

I found @MapKey in Javadoc but I don't know how to use it. Could you help me?


Top
 Profile  
 
 Post subject: Re: [JPA] @MapKey or what?
PostPosted: Mon Feb 23, 2009 2:02 am 
Newbie

Joined: Mon Feb 02, 2009 4:55 am
Posts: 5
Cranegger wrote:
I have the field in my class:
Code:
private Map<Test, Float> prices;

Test is my own Java class and Float is Java type of course.
What annotation should I use to map it?

I found @MapKey in Javadoc but I don't know how to use it. Could you help me?



Try the code below
Code:
@CollectionOfElements(targetElement = Test.class)
@MapKeyManyToMany(targetEntity = Float.class)
private Map<Test,Float> prices= new HashMap<Test,Float>();


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2009 7:49 am 
Newbie

Joined: Sun Feb 22, 2009 10:24 am
Posts: 3
Yesterday I have found the answer. It's similar to your code, but there is a little difference:
Code:
@CollectionOfElements(targetElement = Float.class)
@MapKeyManyToMany(targetEntity = Test.class)
private Map<Test, Float> prices;


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