JPA and generics

前端 未结 2 601
南方客
南方客 2021-02-08 12:56

I\'m wondering how an abstract class with generics would handle with JPA? I mean what kind of annotations do I need for the field?

Consider these:

@Mappe         


        
2条回答
  •  天命终不由人
    2021-02-08 13:08

    We can. if the T implements Serializable

    @Entity
    public class IgsSubject extends BasicObject implements Serializable{
    
        private static final long serialVersionUID = -5387429446192609471L;
    
    @MappedSuperclass
    public class IgsBasicLog extends BasicObject {
    
        @ManyToOne
        @JoinColumn(name = "ITEM_ID")
        private T item;
    
    @Entity
    public class IgsLogA extends IgsBasicLog implements Serializable {
        private static final long serialVersionUID = -8207430344929724212L;
    }
    

提交回复
热议问题