You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Kristian Waagan <Kr...@Sun.COM> on 2008/02/04 11:14:12 UTC

Should EmbeddedSimpleDataSource be serializable?

Hello,

I was working on a test for serializing and deserializing data sources, 
when I found out that EmbeddedSimpleDataSource can't be serialized.

Should it be possible to serialize EmbeddedSimpleDataSource?

The @serial tags suggest so, and (at least some of) the intended 
platforms/JVMs include java.io.Serializable. However, they do not 
support javax.naming.Referenceable. This fact may be the cause of the 
problem, as Derby has a ReferenceableDataSource that the other data 
source implementations inherit from. It is this class that implements 
java.io.Serializable.

Fixing the problem can be as simple as implementing 
java.io.Serializable, but there might be more to it (adding 
serialVersionUID?) and I do not know if it is even supposed to be 
serializable.



-- 
Kristian

Re: Should EmbeddedSimpleDataSource be serializable?

Posted by Kristian Waagan <Kr...@Sun.COM>.
Daniel John Debrunner wrote:
> Kristian Waagan wrote:
>> Hello,
>>
>> I was working on a test for serializing and deserializing data 
>> sources, when I found out that EmbeddedSimpleDataSource can't be 
>> serialized.
>>
>> Should it be possible to serialize EmbeddedSimpleDataSource?
> 
> When I added EmbeddedSimpleDataSource I intentionally did not make it 
> serializable, not sure where the @serial tags came from. I saw creating 
> data sources from a stored representation as more a J2EE capability 
> (e.g. appservers). I thought that it was unlikely that J2ME applications 
> would need to have stored data sources, more likely that they would just 
> hard code the data source for that specific application.
> 
> Note that the regular data sources have actually three ways of being 
> stored, serializable, referencable or as a class name and a set of java 
> bean properties. The latter approach will also work for 
> EmbeddedSimpleDataSource.
> 
> So, I would say only make EmbeddedSimpleDataSource if there's some 
> demand for it, I wouldn't do it just to make it the same as the others.

Thanks for the information Dan.
I have not picked up any signs of demand for a serializable version of 
EmbeddedSimpleDataSource, I was just a bit confused by the tags and 
pieces of the code. You also point out that it is already possible to 
store the data source by using the third technique you mentioned.

I created DERBY-3387 to track improvement of the comments and a few 
pieces of code.



-- 
Kristian

> 
> Dan.


Re: Should EmbeddedSimpleDataSource be serializable?

Posted by Daniel John Debrunner <dj...@apache.org>.
Kristian Waagan wrote:
> Hello,
> 
> I was working on a test for serializing and deserializing data sources, 
> when I found out that EmbeddedSimpleDataSource can't be serialized.
> 
> Should it be possible to serialize EmbeddedSimpleDataSource?

When I added EmbeddedSimpleDataSource I intentionally did not make it 
serializable, not sure where the @serial tags came from. I saw creating 
data sources from a stored representation as more a J2EE capability 
(e.g. appservers). I thought that it was unlikely that J2ME applications 
would need to have stored data sources, more likely that they would just 
hard code the data source for that specific application.

Note that the regular data sources have actually three ways of being 
stored, serializable, referencable or as a class name and a set of java 
bean properties. The latter approach will also work for 
EmbeddedSimpleDataSource.

So, I would say only make EmbeddedSimpleDataSource if there's some 
demand for it, I wouldn't do it just to make it the same as the others.

Dan.