You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by Joerg Heinicke <jo...@gmx.de> on 2004/05/19 16:40:07 UTC
[OTM] NPE on OTMConnection.refresh(object)
When refreshing an already persistent object, that also has been retrieved from
db, I get an NPE:
java.lang.NullPointerException
at org.apache.ojb.otm.core.ConcreteEditingContext.
refresh(ConcreteEditingContext.java:826)
at org.apache.ojb.otm.core.BaseConnection.
refresh(BaseConnection.java:377)
at com.ewerk.erak.db.ojb.otm.
LegalcaseDAOImpl.updateLegalcase(LegalcaseDAOImpl.java:132)
In ConcreteEditingContext.refresh()
public void refresh(Identity oid, Object object)
{
ContextEntry entry = (ContextEntry) _objects.get(oid);
Object[][] origFields = (Object[][]) _original.get(oid);
if (origFields != null)
{
setFields(entry.userObject, origFields);
if (object != entry.userObject)
{
setFields(object, origFields);
}
}
entry.state = entry.state.refresh();
}
the local variable entry is null. Even worse the HashMap _objects it self is
empty. How can this be possible at all?
Joerg
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: [OTM] NPE on OTMConnection.refresh(object)
Posted by Oleg Nitz <on...@ukr.net>.
On Thursday 20 May 2004 00:45, Joerg Heinicke wrote:
> On 19.05.2004 23:37, Oleg Nitz wrote:
> > Hi Jeorg,
> >
> > I guess the object was retrieved in some transaction A,
> > and you refresh it in another transaction B.
>
> Yes, definitely. And that's not a use case for refresh()?
No, it's for reverting of state of object which was modified during
transaction, it's used in JDO.
Regards,
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: [OTM] NPE on OTMConnection.refresh(object)
Posted by Joerg Heinicke <jo...@gmx.de>.
On 19.05.2004 23:37, Oleg Nitz wrote:
> Hi Jeorg,
>
> I guess the object was retrieved in some transaction A,
> and you refresh it in another transaction B.
Yes, definitely. And that's not a use case for refresh()?
As a work around at the moment I do
Creditor c =
conn.getObjectForIdentity(conn.getIdentityForObject(legalcase.getCreditor()));
legalcase.setCreditor(c);
where I thought simply
conn.refresh(legalcase.getCreditor());
would work.
Joerg
> On Wednesday 19 May 2004 17:40, Joerg Heinicke wrote:
>
>>When refreshing an already persistent object, that also has been retrieved
>>from db, I get an NPE:
>>
>>java.lang.NullPointerException
>>at org.apache.ojb.otm.core.ConcreteEditingContext.
>> refresh(ConcreteEditingContext.java:826)
>>at org.apache.ojb.otm.core.BaseConnection.
>> refresh(BaseConnection.java:377)
>>at com.ewerk.erak.db.ojb.otm.
>>
>>LegalcaseDAOImpl.updateLegalcase(LegalcaseDAOImpl.java:132)
>>
>>In ConcreteEditingContext.refresh()
>>
>>public void refresh(Identity oid, Object object)
>>{
>> ContextEntry entry = (ContextEntry) _objects.get(oid);
>> Object[][] origFields = (Object[][]) _original.get(oid);
>> if (origFields != null)
>> {
>> setFields(entry.userObject, origFields);
>> if (object != entry.userObject)
>> {
>> setFields(object, origFields);
>> }
>> }
>> entry.state = entry.state.refresh();
>>}
>>
>>the local variable entry is null. Even worse the HashMap _objects it self
>>is empty. How can this be possible at all?
>>
>>Joerg
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: [OTM] NPE on OTMConnection.refresh(object)
Posted by Oleg Nitz <on...@ukr.net>.
Hi Jeorg,
I guess the object was retrieved in some transaction A,
and you refresh it in another transaction B.
Regards,
Oleg
On Wednesday 19 May 2004 17:40, Joerg Heinicke wrote:
> When refreshing an already persistent object, that also has been retrieved
> from db, I get an NPE:
>
> java.lang.NullPointerException
> at org.apache.ojb.otm.core.ConcreteEditingContext.
> refresh(ConcreteEditingContext.java:826)
> at org.apache.ojb.otm.core.BaseConnection.
> refresh(BaseConnection.java:377)
> at com.ewerk.erak.db.ojb.otm.
>
> LegalcaseDAOImpl.updateLegalcase(LegalcaseDAOImpl.java:132)
>
> In ConcreteEditingContext.refresh()
>
> public void refresh(Identity oid, Object object)
> {
> ContextEntry entry = (ContextEntry) _objects.get(oid);
> Object[][] origFields = (Object[][]) _original.get(oid);
> if (origFields != null)
> {
> setFields(entry.userObject, origFields);
> if (object != entry.userObject)
> {
> setFields(object, origFields);
> }
> }
> entry.state = entry.state.refresh();
> }
>
> the local variable entry is null. Even worse the HashMap _objects it self
> is empty. How can this be possible at all?
>
> Joerg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org