MergeNormal do nothing

Posts   
 
    
mdominguez
User
Posts: 14
Joined: 30-May-2005
# Posted on: 11-Jul-2005 18:29:19   

frowning In the trace what could be the reason for

Method Enter: DataAccessAdapterBase.MergeNormal Method Exit: DataAccessAdapterBase.MergeNormal

The Entitys are Fetched from database well but are not merged.

This is the summary of the trace:


Method Enter: CreateSelectDQ (Paging)
Method Enter: CreateSelectDQ
Generated Sql query: 
    Query: SELECT [nhhosp01].[dbo].[camas].[codigo_estado_cama] AS [CodigoEstadoCama],[nhhosp01].[dbo].[camas].[libre_prev_fecha] AS [LibrePrevFecha],[nhhosp01].[dbo].[camas].[libre_prev_hora] AS [LibrePrevHora],[nhhosp01].[dbo].[camas].[cod_uenf_pk] AS [CodUenfPk],[nhhosp01].[dbo].[camas].[cod_cama] AS [CodCama],[nhhosp01].[dbo].[camas].[cod_habitacion_pk] AS [CodHabitacionPk],[nhhosp01].[dbo].[camas].[tipo_cama_pk] AS [TipoCamaPk],[nhhosp01].[dbo].[camas].[trld_pk] AS [TrldPk],[nhhosp01].[dbo].[camas].[codigo_servicio] AS [CodigoServicio],[nhhosp01].[dbo].[camas].[oficial_sn] AS [OficialSn],[nhhosp01].[dbo].[camas].[cacomp_pk] AS [CacompPk],[nhhosp01].[dbo].[camas].[cama_telefono] AS [CamaTelefono] FROM [nhhosp01].[dbo].[camas]  WHERE ( ( [nhhosp01].[dbo].[camas].[cod_uenf_pk] = @CodUenfPk1))
    Parameter: @CodUenfPk1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 12.
Method Exit: CreateSelectDQ
Method Exit: CreateSelectDQ (Paging): no paging.
Method Enter: DataAccessAdapterBase.ExecuteMultiRowRetrievalQuery
Method Enter: DataAccessAdapterBase.OpenConnection
'testHIS.exe': se cargó 'c:\windows\assembly\gac\system.enterpriseservices\1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseservices.thunk.dll', no se pueden cargar símbolos.
'testHIS.exe': se cargó 'c:\windows\assembly\gac\mscorlib.resources\1.0.5000.0_es_b77a5c561934e089\mscorlib.resources.dll', no se pueden cargar símbolos.
Method Exit: DataAccessAdapterBase.OpenConnection
Method Enter: EntityCollectionBase2.Add
Entity to Add Description: 
    Entity: es.novasoft.xsia.his.novahis.biz.CamaEntity2. ObjectID: 3e9470d6-a49a-4170-b48e-9c2645cc9954
    PrimaryKey field: CodCama. Type: System.String. Value: UCI-1    
Index of added entity: 0

...........

Method Exit: EntityCollectionBase2.Add
Method Enter: DataAccessAdapterBase.CloseConnection
Method Exit: DataAccessAdapterBase.CloseConnection
Method Exit: DataAccessAdapterBase.ExecuteMultiRowRetrievalQuery
Method Exit: DataAccessAdapterBase.FetchEntityCollection(6)
Method Enter: DataAccessAdapterBase.FetchPrefetchPath
Method Enter: DataAccessAdapterBase.FetchEntityCollection(6)
Active Entity Collection Description: 
    EntityCollection: es.novasoft.xsia.his.novahis.dal.HelperClasses.EntityCollection.  Will contain entities of type: IngresosEntity

Method Enter: CreateSelectDQ (Paging)
Method Enter: CreateSelectDQ
Method Enter: CreateSubQuery
Method Enter: CreateSelectDQ
Generated Sql query: 
    Query: SELECT [nhhosp01].[dbo].[camas].[cod_cama] AS [CodCama] FROM [nhhosp01].[dbo].[camas]  WHERE ( ( [nhhosp01].[dbo].[camas].[cod_uenf_pk] = @CodUenfPk1))
    Parameter: @CodUenfPk1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 12.
