Proper way to retrieve sequence int after entity save with hibernate and postgresql?
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
.
精彩评论