【问题标题】:Proper way to retrieve sequence int after entity save with hibernate and postgresql?使用hibernate和postgresql保存实体后检索序列int的正确方法?
【发布时间】:2010-08-12 13:37:55
【问题描述】:

这就是我从 save(entity) 方法中获取 id 的方式:

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

作为一个完全冬眠的菜鸟,我只是想知道这是否是正确的方法? 我会很感激任何建议。

【问题讨论】:

    标签: java hibernate postgresql orm


    【解决方案1】:

    我认为没有必要使用Integer.valueOf(save.toString);,因为您当然也知道标识符的类型和 Hibernate。你可以使用(Integer)save

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-12
      • 2017-07-28
      • 2021-08-26
      • 2011-01-15
      • 1970-01-01
      相关资源
      最近更新 更多