Method Exit: CreateSelectDQ
Method Exit: CreateSubQuery
Generated Sql query: 
    Query: SELECT [nhhosp01].[dbo].[ingresos].[cod_ingreso_pk] AS [CodIngresoPk],[nhhosp01].[dbo].[ingresos].[codigo_servicio] AS [CodigoServicio],[nhhosp01].[dbo].[ingresos].[codigo_cliente] AS [CodigoCliente],[nhhosp01].[dbo].[ingresos].[codigo_contacto] AS [CodigoContacto],[nhhosp01].[dbo].[ingresos].[icd_cod] AS [IcdCod],[nhhosp01].[dbo].[ingresos].[cod_pagador_pk] AS [CodPagadorPk],[nhhosp01].[dbo].[ingresos].[cod_cama] AS [CodCama],[nhhosp01].[dbo].[ingresos].[codigo_personal] AS [CodigoPersonal],[nhhosp01].[dbo].[ingresos].[codigo_servicio1] AS [CodigoServicio1],[nhhosp01].[dbo].[ingresos].[codigo_personal1] AS [CodigoPersonal1],[nhhosp01].[dbo].[ingresos].[motivo_ingreso_pk] AS [MotivoIngresoPk],[nhhosp01].[dbo].[ingresos].[motivo_alta_pk] AS [MotivoAltaPk],[nhhosp01].[dbo].[ingresos].[dest_alting_pk] AS [DestAltingPk],[nhhosp01].[dbo].[ingresos].[medio_trte_pk] AS [MedioTrtePk],[nhhosp01].[dbo].[ingresos].[med_medio_trte_pk] AS [MedMedioTrtePk],[nhhosp01].[dbo].[ingresos].[codigo_personal2] AS [CodigoPersonal2],[nhhosp01].[dbo].[ingresos].[codigo_personal3] AS [CodigoPersonal3],[nhhosp01].[dbo].[ingresos].[codigo_servicio2] AS [CodigoServicio2],[nhhosp01].[dbo].[ingresos].[codigo_servicio3] AS [CodigoServicio3],[nhhosp01].[dbo].[ingresos].[plan_pk] AS [PlanPk],[nhhosp01].[dbo].[ingresos].[codigo_personal4] AS [CodigoPersonal4],[nhhosp01].[dbo].[ingresos].[codigo_personal5] AS [CodigoPersonal5],[nhhosp01].[dbo].[ingresos].[ing_tipo_pk] AS [IngTipoPk],[nhhosp01].[dbo].[ingresos].[ingori_pk] AS [IngoriPk],[nhhosp01].[dbo].[ingresos].[ingdrv_pk] AS [IngdrvPk],[nhhosp01].[dbo].[ingresos].[fecha_ingreso] AS [FechaIngreso],[nhhosp01].[dbo].[ingresos].[hora_ingreso] AS [HoraIngreso],[nhhosp01].[dbo].[ingresos].[reingreso_sn] AS [ReingresoSn],[nhhosp01].[dbo].[ingresos].[fecha_alta] AS [FechaAlta],[nhhosp01].[dbo].[ingresos].[hora_alta] AS [HoraAlta],[nhhosp01].[dbo].[ingresos].[diagno1_ing] AS [Diagno1Ing],[nhhosp01].[dbo].[ingresos].[ing_confirmado_sn] AS [IngConfirmadoSn],[nhhosp01].[dbo].[ingresos].[ing_ultifec_est] AS [IngUltifecEst],[nhhosp01].[dbo].[ingresos].[f_alta_prev] AS [FAltaPrev],[nhhosp01].[dbo].[ingresos].[h_alta_prev] AS [HAltaPrev],[nhhosp01].[dbo].[ingresos].[freg_ing] AS [FregIng],[nhhosp01].[dbo].[ingresos].[hreg_ing] AS [HregIng],[nhhosp01].[dbo].[ingresos].[freg_alta] AS [FregAlta],[nhhosp01].[dbo].[ingresos].[hreg_alta] AS [HregAlta],[nhhosp01].[dbo].[ingresos].[aislado_sn] AS [AisladoSn],[nhhosp01].[dbo].[ingresos].[ing_sec_anual] AS [IngSecAnual],[nhhosp01].[dbo].[ingresos].[ing_sec_diario] AS [IngSecDiario],[nhhosp01].[dbo].[ingresos].[ing_fconf] AS [IngFconf],[nhhosp01].[dbo].[ingresos].[ing_hconf] AS [IngHconf],[nhhosp01].[dbo].[ingresos].[ing_mottxt] AS [IngMottxt],[nhhosp01].[dbo].[ingresos].[ing_observ] AS [IngObserv],[nhhosp01].[dbo].[ingresos].[ci_inter_cod] AS [CiInterCod],[nhhosp01].[dbo].[ingresos].[tipo_hab_pk] AS [TipoHabPk],[nhhosp01].[dbo].[ingresos].[fecha_alta_adm] AS [FechaAltaAdm],[nhhosp01].[dbo].[ingresos].[ing_prest_aut] AS [IngPrestAut],[nhhosp01].[dbo].[ingresos].[ing_observ2] AS [IngObserv2],[nhhosp01].[dbo].[ingresos].[ing_cb_pk] AS [IngCbPk],[nhhosp01].[dbo].[ingresos].[cod_centro] AS [CodCentro],[nhhosp01].[dbo].[ingresos].[grupo_hosp_pk] AS [GrupoHospPk],[nhhosp01].[dbo].[ingresos].[td_dieta_pk] AS [TdDietaPk],[nhhosp01].[dbo].[ingresos].[ing_observ_dieta] AS [IngObservDieta],[nhhosp01].[dbo].[ingresos].[fecha_ing_adm] AS [FechaIngAdm],[nhhosp01].[dbo].[ingresos].[interven_sn] AS [IntervenSn],[nhhosp01].[dbo].[ingresos].[codigo_servicio4] AS [CodigoServicio4],[nhhosp01].[dbo].[ingresos].[icd_cod_salida] AS [IcdCodSalida],[nhhosp01].[dbo].[ingresos].[diag_salida] AS [DiagSalida],[nhhosp01].[dbo].[ingresos].[cod_ubicacion] AS [CodUbicacion],[nhhosp01].[dbo].[ingresos].[ing_tipo_pk_ini] AS [IngTipoPkIni] FROM [nhhosp01].[dbo].[ingresos]  WHERE ( [nhhosp01].[dbo].[ingresos].[cod_cama] IN (SELECT [nhhosp01].[dbo].[camas].[cod_cama] AS [CodCama] FROM [nhhosp01].[dbo].[camas]  WHERE ( ( [nhhosp01].[dbo].[camas].[cod_uenf_pk] = @CodUenfPk1))) And ( ( [nhhosp01].[dbo].[ingresos].[fecha_alta] IS NULL)))
    Parameter: @CodUenfPk1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 12.
Method Exit: CreateSelectDQ
Method Exit: CreateSelectDQ (Paging): no paging.
Method Enter: DataAccessAdapterBase.ExecuteMultiRowRetrievalQuery
Method Enter: DataAccessAdapterBase.OpenConnection
Method Exit: DataAccessAdapterBase.OpenConnection
'testHIS.exe': se cargó 'c:\windows\assembly\gac\system.data.resources\1.0.5000.0_es_b77a5c561934e089\system.data.resources.dll', no se pueden cargar símbolos.
Method Enter: EntityCollectionBase2.Add
Entity to Add Description: 
    Entity: es.novasoft.xsia.his.novahis.biz.IngresoEntity2. ObjectID: 84025c1e-5403-4669-a8a7-208ebb8a314a
    PrimaryKey field: CodIngresoPk. Type: System.Int32. Value: 1457
Index of added entity: 0

.........

