[ad_1]
I have a java entity called Product in which I have a property having a manytoone relation and another property having the manytomany relation as well as other properties having native java types (String,Int,double)
@Entity
@Table(name="PRODUCT")
@NamedQueries(
@NamedQuery(
name="findProductByCategoryAndPictures"
query="Select distinct p from Product p inner join p.categories cat inner join p.picture pic where p.id = :idProduct"
)
)
public class Product {
private int id;
private String name;
private double price;
private int quantity;
@JsonIgnore
@ManyToOne
@JoinColumns({@JoinColumn(...),@JoinColumn(...)})
private Category categories ;
@JsonIgnore
@ManyToMany
@JoinTable(name="Picture",joinColumns={})
private List<Picture> picture ;
// Getters & Setters
}
I created a named query in which I retrieve my Product object with joins on my two properties manytoone and manytomany, but I can’t get in the result of my object the values of my two other properties. I only get the values of my native properties
I have juste this result
{
"id" :"1",
"name" :"test",
"price" :"10",
"quantity" :"18",
}
but i want to have this result
{
"id" :"1",
"name" :"test",
"price" :"10",
"quantity" :"18",
"categories" :"..." ,
"picture" :[] ,
}
How can i do this ?
[ad_2]