开发者

Hibernate one-to-many relationship

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