-->
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: Is generating "protected" setters possible via rev
PostPosted: Fri Aug 01, 2008 11:44 am 
Regular
Regular

Joined: Tue Jul 29, 2008 4:15 pm
Posts: 62
Location: Dallas, TX US
Hibernate version: hibernate-annotations 3.3.1, hibernate-commons-annotations 3.3.0.ga, hibernate-entitymanager3.3.2, hibernate-core 3.2

Name and version of the database you are using: Orcale XE 10g Release 2 (10.2)

I am using Hibernate Tools 3.2.2.Beta1 with Eclipse 3.3.2

Is there a way to tell the reverse engineering process in the Hibernate Tools plugin for Eclipse to generate "protected" setters via the reveng.xml file or a custom ReverseEngineering Strategy?

Thanks!

_________________
pouncilt


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 05, 2008 4:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes, reveng.xml supports adding <meta> tags and the same does the programmatic strategy.

Just set in reveng.xml <meta attribute="scope-set">protected</meta>

or return a properties set with scope-set = protected.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 05, 2008 12:05 pm 
Regular
Regular

Joined: Tue Jul 29, 2008 4:15 pm
Posts: 62
Location: Dallas, TX US
Max,

Thanks for reply to my post.

When I first added this tag it didn't work for me because I was trying to add it inside the column tag of the table tag, like so:
Code:
<table name="COMMAND_ELEMENTS" class="CommandElementVO">
        <primary-key>
            <!-- setting up a specific id generator for a table -->
            <generator class="sequence">
                <param name="sequence">JEDI_DEV.COMMAND_ELEMENTS_SEQ</param>
            </generator>

            <key-column name="ID">
                <meta attribute="scope-set">private</meta>
            </key-column>
        </primary-key>
</table>


But I see now it only works out side of the column tag, like so:
Code:
<table name="COMMAND" class="CommandVO">
        <meta attribute="scope-set">private</meta>
        <primary-key>
            <!-- setting up a specific id generator for a table -->
            <generator class="sequence">
                <param name="sequence">COMMAND_SEQ</param>
            </generator>
            <key-column name="ID" property="getID"/>
        </primary-key>
</table>


This works great when you are not extending a Base Class. However when you are extending a Base Class that defines the setter method for the id as private and defines the getter method for the id as public, how do you tell hibernate not to generate the setter method for the id and to delegate the getter method for the id?

I am guessing to accomplish this, one would have to implement a custom programmatic solution or strategy. I never implemented a programmatic strategy before, but feel I can do it if I had good instructions.


Thanks!

_________________
pouncilt


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 05, 2008 12:31 pm 
Regular
Regular

Joined: Tue Jul 29, 2008 4:15 pm
Posts: 62
Location: Dallas, TX US
Just wanted to added that my mapping strategy is "one table per concrete class". Maybe this is not the best mapping strategy for me to use; since I am trying to extend a base class and then delegate my SomeClass.getID() method to BaseClass.getID() method and set my SomeClass.setID() method to private. Although I am still very interested in implement a custom programmatic solution or strategy to accomplish this, I am now conisdering implementing another mapping strategy that suites my needs.


Any suggestion is welcomed!

Thanks!

_________________
pouncilt


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 05, 2008 1:53 pm 
Regular
Regular

Joined: Tue Jul 29, 2008 4:15 pm
Posts: 62
Location: Dallas, TX US
After reviewing the four different mapping strategies, Map one table per concrete class, Map one table per concrete class with union-subclass mapping, Map one table per class hierarchy, and Map one table per subclass, I still want to stick to the Map one table per concrete class mapping because its the most simplist and efficient.

With that being said, how do I implement a custom programmatic solution or strategy to accomplish delegating my getID() method to my super getID() method and how do I tell hibernate to omit the setID() method in my subclass because it is already implemented in my superclass setID() method?

Thanks Again!

_________________
pouncilt


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 05, 2008 6:36 pm 
Regular
Regular

Joined: Tue Jul 29, 2008 4:15 pm
Posts: 62
Location: Dallas, TX US
I think I will try playing around with the template. See Hibernate Reference Guide 6.1.2.1. I basically want the pojo/PojoPropertyAccessor.ftl template file to detemine if there is an extended class for the pojo and if so, use the extended class to determine when and how to include the property accessor methods to the pojo.

I am new to Hibernate Tools and even more new to FreeMarker. Any help in figuring out this logic is much appreciated.

Thanks!

_________________
pouncilt


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 06, 2008 2:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the simplest method:

Assume the method is always is called setID and just check in the .ftl file that when you bump into that property that you skip the generation or do something else special.

the advanced/complete method:

use toolclass property (see doc for that) to get access to a utility class of yours that uses reflection to load the base class and checks if it has the method already and then do the generation based on that.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 07, 2008 2:20 pm 
Regular
Regular

Joined: Tue Jul 29, 2008 4:15 pm
Posts: 62
Location: Dallas, TX US
Max,

Thanks to your advise I am able to create my POJOs they I prefer to.

Thanks!

_________________
pouncilt


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.