views:

13

answers:

0

I am using JPA Annotation mapping with the table given below, but having problem that i am doing mapping on same table but on diffrent field given

ProductImpl.java

@Entity @Table(name = "Product")

public class ProductImpl extends SimpleTagGroup implements Product {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id = -1;

@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinTable(name = "ProductTagMapping", joinColumns =@JoinColumn(name = "productId"), inverseJoinColumns =@JoinColumn(name = "tagId"))    
private List<SimpleTag> tags;

@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinTable(name = "ProductTagMapping", joinColumns =@JoinColumn(name = "productId"), inverseJoinColumns =@JoinColumn(name = "tagId"))
private List<SimpleTag> licenses;

@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinTable(name = "ProductTagMapping", joinColumns =@JoinColumn(name = "productId"), inverseJoinColumns =@JoinColumn(name = "tagId"))
private List<SimpleTag> os;

I want to get values like windows and linux in os , GPLv2 and GPLv3 in licenses ,so we are using TagGroup table . but here i got all tagValues in each of the os,licenses and tag fileds,so how could i do group by or some other things with JPA.

and ProductTagMapping is the mapping table between Tag and TagGroup

TagGroup Table

ID   TAGGROUPNAME  

1 PRODUCTTYPE
2 LICENSE
3 TAGS
4 OS

SimpleTag

ID   TAGVALUE  

1 Application
2 Framework
3 Apache2
4 GPLv2
5 GPLv3
6 learning
7 Linux
8 Windows
9 mature