我有具有复杂映射的实体,我无法正确注释。
以下是实体:
@Entity
@Table(name = "bank")
class Bank {
@Column(name = "type")
int type
@ElementCollection
@CollectionTable(name = "bank_fp", joinColumns = @JoinColumn(name = "bank_id"))
@MapKeyColumn(name = "finance_percent")
Map<Double, BankRates>
}
? embeddable or entity ?
class BankRates {
@ElementCollection
@CollectionTable(name = "bankrates", joinColumns = @JoinColumn(name = "bfp_id"))
@MapKeyColumn(name = "track_class")
Map<String, TrackRates>
}
? embeddable or entity ?
class TrackRates {
? how to map ?
Map<YearsRange, Double>
}
@Embeddable
@Access(AccessType.FIELD)
class YearsRange {
@Column(name = "from")
int from
@Column(name = "to")
int to
}
在我看来,这些是表格:
Bank: id, type
bank_fp: id, bank_id, finance_percent - table for the map in the bank entity
bank_rates: bfp_id, track_class, from, to, rate - table for BankRates, TrackRates, YearsRange all embedded in a single table cuz its only mappings
那些是hibernate映射高手的请帮助。