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.