deleteAndDissociate method

Hi everybody,
I’ve some little problem with deleteAndDissociate method.
I’ve two class A and B. A is generalization of B.
When I generate code I realize that DAD method is only in generalization class.
I think is very useful to have this method in specialization too.

hi maurizio316,

I’ll discuss with our developers and then get back to you.

Best regards,

Hi maurizio316,

We’ve made several fixes related to deleteAndDissocicate(). Please have a try and let me know if the fix can solve your problem. Here is the patch:

As I remember you were using Linux. If you want a patch for another platform, please let me know and I’ll arrange for you.

Best regards,

Hi Jick,
I’m sorry, but DeleteAndDissociate method still seems doesn’t work.
I tested only 1-n relation. You can see error details on the attached file

You can run this sample code:

static void Main(string[] args) {
            PersistentSession s=Untitled2PersistentManager.Instance().GetSession();
            PersistentTransaction tx = s.BeginTransaction();
            One o = OneFactory.LoadOneByORMID(1);


``` <br><a class='attachment' href='/uploads/default/original/2X/c/c2f5cceab518577c8aace22910962ad55ad7435f.vpp'>untitled2.vpp</a>

Hi maurizio316,

Sorry. I will ask our engineers to look into this problem again.

Best regards,

Hi maurizio316,

There are 2 potential problems:

  1. The object is not saved before using LoadOneByORMID(). Since the id of both entities is using native (auto id), you need to call entity.Save() to retrieve the ID from database before using LoadByORMID

  2. In the project, the relationship from One to Two is exactly 1, which means the Two object must have a One object. In ERD, the fk in two entity will not allow null (you can see that the nullable=false).

As a result, when you dissociate one from two, it is not allowed to do so.

To fix this problem, change the multiplicity in both ends to 0…1, then sync to ERD (you will see the nullable value will change to true).

Hope this helps.

Best regards,