-->
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.  [ 1 post ] 
Author Message
 Post subject: Generating POJOs and customizing order of constructor params
PostPosted: Fri Apr 20, 2012 8:20 am 
Newbie

Joined: Wed Apr 18, 2012 4:37 am
Posts: 7
Hi all,

I have been searching high and low in the forums and the web to find a solution to my problem and I lost quite a few hair already :P
There was also already another user asking a similar question, but did not get an answer up until now:
https://forum.hibernate.org/viewtopic.php?f=1&t=1006040&p=2454320#p2454320

My current eclipse project uses the hibernate reveng.xml together with a generic exporter and custom templates to generate my pojos.
I already have generated classes in my project and it seems, that the order of those parameters is not equal to the ones generated with my current setup. I also found out, that the eclipse DTP changes the order of columns when generating the DDL - this may be the problem.
Because of this, I was hoping, I could just overwrite the automatic method of Hibernate generating the code for the POJOs constructor parameter orders.

What I need:
Code:
public MyClass(final Users users, final Sites sites,  final Roles roles){...}


What I get instead:
Code:
public MyClass(Sites sites, Users users, Roles roles){...}

In order to add the keyword "final" infront of each parameter, I would just edit the template
PojoConstructors.ftl to include the word "final" infront of each parameter.

My questions:
  • Is there a better way of adding the keyword "final"?
  • How does Hibernate know, it is supposed to be "final"?
  • Is there also a way of manually changing the order of the parameters within the generated code for the constructors (e.g. some magic meta attribute within the reveng.xml)?

Additional information about my current setup:
* Oracle 10g enterprise edition database
* Suse Linux Enterprise Edition (SLES) 11 (64bit) with Service Pack 2.
* Eclipse IDE (Indigo)
Version: Indigo Release
Build id: 20110615-0604
* java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)
* JBoss Hibernate Tools Version: 3.4.0.v20120307-2104-H60-Beta1

I connect to the database using an Oracle Thin Driver provided with a jar: /u01/app/oracle/product/11.2.0/xe/jdbc/lib/ojdbc6_g.jar.
Within Eclipse (using DTP), I get the following information about the driver:
Oracle: 0.2.0.1.0 - 64bit Production
The following technologies are available on the server: JDBC: 11.2.0

On opening my driver-jar, I have the following info within the Manifest:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_24-rev-b08 (Sun Microsystems Inc.)
Implementation-Vendor: Oracle Corporation
Implementation-Title: JDBC debug
Implementation-Version: 11.2.0.2.0
Repository-Id: JAVAVM_11.2.0.2.0_LINUX_100812.1
Specification-Vendor: Sun Microsystems Inc.
Specification-Title: JDBC
Specification-Version: 4.0
Main-Class: oracle.jdbc.OracleDriver
sealed: false

Name: oracle/sql/converter/
Sealed: false

Name: oracle/sql/
Sealed: false

Name: oracle/sql/converter_xcharset/
Sealed: false


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

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.