New Posts New Posts RSS Feed: Default PersistenceOrder wrong
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Default PersistenceOrder wrong

 Post Reply Post Reply
Author
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Topic: Default PersistenceOrder wrong
    Posted: 08-Jun-2008 at 9:43am

Do you have the relationships between tables from the two differenves databases defined in the Object Mapper.  That could explain your problem.  If you only have the relationships defined for tables in the same database, the DevForce Framework can't possibly get the Persistence Order correct.  Look at the Advanced Tutorial on "Working with Multiple Databases" for an example.

 

Back to Top
lokheed View Drop Down
Newbie
Newbie


Joined: 07-Jun-2008
Posts: 4
Post Options Post Options   Quote lokheed Quote  Post ReplyReply Direct Link To This Post Posted: 08-Jun-2008 at 8:55am
Could it be because we are using two different databases (both are on the same server)? 

The majority of the application uses something like PrimaryDB but the business objects I am having trouble with are all in CustomModuleDB.  So CustomModuleDB.dbo.Foo.BarID is a fk constraint to PrimaryDB.dbo.Bar.BarID, and then then there are several tables in CustomModuleDB that have foreign key constraints to CustomModuleDB.dbo.Foo.FooID.  What I am seeing is that all of the business objects generated from PrimaryDB are sorted properly, it's the business objects from CustomModuleDB that tend to get out of order. I don't have the option to migrate the tables from CustomModuleDB into PrimaryModuleDB.

What I will try is to run a topological sort on just the business objects from CustomModuleDB within the list, leaving all of the business objects from PrimaryDB in their relative order.
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 08-Jun-2008 at 8:23am

DevForce  uses a Reverse Topological sort to calculate a default Persistence Order.  Occasionally, we hear complaints that the order is not always correct.  After an in-depth analysis of these cases, we have found a couple of contributing causes:  

(1)  There are too many relationships and/or some contradictory relationships and  the problem cannot really be solved.  Simplifying the relationships and reducing the number of relationships can sometimes help.

(2) There are too few and/or missing relationships.  A good example occurs with grandparent-parent-child relationships.  Sometimes the relationship between grandparent and child is not declared and the missing relationship shows up as an apparent persistence order problem. 

In most cases, we find that subtracting relationships or adding missing relationships can solve the problem.  .

I am not saying that there is a better solution to your problem, but we might be able to help you if you could give us a specific example.

 

Back to Top
lokheed View Drop Down
Newbie
Newbie


Joined: 07-Jun-2008
Posts: 4
Post Options Post Options   Quote lokheed Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jun-2008 at 6:46am
In our installation, when persisting new objects to the db in which there are foreign key constraints, it seems that regularly the PersistenceManager.DefaultSaveOptions.PersistenceOrder is not taking those foreign key constraints into consideration when creating the list.  This means that I have had to create a method that casts the PersistenceOrder into a Type array, manually sort the items in that array to take those constraints into account, and then call PersistenceManager.DefaultSaveOptions.SetPersistenceOrder() with the corrected Type array.

My question is, should I really have to do that?  Is there some step or setting I am missing that is causing the persistence manager to not automatically notice those constraints?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down