Method Enter: EntityCollectionBase2.Add
Entity to Add Description: 
    Entity: es.novasoft.xsia.his.novahis.dal.EntityClasses.IngresosEntity. ObjectID: 784749f7-3ced-42e6-a63a-3ef541f2cae8
    PrimaryKey field: CodIngresoPk. Type: System.Int32. Value: 1460
Index of added entity: 5
Method Exit: EntityCollectionBase2.Add
Method Enter: DataAccessAdapterBase.CloseConnection
Method Exit: DataAccessAdapterBase.CloseConnection
Method Exit: DataAccessAdapterBase.ExecuteMultiRowRetrievalQuery
Method Exit: DataAccessAdapterBase.FetchEntityCollection(6)
[b]Method Enter: DataAccessAdapterBase.MergeNormal
Method Exit: DataAccessAdapterBase.MergeNormal[/b]
Method Enter: EntityCollectionBase2.OnClear
Method Exit: EntityCollectionBase2.OnClear
Method Exit: DataAccessAdapterBase.FetchPrefetchPath
Method Exit: DataAccessAdapterBase.FetchEntityCollection(3) ;(

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39916
Joined: 17-Aug-2003
# Posted on: 11-Jul-2005 18:57:55   

I'm a bit lost what the real problem is: you want to fetch something through a prefetch path, but the prefetch path isn't resolving in the right data? If so, please provide your code so I can check if your code is perhaps not correct.

A method enter/exit can mean there is no action to perform, for example there is no data to merge.

Frans Bouma | Lead developer LLBLGen Pro
mdominguez
User
Posts: 14
Joined: 30-May-2005
# Posted on: 13-Jul-2005 16:42:47   

But, there is data to fetch.

See the trace. For every CamaEntity could be several IngresoEntity.

The CamaEntity are Fetched well. The IngresoEntity are fetched as well but when have to merge them the metod do nothing and the EntityCollection that could be filled with IngresoEntity is empty.

The schema is:

CamaEntity | |____ IngresoEntity |____ IngresoEntity |____ ...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39916
Joined: 17-Aug-2003
# Posted on: 13-Jul-2005 17:41:24   

A quick question before I dive in: is this thread related to another thread? As I see not a lot of information about the problem, though it might be that is located in another, related thread.

If not: could you please give me more information to work with? I know nothing about your system, database model and don't have your code, so if you could for example show me what code you execute to fetch the prefetch path (like the code which sets up the prefetch path, and the fetch call), that would be great, thanks.

Frans Bouma | Lead developer LLBLGen Pro
mdominguez
User
Posts: 14
Joined: 30-May-2005
# Posted on: 13-Jul-2005 18:47:55   

The code


EntityCollection camas = new EntityCollection(new CamaEntity2Factory());

// Construcción del PreFetch            
IPrefetchPath2 path = new PrefetchPath2((int)EntityType.CamasEntity);
// Prefetch del ingreso
IPrefetchPathElement2 path2 = CamasEntity.PrefetchPathIngresos;
path2.EntityFactoryToUse = new IngresoEntity2Factory();
IPredicateExpression exp2 = new PredicateExpression();
exp2.Add(PredicateFactory.CompareNull(IngresosFieldIndex.FechaAlta));
// Prefetch del Paciente del Ingreso
// Prefetch de la Historia del Paciente del Ingreso
// Prefetch de las Alergias del Paciente del Ingreso

IPrefetchPathElement2 path3 = IngresosEntity.PrefetchPathClientes;
IPrefetchPathElement2 path4 = ClientesEntity.PrefetchPathHc;
IPredicateExpression exp3 = new PredicateExpression();
exp3.Add(PredicateFactory.CompareValue(HcFieldIndex.ActivaSn, ComparisonOperator.Equal, 1));
path3.SubPath.Add(path4);
path3.SubPath.Add(ClientesEntity.PrefetchPathClienAlergias);
            path2.SubPath.Add(path3);           
            path.Add(path2, 1, exp2);           

// Construcción del filtro
IRelationPredicateBucket filter = new RelationPredicateBucket();
IPredicateExpression expression = new PredicateExpression();
expression.Add(PredicateFactory.CompareValue(CamasFieldIndex.CodUenfPk, ComparisonOperator.Equal, his_unidadpk));
filter.PredicateExpression.Add(expression);

string assembly = ConfigurationSettings.AppSettings["xsiaHIS.AssemblyDataAccessPath"];
using (IDataAccessAdapter adapter = xSiaFactory.newDataAccessAdapter(assembly)) {
    adapter.FetchEntityCollection(camas, filter, path);
}

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39916
Joined: 17-Aug-2003
# Posted on: 14-Jul-2005 11:26:41   

You use special factories, do these factories produce special entities?

the MergeNormal routine shows up in your trace so it has data to merge, and there are no trace statements further down the routines called from mergenormal so it's ok if there are no more trace messages logged between entry and exit.

MergeNormal tries to find the root entity back for all the related entities passed in, in this case for each Ingresos entity it tries to find the related Camas entity based on the FK value of the Ingresos entity and the PK value of the Camas entity. It does this by using computed hashcodes from these values.

When no match is found, nothing is merged, otherwise the method SetRelatedEntityProperty is called in the entity. In your situation, it calls the loaded CamasEntity's SetRelatedEntityProperty and passes in: "Ingresos" and the ingresos entity to set. This method is located in the generated CamasEntity class. Could you please place a breakpoint there and run the code in debug mode to see if it breaks there?

You also specify a limit of 1 for Ingresos, so there is only 1 Ingresos entity fetched per Camas entity.

Also, your code can be optimized a bit:


IPredicateExpression expression = new PredicateExpression();
expression.Add(PredicateFactory.CompareValue(CamasFieldIndex.CodUenfPk, ComparisonOperator.Equal, his_unidadpk));
filter.PredicateExpression.Add(expression);

can be:


filter.PredicateExpression.Add(PredicateFactory.CompareValue(CamasFieldIndex.CodUenfPk, ComparisonOperator.Equal, his_unidadpk));

and you formulate exp3 but that's never used, or is it but you cut that out of your code?

Frans Bouma | Lead developer LLBLGen Pro
mdominguez
User
Posts: 14
Joined: 30-May-2005
# Posted on: 15-Jul-2005 15:39:50   

Otis wrote:

You use special factories, do these factories produce special entities?

of course

Otis wrote:

When no match is found, nothing is merged, otherwise the method SetRelatedEntityProperty is called in the entity. In your situation, it calls the loaded CamasEntity's SetRelatedEntityProperty and passes in: "Ingresos" and the ingresos entity to set. This method is located in the generated CamasEntity class. Could you please place a breakpoint there and run the code in debug mode to see if it breaks there?

I set the breakpoint in:

public override void SetRelatedEntityProperty(string propertyName, IEntityCore entity)

And confused no !! It does not stop there!!

Otis wrote:

You also specify a limit of 1 for Ingresos, so there is only 1 Ingresos entity fetched per Camas entity.

Yes, this is right because one "Cama" (bed) can has several "Ingresos" (inpatients) but there is only one "Ingreso" (inpatient) active.

Otis wrote:

and you formulate exp3 but that's never used, or is it but you cut that out of your code?

No. I'm using it in:

path2.SubPath.Add(path3); path.Add(path2, 1, exp2);

Is this correct?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39916
Joined: 17-Aug-2003
# Posted on: 16-Jul-2005 14:30:56   

mdominguez wrote:

Otis wrote:

You use special factories, do these factories produce special entities?

of course

With 'special' I meant: own entity objects, so entities which might have a different implementation than from the standard generated ones.

Otis wrote:

When no match is found, nothing is merged, otherwise the method SetRelatedEntityProperty is called in the entity. In your situation, it calls the loaded CamasEntity's SetRelatedEntityProperty and passes in: "Ingresos" and the ingresos entity to set. This method is located in the generated CamasEntity class. Could you please place a breakpoint there and run the code in debug mode to see if it breaks there?

I set the breakpoint in:

public override void SetRelatedEntityProperty(string propertyName, IEntityCore entity) And confused no !! It does not stop there!!

In CamasEntity? Hmm. At the 'switch' statement? Because I tried to reproduce it here, and I initially made the mistake to set the breakpoint on the first case and it didn't stop there either. Also please make sure the build you're running is a debug build. VS.NET lets you set breakpoints in release builds.

I tried to reproduce it with a row limited routine and a filter but it works ok:


[Test]
public void PrefetchPathTestSimpleRowLimit()
{
    using(DataAccessAdapter adapter = new DataAccessAdapter())
    {
        RelationPredicateBucket filter = new RelationPredicateBucket();
        filter.PredicateExpression.Add(PredicateFactory.CompareValue(CustomerFieldIndex.Country, ComparisonOperator.Equal, "Mexico"));
        PrefetchPath2 path = new PrefetchPath2((int)EntityType.CustomerEntity);
        IPredicateExpression nodeFilter = new PredicateExpression();
        nodeFilter.Add(PredicateFactory.CompareValue(OrderFieldIndex.Freight, ComparisonOperator.GreaterThan, 20.0));
        path.Add(CustomerEntity.PrefetchPathOrders, 1, nodeFilter);
        EntityCollection customers = new EntityCollection(new CustomerEntityFactory());
        adapter.FetchEntityCollection(customers, filter, path);

        Assert.AreEqual(5, customers.Count);

        foreach(CustomerEntity customer in customers)
        {
            if(customer.CustomerId=="CENTC")
            {
                // this one has to have 0 orders, as all its orders have a freight < 20
                Assert.AreEqual(0, customer.Orders.Count);
            }
            else
            {
                Assert.AreEqual(1, customer.Orders.Count);
            }
        }
    }
}

Also please note that you filter on a Camas field in FetchEntityCollection() which can result in multiple Cama's to be fetched and one or more of these can have no active patient, which then means that the cama's Ingregos collection is empty. The Camas collection isn't filtered on the fact if it has an active ingregos. If you want that, you have to specify the filter for that to 'filter' which you pass in to FetchEntityCollection()

Otis wrote:

and you formulate exp3 but that's never used, or is it but you cut that out of your code?

No. I'm using it in:

path2.SubPath.Add(path3); path.Add(path2, 1, exp2);

Is this correct?

I meant, exp3, which is a filter, but it's not used (if I'm not mistaken). Though I don't think that's the cause of the problem.

