-->
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.  [ 5 posts ] 
Author Message
 Post subject: Using CustomMappingStrategy to specify lazy relationships
PostPosted: Wed Oct 11, 2006 1:40 pm 
Newbie

Joined: Wed Sep 06, 2006 10:06 am
Posts: 11
Location: Lisbon, Portugal
Hibernate version:3.2.0.cr2

I'm using reverse engineering to update my mapping files, but when i do this all the changes that i've made to the hibernate mapping files were lost.

To prevent this and after reading the documentation i've decided to build a Custom Reveng Strategy class extending the class DelegatingReverseEngineeringStrategy and reimplementing the method isForeignKeyCollectionLazy(...) cause all the changes that i pretend to do are putting some references to other tables eager changing the result of this method to false. But when i regenerate the mapping files all stay the same and any change was made.

I would like to know if i have to change something else or if i'm using the correct method to do the Custom Reveng Strategy?
Is there any javadoc of the DelegatingReverseEngineeringStrategy available?

Thank's in advance,
Best regards,
António Silva.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 12, 2006 2:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
overriding isForeignKeyCollectionLazy just decides if a collection created on a foreignkey should be lazy="true" or lazy="false".

The reverse engineering currently overrides all files to ensure that the ending result actually works. If you want to edit the files then copy them to a different location.

What is it exactly you are doing in your edits ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 12, 2006 6:49 am 
Newbie

Joined: Wed Sep 06, 2006 10:06 am
Posts: 11
Location: Lisbon, Portugal
Hi Max,
Thank's for your answer.

Well what i really want to do is most of the time is to put the value of the property lazy=false and the value of the property outer-join= true to change the collection to eager.

If the isForeignKeyCollectionLazy method only changes the lazy property will not do what i want.

But at the moment i'm using this piece of code bellow for testing and changing the return of the isForeignKeyCollectionLazy method to false or true will not change nothing in my generated mapping files.

Code:
public class DigitalisRevengStrategy extends DelegatingReverseEngineeringStrategy {

   public DigitalisRevengStrategy(ReverseEngineeringStrategy revStrat) {
      super(revStrat);
      // TODO Auto-generated constructor stub
   }

   @Override
   public boolean isForeignKeyCollectionLazy(String arg0, TableIdentifier arg1, List arg2, TableIdentifier arg3, List arg4) {
      return false;
   }
}


Note 1: I'm using this with the eclipse reveng tool not thru ant hibernate tool.
Note 2: I've allready put some debug info in the method isForeignKeyCollectionLazy just to be sure if the method is called and i confirmed that.

Soo my first question still is how can i change the collection attributes to lazy=false and outer-join=true in reverse engineering time ?

And Is the situation that i've reported a bug or i'm really missing it :) ?

Note 3: I'm still a newbie in Hibernate.

Thank's in advance.

_________________
António Silva


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 12, 2006 7:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
couple of things:

1) don't use outer-join=true, use fetch="join" (outer-join is the old syntax)

2) if you want lazy="true" then your method should return true, not false

3) fetch is not overridable via reveng.xml (yet) you will have to customize the templates if you want that.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 12, 2006 7:20 am 
Newbie

Joined: Wed Sep 06, 2006 10:06 am
Posts: 11
Location: Lisbon, Portugal
Hi Max,

I was just trying to do it without changing the templates. (Now i'm not just an Hibernate begginer but a freemarker too :) )

Thank's again.

_________________
António Silva


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.