两个表,分别是fund 和 investment_style,
fund [id, name,desccription......, invest_style_id(FK) ]
investment_style [id,value]因为investment_style是一个非常简单的表,只有一个value(text)字段,怎么能够直接映射这个字段,而不用为它创建一个单独的class.现在我的java是这样
fund {
@id
private int id; ....
@ManyToOne
@joinColumn(.....)
private InvestmmentStyle style;
}@entity
@table(name=...)
InvestmmentStyle {
private int id;
private String value;
}这样的确可以做到正确的关联,不过因为fund table 里面类似于 fund 和 investment_style这样的关联还有很多,我不想为每一个这样的简单表都创建一个类,请问有没有什么解决方案?我看到@secondarytable,不知道这个能不能用,怎么用,谢谢
fund [id, name,desccription......, invest_style_id(FK) ]
investment_style [id,value]因为investment_style是一个非常简单的表,只有一个value(text)字段,怎么能够直接映射这个字段,而不用为它创建一个单独的class.现在我的java是这样
fund {
@id
private int id; ....
@ManyToOne
@joinColumn(.....)
private InvestmmentStyle style;
}@entity
@table(name=...)
InvestmmentStyle {
private int id;
private String value;
}这样的确可以做到正确的关联,不过因为fund table 里面类似于 fund 和 investment_style这样的关联还有很多,我不想为每一个这样的简单表都创建一个类,请问有没有什么解决方案?我看到@secondarytable,不知道这个能不能用,怎么用,谢谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货