Len mapping to sleep mode tools?

I have two tables A, and Bin my database. I am a table B. I have a link to the table as Aan integer idA. (idA is the foreign key for B) When I do reverse engineering using hibernation tools, I generate two Java objects.

public class A{
  int id;
} 

and

public class B{
  int id;
  A a;
} 

But I want to have

public class B{
  int id;
  int idA;
}  

How can i do this?

Thanks,

+1
source share
2 answers

So, I found a solution: create a custom one ReverseEngineeringStrategyand change the return method excludeForeignKeyAsManytoOneto 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;
                }

}
+1
source

, , @OneToOne XML-.

Hibernate , , .

0

Source: https://habr.com/ru/post/1620224/


All Articles