We have a table that has more than one columns that should map to blob. The problems is that Hibernate tries to map all of this columns to 'long raw' on Oracle database server (10g) event if the server does not permit more than one column of type long raw in a table. I try to keep mapping as general as possible because the application has to work with MySQL, Oracle and MsSQL database servers without code modifications.
Here is the mapping I came up with:
Code:
<hibernate-mapping>
<class
name="mypackage.MyClass"
table="MYTABLE">
...
<property name="privateKey" type="java.security.PrivateKey"
column="PRIVATEKEY" length="50000" />
<property name="publicKey" type="java.security.PublicKey"
column="PUBLICKEY" length="50000" />
<property name="certificate"
type="java.security.cert.X509Certificate" column="CERTIFICATE"
length="50000" />
...
</class>
</hibernate-mapping>
I tried to specify blob as desired sql-type but the sql type's names are different on different database servers.
Is there any way to map this classes to blob on Oracle database servers without explicitly doing this with the sql-type attribute? The temporary solution we came up was changing
registerColumnType( Types.VARBINARY, "long raw" );
line in org.hibernate.dialect.Oracle9Dialect and org.hibernate.dialect.Oracle8iDialect with
registerColumnType( Types.VARBINARY, "blob" );
line. It seams to be working just fine, but the question is how could we map objects to columns in order to achieve object serialization without modifying hibernate's classes?
Thanks,
--Robert