Duplicate Row IN Hibernate Fetch
posted 14 years ago
The above query is returning a list which contains a duplicate object.
Example: Suppose if it has to return 9 objects it is retuning 10 instead. One object is being duplicated.
But when I changed the code as below. It is returning exactly 9 objects.
Why hibernate is returning duplicate rows and is there any other way i can eliminate duplicate rows instead of changing list to set?
NOTE: I am very beginner in hibernate. Please help me out
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
The above query is returning a list which contains a duplicate object.
Example: Suppose if it has to return 9 objects it is retuning 10 instead. One object is being duplicated.
But when I changed the code as below. It is returning exactly 9 objects.
Why hibernate is returning duplicate rows and is there any other way i can eliminate duplicate rows instead of changing list to set?
NOTE: I am very beginner in hibernate. Please help me out
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hibernate probably works the same in both cases. The difference is that Set can keep only one copy of identical items. Therefore when Hibernate puts two identical items into a List, both will remain, whereas when it puts them into a Set, only one of them will remain there.
Ramesh Sunkara
Ranch Hand
Posts: 78
posted 14 years ago
my question is why hibernate returns two items when the db contains only one?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
when Hibernate puts two identical items into a List
my question is why hibernate returns two items when the db contains only one?
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
hi
may query generated by hibernate will cause the two rows.
Second times it work because Set doesnot allowed duplicate record.
have you run the hibernate generated query in sql console?
may query generated by hibernate will cause the two rows.
Second times it work because Set doesnot allowed duplicate record.
Ramesh Sunkara
Ranch Hand
Posts: 78
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
No I didn't run in sql console.
Actaully I don't know how to run this Hibernate query.
Can you please help me?
And suppose if it returned two rows , how to modify my query such that it returns only one
Actaully I don't know how to run this Hibernate query.
Can you please help me?
And suppose if it returned two rows , how to modify my query such that it returns only one
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
hi,
Better you just check the converted SQL statement by adding the below statement in your Hibernate configuration file,
<property name="show_sql">true</property>
The above statement in hibernate configuration file, results in writing the generated SQL ststement to standard output console, so that you can find what exactly is causing the problem.
Better you just check the converted SQL statement by adding the below statement in your Hibernate configuration file,
<property name="show_sql">true</property>
The above statement in hibernate configuration file, results in writing the generated SQL ststement to standard output console, so that you can find what exactly is causing the problem.
Ramesh Sunkara
Ranch Hand
Posts: 78
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi bala
ya exactly i have tried the same.
When I executed the query I got correct no.of rows. It does't have any dupliates
ya exactly i have tried the same.
When I executed the query I got correct no.of rows. It does't have any dupliates
bala rimmalapudi
Greenhorn
Posts: 7
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi Ramesh,
I didn't get your point.Try to use the above configuration with Set and after that try with List and make sure you make a note of the SQL in both the cases and check the results.
I didn't get your point.Try to use the above configuration with Set and after that try with List and make sure you make a note of the SQL in both the cases and check the results.
Ramesh Sunkara
Ranch Hand
Posts: 78
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi Bala,
I got the issue.
My DB has duplicate rows.
Thanks a lot for your valuable time.
I got the issue.
My DB has duplicate rows.
Thanks a lot for your valuable time.
| Politics is a circus designed to distract you from what is really going on. So is this tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |








