-->
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.  [ 1 post ] 
Author Message
 Post subject: Persisting blobs (type=serialize)
PostPosted: Fri Aug 15, 2008 2:17 pm 
Newbie

Joined: Fri Aug 15, 2008 1:55 pm
Posts: 1
As shown below, I have a class Foo with a data member of type Bar. The data member, bar, is mapped as "Serializable". Hence during a hibernate commit to the database its Serialization code is called (readExternal and writeExternal).

During performance testing we noticed that each call to commit an instance of "Foo" calls the Serialization code for the "bar" data member 4 times AND the De-Serialization code 1 time. The sequence is as follows:
For each bar:
Serialize bar;
DeSerialize bar;
Serialize bar;
Serialize bar;
Serialize bar

The data member "bar" (of type Bar) is stored as a Blob in the database. This object can get to be quite large. Hence the multiple Serializations and De-Serializations add up very fast.

Does anyone know why this is done this way and if there's a way to avoid the multiple calls?

Thanks
Zac George

Hibernate version: 3

// Mapping file
<hibernate-mapping
package="com.makesys.common.utilities.config">
<class name="Foo" table="FOO">
...
<property name="bar"
column="bar"
type="serializable"
not-null="false"
access="field"/>
</class>

// class Foo
public class Foo
{
private Bar bar; // Bar implements Serializable
...
}

//class Bar
public class Bar
{
public void writeExternal(ObjectOutput out)
{
... // code to serialize bar
}

public void readExternal(ObjectInput in)
{
... // code to de-serialize bar
}
}


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

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.