-->
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.  [ 11 posts ] 
Author Message
 Post subject: Reverse Engineering Strategy
PostPosted: Thu Sep 14, 2006 5:28 pm 
Regular
Regular

Joined: Mon May 22, 2006 4:28 am
Posts: 56
Location: Göteborg, Sweden
Hi,
I have created a custom reverse engineering strategy for getting rid of Sets for foreign keys. I want to use this instead of adding xml code in my reveng.xml file to exclude them.
My RevEngStrategy looks like this:

Code:
public class RevEngStrategy extends DelegatingReverseEngineeringStrategy {

   public RevEngStrategy(ReverseEngineeringStrategy delegate) {
      super(delegate);
   }
   
   public boolean excludeForeignKeyAsCollection(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns) {
       return true;
   }
   
}


My question are: How do I use this through eclipse? I generate hbm.xml and pojos in eclipse and all my other classes from ant.

Thanks
Jacob


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 1:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
set the full class name in the Reverse Engineering strategy field when doing the reverse engineering.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 9:18 am 
Regular
Regular

Joined: Mon May 22, 2006 4:28 am
Posts: 56
Location: Göteborg, Sweden
max wrote:
set the full class name in the Reverse Engineering strategy field when doing the reverse engineering.


I tried that, but I get a java.lang.ClassNotFoundException.
"Could not create or find \MycompanyPersistence\hibernate\src\java\com\mycompany\persistenceutils\RevEngStrategy.java with one argument delegate constructor"

the path looks like this:

\MyCompanyPersistence\hibernate\src\java\com\mycompany\persistenceutils\RevEngStrategy.java

Thanks
Jacob

One update:
I wrote this path myself, when I try to use the browse... button I only have this under "Choose a reverse engineering strategy:
org.hibernate.cfg.reveng.ReverseEngineeringStrategy

and under matching types I have:
ReverseEngineeringStrategyUtil - org.hibernate.cfg.reveng -C:\DevArea\MycompanyPersistence\hibernate\toolslib\hibernate-tools.jar

I can not browse to my own class....


Last edited by Jake123 on Fri Sep 15, 2006 9:28 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 9:27 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you should put a *class* name not a *file* name.

so it should be: com.mycompany.persistenceutils.RevEngStrategy

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 9:38 am 
Regular
Regular

Joined: Mon May 22, 2006 4:28 am
Posts: 56
Location: Göteborg, Sweden
Hi Max,
sorry for that, but when I changed that it still does not work.

Now I get this error:
"org.hibernate.console.HibernateConsoleRuntimeException: Could not create or find com.mycompany.persistenceutils.RevEngStrategy with one argument delegate constructor"

I posted in my first posting my revengstrategy class... have I done anything wrong in that? Or why cant the console find it"?

Thanks again
Jacob


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 9:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
code looks fine.

is the class actually compiled into one of the paths you've put into the console configuration ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 10:01 am 
Regular
Regular

Joined: Mon May 22, 2006 4:28 am
Posts: 56
Location: Göteborg, Sweden
max wrote:
code looks fine.

is the class actually compiled into one of the paths you've put into the console configuration ?


Yes. in my compiled directory I find the class: It is located in
target\classes\com\mycompany\persistenceutils\RevEngStrategy.class

So what else can be the problem?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 10:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
and target\classes is in the console configuration class path ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 11:07 am 
Regular
Regular

Joined: Mon May 22, 2006 4:28 am
Posts: 56
Location: Göteborg, Sweden
the target/classes is my output folder in eclipse.

so the package declaration looks like this: com.mycompany.persistenceutils
for the RevEngStrategy class.

I thought that the console is checking my output folder and therefor start looking in target/classes after the class name I specify.
So I only put com.mycompany.persistenceutils.RevEngStrategy in the placeholder for reveng strategy in the Hibernate Code Generation console...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 11:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
ok - please read what i'm asking for!

Is it in your *console configuraiton classpath* ?
(i am *not* asking about wether it is in your eclipse project or anywhere else)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 1:10 pm 
Regular
Regular

Joined: Mon May 22, 2006 4:28 am
Posts: 56
Location: Göteborg, Sweden
max wrote:
ok - please read what i'm asking for!

Is it in your *console configuraiton classpath* ?
(i am *not* asking about wether it is in your eclipse project or anywhere else)


Ah... sorry... I forgot about the configuration console... now everything is working.... thank you very much for your help

Cheers,
Jacob


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 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.