Hibernate工具(用于Eclipse)逆向工程生成带参考字段的POJO。如何忽略数据库关系?例如,
class User {
private City city;
...
}
我想要
class User{
private Integer cityId;
...
}
答案 0 :(得分:1)
最后,我找到了我的问题的答案。我创建了逆向工程策略类并覆盖了一些方法:
public class RevengStrategy extends DelegatingReverseEngineeringStrategy {
public RevengStrategy(ReverseEngineeringStrategy delegate) {
super(delegate);
}
@Override
public boolean excludeForeignKeyAsManytoOne(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns) {
return true;
}
@Override
public boolean excludeForeignKeyAsCollection(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns) {
return true;
}
}