Hi Matt,

thanks for your interest in empire-db.

regarding your request ... unfortunately the codegen does not set up the relation of the database model. At the moment the codegen will only set up views and tables. We thought these are the most important for the most people as they are usually sufficient for simple data access.

However i think there are two occasions where the relations are important:
    - database creation
    - deletion of records with cascading deletion enabled

At the moment we have not planned to add "relationship generation" to the codegen component, but I am glad to hear that you consider to extend it on your own.

The right place to start with that would be:
*CodeGenParser.populateDatabase(..) : 131* : This is the point where the DatabaseMetaData is querried and used to populate empire-db's model *CodeGenWriter.generateCodeFiles(..) : 125* : Is used to serialize the populated model as java code *src/main/resources/Database.vm : 70* : This is the velocity template we use to create the java class for the database.
                                                                           In 
its default constructor you'd need to add a line for each relationship similar 
to this:

*addRelation( EMPLOYEES.DEPARTMENT_ID.referenceOn( DEPARTMENTS.DEPARTMENT_ID ));*

I hope this is of some help to you. Feel free to ask if you have further questions!

Cherio
    Benjamin

Am 28.06.2011 19:37, schrieb Matt DeHoust:
Hello,

I see that the empire-db model supports relationships (for example DBDatabase.getRelations()), but it doesn't seem that the codegen component sets them up. Am I missing something? (I am using MySQL if that matters.)

If not, are there plans to introduce relationship setup in the codegen component?

If not, where should I look to add them myself? CodeGenParser?

Thanks,
Matt

P.S. I apologize if I posted this question twice by mitake.

Reply via email to