-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: How do I _not_ generate relationships with Hibernate Tools?
PostPosted: Tue Nov 11, 2008 12:50 am 
Newbie

Joined: Tue Nov 11, 2008 12:36 am
Posts: 14
Hibernate version: 3, NetBeans 6.5 RC2

I'd like to use Hibernate tools within ant to generate my Java domain classes and the hibernate mapping file, but I don't want the related table relationships to be included in the mapping and java. I currently have my ant task generation of both the Java domain object and mapping files working, but I get the related tables. Here is my reveng.xml file.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
<hibernate-reverse-engineering>

<!-- limit generation to the MMerch databsee -->
<schema-selection match-catalog="MMerch"/>

<!-- force integer to map to simple types -->
<type-mapping>
<sql-type jdbc-type="INTEGER" not-null="true" hibernate-type="int" />
<sql-type jdbc-type="INTEGER" not-null="false" hibernate-type="int" />
</type-mapping>

<!-- process all tables -->
<table-filter match-name="actual_version_of_script"/>
<table-filter match-name="api_keys"/>
...
<table-filter match-name="z_scripts"/>
</hibernate-reverse-engineering>


I would like to just generate a getter and setter for the foreign key, rather than a collection.

Thanks for your help.

_________________
This signature left intentionally blank.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2008 9:02 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
simplest is to setup a reverse enginerring strategy that just ignores all foreign keys by implementing

/** Should this foreignkey be excluded as a oneToMany */
public boolean excludeForeignKeyAsCollection(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns);

/** Should this foreignkey be excluded as a many-to-one */
public boolean excludeForeignKeyAsManytoOne(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns);


to return true for every input.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2008 1:02 am 
Newbie

Joined: Tue Nov 11, 2008 12:36 am
Posts: 14
Great. Thanks.

_________________
This signature left intentionally blank.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.