When specifying one to many relationships in the domain model....is it better to initialize the set?
i.e.
private Set<Book> books = new HashSet<Book>();
OR
private Set<Book> books;
Thxs.
When specifying one to many relationships in the domain model....is it better to initialize the set?
i.e.
private Set<Book> books = new HashSet<Book>();
OR
private Set<Book> books;
Thxs.
Initializing it in the first place prevents you from null checks all over the place, so my advice would be the first.
It doesn't matter from hibernate perspective. It basically question of basic java practice.