Custom Mapping
CapableObjects Forums
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



Custom Mapping Expand / Collapse
Author
Message
Posted 2008-12-15 16:58:11
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme 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
Post #1431
Posted 2008-12-15 17:28:57
Forum Guru

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum 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?
Post #1432
Posted 2008-12-15 18:45:40
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme 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
Post #1434
Posted 2008-12-15 21:51:38
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme 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]
Post #1438
Posted 2008-12-16 00:35:27
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme 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]
Post #1439
Posted 2008-12-16 04:33:07


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme 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
Post #1442
Posted 2008-12-16 04:38:33


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 2010-08-11 16:02:44
Posts: 338, Visits: 890
Also How to reverse engineer the .Text database into Eco deserves the most of your attention.

My Blog: http://dnagir.blogspot.com
Post #1443
Posted 2008-12-16 09:36:16
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme 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]
Post #1446
Posted 2008-12-16 12:56:55
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme 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
Post #1449
Posted 2008-12-16 23:31:39


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme 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
Post #1462
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: HansKarlsen, Jonas Hogstrom, PeterMorris

Permissions Expand / Collapse

All times are GMT +1:00, Time now is 12:06

Powered By InstantForum.NET v4.1.4 © 2012
Execution: 0,359. 9 queries. Compression Disabled.