Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: akede 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
-
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
-
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
-
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 :)
-
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
-
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
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 :)
-
Hi Mike,
it's not as difficult as it sounds - all better database modeling tools do this.
Bruno
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