Hi xiaofong,
I am not sure this will help you to map Geometry type fields, but to map Oracle CLOB() type fields to String, here is the user type class:
Code:
public class OracleClobStringType extends ClobStringType
{
//Oracle clob handler
private static OracleLobHandler oracleLobHandler = new OracleLobHandler();
public static final String WEBSPHERE_CLASS_NAME="com.ibm.websphere.management.AdminServiceFactory";
static
{
try
{
ClassUtils.forName(WEBSPHERE_CLASS_NAME);
//we are running in Websphere
oracleLobHandler.setNativeJdbcExtractor(new WebSphereNativeJdbcExtractor());
}
catch (ClassNotFoundException e)
{
//assume we are in Tomcat
oracleLobHandler.setNativeJdbcExtractor(new CommonsDbcpNativeJdbcExtractor());
}
}
public OracleClobStringType()
{
super(oracleLobHandler, LocalSessionFactoryBean.getConfigTimeTransactionManager());
}
}
In the static block I initialize the app server-specific NativeJdbcExtractor, in this case the app server could be either Websphere or Tomcat. To map Java String field to Oracle clob column use this annotation:
Code:
@org.hibernate.annotations.Type(type="org.xyz.OracleClobStringType")
@Column(name = "COMMENT", nullable = true)
public String getComment()
{
return this.comment;
}
In order to support a Geometry type field you may need to implement org.hibernate.usertype.UserType from scratch and use Oracle-supplied jars to convert Geometry types to/from String.
Hope this helps.