New Posts New Posts RSS Feed: Working with Tightly Coupled (1-to-1) Entities
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Working with Tightly Coupled (1-to-1) Entities

 Post Reply Post Reply
Author
Customer View Drop Down
Senior Member
Senior Member
Avatar
User Submitted Questions to Support

Joined: 30-May-2007
Location: United States
Posts: 260
Post Options Post Options   Quote Customer Quote  Post ReplyReply Direct Link To This Post Topic: Working with Tightly Coupled (1-to-1) Entities
    Posted: 30-May-2007 at 4:50pm
Question:

Is there any built-in DevForce support for managing one-to-one relationships?

I have a main (TableA) and a related table (TableB) which contains additional information that logically does not belong in TableA.

The business rules are:
•     There should always be exactly one TableB object.
•     When a TableA entity is created, a related TableB record should automatically be created. Same when TableA entity is deleted, TableB entity is also deleted. TableB entity cannot be deleted directly.
•     TableA should not expose a TableBs collection. Instead, it should expose a single TableB object that returns the single TableB object.
Back to Top
IdeaBlade View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 30-May-2007
Location: United States
Posts: 353
Post Options Post Options   Quote IdeaBlade Quote  Post ReplyReply Direct Link To This Post Posted: 30-May-2007 at 4:57pm

When examining table relations in a database, DevForce can’t tell the difference between a 1-to-Many relation and a 1-to-1 relation, so it generates relations as 1-to-Many.  You can override this assigned cardinality in the Object Mapper to make the relation 1-to-1; doing so will change the nature of the relation properties that are generated into the two entity classes.  Instead of a relation property representing a collection, it will represent a single related object.

You might want to look at the Instructional Unit on Generalization Hierarchies.  There you will find a discussion (in the PowerPoint slides) and examples of different ways to approach your development in the  case where two business objects have this tight coupling.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down