开发者

How can I change the name of the self-referential many-to-many set using hibernate.reveng.xml?

I have a project using Hibernate on an Oracle datab开发者_开发知识库ase 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.


on your hibernate.reveng.xml file try marking related columns like this;

<column name="personsForParentId" property="parents" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