Issue Details (XML | Word | Printable)

Key: APF-1049
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Matt Raible
Reporter: ChenZhiguo
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
AppFuse

Hibernate returns repeat records when getAll

Created: 15/Apr/08 03:20 AM   Updated: 15/Jul/08 11:12 PM   Resolved: 15/Jul/08 11:12 PM
Component/s: Persistence Layer
Affects Version/s: None
Fix Version/s: 2.0.2

File Attachments: 1. File test1.rar (68 kB)

Environment: windows,struts2,hibernate,mysql


 Description  « Hide
I have a entity named salary.
salary is oneToOne user.

if a user has two roles,when I get all of salary,there will be one repeat record.
if a user has three roles,when I get all of salary,there will be two repeat records.
and so on.

attachment is my demo project.

ChenZhiguo added a comment - 23/Apr/08 02:10 AM
The hql is:
select this_.id as id2_2_, this_.salary as salary2_2_, this_.userId as userId2_2_, user2_.id as id0_0_, user2_.account_expired as account2_0_0_, user2_.account_locked as account3_0_0_, user2_.address as address0_0_, user2_.city as city0_0_, user2_.country as country0_0_, user2_.postal_code as postal7_0_0_, user2_.province as province0_0_, user2_.credentials_expired as credenti9_0_0_, user2_.email as email0_0_, user2_.account_enabled as account11_0_0_, user2_.first_name as first12_0_0_, user2_.last_name as last13_0_0_, user2_.password as password0_0_, user2_.password_hint as password15_0_0_, user2_.phone_number as phone16_0_0_, user2_.username as username0_0_, user2_.version as version0_0_, user2_.website as website0_0_, roles3_.user_id as user1_4_,role4_.id as role2_4_, role4_.id as id1_1_, role4_.description as descript2_1_1_, role4_.name as name1_1_ from Salary this_ left outer join app_user user2_ on this_.userId=user2_.id left outer join user_role roles3_ on user2_.id=roles3_.user_id left outer join role role4_ on roles3_.role_id=role4_.id

ChenZhiguo added a comment - 23/Apr/08 02:40 AM
If I use hql="from Salary", the hql will be:
select salary0_.id as id2_, salary0_.salary as salary2_, salary0_.userId as userId2_ from Salary salary0_

select user0_.id as id0_1_, user0_.account_expired as account2_0_1_, user0_.account_locked as account3_0_1_, user0_.address as address0_1_, user0_.city as city0_1_, user0_.country as country0_1_, user0_.postal_code as postal7_0_1_, user0_.province as province0_1_, user0_.credentials_expired as credenti9_0_1_, user0_.email as email0_1_, user0_.account_enabled as account11_0_1_, user0_.first_name as first12_0_1_, user0_.last_name as last13_0_1_, user0_.password as password0_1_, user0_.password_hint as password15_0_1_, user0_.phone_number as phone16_0_1_, user0_.username as username0_1_, user0_.version as version0_1_, user0_.website as website0_1_, roles1_.user_id as user1_3_, role2_.id as role2_3_, role2_.id as id1_0_, role2_.description as descript2_1_0_, role2_.name as name1_0_ from app_user user0_ left outer join user_role roles1_ on user0_.id=roles1_.user_id left outer join role role2_ on roles1_.role_id=role2_.id where user0_.id=?

and so on.

ChenZhiguo added a comment - 23/Apr/08 02:42 AM
and when I use hql=""from Salary" will resolve the problem.

Sharif Uddin added a comment - 15/Jul/08 07:29 AM
Here is a possible solution posted by me
http://jira.springframework.org/browse/SPR-5007

ChenZhiguo added a comment - 15/Jul/08 09:58 PM
Is this a good solution?

Matt Raible added a comment - 15/Jul/08 11:12 PM
Fixed in 2.0.2 by adding getAllDistinct via APF-1013.

Matt Raible made changes - 15/Jul/08 11:12 PM
Field Original Value New Value
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 2.0.2 [ 10110 ]
Resolution Fixed [ 1 ]