user1632980
user1632980

Reputation: 275

Duplicate records in hibernate

I'm getting some records from multiple tables. With Hibernate join fetch query. But I'm getting duplicate records. If I specify setMaxResults parameter without any modification the query its working fine. I don't know what is wrong with the query.

Table structure is products to Quantity (one to many) and products to category(many to one) and products to brand(many to one)

My query looks like:

from ProductVO  p 
join fetch p.productsWithQuantity pq 
join fetch pq.store 
join fetch p.category cat 
join fetch p.brand brand 
join fetch p.subCategorys subCategory 
where  pq.productId=p.productId

Upvotes: 0

Views: 156

Answers (1)

CJ.
CJ.

Reputation: 71

I think it is because of join between product and quantity table, because quantity table has multiple rows for a product. Try to use DISTINCT.

Upvotes: 1

Related Questions