-->
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.  [ 2 posts ] 
Author Message
 Post subject: Can i force code generator to omit a constructor's argument
PostPosted: Mon Feb 07, 2005 4:36 pm 
Newbie

Joined: Thu Jun 17, 2004 4:16 pm
Posts: 18
Hi all,
I am a new hibernate developers so my question might seem easy...

I have the following mapping xml...

------------------------------------------------------------------------
<class name="essex.cc403.hbeans.User" table="USER">
<id name="id" type="int" column="USER_ID">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>

...

<many-to-one name="rank" class="essex.cc403.hbeans.Rank" column="RANK_ID"/>

</class>

<class name="essex.cc403.hbeans.Rank" table="RANK">

<id name="rankID" type="int" column="RANK_ID">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>

...

<set name="Users" cascade="all" inverse="true" lazy="true">
<key column="RANK_ID"/>
<one-to-many class="essex.cc403.hbeans.User"/>
</set>

</class>

------------------------------------------------------------------------

When I generate the Java classes I get the following constructors for Rank...

------------------------------------------------------------------------
Code:
  /** full constructor */
    public Rank(String name, boolean canBook, boolean canDeleteAccount, boolean canViewBookings, boolean canEditBookings, boolean canCancelBookings, Set Users) {
        this.name = name;
        this.canBook = canBook;
        this.canDeleteAccount = canDeleteAccount;
        this.canViewBookings = canViewBookings;
        this.canEditBookings = canEditBookings;
        this.canCancelBookings = canCancelBookings;
        this.Users = Users;
    }

    /** default constructor */
    public Rank() {
    }

    /** minimal constructor */
    public Rank(boolean canBook, boolean canDeleteAccount, boolean canViewBookings, boolean canEditBookings, boolean canCancelBookings, Set Users) {
        this.canBook = canBook;
        this.canDeleteAccount = canDeleteAccount;
        this.canViewBookings = canViewBookings;
        this.canEditBookings = canEditBookings;
        this.canCancelBookings = canCancelBookings;
        this.Users = Users;
    }

------------------------------------------------------------------------

Is it possible to give a directive inside the mapping xml file so that the code generator will omit the Set Users argument at the constructor?


Top
 Profile  
 
 Post subject: XDoclet
PostPosted: Mon Feb 07, 2005 4:57 pm 
Newbie

Joined: Tue Dec 14, 2004 2:57 pm
Posts: 12
I don't belive so. I know I started out using the code generator, but soon found it insufficient once I inevitibly wanted to include some buisness logic. However I lothed having to keep updating my mappings everytime a made a change to my code: enter XDoclet.
If all you're after is keeping everything in one place, it is definitely better to generate the mapping rather then the code.

--Ryan


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