-->
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.  [ 8 posts ] 
Author Message
 Post subject: Prefix for each class
PostPosted: Thu May 03, 2007 7:24 am 
Regular
Regular

Joined: Thu Apr 05, 2007 7:05 am
Posts: 53
Location: Troisdorf, Germany
Hi,

I have a question. I want to add a prefix to each classname. I mean that I have the table Test and I want to get the java class DatabaseTest. I already tried it with the reverse engineering strategy but it didn't worked. The result was that not a single class was produced. Here is the code I tried:

Code:
   public String tableToClassName(TableIdentifier tableIdentifier)
    {
        return "Database" + super.tableToClassName(tableIdentifier);
    }

Hibernate version: 3.2 beta 8

Name and version of the database you are using: Oracle 10g

Ciao Carina


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 10:19 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
I wanted to do something like that, I just did it in the ant tank though...
For example:
Code:
      <copy todir="${tools.dir}/hibernate/generated/tmp" includeemptydirs="false" overwrite="true">
         <fileset dir="${tools.dir}/hibernate/generated/uk/ltd/goFurther/domain/data">
            <include name="*.*" />
         </fileset>
         <globmapper from="*.java" to="*Data.java"/>
      </copy>

_________________
Everytime you get an answer to your question without giving credit; god kills a kitten. :(


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 10:45 am 
Regular
Regular

Joined: Thu Apr 05, 2007 7:05 am
Posts: 53
Location: Troisdorf, Germany
That seems to be the same stuff that I want to do. But I don't use the Ant task. Or better I know nothing about this Ant task. Till now I thought I would not need to use it directly...or is it used by hibernate tools as part of the reverse engineering function?! (Didn't get the way it exactly works by now...)


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 10:58 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
I believe that tableToClassName should return a *fully-qualifed class name*, so your method will to build "Databasecom.company.Employee".


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 11:05 am 
Regular
Regular

Joined: Thu Apr 05, 2007 7:05 am
Posts: 53
Location: Troisdorf, Germany
Ananasi wrote:
I believe that tableToClassName should return a *fully-qualifed class name*, so your method will to build "Databasecom.company.Employee".


Yes, exactly that happened. I just didn't noticed first because in my source folder are a lot of packages.
Knowing this I found a solution. It's not pretty, but it works.
Code:
public String tableToClassName(TableIdentifier tableIdentifier) {
        String name = super.tableToClassName(tableIdentifier);
        return name.subSequence(0, name.lastIndexOf(".")+1) + "Database" + name.subSequence(name.lastIndexOf(".")+1, name.length());
    }


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 11:18 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
N-te Jr. wrote:
That seems to be the same stuff that I want to do. But I don't use the Ant task. Or better I know nothing about this Ant task. Till now I thought I would not need to use it directly...or is it used by hibernate tools as part of the reverse engineering function?! (Didn't get the way it exactly works by now...)

You don't need to use an ant task to do revenge (but you can if you want), I find it nicer.

_________________
Everytime you get an answer to your question without giving credit; god kills a kitten. :(


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 11:40 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Ant gives you more fine grained control over the reverse engineering process. If you don't need that kind of control, or don't have the time to learn Ant, then use the console.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 5:56 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
I learnt Ant in a day, it's pretty easy. lol :P

_________________
Everytime you get an answer to your question without giving credit; god kills a kitten. :(


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