Frans Bouma | Lead developer LLBLGen Pro
mdominguez
User
Posts: 14
Joined: 30-May-2005
# Posted on: 19-Jul-2005 12:40:46   

Otis wrote:

mdominguez wrote:

Otis wrote:

You use special factories, do these factories produce special entities?

of course

With 'special' I meant: own entity objects, so entities which might have a different implementation than from the standard generated ones.

I'm sorry. Really not, we use a new entity that inherit from the generated one. And It implements a specific interface:

public class CamaEntity2 : CamasEntity, ICama

The interface only define a set of properties to fulfil.

Otis wrote:

mdominguez wrote:

Otis wrote:

and you formulate exp3 but that's never used, or is it but you cut that out of your code?

No. I'm using it in:

path2.SubPath.Add(path3); path.Add(path2, 1, exp2);

Is this correct?

I meant, exp3, which is a filter, but it's not used (if I'm not mistaken). Though I don't think that's the cause of the problem.

Yes, you aren't mistaken. It's my fault flushed . But is not the cause of the problem smile .

mdominguez
User
Posts: 14
Joined: 30-May-2005
# Posted on: 19-Jul-2005 12:56:31   

Otis wrote:

In CamasEntity? Hmm. At the 'switch' statement? Because I tried to reproduce it here, and I initially made the mistake to set the breakpoint on the first case and it didn't stop there either. Also please make sure the build you're running is a debug build. VS.NET lets you set breakpoints in release builds.

