Correct way to retrieve an int sequence after saving an object using hibernate and postgresql?

This is how I get the identifier from the save (entity) method:

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

Being a complete noob for hibernation, I'm just wondering if this is the right thing to do? I would be grateful for any advice.

+3
source share
1 answer

I think there is no need to use it Integer.valueOf(save.toString);, because of course you know the type of your identifier and Hibernate. You can use (Integer)save.

+2
source

Source: https://habr.com/ru/post/1759326/


All Articles