如何使用 hibernate.reveng.xml 更改自引用多对多集的名称?
我有一个在 Oracle 数据库上使用 Hibernate 的项目,该项目的所有实体都是在 hibernate.reveng.xml 文件的控制下直接从 Hibernate 工具生成的。
我有一个类,它使用中间表与其自身具有多对多关系,如下所示:
PERSON:
ID
...
PERSON_PERSON:
PARENT_ID --> PERSON.ID
CHILD_ID --> PERSON.ID
如果没有任何特定指令,Hibernate Tools 将自动生成一个如下所示的类:
public class Person {
private Long id;
private Set<Person> personsForParentId = new HashSet<Person>(0);
private Set<Person> personsForChildId = new HashSet<Person>(0);
}
因为在编码以确定哪个类时,这不是很有帮助是父集,哪个是子集,我想将它们重命名为“父母”和“孩子”。
我一直在编辑 hibernate.reveng.xml 以尝试强制它重命名该字段,但我找不到有效的东西。我不确定是否指定对 PERSON 表、PERSON_PERSON 表或两者进行更改,以及要更改哪些属性。
我习惯于手动设置这些类,但是在这个项目中,我无法控制构建过程,所以我必须使用 Hibernate Tools 生成的内容,所以我真的只需要让 Hibernate Tools 来做我想做的事。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 hibernate.reveng.xml 文件上尝试标记相关列,如下所示;
on your hibernate.reveng.xml file try marking related columns like this;