Also please note that you filter on a Camas field in FetchEntityCollection() which can result in multiple Cama's to be fetched and one or more of these can have no active patient, which then means that the cama's Ingregos collection is empty. The Camas collection isn't filtered on the fact if it has an active ingregos. If you want that, you have to specify the filter for that to 'filter' which you pass in to FetchEntityCollection()

The breakpoint is well placed. That is not the problem.

But let me show you the trace again:

First the select to fetch 'Camas' is done:

Method Enter: CreateSelectDQ
Generated Sql query: 
    Query: SELECT [nhhosp01].[dbo].[camas].[codigo_estado_cama] AS [CodigoEstadoCama],[nhhosp01].[dbo].[camas].[libre_prev_fecha] AS [LibrePrevFecha],[nhhosp01].[dbo].[camas].[libre_prev_hora] AS [LibrePrevHora],[nhhosp01].[dbo].[camas].[cod_uenf_pk] AS [CodUenfPk],[nhhosp01].[dbo].[camas].[cod_cama] AS [CodCama],[nhhosp01].[dbo].[camas].[cod_habitacion_pk] AS [CodHabitacionPk],[nhhosp01].[dbo].[camas].[tipo_cama_pk] AS [TipoCamaPk],[nhhosp01].[dbo].[camas].[trld_pk] AS [TrldPk],[nhhosp01].[dbo].[camas].[codigo_servicio] AS [CodigoServicio],[nhhosp01].[dbo].[camas].[oficial_sn] AS [OficialSn],[nhhosp01].[dbo].[camas].[cacomp_pk] AS [CacompPk],[nhhosp01].[dbo].[camas].[cama_telefono] AS [CamaTelefono] FROM [nhhosp01].[dbo].[camas]  WHERE ( ( [nhhosp01].[dbo].[camas].[cod_uenf_pk] = @CodUenfPk1))
    Parameter: @CodUenfPk1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 12.
Method Exit: CreateSelectDQ

after that the 'CamasEntity' is fetched fine:

Method Enter: EntityCollectionBase2.Add
Entity to Add Description: 
    Entity: es.novasoft.xsia.his.novahis.biz.CamaEntity2. ObjectID: 45d7112e-0ddc-4872-ab46-00480c8149cf
    PrimaryKey field: CodCama. Type: System.String. Value: UCI-1    
Index of added entity: 0
Method Exit: EntityCollectionBase2.Add
Method Enter: EntityCollectionBase2.Add
Entity to Add Description: 
    Entity: es.novasoft.xsia.his.novahis.biz.CamaEntity2. ObjectID: 5db3bc37-d10c-47d1-8d1d-e915de743c80
    PrimaryKey field: CodCama. Type: System.String. Value: UCI-2    
Index of added entity: 1

then the Prefetch code starts:

Method Enter: DataAccessAdapterBase.FetchPrefetchPath
Method Enter: DataAccessAdapterBase.FetchEntityCollection(6)
Active Entity Collection Description: 
    EntityCollection: es.novasoft.xsia.his.novahis.dal.HelperClasses.EntityCollection.  Will contain entities of type: IngresosEntity

Method Enter: CreateSelectDQ (Paging)
Method Enter: CreateSelectDQ
Method Enter: CreateSubQuery
Method Enter: CreateSelectDQ
Generated Sql query: 
    Query: SELECT [nhhosp01].[dbo].[camas].[cod_cama] AS [CodCama] FROM [nhhosp01].[dbo].[camas]  WHERE ( ( [nhhosp01].[dbo].[camas].[cod_uenf_pk] = @CodUenfPk1))
    Parameter: @CodUenfPk1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 12.
