So the best way to do this is to keep my shared DataContext for reading
and when I need to change something I create a new DataContext, pass the
object read to this new context (using for instants an ObjectIdQuery)
and commit on this new Context. To refresh the read-only Context with
the changes I will need to perform a new query?
Thanx
Bruno
Em 24-01-2011 10:45, Andrus Adamchik escreveu:
This is wrong. You shouldn't be sharing a read/write DataContext between
requests. I can't say with 100% certainty that this is causing this particular
problem, but it is guaranteed to cause various consistency issues.
I often use a pattern of 1 shared app-scoped DataContext for reads, and then create
short-lived throwaway DataContexts to change objects ("short-lived" means a
lifespan<= request duration).
Andrus
On Jan 24, 2011, at 12:35 PM, Bruno René Santos wrote:
In the init() phase of each portlet (I'm using liferay) I call the
DataContext.createDataContext() to create a DataContext that is used throughout
the application (always the same instance, I create an object that is passed as
parameter to all other objects). And yes my app is not readonly but I also do
not try to write on the view... Have you ever thought how we could handle these
cases near the comment you left on the code? Could I try like a commitChanges
there? Any ideas are welcome :)
Thanx
Bruno
Em 24-01-2011 10:18, Andrus Adamchik escreveu:
I am developing a web application so it is possible that some thread is
interfering on the refreshing of the Object Cache?
This depends on how you share a DataContext. If your app is not read-only,
DataContext should not be shared.
Andrus
On Jan 24, 2011, at 12:09 PM, Bruno René Santos wrote:
HoVPlanoContas is a view. And yes the id 129 exists. On that piece of code
you're expecting a committed object but you're getting a modified one... I am
going to analyze a little further why on this region of code this happens (On
other parts I dont get this error). But it would help to know the purpose of
this PrepareForAccess method and how the object starts as HOLLOW and all of a
sudden it is supposed to be committed (but in the end is modified...). I am
developing a web application so it is possible that some thread is interfering
on the refreshing of the Object Cache? Any other ideas?
Thanx
Bruno
Em 24-01-2011 09:43, Andrus Adamchik escreveu:
Can you confirm that there is a record for HoVPlanoContas in the database with
id of 129? Is it reproducible?
Andrus
On Jan 24, 2011, at 3:03 AM, Bruno René Santos wrote:
Hello all,
Im having an error when I access an object:
Caused by: org.apache.cayenne.FaultFailureException: [v.3.0.1 Aug 25 2010 19:38:17]
Error resolving fault for ObjectId:<ObjectId:HoVPlanoContas, id=129> and
state (modified). Possible cause - matching row is missing from the database.
at org.apache.cayenne.BaseContext.prepareForAccess(BaseContext.java:171)
at
org.apache.cayenne.CayenneDataObject.readProperty(CayenneDataObject.java:230)
When I go to the line 171 of BaseContext there is this comment from Andrus:
// TODO: andrus 4/13/2006, modified and deleted states are possible due to
// a race condition, should we handle them here?
Why this happens? Any solutions?
Thanx
Bruno
--
Bruno René Santos | [email protected]<mailto:[email protected]> | Gestor
de Projectos | Analista | Programador | Investigador
Holos - Soluções Avançadas em Tecnologias de Informação S.A.
Parque de Ciência e Tecnologia de Almada/Setúbal . Edifício Madan Parque
Rua dos Inventores . Quinta da Torre . 2825 - 182 Caparica . Portugal
Phone: +351 210 438 686 . Fax: +351 210 438 687 . Web: www.holos.pt
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed. If
you are not the intended recipient or the person responsible for delivering the
email to the intended recipient, be advised that you have received this email
in error and that any use, dissemination, forwarding, printing, or copying of
this email is strictly prohibited. If you have received this email in error
please notify Bruno René Santos by telephone on +351 210 438 686
--
Bruno René Santos | [email protected]<mailto:[email protected]> | Gestor de
Projectos | Analista | Programador | Investigador
Holos - Soluções Avançadas em Tecnologias de Informação S.A.
Parque de Ciência e Tecnologia de Almada/Setúbal . Edifício Madan Parque
Rua dos Inventores . Quinta da Torre . 2825 - 182 Caparica . Portugal
Phone: +351 210 438 686 . Fax: +351 210 438 687 . Web: www.holos.pt
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed. If
you are not the intended recipient or the person responsible for delivering the
email to the intended recipient, be advised that you have received this email
in error and that any use, dissemination, forwarding, printing, or copying of
this email is strictly prohibited. If you have received this email in error
please notify Bruno René Santos by telephone on +351 210 438 686
--
Bruno René Santos | [email protected]<mailto:[email protected]> | Gestor de
Projectos | Analista | Programador | Investigador
Holos - Soluções Avançadas em Tecnologias de Informação S.A.
Parque de Ciência e Tecnologia de Almada/Setúbal . Edifício Madan Parque
Rua dos Inventores . Quinta da Torre . 2825 - 182 Caparica . Portugal
Phone: +351 210 438 686 . Fax: +351 210 438 687 . Web: www.holos.pt
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed. If
you are not the intended recipient or the person responsible for delivering the
email to the intended recipient, be advised that you have received this email
in error and that any use, dissemination, forwarding, printing, or copying of
this email is strictly prohibited. If you have received this email in error
please notify Bruno René Santos by telephone on +351 210 438 686
--
Bruno René Santos | [email protected] <mailto:[email protected]> |
Gestor de Projectos | Analista | Programador | Investigador
Holos - Soluções Avançadas em Tecnologias de Informação S.A.
Parque de Ciência e Tecnologia de Almada/Setúbal . Edifício Madan Parque
Rua dos Inventores . Quinta da Torre . 2825 - 182 Caparica . Portugal
Phone: +351 210 438 686 . Fax: +351 210 438 687 . Web: www.holos.pt
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they are
addressed. If you are not the intended recipient or the person
responsible for delivering the email to the intended recipient, be
advised that you have received this email in error and that any use,
dissemination, forwarding, printing, or copying of this email is
strictly prohibited. If you have received this email in error please
notify Bruno René Santos by telephone on +351 210 438 686