-->
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: Problem with blob/image mapping in SQLServer
PostPosted: Fri Nov 05, 2004 6:25 am 
Beginner
Beginner

Joined: Tue Jun 22, 2004 7:50 am
Posts: 25
I'm having a problem when swtching from MySQL: where everything works, to SQLServer 2000 where hibernate seems to be having a problem with a particular "image" column.

I use a UserType to map the blob (BinaryBlobType) which I stole from one of the other postings here. In this case it perfectly in MySQL but not in SQLServer. Strangely, for another class that also maps an image/blob, it works perfectly in both places!

However for this particular mapping I get a SQL Exception saying the amount of data in the stream is not the same as the length set. This is the method in BinaryBlobType where the exception is being thrown:

Code:
public Object nullSafeGet(ResultSer rs, String[] name, Object owner) throws HibernateException, SQLException
{
    Blob blob = rs.getBlob(names[0]);
    return blob.getBytes(1, (int)blob.length());
}


As I say, this works perfectly for another class that has a column mapped to an image column, and it works in both cases on MySQL but not on SQLServer.

This is the mapping:

Code:
<property name="content" type="BinaryBlobType">
    <column name="fileContent"/>
</property>


What gets stranger is if I comment out this mapping then I get another, equally inexplicable error for another class (just to re-iterate this works PERFECTLY with MySQL) that cglib can't find a setter for FileLenght : despite the fact there is a setFileLength method, that's public and takes the correct type. (Well let's face it, it wouldn't work with MySQL either if it wasn't now would it??).

The only difference between connecting to SQLServer and MYSQL is the driver (jtds for SQLServer). But, again, this same mapping works fine in another class.

Help!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 05, 2004 7:21 am 
Beginner
Beginner

Joined: Tue Jun 22, 2004 7:50 am
Posts: 25
OK problem solved.

It went away if, instead of trying to load in every instance, I loaded just a single one.

On MySQL I only have a small test set of data, however on SQLServer I have several thousand instances of the entities involved.

The final fix was to add in some lazy loading.

So it looks like a mis-reported out of memory exception.


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.