Method Exit: CreateSelectDQ
Method Exit: CreateSubQuery
Generated Sql query: 
    Query: SELECT [nhhosp01].[dbo].[ingresos].[cod_ingreso_pk] AS [CodIngresoPk],[nhhosp01].[dbo].[ingresos].[codigo_servicio] AS [CodigoServicio],[nhhosp01].[dbo].[ingresos].[codigo_cliente] AS [CodigoCliente],[nhhosp01].[dbo].[ingresos].[codigo_contacto] AS [CodigoContacto],[nhhosp01].[dbo].[ingresos].[icd_cod] AS [IcdCod],[nhhosp01].[dbo].[ingresos].[cod_pagador_pk] AS [CodPagadorPk],[nhhosp01].[dbo].[ingresos].[cod_cama] AS [CodCama],[nhhosp01].[dbo].[ingresos].[codigo_personal] AS [CodigoPersonal],[nhhosp01].[dbo].[ingresos].[codigo_servicio1] AS [CodigoServicio1],[nhhosp01].[dbo].[ingresos].[codigo_personal1] AS [CodigoPersonal1],[nhhosp01].[dbo].[ingresos].[motivo_ingreso_pk] AS [MotivoIngresoPk],[nhhosp01].[dbo].[ingresos].[motivo_alta_pk] AS [MotivoAltaPk],[nhhosp01].[dbo].[ingresos].[dest_alting_pk] AS [DestAltingPk],[nhhosp01].[dbo].[ingresos].[medio_trte_pk] AS [MedioTrtePk],[nhhosp01].[dbo].[ingresos].[med_medio_trte_pk] AS [MedMedioTrtePk],[nhhosp01].[dbo].[ingresos].[codigo_personal2] AS [CodigoPersonal2],[nhhosp01].[dbo].[ingresos].[codigo_personal3] AS [CodigoPersonal3],[nhhosp01].[dbo].[ingresos].[codigo_servicio2] AS [CodigoServicio2],[nhhosp01].[dbo].[ingresos].[codigo_servicio3] AS [CodigoServicio3],[nhhosp01].[dbo].[ingresos].[plan_pk] AS [PlanPk],[nhhosp01].[dbo].[ingresos].[codigo_personal4] AS [CodigoPersonal4],[nhhosp01].[dbo].[ingresos].[codigo_personal5] AS [CodigoPersonal5],[nhhosp01].[dbo].[ingresos].[ing_tipo_pk] AS [IngTipoPk],[nhhosp01].[dbo].[ingresos].[ingori_pk] AS [IngoriPk],[nhhosp01].[dbo].[ingresos].[ingdrv_pk] AS [IngdrvPk],[nhhosp01].[dbo].[ingresos].[fecha_ingreso] AS [FechaIngreso],[nhhosp01].[dbo].[ingresos].[hora_ingreso] AS [HoraIngreso],[nhhosp01].[dbo].[ingresos].[reingreso_sn] AS [ReingresoSn],[nhhosp01].[dbo].[ingresos].[fecha_alta] AS [FechaAlta],[nhhosp01].[dbo].[ingresos].[hora_alta] AS [HoraAlta],[nhhosp01].[dbo].[ingresos].[diagno1_ing] AS [Diagno1Ing],[nhhosp01].[dbo].[ingresos].[ing_confirmado_sn] AS [IngConfirmadoSn],[nhhosp01].[dbo].[ingresos].[ing_ultifec_est] AS [IngUltifecEst],[nhhosp01].[dbo].[ingresos].[f_alta_prev] AS [FAltaPrev],[nhhosp01].[dbo].[ingresos].[h_alta_prev] AS [HAltaPrev],[nhhosp01].[dbo].[ingresos].[freg_ing] AS [FregIng],[nhhosp01].[dbo].[ingresos].[hreg_ing] AS [HregIng],[nhhosp01].[dbo].[ingresos].[freg_alta] AS [FregAlta],[nhhosp01].[dbo].[ingresos].[hreg_alta] AS [HregAlta],[nhhosp01].[dbo].[ingresos].[aislado_sn] AS [AisladoSn],[nhhosp01].[dbo].[ingresos].[ing_sec_anual] AS [IngSecAnual],[nhhosp01].[dbo].[ingresos].[ing_sec_diario] AS [IngSecDiario],[nhhosp01].[dbo].[ingresos].[ing_fconf] AS [IngFconf],[nhhosp01].[dbo].[ingresos].[ing_hconf] AS [IngHconf],[nhhosp01].[dbo].[ingresos].[ing_mottxt] AS [IngMottxt],[nhhosp01].[dbo].[ingresos].[ing_observ] AS [IngObserv],[nhhosp01].[dbo].[ingresos].[ci_inter_cod] AS [CiInterCod],[nhhosp01].[dbo].[ingresos].[tipo_hab_pk] AS [TipoHabPk],[nhhosp01].[dbo].[ingresos].[fecha_alta_adm] AS [FechaAltaAdm],[nhhosp01].[dbo].[ingresos].[ing_prest_aut] AS [IngPrestAut],[nhhosp01].[dbo].[ingresos].[ing_observ2] AS [IngObserv2],[nhhosp01].[dbo].[ingresos].[ing_cb_pk] AS [IngCbPk],[nhhosp01].[dbo].[ingresos].[cod_centro] AS [CodCentro],[nhhosp01].[dbo].[ingresos].[grupo_hosp_pk] AS [GrupoHospPk],[nhhosp01].[dbo].[ingresos].[td_dieta_pk] AS [TdDietaPk],[nhhosp01].[dbo].[ingresos].[ing_observ_dieta] AS [IngObservDieta],[nhhosp01].[dbo].[ingresos].[fecha_ing_adm] AS [FechaIngAdm],[nhhosp01].[dbo].[ingresos].[interven_sn] AS [IntervenSn],[nhhosp01].[dbo].[ingresos].[codigo_servicio4] AS [CodigoServicio4],[nhhosp01].[dbo].[ingresos].[icd_cod_salida] AS [IcdCodSalida],[nhhosp01].[dbo].[ingresos].[diag_salida] AS [DiagSalida],[nhhosp01].[dbo].[ingresos].[cod_ubicacion] AS [CodUbicacion],[nhhosp01].[dbo].[ingresos].[ing_tipo_pk_ini] AS [IngTipoPkIni] FROM [nhhosp01].[dbo].[ingresos]  WHERE ( [nhhosp01].[dbo].[ingresos].[cod_cama] IN (SELECT [nhhosp01].[dbo].[camas].[cod_cama] AS [CodCama] FROM [nhhosp01].[dbo].[camas]  WHERE ( ( [nhhosp01].[dbo].[camas].[cod_uenf_pk] = @CodUenfPk1))) And ( ( [nhhosp01].[dbo].[ingresos].[fecha_alta] IS NULL)))
    Parameter: @CodUenfPk1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 12.
Method Exit: CreateSelectDQ
Method Exit: CreateSelectDQ (Paging): no paging.

The 'IngresosEntity' are well fetched too.

Method Enter: EntityCollectionBase2.Add
Entity to Add Description: 
    Entity: es.novasoft.xsia.his.novahis.biz.IngresoEntity2. ObjectID: c07a22b2-956b-497f-acfd-54388192fb1f
    PrimaryKey field: CodIngresoPk. Type: System.Int32. Value: 1457
Index of added entity: 0
Method Exit: EntityCollectionBase2.Add
Method Enter: EntityCollectionBase2.Add
Entity to Add Description: 
    Entity: es.novasoft.xsia.his.novahis.biz.IngresoEntity2. ObjectID: 19b96051-acc5-4e5f-85f0-d74167401d4b
    PrimaryKey field: CodIngresoPk. Type: System.Int32. Value: 1412
Index of added entity: 1

ALL IS FINE UP TO HERE !!stuck_out_tongue_winking_eye

But inmediatly after i have this:

Method Enter: DataAccessAdapterBase.MergeNormal
Method Exit: DataAccessAdapterBase.MergeNormal

frowning frowning frowning

Do you understand this???

It's clear that the Ingresos collection before to merge is not empty, then what it's happening??

The execution don't stop in 'SetRelatedEntityProperty' of the 'CamasEntity', then the method is not invoqued.

Do you know? It's like the pk prefetched and the fk fetched was not the same. Or something similar.

