开发者

Hibernate one-to-many relationship

开发者 https://www.devze.com 2023-04-10 02:03 出处:网络
While iterating the data from one-to-may relationship in hibernate,the next record is not fe开发者_如何学Gotching, instead the first record printing twice if two records present in DB...

While iterating the data from one-to-may relationship in hibernate,the next record is not fe开发者_如何学Gotching, instead the first record printing twice if two records present in DB...

I just fetching the data from DB..

I haven't set data using Hibernate;


I'm going to take a stab at this. Depending on your query construction, it is possible that you can return rows more than once. This can be eliminated using result transformer.

Criteria criteria = ...
// Build your query
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); // Ensure no duplicates

I have had to use this in several complex queries.

0

精彩评论

暂无评论...
验证码 换一张
取 消