Hi,
We've got a problem with the batched execution as follows:
- In a Person object an Address should be present. When no Address is present in the List, a new one is created.
- In the Address we have an AddressType (Home Address, Bussiness Address, etc). The reference for this one is set to 'not nullable'
- In the Constructor of Address the Default for the AddressType is fetched from the AddressType Table.
- During the fetch of the Default AddressType a batch SQL Query is started, which is trying to save the Address. The DB does not allow this because the AddressType is NULL.
Can we suspend batches during initialization? We've already tried the Validation.Disable() (see below) but that didn't prevent the batch from executing.
Regards
Paul Sinnema
Diartis AG
using (var inconsistentArea = Validation.Disable())
{
Z_Supplement1 = string.Empty; // Setting string default
Z_Supplement2 = string.Empty; // Setting string default
Z_Street = string.Empty; // Setting string default
Z_BuildingNumber = string.Empty; // Setting string default
Z_PostOfficeBox = string.Empty; // Setting string default
Z_PostOfficeBoxNumber = string.Empty; // Setting string default
Z_Comment = string.Empty; // Setting string default
Z_AddressType = AddressType.Default; // Setting single navigation default
if (createArgumentsIn != null)
{
AddressCreateArguments createArguments = (AddressCreateArguments)createArgumentsIn;
createArguments.Fill(this);
}
EntityStateP.Value = EntityState.CreatedNew;
OnInitializing(EntityInitializationMode.Created);
}
Updated at 14.07.2010 16:25:17
Hi,
While trying to create a work-around for this issue (viewtopic.php?f=29&t=6014) this situation was produced.
What I tried to do is create the object in a different session, persist it to the DB and refetch it in the main session. What I forgot was to add a DisconnectedState to the temporary session. This caused the batches to fire.
B.t.w. This work-around gives other problems. We now get an exception which is the same as an issue described here: viewtopic.php?f=29&t=5828&start=0&hilit=differs
Regards
Paul Sinnema
Updated at 14.07.2010 18:09:35
Can we use this in the Constructor?
using (session.Pin(this)) {
// this Entity isn't persisted here
}
Updated at 18.07.2010 14:44:07
Ignoring would mean the code is in there but it does nothing. So programmers will never get a message that they programmed something wrong.
I'm always at the standpoint that when something isn't allowed it should throw an exception with a clear message, so programmers know what they did wrong.
This thread was imported from our support forum. The original discussion may contain more detailed answer.
asked
Jul 14 '10 at 14:16
Paul Sinnema
261●88●88●96
Does pinning help here? I mean:
Yes.