Hello,
I have a system using hibernate-3.2+entity-mgr+annotations that works with Oracle, PostgreSQL, MySQL5, SQLServer. I want it to also work with Sybase.
But the Sybase IMAGE column type is giving me a problem. I am mapping a java byte[] field to the appropriate database types -- such as oracle's LONGRAW -- without problems. However, since this field is used to store a large value -- raw e-mail mime data -- the mapping of byte[] TO sybase column is IMAGE, not VARBINARY(n). When I try to insert or read from this IMAGE column I get a Sybase datatype conversion error.
I don't think that a subclass of SybaseDialect that maps java btye[] to sybase VARBINARY(n) will work because the size of the data stored in the column is too big for the Sybase VARBINARY(n) type. So I'm stuck with IMAGE.
Is a custom UserType the answer? Can I make the custom UserType in such a way that it doesn't break the system when run against the other databases (oracle/sqlsserver, mysql, postgresql)?
If the UserType is the solution, how should it work? Should it alter the Sybase SQL -- and ONLY the *Sybase* SQL -- so that a CONVERT function is called during sql insert and select? Is that sensible and/or possible?
Thanks for any advice!
|