-->
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: Customizing POJO code generation
PostPosted: Wed Dec 24, 2008 6:39 am 
Newbie

Joined: Wed Dec 24, 2008 5:43 am
Posts: 2
Hello all:

I'm starting with hibernate tools. It works quite well, but there's a feature that I don't know how to use: the custom code generation.

First of all, I'm using the "3.2.4 CR1" version of the eclipse plugin, in "Ganymede". The pojo's are generated fine with the default configuration, but I want more: I want to generate a pair of extra annotations for the getter of the id column. I've looked at the class "org.hibernate.tool.hbm2x.pojoEntityPOJOClass", at method "generateAnnIdGenerator()". It seems as it is ready to check if a sequence generator is defined:

Code:
if("sequence".equals(strategy))
                    {
                        builder.resetAnnotation(importType("javax.persistence.GeneratedValue")).addAttribute("strategy", staticImport("javax.persistence.GenerationType", "SEQUENCE")).addQuotedAttribute("generator", "generator");
                        idResult.append(builder.getResult());
                        builder.resetAnnotation(importType("javax.persistence.SequenceGenerator")).addQuotedAttribute("name", "generator").addQuotedAttribute("sequenceName", properties.getProperty("sequence", null));
                        wholeString.append(builder.getResult());
                    }




but I don't know how to specify it. The id generator that I want to create is:

Code:
@Id
@GeneratedValue(generator="myGen")
@SequenceGenerator(name="myGen", sequenceName="${currentTableName}_SEQ", allocationSize=1)



...when ${currentTableName} must be changed at generation time for all the pojo's.


Can you help me? Where must I put my custom code or configuration?

Thanks in advance:

Carlos.


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.