0

我想将 Train.trainFares 从瞬态更改为映射到 TrainFare 类。但是,我想将 TrainFares 限制为对 Train.ddate 有效的那些。我该怎么做呢?

我发现了一个 Hibernate Jira问题,我认为这可能是我的问题的根源。有没有其他人遇到过这个问题?你找到解决方法了吗?

@Entity
@Table(name = "TRAIN")
public class Train { 

    @EmbeddedId
    private TrainPK id;

    @Column
    private String trainType;

    @Transient
    private List<TrainFare> trainFares;

    @Embeddable
    public static class TrainPK {

        @Column
        private String company;

        @Column
        private Date departDate;

        @Column 
        private String trainNumber;
    }

    ... setters & getters
}

@Entity
@Table(name = "SEATRATE")
public class SeatRate { 

    @EmbeddedId
    private SeatRatePK id;

    @Column
    private Date expiryDate; 

    @Column
    private String trainNumber;

    @Embeddable
    public static class SeatRatePK { 

        @Column
        private String company

        @Column 
        private Date effectiveDate;

    }

    ... setters & getters
}
4

0 回答 0