Hi,
Thanks for the response Dave. Your work-around works a treat for Boolean types. Unfortunately, it doesn't work with Oracle Clobs. The problem with Clob is that the JDBC type is a Clob, the hibernate type needs to be Text, but the Java type needs to be a String. Currently, the reveng.xml schema does not support 3 different types nor does hbm2java produce proper @Type annotations.
Using your work-around for Booleans, I can add this to the Ejb3PropertyGetAnnotation.ftl:
Code:
<#if pojo.getJavaTypeName(property, jdk5)="Clob">
@${pojo.importType("org.hibernate.annotations.Type")}(type="text")
</#if>
which will render the appropriate Type annotation, but it also uses Clob as the Java type for the setters, getters, fields, and constructors. In this case, what I need is a String. I modified other ftl files to change the setters, getters, and fields to change occurrences of Clob to String, but because the constructors are generated within the Pojo java code using methods like this:
Code:
${c2j.asParameterList(pojo.getPropertyClosureForMinimalConstructor(), jdk5, pojo)}
I am unable to change the Clob type to a String in the constructor and manual changes to the domain model is required. Something I want to avoid.
Rather than hacking my way through the ftl files to work-around this, perhaps the reveng.xml schema needs the flexibility to do something like this:
Code:
<hibernate-reverse-engineering>
<type-mapping>
<sql-type jdbc-type="CLOB" java-type="java.lang.String" hibernate-type="org.hibernate.type.TextType" />
</type-mapping>
...
</hibernate-reverse-engineering>
which would generate this:
Code:
private String stringX;
... appropriate constructors as needed
@Type(type="text")
public String getStringX(){
return this.stringX;
}
public void setStringX(String stringX) {
this.stringX = stringX;
}
The java type would need be an optional attribute.
Of course, if there is a solid work-around for this I'm very happy to try it!
Thanks!
Rob