How to handle JPA annotations for a pointer to a generic interface

前端 未结 3 1871
忘了有多久
忘了有多久 2021-01-18 01:29

I have a generic class that is also a mapped super class that has a private field that holds a pointer to another object of the same type:

@MappedSuperclass
         


        
3条回答
  •  滥情空心
    2021-01-18 01:52

    Since JDO supports persistence of interface fields (which is a similar concept to what you have here), and since DataNucleus JPA is built on top of the JDO capabilities, then it likely would allow you to persist such a field (I have an example using JDO that does something very similar, but without seeing the remains of your classes and persistence code its impossible to be definitive). Give it a try and see what happens.

    Obviously that is beyond the JPA spec, hence if portability is a concern for you then have a think first

提交回复
热议问题