0

I noticed that in tutorials for mapping columns in Hibernate, somebody initialize List(Set). What is difference when I don't use "new" and new ArrayList()? Can I use new LinkedList() too? And what about Set? Is it same like in List? And is there same difference across versions of Hibernate?

@Entiy
public class Student implements Serializable{
private List<String> subjects1;
private List<String> subjects2 = new ArrayList();
}

or

@Entiy
public class Student implements Serializable{
private Set<String> subjects1;
private Set<String> subjects2 = new HashSet();
}
Dušan Salay
  • 309
  • 1
  • 12

1 Answers1

0

like with any other collection, you need to create the instance before you can add elements. But when you load an entity from the database, the collection will be created, so you don't need to do it.

EasterBunnyBugSmasher
  • 1,507
  • 2
  • 15
  • 34