开发者

Hibernate domain model

开发者 https://www.devze.com 2022-12-20 07:51 出处:网络
When specifying one to many r开发者_运维技巧elationships in the domain model....is it better to initialize the set?

When specifying one to many r开发者_运维技巧elationships 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消