开发者

Proper way to retrieve sequence int after entity save with hibernate and postgresql?

开发者 https://www.devze.com 2023-01-11 12:27 出处:网络
This is how I\'m getting the id from save(entity) method: Serializable save = hibernateTemplate.save(article);

This is how I'm getting the id from save(entity) method:

Serializable save = hibernateTemplate.save(article);
return Integer.valueOf(save.toString());

Being a complete noob to hibernate, I just wonder if this is the proper way to do it? I'll appreciate an开发者_开发知识库y advice.


I think it is unnecessary to use Integer.valueOf(save.toString); because you know type of your identifier and Hibernate of course too. You can use (Integer)save.

0

精彩评论

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