• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Not serializable objects

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am having trouble saving objects into a blob.
I get the NotSerializableException.
From what I have gathered, the object I am trying to save cannot be serialized. I also cannot serialize it since it is an automatically generated object from an SDK i have no control over. What I am trying to do is find a workaround on how to save an object into a blob without serializing it. Can someone help me with this please?

Thank you
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to store an object itself, it has to be serializable
If it is not possible for you to make it serializable, you have to store each and every state of an object into a file, and when you want the object back , you have to create a new object and flush tht object with stored states
 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi suji

i am not sure what you mean by store each and every state into a file
 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
help
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like it will not be possible to use standard Java serialization here. However one simple-to-use alternative would be to use XStream to convert the object to an XML representation instead. (See the two minute tutorial, it's very easy to use.) In this case you don't really need a BLOB - character-based types like CLOB or VARCHAR might be slightly more appropriate. But BLOB would still work.
 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks. i'll take a look at that one and see what i can do.
 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

can anyone help me with xtream?
i read their 2 minute tutorial and its different from what i have.
i dont have a class, and i just implement an interface.
that interface produces a template object which i have to save into a Blob in Oracle. i need to serialize that object for it be saved into oracle.
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Bernard]: i dont have a class, and i just implement an interface.

If you have an object, it must be a concrete class instance. That class may implement an interface, and maybe you don't know what the class is (perhaps it's anonymous, for example), but there is a class of some sort. You could call getClass() to find out what it is, exactly.

Regardless, You don't need to know the class to make this work. Skipping past various ways that you could customize the process, you can just use

I chose UTF-8 because that's a common encoding guaranteed to always work, for any strange character that may be present. You can probably replace it with something else if you want.

Later you can reverse the process:

If this isn't working for you, please provide more detail about what exactly goes wrong.
 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jim,

Thanks for the explanation.

My object is a fingerprint template. I just learned that it can't be serialized because it is a set of mathematical equations. The fingerpitn kinda gets encrypted resulting in the fingerprint template. And it needs to be saved into a blob. So far, I have found no way of saving an object into a blob without serializing it, except maybe for xtream which i learned here, and i am still exploring it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic