query with JoinTable [message #553198] |
Mon, 16 August 2010 16:28 |
Lars Fischer Messages: 105 Registered: July 2009 |
Senior Member |
|
|
Hello,
I need some help with a JPA query and would be happy, if someone could
give me a hint, how to solve this:
I have an entity "Receipt" which holds a map of "Item" entities. The
map-key is an integer, which represents the order of the contained
items. My mapping looks like this:
@ManyToMany()
@JoinTable(name = "RECEIPT_ITEM", joinColumns = @JoinColumn(name =
"RECEIPT_ID"), inverseJoinColumns = @JoinColumn(name = "ITEM_ID"))
@MapKeyColumn(name = "POSITION", table = "RECEIPT_ITEM")
private Map<Integer, Item> items;
Item has a mapped unique string property "name" and no knowledge of
Receipts.
Now I need a query returning all Receipts, which are connected to an
Item with a given name.
Do I have to join Receipt and Item or can I query about the contents of
the "items" map?
Regards,
Lars
|
|
|
Re: query with JoinTable [message #553199 is a reply to message #553198] |
Mon, 16 August 2010 16:30 |
Lars Fischer Messages: 105 Registered: July 2009 |
Senior Member |
|
|
On 16.08.2010 18:28, Lars Fischer wrote:
> I need some help with a JPA query and would be happy, if someone could
> give me a hint, how to solve this:
>
> I have an entity "Receipt" which holds a map of "Item" entities. The
> map-key is an integer, which represents the order of the contained
> items. My mapping looks like this:
>
> @ManyToMany()
> @JoinTable(name = "RECEIPT_ITEM", joinColumns = @JoinColumn(name =
> "RECEIPT_ID"), inverseJoinColumns = @JoinColumn(name = "ITEM_ID"))
> @MapKeyColumn(name = "POSITION", table = "RECEIPT_ITEM")
> private Map<Integer, Item> items;
>
> Item has a mapped unique string property "name" and no knowledge of
> Receipts.
>
> Now I need a query returning all Receipts, which are connected to an
> Item with a given name.
>
> Do I have to join Receipt and Item or can I query about the contents of
> the "items" map?
Additional info:
- EclipseLink 2.1.0 (JPA 2.0)
Regards,
Lars
|
|
|
|
Powered by
FUDForum. Page generated in 0.03342 seconds