我有两个表,A并且B在数据库中。在表中,B我有A一个Integer 对该表的引用idA。(idA是B的外键)当我使用hibernate- tools进行反向工程时,会生成两个Java对象。
A
B
idA
public class A{ int id; }
和
public class B{ int id; A a; }
但是我想要
public class B{ int id; int idA; }
我怎样才能做到这一点?
谢谢,
因此,我找到了一个解决方案:创建一个自定义ReverseEngineeringStrategy并将excludeForeignKeyAsManytoOne方法的返回更改为true。
ReverseEngineeringStrategy
excludeForeignKeyAsManytoOne
true
public class MyReverseEngineeringStrategy extends DelegatingReverseEngineeringStrategy { public MyReverseEngineeringStrategy(ReverseEngineeringStrategy delegate) { super(delegate); } @Override public boolean excludeForeignKeyAsManytoOne(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns) { return true; } }