GeeCON Prague 2014*
The moose likes Object Relational Mapping and the fly likes ORM Syncronizer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "ORM Syncronizer" Watch "ORM Syncronizer" New topic
Author

ORM Syncronizer

Oshkalo Dmitry
Greenhorn

Joined: Nov 14, 2012
Posts: 2
Hello, guys!

(Sorry, if my English is not good enouth)
I have an idea of developing a tool that could be integrated into your development environment (thinking of Eclipse) that could help you when you're working on classes structure and it's relational mapping. For example, if you need to add some classes into your object model, you also have to propogate these changes to mapping file and DB schema manually. The same thing you face when you modifying you database. I want to produce a syncronizing module that will try to propogate changes automatically in both directions (from classes to mapping and database and from database to mapping and classes) according to certain mapping strategies, thus keeping co-evolution of both of your models (object and relational).
There are some tools providing various syncronization mechanisms, but all of them based on the autogeneration, so your models are offen being full re-generated. Also they support only one strategy, when every class is mapped to its own table and every class attribute has its own column. Also such tools does not provide correct strategies for inheritance, abstract classes mapping etc. - all of these makes you to perform modifications of models and mapping manually.
Do you think such idea is worth developing? Or you know some other efficient techniques for keeping object and relational models synchronized?
Thamk you.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1652
    
    7

Personally I don't ever generate objects from tables. I create my objects in a way that makes sense to my domain and application, I don't want it tied to the relational model which is different. This mismatch between object and relational models is one of the issues an ORM is designed to address. Generating objects from a database schema completely defeats this imo.

Once I have my objects defined if there is no pre-existing database I will apply the correct mappings and generate the database schema and make tweaks as needed. If the database already exists I will map my objects so they work with the existing schema. Since the ability to generate a schema already exists I don't feel there is a need for anything more. That is my opinion.

[How To Ask Questions][Read before you PM me]
Oshkalo Dmitry
Greenhorn

Joined: Nov 14, 2012
Posts: 2
Thank you for your opinion.

I don't want it tied to the relational model which is different


But you have it tied when you define mapping. And I don't want this connection between your object and relational models to be lost when you applying some modifications. That doesn't mean that all of your classes are completely tied to your database. Of course, these models are different and there is a mismatch between them. But if you modify your classes (or add some new classes) that should be mapped to your DB, won't it be great if there would be much less to be done manually?

Since the ability to generate a schema


Yes, of course there is an ability to generate schema. But in that case you have to count on the generation engine and it may generate schema that will be not convinient to you. For example, you have two inheritance structures in your object-oriented model and you want one of them to be mapped to only one table and another one to be mapped to several different tables (thus, each class has its own table). But generation engine will perform the only generation rule, so you will have to modify you DB schema manually.

If the database already exists I will map my objects so they work with the existing schema


If you already have a DB and your object-oriented model mapped to it, there could be a need to add some classes to your model. Then you have to perform mapping and DB schema modifications manually or re-generate whole DB schema and modify it. In the other hand if you need to modify your DB schema, you will have to propogate these changes to your object model and mapping.
 
GeeCON Prague 2014
 
subject: ORM Syncronizer