且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

始终对JPA @Id使用原始对象包装而不是原始类型?

更新时间:2023-02-26 22:22:55

我会说是的,由于您遇到的情况,建议使用对象类型而不是基元.无法通过实体标识符来区分该实体是新实体还是现有实体.我已经使用了hibernate多年了,而且我总是使用对象作为标识符.

I would say yes it is recommended to use object types instead of primitives because of the case you are seeing. There is no way of distinguishing if the entity is new or pre existing with a primitive identifier. I have used hibernate for years and I always use objects for identifiers.