A-- OneToMany ---B
I have a class that has a collection. This collection uses lazy in the XML. But When I find a object A, all collection is populated. It is supposed that it is not necessary to fill the collection or yes?
I need code extra in the property of the collection to implement lazy collection (how in OneToOne). My problem is that I have one Master/Detail structure. My detail have many object that I do not need to load in certain cases.
Saludos
Victor
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Lazy loading the association will cause proxy versions of the B objects to be loaded into the collection of object A
What you will need to do in your B class is determine if your object is a proxy object or not and then self load the full version of the object when required.
For one-to-one associations the lazy load causes the target attribute to be loaded with the proxy version of the object instead of the full version.
Also, no further association processing is done with a proxy load. For example if you have
A --(1:N)-- B --(1:1)-- C
A lazy load of the A/B association will mean that A is loaded, proxy versions of B are loaded and that the B/C association is not processed (ie no C objects are loaded).
- Richard.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
this mean that the collection always is loaded ???
My problem is that I have:
A -- OneToMany --B B-- OneToOne --C
A -- OneToMany --D
A -- OneToMany --E
But, i don't need retrive all association in some cases. My idea is that when accesses to the get of the collection, in this moment recovers of the data base. Or any form to don't load the collection, for example retriveAutomatic=false and in the property of the collection retrive the collection.
Saludos
Victor
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> this mean that the collection always is loaded ???
If RetrieveAutomatic for an association is set to "true" or "lazy" then the collection is always loaded. "true" will populate the collection with full objects, "lazy" will populate it with proxy objects.
> for example retriveAutomatic=false and in the property of the collection retrive the collection.
This is the perfect way to do it if you only want to load the collection when you access it! :-)
All you need to do in your property get is to check if the collection is nothing, instantiate it and use a retrievecriteria or getall() to load it.
- Richard.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But getAll() retrive object the same class, but not the collection associated.
I have a following code in class Cuenta:
Property Transacciones() As TransaccionC
Get
If _transacciones Is Nothing Or _transacciones.Count = 0 Then
Me.getAll(True)
End If
Return _transacciones
End Get
Set(ByVal Value As TransaccionC)
If Not CPersistentObject.Equals(_transacciones, Value) Then
_transacciones = Value
SetDirtyFlag()
End If
End Set
End Property
this code retrive all objects of the Cuenta Class and not the collection Transacciones.
I am trying use getall(true), but Cuenta is in the cache and not proccess the associate.
Any form to retrive collection, for example
me.transacciones.retrive or something. My idea is that sql query only join of the two tables.
Saludos
Victor
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just use a RetrieveCriteria and populate the collection manually.
Try something like this
Dim t as New TransaccionC
Dim rc as New CRetrieveCriteria
rc.ClassMap = t.GetClassMap
rc.WhereCondition.AddSelectEqual("CuentaKey",Me.KeyValue)
Dim cc as CCursor = rc.perform()
While Not cc.EOF
t = new TransaccionC
cc.LoadObject(t)
_transacciones.Add(t)
cc.NextCursor
End While
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi.
A-- OneToMany ---B
I have a class that has a collection. This collection uses lazy in the XML. But When I find a object A, all collection is populated. It is supposed that it is not necessary to fill the collection or yes?
I need code extra in the property of the collection to implement lazy collection (how in OneToOne). My problem is that I have one Master/Detail structure. My detail have many object that I do not need to load in certain cases.
Saludos
Victor
Lazy loading the association will cause proxy versions of the B objects to be loaded into the collection of object A
What you will need to do in your B class is determine if your object is a proxy object or not and then self load the full version of the object when required.
For one-to-one associations the lazy load causes the target attribute to be loaded with the proxy version of the object instead of the full version.
Also, no further association processing is done with a proxy load. For example if you have
A --(1:N)-- B --(1:1)-- C
A lazy load of the A/B association will mean that A is loaded, proxy versions of B are loaded and that the B/C association is not processed (ie no C objects are loaded).
- Richard.
Hi.
this mean that the collection always is loaded ???
My problem is that I have:
A -- OneToMany --B B-- OneToOne --C
A -- OneToMany --D
A -- OneToMany --E
But, i don't need retrive all association in some cases. My idea is that when accesses to the get of the collection, in this moment recovers of the data base. Or any form to don't load the collection, for example retriveAutomatic=false and in the property of the collection retrive the collection.
Saludos
Victor
> this mean that the collection always is loaded ???
If RetrieveAutomatic for an association is set to "true" or "lazy" then the collection is always loaded. "true" will populate the collection with full objects, "lazy" will populate it with proxy objects.
> for example retriveAutomatic=false and in the property of the collection retrive the collection.
This is the perfect way to do it if you only want to load the collection when you access it! :-)
All you need to do in your property get is to check if the collection is nothing, instantiate it and use a retrievecriteria or getall() to load it.
- Richard.
Hi.
But getAll() retrive object the same class, but not the collection associated.
I have a following code in class Cuenta:
Property Transacciones() As TransaccionC
Get
If _transacciones Is Nothing Or _transacciones.Count = 0 Then
Me.getAll(True)
End If
Return _transacciones
End Get
Set(ByVal Value As TransaccionC)
If Not CPersistentObject.Equals(_transacciones, Value) Then
_transacciones = Value
SetDirtyFlag()
End If
End Set
End Property
this code retrive all objects of the Cuenta Class and not the collection Transacciones.
I am trying use getall(true), but Cuenta is in the cache and not proccess the associate.
Any form to retrive collection, for example
me.transacciones.retrive or something. My idea is that sql query only join of the two tables.
Saludos
Victor
You're property get code is wrong since Me is of type Cuenta, so getAll will retrieve all the Cuenta objects.
You want to do something like this
dim t as new TransaccionC
_transacciones = t.GetAll(true)
Hi
Or need a retrievecriteria.
Hi.
ok, but i need retrive only Transaccion that is associated with a Cuenta and not all.
That's OK.
Just use a RetrieveCriteria and populate the collection manually.
Try something like this
Dim t as New TransaccionC
Dim rc as New CRetrieveCriteria
rc.ClassMap = t.GetClassMap
rc.WhereCondition.AddSelectEqual("CuentaKey",Me.KeyValue)
Dim cc as CCursor = rc.perform()
While Not cc.EOF
t = new TransaccionC
cc.LoadObject(t)
_transacciones.Add(t)
cc.NextCursor
End While