2

Hibernate tools (for Eclipse) reverse engeneering generates POJO with reference fields. How to ignore DB relation? For example,

class User {
 private City city;
...
}

I want get

class User{
private Integer cityId;
...
}
Satmurat
  • 41
  • 7
  • What tools? You could code by hand? Why do you not want the relationships? – farrellmr Feb 21 '15 at 08:48
  • I mean [Hibernate tools for Eclipse](http://hibernate.org/tools/). Tables on DB too many, I can not code by hand every entity. I don't want relationships, because objects will be keeps on cache. – Satmurat Feb 21 '15 at 09:34
  • Instruct it not to detect one-many or many-many in the configuration window – farrellmr Feb 21 '15 at 09:51
  • I did so, unchecked "Detect many-to-many tables" and "Detect one-to-one associations". It is not helps. – Satmurat Feb 21 '15 at 10:24

1 Answers1

1

Finally, I found answer for my question. I created reverse engeneering strategy class and override some methods:


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;
    }

}
Satmurat
  • 41
  • 7