The fantastic thing is that this only happen for MSSQL. I try with the same schema in Oracle and it works.

cry

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39916
Joined: 17-Aug-2003
# Posted on: 19-Jul-2005 13:27:00   

Do you understand this???

Yes, I've explained that above: those messages are the last ones in the call chain, there aren't any more logged deeper down, so it's natural you get only these even if there are entities to merge.

I've asked you a couple of questions in my earlier postings, I hope these show more lights on the matter. The main issue I have is that I don't know if the fetch reads 1 camas entity or more of them. If it's more, it can be there are ones without an ingregos entity, and perhaps you're checking these. (see my test code, which also checks for a given parent entity which doesn't have a child entity).

Also, if it works on oracle and not on sqlserver, it is likely the data which isn't correct. The code is generic, it doesn't work with any database specific element, so it works the same for all database systems.

What you can do is the following: - go to the runtime library sourcecode in the llblgen pro installation folder on your harddrive - open the AssemblyInfoDotNet11.cs in the ormsupportclasses library. - remove the reference at the bottom to the strong key. - do the same with the assemblyinfoDotNet11.cs in the sqlserver dqe. - open a commandprompt and go to the ormsupportclasses sourcecode folder - type: vsvars32.bat <enter> - type: make11_debug.cmd <enter> this will build the orm support classes in debug mode and also create a .pdb file. - go to the sqlserverdqe folder - type make11_debug.cmd <enter>

you now have a debug build of the ormsupportclasses and the sqlserver dqe. If your application requires the oracle dqe at the same time, also repeat it for the oracle DQE. Be sure to alter make11_debug.cmd to exclude the oracle types you don't need (like datadirect and 10g if you're targeting 9i)

RECOMPILE your complete application using these new builds. They're located in ORMSupportClasses\DotNET11\Bin and SqlServerDQE\DotNET11\bin

You are then able to set a breakpoint in MergeNormal and step into that method. The thing is I can't reproduce it here, so I can't help you further with this situation, though I'd encourage you to check the data you're testing with and also please PLEASE try to help me to get a clear picture on what you want to achieve, otherwise I can't help you, as I need to have a clear understanding of the functionality you want to be able to say if your code is wrong, the data is wrong or my code is wrong and I can only check if my code is wrong if I can setup a representative testcase. The testcase I wrote is IMHO reflecting what you want, but I'm not sure.

Frans Bouma | Lead developer LLBLGen Pro
mdominguez
User
Posts: 14
Joined: 30-May-2005
# Posted on: 19-Jul-2005 18:06:29   

I do what you said and I have this problem now.

can you help me?

=== Pre-bind state information === LOG: DisplayName = SD.LLBLGen.Pro.ORMSupportClasses.NET11, Version=1.0.2004.2, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27 (Fully-specified) LOG: Appbase = C:\SRC\xsiaHIS\testHIS\bin\Debug\ LOG: Initial PrivatePath = NULL

Calling assembly : es.novasoft.xsia.his.novahis.dal, Version=1.0.2018.27636, Culture=neutral, PublicKeyToken=null.

LOG: Publisher policy file is not found. LOG: Host configuration file not found. LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config. LOG: Post-policy reference: SD.LLBLGen.Pro.ORMSupportClasses.NET11, Version=1.0.2004.2, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27 LOG: Attempting download of new URL filedisappointed //Cdisappointed SRC/xsiaHIS/testHIS/bin/Debug/SD.LLBLGen.Pro.ORMSupportClasses.NET11.DLL. WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN

mdominguez
User
Posts: 14
Joined: 30-May-2005
# Posted on: 19-Jul-2005 19:02:52   

Forget the last message, I thing my VS was make me crazy. After the traditional method of restart the VS five or six times now is working.

Well, the problem.

Method MergeNormal line 3627

IEntity2 pkObject = FindPkObject(pkSideHashes, fkHash, fkSideCollection[j], currentElement.Relation);
if(pkObject==null)
{
    // no pk object found. continue
    continue;
}

First, I thing that is not normal that I don't find the pk object because the SQL make for do the prefetch retrieve exactly the rows that are relate in BD. Then I think that is an error do a continue without almost note that fact with a trace (maybe an execption).

Well, my problem is that while the pkSideHashes has a Cama code like "CAMA01 " (note the blank spaces) the fkSideCollection has "CAMA01" (without blank spaces) then really the codes don't match.

In my Database both fields are char(10) and the referential integrity is well build.

Any help?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39916
Joined: 17-Aug-2003
# Posted on: 19-Jul-2005 19:24:02   

Aha, a char based problem. disappointed

The sad thing is, stripping the space off the key (so "CAMA01 " becomes "CAMA01") to have a match is not correct, as the space IS in the data so stripping it off in the code would alter the value, and can lead to other results which don't match.

The space in the "CAMA01 " value, is in the db, and therefore is seen as another value. It's not the space you get normally from char fields, as the field is 10 long and just 1 space is present.

My suggestion is that you trim off the space from the field values and make sure the space isn't inserted again, if you don't want the space to be inserted.

Now, another thing is of course: how did it get there in the first place simple_smile . I mean: the FK value doesn't have the space, and I don't cut off any spaces whatsoever, so if the two entities were saved together, the FK value should have the space as well... If that's the case, please let me know.

Frans Bouma | Lead developer LLBLGen Pro
mdominguez
User
Posts: 14
Joined: 30-May-2005
# Posted on: 20-Jul-2005 08:55:11   

Otis wrote:

Now, another thing is of course: how did it get there in the first place simple_smile . I mean: the FK value doesn't have the space, and I don't cut off any spaces whatsoever, so if the two entities were saved together, the FK value should have the space as well... If that's the case, please let me know.

It's the case Otis.

In my Database both fields are char(10) and the referential integrity is well build. I mean, there are two tables ([camas] and [ingresos]), one with the PK field ([camas].cod_cama) and one with the FK field ([ingresos].cod_cama).

ingresos

cod_ingreso (PK) : integer cod_cama (FK) : char(10)

