Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Emitting ManyValuedAssociation

 Post Reply Post Reply
Author
Byrne William View Drop Down
New Member
New Member
Avatar

Joined: 19 Jul 2014
Posts: 2
Post Options Post Options   Quote Byrne William Quote  Post ReplyReply Direct Link To This Post Topic: Emitting ManyValuedAssociation
    Posted: 19 Jul 2014 at 1:07pm
What are the minimum Data Modeler and schema requirements (let's say for MSSQL) to emit the [ManyValuedAssociation] attribute for entity relationships exported by DM for Aurelius? 

I'd like to take advantage of the TAureluisDataset.DatasetField property thinking master-detail relationships will be automatically synchronized. I'm hoping this would eliminate the necessity of manually detecting row changes to the parent with a corresponding refresh to the child. The implementation in this particular scenario is using the classic TDataSource, TDBGrid, and TDBNavigator configuration.


Back to Top
Byrne William View Drop Down
New Member
New Member
Avatar

Joined: 19 Jul 2014
Posts: 2
Post Options Post Options   Quote Byrne William Quote  Post ReplyReply Direct Link To This Post Posted: 20 Jul 2014 at 1:47am
Partial success...

I discovered the Many-Valued Associations option on DM's Aurelius export dialog. Specifically, I selected the parent table in the Mappings section, then enabled the MVA property for the child table located in the Many-Value Associations section. With this option enabled, the expected ManyValuedAssociation attribute was emitted thereby providing the anticipated master-detail code support I mentioned in my initial post.

I'm now noticing that it's necessary to manually assign the parent entity to the child's FK field in the dataset's BeforePost handler. If this isn't done, the native CheckRequiredFields method in Data.DB.pas triggers a "Field Required" exception (because the given FK field was never set and remains Null.) When this native check is bypassed (via debugging,) the process continues until SQL complains about a Null value in the child's FK column. This seems to indicate the FK is never set by the ORM. The child's FK column in this scenario is not permitted to be Null in the SQL schema.

The Data Modeler version is 2.3.0.0
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2485
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 20 Jul 2014 at 5:41pm
If the ManyValuedAssociation is bidirectional (i.e, if you have a property "Parent" (or whatever) in the detail class pointing back to the master class), then you must set that property yourself. If the association is unidirectional, then Aurelius fills that field automatically for you.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down