You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Juan Toro Marty <ju...@gmail.com> on 2009/07/22 12:01:12 UTC
updating...
Can anybody helpme teachme any way to make an update... i am using the
following way:
Perfiles perfil = this.getPerfil(objid);//with this i retrieve an
object Perfil. then...
perfil.setName = name;
perfil.setAge = age;
....etc...
this.datacontext.commitChanges();
but nothing happens...
is this the right way to do an update? it seems to me... but i have to
say here are the 6am in the morning and i only want to go to the
bed... x_X
please advice me.... thanks.
btw: sorry about my english...
Re: updating...
Posted by Juan Toro Marty <ju...@gmail.com>.
Thanks for the replies, i solved my problem... i guess i was too
sleepy to notice that I was not given the correct ObjectId of my
jtable row to make the update works...
2009/7/22 Juan Toro Marty <ju...@gmail.com>:
> public Perfiles buscarPerfil(ObjectId id)
> {
> ObjectIdQuery query = new ObjectIdQuery(id);
> this.p = (Perfiles) DataObjectUtils.objectForQuery(this.dc, query);
> // this.perfiles.add(this.p);
> // return this.perfiles;
> return this.p;
> }
>
> this is my buscarPerfiles method... its return a global uninitialized var.
>
> and btw this is my delete perfil methos...
> public void borrarPerfil(ObjectId id)
> {
> this.p = this.buscarPerfil(id);
> this.dc.deleteObject(this.p);
> this.dc.commitChanges();
> }
> and it works... I'll try to be sure that I am creating the object
> into the datacontext.
>
> thanks for the replies btw
>
> 2009/7/22 Emanuele Maiarelli <ev...@yahoo.it>:
>> this.datacontext.commitChanges(); is correct
>> I fear u didn't create the object that you are populating, into datacontext.
>>
>> Check ur this.getPerfil(objid), the object that you are updating must be created into context or by a query
>> SelectQuery q=new SelectQuery(this.queryClass);
>> List data = ctx.performQuery(q);
>>
>> where data is a List of queryClass objects,
>> or if u want create a new object
>>
>> Object o=ctx.newObject(this.queryClass);
>>
>> In any case youcan check what is present into ur context:
>>
>> ctx.modifiedObjects(); will return a Collection of objects that you modified
>> ctx.newObjects(); will return a Collection of objects that you created
>>
>>
>>
>>
>>
>>
>> ________________________________
>> Da: Juan Toro Marty <ju...@gmail.com>
>> A: user@cayenne.apache.org
>> Inviato: Mercoledì 22 luglio 2009, 12:01:12
>> Oggetto: updating...
>>
>> Can anybody helpme teachme any way to make an update... i am using the
>> following way:
>>
>> Perfiles perfil = this.getPerfil(objid);//with this i retrieve an
>> object Perfil. then...
>> perfil.setName = name;
>> perfil.setAge = age;
>> ....etc...
>> this.datacontext.commitChanges();
>>
>> but nothing happens...
>> is this the right way to do an update? it seems to me... but i have to
>> say here are the 6am in the morning and i only want to go to the
>> bed... x_X
>> please advice me.... thanks.
>>
>> btw: sorry about my english...
>>
>>
>>
>>
>
Re: updating...
Posted by Juan Toro Marty <ju...@gmail.com>.
public Perfiles buscarPerfil(ObjectId id)
{
ObjectIdQuery query = new ObjectIdQuery(id);
this.p = (Perfiles) DataObjectUtils.objectForQuery(this.dc, query);
// this.perfiles.add(this.p);
// return this.perfiles;
return this.p;
}
this is my buscarPerfiles method... its return a global uninitialized var.
and btw this is my delete perfil methos...
public void borrarPerfil(ObjectId id)
{
this.p = this.buscarPerfil(id);
this.dc.deleteObject(this.p);
this.dc.commitChanges();
}
and it works... I'll try to be sure that I am creating the object
into the datacontext.
thanks for the replies btw
2009/7/22 Emanuele Maiarelli <ev...@yahoo.it>:
> this.datacontext.commitChanges(); is correct
> I fear u didn't create the object that you are populating, into datacontext.
>
> Check ur this.getPerfil(objid), the object that you are updating must be created into context or by a query
> SelectQuery q=new SelectQuery(this.queryClass);
> List data = ctx.performQuery(q);
>
> where data is a List of queryClass objects,
> or if u want create a new object
>
> Object o=ctx.newObject(this.queryClass);
>
> In any case youcan check what is present into ur context:
>
> ctx.modifiedObjects(); will return a Collection of objects that you modified
> ctx.newObjects(); will return a Collection of objects that you created
>
>
>
>
>
>
> ________________________________
> Da: Juan Toro Marty <ju...@gmail.com>
> A: user@cayenne.apache.org
> Inviato: Mercoledì 22 luglio 2009, 12:01:12
> Oggetto: updating...
>
> Can anybody helpme teachme any way to make an update... i am using the
> following way:
>
> Perfiles perfil = this.getPerfil(objid);//with this i retrieve an
> object Perfil. then...
> perfil.setName = name;
> perfil.setAge = age;
> ....etc...
> this.datacontext.commitChanges();
>
> but nothing happens...
> is this the right way to do an update? it seems to me... but i have to
> say here are the 6am in the morning and i only want to go to the
> bed... x_X
> please advice me.... thanks.
>
> btw: sorry about my english...
>
>
>
>
Re: updating...
Posted by Emanuele Maiarelli <ev...@yahoo.it>.
this.datacontext.commitChanges(); is correct
I fear u didn't create the object that you are populating, into datacontext.
Check ur this.getPerfil(objid), the object that you are updating must be created into context or by a query
SelectQuery q=new SelectQuery(this.queryClass);
List data = ctx.performQuery(q);
where data is a List of queryClass objects,
or if u want create a new object
Object o=ctx.newObject(this.queryClass);
In any case youcan check what is present into ur context:
ctx.modifiedObjects(); will return a Collection of objects that you modified
ctx.newObjects(); will return a Collection of objects that you created
________________________________
Da: Juan Toro Marty <ju...@gmail.com>
A: user@cayenne.apache.org
Inviato: Mercoledì 22 luglio 2009, 12:01:12
Oggetto: updating...
Can anybody helpme teachme any way to make an update... i am using the
following way:
Perfiles perfil = this.getPerfil(objid);//with this i retrieve an
object Perfil. then...
perfil.setName = name;
perfil.setAge = age;
....etc...
this.datacontext.commitChanges();
but nothing happens...
is this the right way to do an update? it seems to me... but i have to
say here are the 6am in the morning and i only want to go to the
bed... x_X
please advice me.... thanks.
btw: sorry about my english...
Re: updating...
Posted by Andrus Adamchik <an...@objectstyle.org>.
On Jul 22, 2009, at 1:01 PM, Juan Toro Marty wrote:
> Perfiles perfil = this.getPerfil(objid);//with this i retrieve an
> object Perfil. then...
> perfil.setName = name;
> perfil.setAge = age;
> ....etc...
> this.datacontext.commitChanges();
assuming 'perfil' is created in the same 'datacontext' as
'this.datacontext', this looks about right.
Andrus