camas

cod_cama (PK) : char(10)

And we have a referential constraint between [ingresos].cod_cama and [camas].cod_cama.

Then, in the Database is impossible that the fields was different one from another.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39916
Joined: 17-Aug-2003
# Posted on: 20-Jul-2005 10:15:03   

mdominguez wrote:

Otis wrote:

Now, another thing is of course: how did it get there in the first place simple_smile . I mean: the FK value doesn't have the space, and I don't cut off any spaces whatsoever, so if the two entities were saved together, the FK value should have the space as well... If that's the case, please let me know.

It's the case Otis.

In my Database both fields are char(10) and the referential integrity is well build. I mean, there are two tables ([camas] and [ingresos]), one with the PK field ([camas].cod_cama) and one with the FK field ([ingresos].cod_cama).

ingresos

cod_ingreso (PK) : integer cod_cama (FK) : char(10)

camas

cod_cama (PK) : char(10)

And we have a referential constraint between [ingresos].cod_cama and [camas].cod_cama. Then, in the Database is impossible that the fields was different one from another.

The space problem is a vague one. Here I have added a 2 char length PK ('SD') and FK in customer and order. I fetch them in a prefetch path and it works. :


[Test]
public void CharLenTest()
{
    CustomerEntity sd = new CustomerEntity("SD");
    PrefetchPath2 path = new PrefetchPath2((int)EntityType.CustomerEntity);
    path.Add(CustomerEntity.PrefetchPathOrders);
    using(DataAccessAdapter adapter = new DataAccessAdapter())
    {
        adapter.FetchEntity(sd, path);
        Assert.AreEqual(1, sd.Orders.Count);
        Assert.AreEqual(5, sd.CustomerId.Length);
        Assert.AreEqual(2, sd.CustomerId.Trim().Length);
    }
}

Both the pk and fk are nchar(5). (I ran the tests on char(10) as well, no difference) sd.CustomerId.Length is 5, not 2, but contains the 3 trailing spaces as it's a char field.

I added these records in Query Analyzer.

Now, I ran a test where I add the entities in code, with a PK with a space and an FK without the space:


[Test]
public void CharLenTest()
{
    using(DataAccessAdapter adapter = new DataAccessAdapter())
    {
        CustomerEntity sd = new CustomerEntity();
        sd.CustomerId = "SD ";
        sd.CompanyName = "SolutionsDesign";
        adapter.SaveEntity(sd);

        OrderEntity sdOrder = new OrderEntity();
        sdOrder.CustomerId = "SD";
        adapter.SaveEntity(sdOrder);
    
        EntityCollection customers = new EntityCollection(new CustomerEntityFactory());
        RelationPredicateBucket filter = new RelationPredicateBucket();
        filter.PredicateExpression.Add(PredicateFactory.CompareValue(CustomerFieldIndex.CompanyName, ComparisonOperator.Equal, "SolutionsDesign"));
        PrefetchPath2 path = new PrefetchPath2((int)EntityType.CustomerEntity);
        path.Add(CustomerEntity.PrefetchPathOrders);
        adapter.FetchEntityCollection(customers, filter, path);
        Assert.AreEqual(1, customers.Count);
        CustomerEntity fetchedCustomer = (CustomerEntity)customers[0];
        Assert.AreEqual(1, fetchedCustomer.Orders.Count);

        adapter.DeleteEntity(sdOrder);
        adapter.DeleteEntity(sd);
    }
}

I also fetch the entity like you do, e.g.: with a collection and a filter on another field. This also succeeds.

I.o.w.: I really don't know how the FK field doesn't have the space(s) trailing its value, as it should have the trailing spaces as they're of the same length.

(I previously mentioned that 'lalala ' and 'lalala' were two different values, which they are, though for sqlserver they aren't. I don't know how other databases handle these)

I also tested it on normal char fields, same result.

I can't reproduce it in any way. I use the latest runtime library code (1.0.2004.2.07082005). I've no idea what caused the problem on your end...

If you fetch the ingregos entity separately, does the FK field has the space as well (i.e.: a length of 10) ?

Frans Bouma | Lead developer LLBLGen Pro
mdominguez
User
Posts: 14
Joined: 30-May-2005
# Posted on: 20-Jul-2005 13:53:43   

confused confused confused Incredible !!!!!

I fetch separately the "Camas" entity and I get:

cod_cama

[UCI-10 ]

I fetch separately the "Ingresos" entity and I get:

cod_ingreso cod_cama


[1457] [UCI-10]

The PK entity have 10 characters length but the FK entity is trimmed !!!

The referencial integrity constraint is well formed and it is: ALTER TABLE [dbo].[ingresos] ADD CONSTRAINT [fk_ingresos_camas_ing_camas] FOREIGN KEY ( [cod_cama] ) REFERENCES [camas] ( [cod_cama] ) GO

Otis, your test was with MSSQL, isn't it?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39916
Joined: 17-Aug-2003
# Posted on: 20-Jul-2005 14:06:04   

Hmm. that's very strange indeed.. Yes I tested with Sqlserver 2000 SP3a. My server is installed using the default collation.

Frans Bouma | Lead developer LLBLGen Pro
mdominguez
User
Posts: 14
Joined: 30-May-2005
# Posted on: 22-Jul-2005 08:45:24   

Otis,

Is there some news about this? Do you need more help.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39916
Joined: 17-Aug-2003
# Posted on: 22-Jul-2005 09:47:16   

mdominguez wrote:

Otis, Is there some news about this? Do you need more help.

Well, as I can't reproduce it here in any way, I'm out of options, so I wonder if your sqlserver is installed with a different collation, like a case sensitive collation or different character table. I find it very strange the CHAR(10) field in ingregos gives a value without trailing spaces, especially because I do nothing with the value, so the value you read from the property is what's been read from the DB. If you also don't do anything with the value of that property, e.g. trim it or do other processing, it's beyond me why this happens. disappointed

Frans Bouma | Lead developer LLBLGen Pro