Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ORM Newbie queston: How to persist my OM without redundancy ???  RSS feed

Klaas van Gelder
Ranch Hand
Posts: 111
Java Linux PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am a novice at this topic and have a very urgent problem...
I have developed a Java/Swing application around a MVC architecture using an Object Model to hold my data in a redundancy-free way. Some of the objects holds collections of other objects, but every piece of the data is actually stored in one and only one object.
This is pretty straightforward. Because I needed a quick way of persisting my data, I used XStream to persist my complete OM as XML (ok, not as one XML file but a separate XML file for each of the leading OM classes).

This works, but I noticed that redundancy is created in those XStream XML files. Not strange, because in fact it is nothing else than serializing each object using a deep-copy strategy.
This is not acceptable, because modifications in object A are not reflected in object B holding a collection of object A, beause object B is serialized using its own copies of object A ! So when reading in my OM from the serialized XML files, the associations are in fact not anymore associations, but copies are created.

I guess that serialization is not the way to persist an object model with associations and aggregations... so I think of switching to some kind of ORM.

Probably this is a very trivial issue. But I have no good idea where to start... Is Hibernate the way to success ? Are there any other simple options ?
I hope for some good hints !

Best regards, Klaas
Mark Spritzler
Posts: 17309
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate is the most common. I think it is the best way to go. But there are other solutions.

1. Other Orm tools like ObjectRelationalBridge
2. JDO
3. Entity Beans
4. Code your own JDBC.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!