Oracle – Serializing objects as BLOBs in Oracle

bloboracleserialization

I have a HashMap that I am serializing and deserializing to an Oracle db, in a BLOB data type field.
I want to perform a query, using this field.
Example, the application will make a new HashMap, and have some key-value pairs.
I want to query the db to see if a HashMap with this data already exists in the db.
I do not know how to do this, it seems strange if i have to go to every record in the db, deserialize it, then compare, Does SQL handle comparing BLOBs, so i could have…select * from PROCESSES where foo = ?….and foo is a BLOB type, and the ? is an instance of the new HashMap?
Thanks

Best Solution

Here's an article for you to read: Pounding a Nail: Old Shoe or Glass Bottle

I haven't heard much about your application's underlying architecture, but I can tell you immediately that there is never a reason why you should need to use a HashMap in this way. Its a bad technique, plain and simple.

The answer to your question is not a clever Oracle query, its a redesign of your application's architecture.

For a start, you should not serialize a HashMap to a database (more generally, you shouldn't serialize anything that you need to query against). Its much easier to create a table to represent hashmaps in your application as follows:

HashMaps
--------
MapID (pk int)
Key   (pk varchar)
Value

Once you have the content of your hashmaps in your database, its trivial to query the database to see if the data already exists or produce any other kind of aggregate data:

SELECT Count(*) FROM HashMaps where MapID = ? AND Key = ?