ORM supporting immutable classes

前端 未结 6 797
暖寄归人
暖寄归人 2021-02-03 22:15

Which ORM supports a domain model of immutable types?

I would like to write classes like the following (or the Scala equivalent):

class          


        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-03 23:09

    You can do this with Ebean and OpenJPA (and I think you can do this with Hibernate but not sure). The ORM (Ebean/OpenJPA) will generate a default constructor (assuming the bean doesn't have one) and actually set the values of the 'final' fields. This sounds a bit odd but final fields are not always strictly final per say.

提交回复
热议问题