Easy way to store and retrieve objects in Java without using a relational DB? [closed]
Asked Answered
T

9

11

Do you know of an "easy" way to store and retrieve objects in Java without using a relational DB / ORM like Hibernate?

[Note that I am not considering serialization as-is for this purpose, as it won't allow to retrieve arbitrary objects in the middle of an object graph. Neither am I considering DB4O because of its restrictive license. Thanks.]

"Easy" meaning: not having to handle low-level details such as key/value pairs to rebuild an object graph (as with BerkeleyDB or traditional caches). The same applies for rebuilding objects from a document- or column-oriented DB (CouchDB, HBase, ..., even Lucene).

Perhaps there are interesting projects out there that provide a layer of integration between the mentioned storage systems and the object model (like ORM would be for RDBMSs) that I am not aware of.

Anyone successfully using those in production, or experimenting with persistence strategies other than relational DBs? How about RDF stores?

Update: I came across a very interesting article: A list of distributed key-value stores

Tetrafluoroethylene answered 14/1, 2009 at 16:10 Comment(5)
Maybe you should rephrase your question to something like "Easy way to store and retrieve objects in Java without using a relational DB, object serialization or any GPL-licenced product?". I'd be curious to know about such a solution too, btw.Convey
thanks, but i think that title would be way too long!Tetrafluoroethylene
I agree. I see 2 options here: write to file system directly (serialization) or use a database. You don't want either of these? Or do you want something like DB40 but with a less restrictive license?Saks
I don't follow your objection to serialisation. You can serialise maps, have maps to serialised objects, etc.Knowledge
@Tom: maybe i wasn't clear enough there. what i'm saying is, if i serialize i.e. a zoo object that contains 5 animals, how could i possibly retrieve/deserialize any given animal independently? you see?Tetrafluoroethylene
T
0

I guess I have found a sort of answer to my question.

Getting the document-oriented paradigm mindset is no easy task when you have always thought your data in terms of relationships, normalization and joins.

CouchDB seems to fit the bill. It still could act as a key-value store but its great querying capabilities (map/reduce, view collations), concurrency readiness and language-agnostic HTTP access makes it my choice.

Only glitch is having to correclty define and map JSON structures to objects, but I'm confident I will come up with a simple solution for usage with relational models from Java and Scala (and worry about caching later on, as contention is moved away from the database). Terracotta could still be useful but certainly not as with an RDBMS scenario.

Thank you all for your input.

Tetrafluoroethylene answered 1/3, 2009 at 23:1 Comment(0)
S
5

I would suggest Hibernate because it will deal with most of the ugly details that bog developers down when using a database while still allowing for the optimizations that have been made to database software over the years.

Slapbang answered 14/1, 2009 at 16:17 Comment(1)
thanks for your answer, but i just said i don't want to use DBs! that implies not using ORMs i guess... i'm looking for alternative stuff. also as i stated in the post, no serialization!!!Tetrafluoroethylene
D
2

NeoDatis looks interesting. It is licensed under the LGPL, so not quite as restrictive as the GLP proper.

Check out their 1 minute tutorial to see if it will work for your needs.

Dissolve answered 14/1, 2009 at 16:32 Comment(3)
thanks steve. i actually know neodatis pretty well (i even wrote warp-persist-neodatis integration) - i just stopped using it because it was really buggy, but i should give it a shot once again. damn i guess i'm being too demanding here... :)Tetrafluoroethylene
Were you very involved with the NeoDatis project? Most of the open source project I've been around are fairly responsive to bug reports / patches. I haven't been involved with NeoDatis - so they may be the exception :)Dissolve
yes, the guy is quite responsive. but he's alone and problem is i kept on having problems all the time - so i'm not sure about stability. i'm going to check out again now :) and have a look at the source codeTetrafluoroethylene
B
2

I would like to recommend XStream which simply takes your POJOs and creates XML out of them so you can store it on disk. It is very easy to use and is also open source.

Brazee answered 14/1, 2009 at 16:58 Comment(0)
G
1

I'd recommend Hibernate (or, more general, OR-mapping) like Matt, but there is also a RDBMS at the backend and I'm not so sure about what you mean by

...without using a relational DB?...

It also would be interesting to know more about the application, because OR-mapping is not always a good idea (development performance vs. runtime performance).

Edit: I shortly learned about terracotta and there is a good stackoverflow discussion here about replacing DBs with that tool. Still experimental, but worth reading.

Gluck answered 14/1, 2009 at 16:22 Comment(1)
thanks. i meant "take out of the picture RDBMSs and ORMs"Tetrafluoroethylene
G
1

I still think you should consider paying for db4o.

If you want something else, add "with an MIT-style license" to the title.

Gasaway answered 14/1, 2009 at 17:34 Comment(1)
i don't think so. thanks for your commentTetrafluoroethylene
A
0

Check out comments on Prevayler on this question. Prevayler is a transactional wrapper around object serialization - roughly, use objects in plain java and persist to disk through java API w/o sql, a bit neater than writing your own serialization.

Caveats- with serialization as a persistance mechanism, you run the risk of invalidating your saved data when you update the class. Even with a wrapper library you'll probably want to customize the serialization/deserialization handling. It also helps to include the serialVersionUID in the class so you override the JVM's idea of when the class is updated (and therefore can't reload your saved serialized data).

Ashlynashman answered 14/1, 2009 at 16:25 Comment(0)
S
0

Hmm... without serialization, and without an ORM solution, I would fall back to some sort of XML based implementation? You'd still have to design it carefully if you want to pull out only some of the objects from the object graph - perhaps a different file for each object, where object relationships are referenced by a URI to another file?

I would have said that wasn't "easy" because I've always found designing the mapping of XML to objects to be somewhat time consuming, but I was really inspired by a conversation on Apache Betwixt that has me feeling hopeful that I'm just out of date, and easier solutions are now available.

Sullivan answered 14/1, 2009 at 16:49 Comment(1)
Isn't this just serialization?Saks
E
0

Terracotta provides a highly available, highly scalable persistent to disk object store. You can use it for just this feature alone - or you can use it's breadth of features to implement a fully clustered application - your choice.

Terracotta:

  • does not break object identity giving you the most natural programming interface
  • does not require Serialization
  • clusters (and persists) nearly all Java classes (Maps, Locks, Queues, FutureTask, CyclicBarrier, and more)
  • persists objects to disk at memory speeds
  • moves only object deltas, giving very high performance

Here's a case study about how gnip uses Terracotta for in-memory persistence - no database. Gnip takes in all of the events on Facebook, Twitter, and the like and produces them for consumers in a normalized fashion. Their current solution is processing in excess of 50,000 messages / second.

It's OSS and has a high degree of integration with many other 3rd party frameworks including Spring and Hibernate.

Exeunt answered 17/2, 2009 at 8:21 Comment(0)
T
0

I guess I have found a sort of answer to my question.

Getting the document-oriented paradigm mindset is no easy task when you have always thought your data in terms of relationships, normalization and joins.

CouchDB seems to fit the bill. It still could act as a key-value store but its great querying capabilities (map/reduce, view collations), concurrency readiness and language-agnostic HTTP access makes it my choice.

Only glitch is having to correclty define and map JSON structures to objects, but I'm confident I will come up with a simple solution for usage with relational models from Java and Scala (and worry about caching later on, as contention is moved away from the database). Terracotta could still be useful but certainly not as with an RDBMS scenario.

Thank you all for your input.

Tetrafluoroethylene answered 1/3, 2009 at 23:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.