Hibernate version: 2.1
Name and version of the database you are using:Oracle 9i
I've come across a problem with using Oracle SQL Long type and Hibernate.
The Oracle schema is using a depricated Long type (2Gig ASCII), we are unable to convert this to a LOB due to pl/sql dependencies.
I am trying to create a Hibernate type and EntityPersister to work around the problem.
There are a few limitation when dealing with the LONG data types in java.
1. The LONG must be referenced as the last element in the select, insert, update statement.
2. The LONG must be read in as ASCII.
We have created a usertype that works, the problem we are having is forcing Hibernate to make the LONG type the last element in the statement.
I've looked at extending the EntityPersister class and overriding the method that generates the statement, but this doesn't seem straight forward when joins are involved.
The only other way I thought of is using dynamic proxies to intercept the requests. Don't really want to go down this route at the moment.
Has anyone else solved this problem or could give advice on extending the EntityPersister.
Below is the method for reading a LONG type.
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException
{
InputStream data;
StringBuffer bf = new StringBuffer();
int chunk;
data = rs.getAsciiStream(names[0]);
try
{
while ((chunk = data.read()) != -1)
{
bf.append((char) chunk);
}
return bf.toString();
}
catch (IOException ex)
{
throw new HibernateException("IO Exception occured reading Oracle LONG type: ", ex);
}
}
|