• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Set of Workers or List of Workers in POJO ?

 
Rajab Davudov
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new at hibernate. I want to ask what is there difference between using
Set<Worker> and List<Worker> in hibernate by implementation and by db structure. In Tutorials Set is mostly used, why ?

Thanks,
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, from the Java API Docs, a List will allow duplicates and a Set will not. So, that's a pretty significant basis for the difference.

-Cameron McKenzie
 
Rajab Davudov
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats right for implementation part. And I guess for db part
if it is Set hibernate puts some constraints to avoid duplicity automatically.

thank you very much.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rajab Davudov:
hibernate puts some constraints to avoid duplicity automatically.


And I'm not sure if Hibernate3 even needs to. I'm not sure of the internals, be even if Hibernate threw a bunch of duplicate records/entities into the Set, they'd just load on top of the existing entity in the Set, so the JVM pretty much takes care of it!

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic