Author Topic: ERD class 2 OO class conversion  (Read 4587 times)

akede

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
ERD class 2 OO class conversion
« on: December 13, 2004, 09:36:37 am »
Hello everybody,

I was wondering if there is a possibility to automatically generate a OO class based on the ER table definition (which is stored in a class symbol).

The idea is the following. After I generated my whole DB I would like to automatically generate the objects for the database abstraction layer. For that I would need a class which has the same attributes as the ER table and get/set methods to access these attributes.

Is there a way to generate these classes, I had a look at EA but couldn't find it directly.

Thx

Alex
Alex

~~~~~~~~~~~~~~~~~~~~~~~~~~~
Think Network GmbH, Munich Germany
http://www.thinknetwork.com

Molto Mike

  • EA User
  • **
  • Posts: 66
  • Karma: +0/-0
    • View Profile
Re: ERD class 2 OO class conversion
« Reply #1 on: December 13, 2004, 11:17:34 pm »
Hi Alex,

I don't think this exists in EA. And IMHO this is not directly feasible.

ERDs will contain index columns and all kinds of other DB specific things. Also associations are not forward generated into the DDL, so for each relation you still need the corresponding attribute/column in the respective class.

In short: ERDs are too specific (my understanding).

What may work is to create an abstract layer that is neither programming language nor DB specific and then to derive the two packages, one for the ERD and one for the programmatic API.

Mike
« Last Edit: December 13, 2004, 11:18:15 pm by molto_b »

akede

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: ERD class 2 OO class conversion
« Reply #2 on: December 14, 2004, 12:47:54 am »
Quote
ERDs will contain index columns and all kinds of other DB specific things. Also associations are not forward generated into the DDL, so for each relation you still need the corresponding attribute/column in the respective class.

In short: ERDs are too specific (my understanding).



Hey Mike,

basically this is no big deal. Java with J2EE is doing all the time. The Java beans are just a representation of an object and in the J2EE environment you just map it to a db table.

When I use a class template I'm already pretty close to what I want, because when you look at a persistent data holding class their attributes are normally what the table columns are. And for a complete storage you also need the additional internal index and PK fields. That these fields might not be public accessable can be changed in a second step.

First step would be, to create a object based on a table class. IMO it wouldn't be a big deal with all the technique I see that it is already implemented in EA.

Alex
Alex

~~~~~~~~~~~~~~~~~~~~~~~~~~~
Think Network GmbH, Munich Germany
http://www.thinknetwork.com

thomaskilian

  • Guest
Re: ERD class 2 OO class conversion
« Reply #3 on: December 14, 2004, 12:53:49 am »
There are two ways.
A) Export the tables package to XMI; edit the stereotypes; re-import it to the objects package.
B) write an addin working e.g. similar to ROSE's database modeller. There's quite a market for that and you could sell it  :)

akede

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: ERD class 2 OO class conversion
« Reply #4 on: December 14, 2004, 01:37:59 am »
Quote
There are two ways.
A) Export the tables package to XMI; edit the stereotypes; re-import it to the objects package.
B) write an addin working e.g. similar to ROSE's database modeller. There's quite a market for that and you could sell it  :)



;D

Hey Thomas,

selling, please no more additional development. I'm member of the core development team of Mambo and have my own company doing consulting in the OO & IT strategy area, that's more then enough work to do.

But you got the point, I also would pay for such a plugin.

Thank's for the idea with the export, I'm going to test this.

Alex
Alex

~~~~~~~~~~~~~~~~~~~~~~~~~~~
Think Network GmbH, Munich Germany
http://www.thinknetwork.com

Bruno.Cossi

  • EA User
  • **
  • Posts: 803
  • Karma: +0/-0
    • View Profile
Re: ERD class 2 OO class conversion
« Reply #5 on: December 14, 2004, 04:13:14 am »
And two other ways:

- export to CVS file and re-import without the stereotypes
- duplicate (copy + paste) the classes and edit them within EA - suitable if you do not have too many classes

Bruno

Quote
There are two ways.
A) Export the tables package to XMI; edit the stereotypes; re-import it to the objects package.
B) write an addin working e.g. similar to ROSE's database modeller. There's quite a market for that and you could sell it  :)


Bruno.Cossi

  • EA User
  • **
  • Posts: 803
  • Karma: +0/-0
    • View Profile
Re: ERD class 2 OO class conversion
« Reply #6 on: December 14, 2004, 04:15:09 am »
Hi Mike,

it's not as difficult as it sounds - all better database modeling tools do this.

Bruno


Quote
Hi Alex,

I don't think this exists in EA. And IMHO this is not directly feasible.

ERDs will contain index columns and all kinds of other DB specific things. Also associations are not forward generated into the DDL, so for each relation you still need the corresponding attribute/column in the respective class.

In short: ERDs are too specific (my understanding).

What may work is to create an abstract layer that is neither programming language nor DB specific and then to derive the two packages, one for the ERD and one for the programmatic API.

Mike