-->
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.  [ 4 posts ] 
Author Message
 Post subject: HowTo rewrite reveng strategy?
PostPosted: Thu Dec 30, 2010 10:19 am 
Newbie

Joined: Thu Dec 30, 2010 10:13 am
Posts: 2
I have two problems with the Pojo reverse engeneering:

Sequences and cascades have to be generated.

Primarykeys with Sequences should look like this:
Code:
   @Id
   @Column(name = "id", unique = true, nullable = false)
   @GeneratedValue (strategy = GenerationType.SEQUENCE, generator ="gen")
   @SequenceGenerator( name="gen" , sequenceName="public.mytable_id_seq", allocationSize=1)   


Cascades should look like this:
Code:
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)


I am trying to adopt this by rewriting the reveng strategy:

Code:
import java.util.Properties;

import org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.TableIdentifier;

public class ExampleStrategy extends DelegatingReverseEngineeringStrategy {


    public ExampleStrategy(ReverseEngineeringStrategy delegate) {

     super(delegate);

    }
   
      public Properties getTableIdentifierProperties(TableIdentifier arg0) {
         
            Properties pr = new Properties();
            pr.put("sequence", "public."+arg0.getName()+"_id_seq");
            return pr;
         }

         public String getTableIdentifierStrategyName(TableIdentifier arg0) {
            return "sequence";
         }


   }


This is not flexible enough to adopt it like I need it. Is there a possibility to go down to string-building level to write what I need? Is there a howto that explaines, how to rewrite the strategy and match ones needs? What are the possibilities?


Top
 Profile  
 
 Post subject: Re: HowTo rewrite reveng strategy?
PostPosted: Mon Jan 03, 2011 10:02 am 
Newbie

Joined: Thu Dec 30, 2010 10:13 am
Posts: 2
I found a few ftl files in some subdirs like pojo, but this seems another way to adopt the generation. Since this again seems to be totally undocumented I would like to stick to rewriting the strategy, like I have begun. Is there anywhere more documentation or are there some examples?


Top
 Profile  
 
 Post subject: Re: HowTo rewrite reveng strategy?
PostPosted: Wed Jan 05, 2011 9:43 am 
Senior
Senior

Joined: Fri May 08, 2009 12:27 pm
Posts: 168
These links all require a user name and a password.


Top
 Profile  
 
 Post subject: Re: HowTo rewrite reveng strategy?
PostPosted: Thu Jan 06, 2011 11:21 am 
Senior
Senior

Joined: Fri May 08, 2009 12:27 pm
Posts: 168
Links now work from the outside without a login.

Though I have to say that they're just barely better than nothing.
Reading sources takes a lot of time, which is particularly unpleasant if you're after just a tiny bit of information.
Worse, it doesn't tell you what will work tomorrow. The sources give no guarantees about how the next version will work. That's why good docs are so all-important.


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