[hibernate-issues] [Hibernate-JIRA] Commented: (HBX-622) Allow ability to ignore Foreign Keys
Lajos Gathy (JIRA)
noreply at atlassian.com
Fri Jun 26 05:48:36 EDT 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-622?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33477#action_33477 ]
Lajos Gathy commented on HBX-622:
---------------------------------
I also ran into this problem and I think I found an other solution, maybe it is a bit simpler:
I noticed that the org.hibernate.cfg.reveng.ReverseEngineeringSettings class contains these properties: createManyToOneForForeignKey and createCollectionForForeignKey. They are both set to true, and you cannot set them on the Hibernate Code Generation Configurations dialog. But since I already had my own reveng strategy implementation (inherited from DelegatingReverseengineeringStrategy of course), I used the setSettings method to change these two properties to false:
private ReverseEngineeringSettings settings;
@Override
public void setSettings(ReverseEngineeringSettings settings) {
settings.setCreateManyToOneForForeignKey(false);
settings.setCreateCollectionForForeignKey(false);
this.settings = settings;
super.setSettings(settings);
}
This way the generated POJOs did not contain the @ManyToOne/@OneToMany associations for the FKs (however there were some blank lines generated in the source).
I am not sure, if this works with HT 3.1 (I used 3.2.4).
> Allow ability to ignore Foreign Keys
> ------------------------------------
>
> Key: HBX-622
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-622
> Project: Hibernate Tools
> Issue Type: New Feature
> Components: reverse-engineer
> Affects Versions: 3.1beta4
> Environment: As per patch.
> Reporter: James Olsen
> Fix For: 3.2.beta11
>
> Attachments: svn-patch.txt
>
>
> On the project I'm currently working on we want 1:1 POJO<->Table mapping without any relationships between the POJOs. Although this is not a configuration that I would normally choose or recommend, in this case it is forced upon us be external architectural requirements.
> Currently in order to avoid relationships in your POJOs you have to reveng each table individually. The attached patch is a proposed solution to allow the reveng to ignore relationships between tables when reverse engineering multiple tables at the same time.
> Note that the patch only supports this for ReverseEngineeringStrategy not for reveng.xml.
> I'm supplying the patch in the hope that it (or something similar) can be incorporated into the main code and in case anyone else has (unfortunately) similar requirements.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list