views:

10

answers:

0

I have a project using Hibernate on an Oracle database for which all entities are generated directly from Hibernate Tools under control of a hibernate.reveng.xml file.

I have one class which has a many-to-many relationship to itself using an intermediary table, like so:

PERSON:
  ID
  ...

PERSON_PERSON:
  PARENT_ID --> PERSON.ID
  CHILD_ID  --> PERSON.ID

Without any specific directives, Hibernate Tools will automatically generate a class that looks like this:

public class Person {
    private Long id;
    private Set<Person> personsForParentId = new HashSet<Person>(0);
    private Set<Person> personsForChildId = new HashSet<Person>(0);
}

Since that's not very helpful when coding to determine which is the parent set and which is the child set, I'd like to rename them as 'parents' and 'children'.

I've been editing the hibernate.reveng.xml to try to force it to rename that field, but I'm not able to find something that works. I'm not sure whether I'm specifying a change on the PERSON table, the PERSON_PERSON table, or both, and which attributes to change.

I'm used to setting these classes up manually, but on this project I don't have control over the build process, so I have to make do with what gets generated by Hibernate Tools, so I really just have to make Hibernate Tools to do what I want.