-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Oracle Long datatype and EntityPersister
PostPosted: Thu Nov 18, 2004 1:04 pm 
Newbie

Joined: Thu Nov 18, 2004 12:28 pm
Posts: 1
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);
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 18, 2004 4:29 pm 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
In Hibernate 3 you'll have the possibility to write the complete SQL for the CRUD operations yourself.
See http://blog.hibernate.org/cgi-bin/blosxom.cgi/Gavin%20King/customsql.html

HTH
Ernst


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.