|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2009-12-21 19:09:25
Posts: 111,
Visits: 839
|
|
Hi,
My company is about to star a new project, and I want to convince my boss to use ECO. The problem is that I have to generate the Database using some standards, so I have to learn more about ECO custom mapping with FileMappingProvider. Where can I foud more information about this?
Thanks
--
Pedro Brown
pedro@tectrilha.com.br
Tectrilha Software - Borland Learning Partner
|
|
|
|
|
Forum Guru
      
Group: Forum Members
Last Login: 2011-08-30 12:38:11
Posts: 61,
Visits: 183
|
|
You can map quite any database using custom mappings.
What are yours standards?
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2009-12-21 19:09:25
Posts: 111,
Visits: 839
|
|
My standards are only a few. The main thing is that my boss is willing to be able to "unplug" ECO at any time and change it to our custom mapping solution. Becaouse of this, the database should be clean.
Each table must have a PK column named after the table name (eg.: User table: UserID PK).
There shouldn't be any helper tables: ECOModelRoot, ECO_ID, ECO_ORMAPPING, ECO_TABLES, ECO_TYPES.
No ECO_TYPE column.
All FK createad.
I think ECO can do this, because it can reverse engineer a database, I just want some document teaching how to write the necessary XML .
Thanks
--
Pedro Brown
pedro@tectrilha.com.br
Tectrilha Software - Borland Learning Partner
|
|
|
|
|
Supreme Being
      
Group: Administrators
Last Login: 2010-11-30 12:17:13
Posts: 1 230,
Visits: 1 382
|
|
The best documentation for the xml-format for custom OR mapping is in the D2006 documentation:
http://docs.codegear.com/docs/radstudio/delphi2006/D2006_Help_EN.pdf
pages 793-808
I'll incorporate that documentation in ECO5...
/Jonas Hogstrom [CapableObjects]
|
|
|
|
|
Supreme Being
      
Group: Administrators
Last Login: 2010-11-30 12:17:13
Posts: 1 230,
Visits: 1 382
|
|
there are also some sample OR mapping files in the ECO samples folder.
/Jonas Hogstrom [CapableObjects]
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2010-08-11 16:02:44
Posts: 338,
Visits: 890
|
|
pedro_brown (2008-12-15)
Each table must have a PK column named after the table name (eg.: User table: UserID PK).
Just change ECO_ID to TableID at:
ClassDef/AliasDef/KeyImpl/KeyColumn[@Name] and
ClassDef/AliasDef/DiscriminatorImpl[@Column]
(Not sure why it's duplicated)
pedro_brown (2008-12-15)
ECOModelRoot
Have a look here.
It applies to Eco3. I believe it is simpler since Eco4.
pedro_brown (2008-12-15)
ECO_ID,
You must have this column (or at least some other PK, maybe in terms of TableID as described above).
pedro_brown (2008-12-15)
ECO_ORMAPPING
Just use FileMappingProvider. This table only stores the default mapping. You don't need it.
pedro_brown (2008-12-15)
ECO_TABLES, ECO_TYPES
They are required for automatic DB evolves.
I completely ignore (and don't use) them and update DB manually. I recommend you to do so as well.
pedro_brown (2008-12-15)
No ECO_TYPE column.
Set to False:
ClassDef/AliasDef[@ExtentRequiresDiscriminator]
Remove:
ClassDef/AliasDef/DiscriminatorImpl
But still maintain:
ClassDef/DiscriminatorValue with unique Value attribute.
pedro_brown (2008-12-15)
All FK createad.
In Eco3 you need to do it manually and make sure mapping xml has IsConstrained="True" attribute for associations with FKs.
There is a small issue in ECO3 with it (which is fixed in Eco4).
pedro_brown (2008-12-15)
I just want some document teaching how to write the necessary XML .
Best place to have a look is code samples and maybe here.
Hope this helps.
Cheers,
Dmitriy.
My Blog: http://dnagir.blogspot.com
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2010-08-11 16:02:44
Posts: 338,
Visits: 890
|
|
|
|
|
|
Supreme Being
      
Group: Administrators
Last Login: 2010-11-30 12:17:13
Posts: 1 230,
Visits: 1 382
|
|
If you don't use the ECO_TYPE column, you don't need to specify any discriminators at all.
ECO doesn't add any foreign keys to the schema, but if you have foreign keys (manually added), you must (as nagir mentioned) add the "IsConstrained" attribute in the xml-file (so ECO knows the correct order in which to update the objects in a transaction).
If you expose the primary key column as an attribute, or generate it automatically using autoinc mechanisms, there is no need for the ECO_ID table. I believe there are examples of both in the D2006/ECOIII documentation that I linked to above.
In ECO5 there will be a brand new database-reverse-tool that doesn't need a separate mapping-xml for the most common cases. Mapping to "standard databases" with one table per class can be specified directly in the model with a few additional tagged values.
/Jonas Hogstrom [CapableObjects]
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2009-12-21 19:09:25
Posts: 111,
Visits: 839
|
|
Thanks Dmitriy and Jonas,
I'll take a look at that documentation, but I have one more question. By doing this, I'm giving up the Model? Can I still use it to design my application?
Thanks
--
Pedro Brown
pedro@tectrilha.com.br
Tectrilha Software - Borland Learning Partner
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2010-08-11 16:02:44
Posts: 338,
Visits: 890
|
|
You don't give up the model.
That's the way you configure your application.
You first design your objects, then change mapping and update database appropriately.
You'll just have additional steps to do.
My Blog: http://dnagir.blogspot.com
|
|