You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Jan Lendholt <jl...@hotmail.com> on 2007/11/19 19:48:00 UTC

Deletion of obejcts

Hey folks,

I got pretty frustrated in the meantime with cayenne, as i think there are happing some pretty ugly thingsin cayenne's internals.

At first, I again need help on deleting objects with relationships.

Let's say I've got one table called "booking" with its entity Booking.
And I've got another table extras with entity Extras.

The relationship is from booking to Extras one to many (1-n entries in Extra for one booking entry).
I've set both relationships with delete rule to nullify.

Now, sime pseudo-code:

Booking booking = ...;

List<Extras> extras = booking.getExtrasArray();

for (int i= 0;...)
{
    booking.getDataContext().deleteObject(extras.get(i));
    
}

commitChanges();

Now, the data are deleted from the database.
But if I do a booking.getExtrasArray(); again, it still contains the deleted objects; it seems as if they were cached or so :-/
Even an booking.RemoveFromExtras(extras.get(i)) won't work.

Hiow does the deletion work correctly? I really don't understand why cayenne won't manage that automatically, for it would be quite logic to remove deleted objects form the object graph.

Well, some words about the "ugly things": We had some really strange errors coming up which are at the end quite logic, but do not help finding the problem so wen spent about 3 hours to find it.
We deleted an entity in the modeler and recreated it. Unfortunately, there was a reference missing. So cayenne just threw an index out of bounds exception. I really don't understand such a behaviour either :/ To me, such kind of errors should be handeled and analyzed automatically by a framework, e.g. like spring does. Ok, that's it for now. Hope you still like me :-D


Tahnks a lot in advance & kind regards form Hamburg!

Jan




_________________________________________________________________
Importieren Sie ganz einfach Ihre E-Mail Adressen in den Messenger!
http://messenger.live.de/community/neuekontakte_adressimport.html

RE: Deletion of obejcts

Posted by Jan Lendholt <jl...@hotmail.com>.
Well, I just saw, that these deleted objects have the PersistenceState TRANSIENT.
Why are they then still listed in the array? Do I really manually have to check the PS on each request on an array list? That really sounds strange to me...



> Date: Mon, 19 Nov 2007 15:08:38 -0500
> Subject: Re: Deletion of obejcts
> From: kmenard@servprise.com
> To: user@cayenne.apache.org
> 
> Hi Jan,
> 
> On 11/19/07 1:48 PM, "Jan Lendholt" <jl...@hotmail.com> wrote:
> 
> > The relationship is from booking to Extras one to many (1-n entries in Extra
> > for one booking entry).
> > I've set both relationships with delete rule to nullify.
> 
> Are you sure that's correct?  It would seem to me that you would want to
> cascade in one direction and do nothing in the other.  I.e., you would
> probably want to delete all extras (cascade) if the Booking is deleted, but
> do nothing if an Extra is deleted.
> 
> -- 
> Kevin Menard
> Servprise International, Inc.
> Remote reboot & power control for network equipment
> www.servprise.com              +1 508.892.3823 x308
> 

_________________________________________________________________
Neu: Internet Explorer 7 optimiert für MSN!
http://optimize.de.msn.com/default.aspx?mkt=de-de

RE: Deletion of obejcts

Posted by Kevin Menard <km...@servprise.com>.
The rules I suggested are what you want.  They are also consistent with
foreign key deletion rules used by many RDBMSs.

Please note that with nullify, only the object that was deleted should
be yanked out of the context.  Otherwise, the only thing that is
happening is that the other end of the relationship is being set to
NULL.  Moreover, this is only happening inside of Cayenne, so even if
your DB ultimately disallows NULL values in those columns, you won't
trip over validation until you try to commit all of those objects.  This
is because it is perfectly legal to have an "inconsistent" object sit
around in memory as you set values on it.

-- 
Kevin

-----Original Message-----
From: Jan Lendholt [mailto:jlendholt@hotmail.com] 
Sent: Monday, November 19, 2007 3:12 PM
To: user@cayenne.apache.org
Subject: RE: Deletion of obejcts

Well, what would be the right rule for me?

I want - if booking recordset is deleted - to delete everything in
extras.
If a recordset in extras is deleted, I simply want the row to be
deleted. That works perfectly - but the object graph seems not get
updated :/

RE: Deletion of obejcts

Posted by Jan Lendholt <jl...@hotmail.com>.
Well, what would be the right rule for me?

I want - if booking recordset is deleted - to delete everything in extras.
If a recordset in extras is deleted, I simply want the row to be deleted. That works perfectly - but the object graph seems not get updated :/



> Date: Mon, 19 Nov 2007 15:08:38 -0500
> Subject: Re: Deletion of obejcts
> From: kmenard@servprise.com
> To: user@cayenne.apache.org
> 
> Hi Jan,
> 
> On 11/19/07 1:48 PM, "Jan Lendholt" <jl...@hotmail.com> wrote:
> 
> > The relationship is from booking to Extras one to many (1-n entries in Extra
> > for one booking entry).
> > I've set both relationships with delete rule to nullify.
> 
> Are you sure that's correct?  It would seem to me that you would want to
> cascade in one direction and do nothing in the other.  I.e., you would
> probably want to delete all extras (cascade) if the Booking is deleted, but
> do nothing if an Extra is deleted.
> 
> -- 
> Kevin Menard
> Servprise International, Inc.
> Remote reboot & power control for network equipment
> www.servprise.com              +1 508.892.3823 x308
> 

_________________________________________________________________
Die neue Version vom Windows Live Messenger ist da!
http://get.live.com/messenger/overview

Re: Deletion of objects

Posted by Andrus Adamchik <an...@objectstyle.org>.
Would be nice to open a Jira with details. We should be able to do  
something about it.

Andrus


On Nov 22, 2007, at 12:43 AM, Jan Lendholt wrote:

> Okay, I found the error - I used a wrong datatype for the  
> matchExpression.
> Well, in fact this is a stupid mistake by me; but in my opinion the  
> framework could handle this more smoothly.
>
> Just told you this nice exception as a illustration on how difficult  
> it could become working with cayenne if one is just a bit hasty on  
> cayennes use.
> I think that hibernate in this context is more reliable; but  
> therefore requires more work to be running at first.
> But dont want to talk about that now.
>
> Greets Jan
>
>
>
>> From: jlendholt@hotmail.com
>> To: user@cayenne.apache.org
>> Subject: RE: Deletion of obejcts
>> Date: Wed, 21 Nov 2007 22:38:34 +0000
>>
>> Hey Kevin,
>>
>> here is one of those exceptions I cannot get used to:
>>
>> java.lang.NullPointerException
>>    at  
>> org 
>> .apache 
>> .cayenne 
>> .access 
>> .trans 
>> .QualifierTranslator.appendObjectMatch(QualifierTranslator.java:153)
>>    at  
>> org 
>> .apache 
>> .cayenne 
>> .access.trans.QualifierTranslator.endNode(QualifierTranslator.java: 
>> 321)
>>    at org.apache.cayenne.exp.Expression.traverse(Expression.java:520)
>>    at org.apache.cayenne.exp.Expression.traverse(Expression.java:511)
>>    at org.apache.cayenne.exp.Expression.traverse(Expression.java:491)
>>    at  
>> org 
>> .apache 
>> .cayenne 
>> .access 
>> .trans.QualifierTranslator.doTranslation(QualifierTranslator.java:74)
>>    at  
>> org 
>> .apache 
>> .cayenne 
>> .access 
>> .trans.SelectTranslator.createSqlString(SelectTranslator.java:129)
>>    at  
>> org 
>> .apache 
>> .cayenne 
>> .access.trans.QueryAssembler.createStatement(QueryAssembler.java:95)
>>    at  
>> org 
>> .apache 
>> .cayenne.access.jdbc.SelectAction.performAction(SelectAction.java:71)
>>    at  
>> org 
>> .apache 
>> .cayenne 
>> .access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:59)
>>    at  
>> org.apache.cayenne.access.DataNode.performQueries(DataNode.java:273)
>>    at  
>> org 
>> .apache 
>> .cayenne 
>> .access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java: 
>> 301)
>>    at org.apache.cayenne.access.DataDomainQueryAction.access 
>> $000(DataDomainQueryAction.java:60)
>>    at org.apache.cayenne.access.DataDomainQueryAction 
>> $1.transform(DataDomainQueryAction.java:273)
>>    at  
>> org 
>> .apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java: 
>> 836)
>>    at  
>> org 
>> .apache 
>> .cayenne 
>> .access 
>> .DataDomainQueryAction 
>> .runQueryInTransaction(DataDomainQueryAction.java:270)
>>    at  
>> org 
>> .apache 
>> .cayenne 
>> .access.DataDomainQueryAction.execute(DataDomainQueryAction.java:110)
>>    at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java: 
>> 746)
>>    at  
>> org 
>> .apache 
>> .cayenne 
>> .util 
>> .ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:217)
>>    at  
>> org 
>> .apache 
>> .cayenne 
>> .access.DataContextQueryAction.execute(DataContextQueryAction.java: 
>> 54)
>>    at  
>> org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1387)
>>    at  
>> org 
>> .apache 
>> .cayenne 
>> .util 
>> .ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:217)
>>    at  
>> org 
>> .apache 
>> .cayenne 
>> .access.DataContextQueryAction.execute(DataContextQueryAction.java: 
>> 54)
>>    at  
>> org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1387)
>>    at  
>> org.apache.cayenne.access.DataContext.performQuery(DataContext.java: 
>> 1376)
>>    at  
>> ams 
>> .maintabpanes 
>> .buchungdetail 
>> .SingleBuchungContentPaneCatering 
>> .<init>(SingleBuchungContentPaneCatering.java:195)
>>    at  
>> ams 
>> .maintabpanes 
>> .buchungdetail 
>> .BuchungDetailWindowPane.<init>(BuchungDetailWindowPane.java:103)
>>    at ams.maintabpanes.event.EventTabPane 
>> $4.actionPerformed(EventTabPane.java:522)
>>    at  
>> nextapp 
>> .echo2 
>> .app.button.AbstractButton.fireActionPerformed(AbstractButton.java: 
>> 135)
>>    at nextapp.echo2.app.button.AbstractButton 
>> $1.actionPerformed(AbstractButton.java:100)
>>    at  
>> nextapp 
>> .echo2 
>> .app 
>> .button 
>> .DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:70)
>>    at  
>> nextapp 
>> .echo2 
>> .app.button.DefaultButtonModel.doAction(DefaultButtonModel.java:58)
>>    at  
>> nextapp 
>> .echo2.app.button.AbstractButton.doAction(AbstractButton.java:121)
>>    at  
>> nextapp 
>> .echo2.app.button.AbstractButton.processInput(AbstractButton.java: 
>> 506)
>>    at  
>> nextapp 
>> .echo2 
>> .app.update.ClientUpdateManager.process(ClientUpdateManager.java:116)
>>    at  
>> nextapp 
>> .echo2 
>> .app.update.UpdateManager.processClientUpdates(UpdateManager.java:89)
>>    at  
>> nextapp 
>> .echo2 
>> .webcontainer 
>> .ContainerSynchronizeService 
>> .renderUpdate(ContainerSynchronizeService.java:472)
>>    at  
>> nextapp 
>> .echo2 
>> .webrender 
>> .service.SynchronizeService.service(SynchronizeService.java:279)
>>    at  
>> nextapp 
>> .echo2.webrender.WebRenderServlet.process(WebRenderServlet.java:276)
>>    at  
>> nextapp 
>> .echo2.webrender.WebRenderServlet.doPost(WebRenderServlet.java:192)
>>    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
>>    at ams.AMSServlet.service(AMSServlet.java:36)
>>    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>>    at  
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java: 
>> 356)
>>    at org.mortbay.jetty.servlet.WebApplicationHandler 
>> $Chain.doFilter(WebApplicationHandler.java:342)
>>    at  
>> org 
>> .apache 
>> .cayenne 
>> .conf 
>> .WebApplicationContextFilter 
>> .doFilter(WebApplicationContextFilter.java:91)
>>    at org.mortbay.jetty.servlet.WebApplicationHandler 
>> $Chain.doFilter(WebApplicationHandler.java:334)
>>    at  
>> org 
>> .mortbay 
>> .jetty 
>> .servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java: 
>> 286)
>>    at  
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java: 
>> 567)
>>    at org.mortbay.http.HttpContext.handle(HttpContext.java:1776)
>>    at  
>> org 
>> .mortbay 
>> .jetty 
>> .servlet.WebApplicationContext.handle(WebApplicationContext.java:514)
>>    at org.mortbay.http.HttpContext.handle(HttpContext.java:1726)
>>    at org.mortbay.http.HttpServer.service(HttpServer.java:879)
>>    at org.mortbay.http.HttpConnection.service(HttpConnection.java: 
>> 790)
>>    at  
>> org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:952)
>>    at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
>>    at  
>> org 
>> .mortbay.http.SocketListener.handleConnection(SocketListener.java: 
>> 196)
>>    at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
>>    at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:487)
>>
>>
>> Well, the only thing I was doing was setting up a select query end  
>> performing the query. I received this.
>>
>> How shall someone solve this issue without having a look into  
>> cayenne's sources?
>> I developed quite a few frameworks for company-internal uses and I  
>> am ALWAYS checking, if all possible exceptions are correctly caught  
>> and at least giving a possible reasong for an exception. For now, I  
>> did not solve the problem but guess, there something wrong in my  
>> statement; but even if: The framework should handle this more  
>> gently telling me where the problem exactly lies.
>>
>> Thanks a lot.
>>
>> Jan
>>
>>
>>> Date: Mon, 19 Nov 2007 20:16:04 -0500
>>> Subject: Re: Deletion of obejcts
>>> From: kmenard@servprise.com
>>> To: user@cayenne.apache.org
>>>
>>> If you're having another issue, please start a new thread and post  
>>> the
>>> relevant code snippets and exception message.  I'll be the first  
>>> to beat up
>>> on Cayenne's error messages, so if you can give concrete examples  
>>> of where
>>> they fail, I'll try to get them fixed for you.
>>>
>>>
>>> On 11/19/07 7:10 PM, "Jan Lendholt" <jl...@hotmail.com> wrote:
>>>
>>>> Thanks all for your replies. I will try that one out (deleting an  
>>>> iterator).
>>>>
>>>> but, yet another problem: Ich use an object and say:
>>>> object.removeFromTestArray(Test);
>>>> Afterwards I call Test.getDataContext().commitChanges() to make  
>>>> these changes
>>>> persistent; but all I get is a "Null Objectid" exception which is  
>>>> yet again an
>>>> exception which requires a good overview over cayenne's  
>>>> internals; to me and
>>>> all my people around these error messages cayenne throws are not  
>>>> just a bit
>>>> intuitive :(
>>>>
>>>> _________________________________________________________________
>>>> Neu: Internet Explorer 7 optimiert für MSN!
>>>> http://optimize.de.msn.com/default.aspx?mkt=de-de
>>>
>>> -- 
>>> Kevin Menard
>>> Servprise International, Inc.
>>> Remote reboot & power control for network equipment
>>> www.servprise.com              +1 508.892.3823 x308
>>>
>>
>> _________________________________________________________________
>> Windows Live Fotogalerie: So einfach organisieren Sie Ihre Fotos!
>> http://get.live.com/photogallery/overview
>
> _________________________________________________________________
> Jetzt kostenlos downloaden: 30 Messenger Emoticons!
> http://www.messenger-emoticons.de/


RE: Deletion of obejcts

Posted by Jan Lendholt <jl...@hotmail.com>.
Okay, I found the error - I used a wrong datatype for the matchExpression.
Well, in fact this is a stupid mistake by me; but in my opinion the framework could handle this more smoothly.

Just told you this nice exception as a illustration on how difficult it could become working with cayenne if one is just a bit hasty on cayennes use.
I think that hibernate in this context is more reliable; but therefore requires more work to be running at first.
But dont want to talk about that now.

Greets Jan



> From: jlendholt@hotmail.com
> To: user@cayenne.apache.org
> Subject: RE: Deletion of obejcts
> Date: Wed, 21 Nov 2007 22:38:34 +0000
> 
> Hey Kevin,
> 
> here is one of those exceptions I cannot get used to:
> 
> java.lang.NullPointerException
>     at org.apache.cayenne.access.trans.QualifierTranslator.appendObjectMatch(QualifierTranslator.java:153)
>     at org.apache.cayenne.access.trans.QualifierTranslator.endNode(QualifierTranslator.java:321)
>     at org.apache.cayenne.exp.Expression.traverse(Expression.java:520)
>     at org.apache.cayenne.exp.Expression.traverse(Expression.java:511)
>     at org.apache.cayenne.exp.Expression.traverse(Expression.java:491)
>     at org.apache.cayenne.access.trans.QualifierTranslator.doTranslation(QualifierTranslator.java:74)
>     at org.apache.cayenne.access.trans.SelectTranslator.createSqlString(SelectTranslator.java:129)
>     at org.apache.cayenne.access.trans.QueryAssembler.createStatement(QueryAssembler.java:95)
>     at org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.java:71)
>     at org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:59)
>     at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:273)
>     at org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:301)
>     at org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQueryAction.java:60)
>     at org.apache.cayenne.access.DataDomainQueryAction$1.transform(DataDomainQueryAction.java:273)
>     at org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:836)
>     at org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:270)
>     at org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:110)
>     at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:746)
>     at org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:217)
>     at org.apache.cayenne.access.DataContextQueryAction.execute(DataContextQueryAction.java:54)
>     at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1387)
>     at org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:217)
>     at org.apache.cayenne.access.DataContextQueryAction.execute(DataContextQueryAction.java:54)
>     at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1387)
>     at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:1376)
>     at ams.maintabpanes.buchungdetail.SingleBuchungContentPaneCatering.<init>(SingleBuchungContentPaneCatering.java:195)
>     at ams.maintabpanes.buchungdetail.BuchungDetailWindowPane.<init>(BuchungDetailWindowPane.java:103)
>     at ams.maintabpanes.event.EventTabPane$4.actionPerformed(EventTabPane.java:522)
>     at nextapp.echo2.app.button.AbstractButton.fireActionPerformed(AbstractButton.java:135)
>     at nextapp.echo2.app.button.AbstractButton$1.actionPerformed(AbstractButton.java:100)
>     at nextapp.echo2.app.button.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:70)
>     at nextapp.echo2.app.button.DefaultButtonModel.doAction(DefaultButtonModel.java:58)
>     at nextapp.echo2.app.button.AbstractButton.doAction(AbstractButton.java:121)
>     at nextapp.echo2.app.button.AbstractButton.processInput(AbstractButton.java:506)
>     at nextapp.echo2.app.update.ClientUpdateManager.process(ClientUpdateManager.java:116)
>     at nextapp.echo2.app.update.UpdateManager.processClientUpdates(UpdateManager.java:89)
>     at nextapp.echo2.webcontainer.ContainerSynchronizeService.renderUpdate(ContainerSynchronizeService.java:472)
>     at nextapp.echo2.webrender.service.SynchronizeService.service(SynchronizeService.java:279)
>     at nextapp.echo2.webrender.WebRenderServlet.process(WebRenderServlet.java:276)
>     at nextapp.echo2.webrender.WebRenderServlet.doPost(WebRenderServlet.java:192)
>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
>     at ams.AMSServlet.service(AMSServlet.java:36)
>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>     at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:356)
>     at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:342)
>     at org.apache.cayenne.conf.WebApplicationContextFilter.doFilter(WebApplicationContextFilter.java:91)
>     at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:334)
>     at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:286)
>     at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
>     at org.mortbay.http.HttpContext.handle(HttpContext.java:1776)
>     at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:514)
>     at org.mortbay.http.HttpContext.handle(HttpContext.java:1726)
>     at org.mortbay.http.HttpServer.service(HttpServer.java:879)
>     at org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
>     at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:952)
>     at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
>     at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:196)
>     at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
>     at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:487)
> 
> 
> Well, the only thing I was doing was setting up a select query end performing the query. I received this.
> 
> How shall someone solve this issue without having a look into cayenne's sources?
> I developed quite a few frameworks for company-internal uses and I am ALWAYS checking, if all possible exceptions are correctly caught and at least giving a possible reasong for an exception. For now, I did not solve the problem but guess, there something wrong in my statement; but even if: The framework should handle this more gently telling me where the problem exactly lies.
> 
> Thanks a lot.
> 
> Jan
> 
> 
> > Date: Mon, 19 Nov 2007 20:16:04 -0500
> > Subject: Re: Deletion of obejcts
> > From: kmenard@servprise.com
> > To: user@cayenne.apache.org
> > 
> > If you're having another issue, please start a new thread and post the
> > relevant code snippets and exception message.  I'll be the first to beat up
> > on Cayenne's error messages, so if you can give concrete examples of where
> > they fail, I'll try to get them fixed for you.
> > 
> > 
> > On 11/19/07 7:10 PM, "Jan Lendholt" <jl...@hotmail.com> wrote:
> > 
> > > Thanks all for your replies. I will try that one out (deleting an iterator).
> > > 
> > > but, yet another problem: Ich use an object and say:
> > > object.removeFromTestArray(Test);
> > > Afterwards I call Test.getDataContext().commitChanges() to make these changes
> > > persistent; but all I get is a "Null Objectid" exception which is yet again an
> > > exception which requires a good overview over cayenne's internals; to me and
> > > all my people around these error messages cayenne throws are not just a bit
> > > intuitive :( 
> > > 
> > > _________________________________________________________________
> > > Neu: Internet Explorer 7 optimiert für MSN!
> > > http://optimize.de.msn.com/default.aspx?mkt=de-de
> > 
> > -- 
> > Kevin Menard
> > Servprise International, Inc.
> > Remote reboot & power control for network equipment
> > www.servprise.com              +1 508.892.3823 x308
> > 
> 
> _________________________________________________________________
> Windows Live Fotogalerie: So einfach organisieren Sie Ihre Fotos!
> http://get.live.com/photogallery/overview 

_________________________________________________________________
Jetzt kostenlos downloaden: 30 Messenger Emoticons!
http://www.messenger-emoticons.de/

RE: Deletion of obejcts

Posted by Jan Lendholt <jl...@hotmail.com>.
Hey Kevin,

here is one of those exceptions I cannot get used to:

java.lang.NullPointerException
    at org.apache.cayenne.access.trans.QualifierTranslator.appendObjectMatch(QualifierTranslator.java:153)
    at org.apache.cayenne.access.trans.QualifierTranslator.endNode(QualifierTranslator.java:321)
    at org.apache.cayenne.exp.Expression.traverse(Expression.java:520)
    at org.apache.cayenne.exp.Expression.traverse(Expression.java:511)
    at org.apache.cayenne.exp.Expression.traverse(Expression.java:491)
    at org.apache.cayenne.access.trans.QualifierTranslator.doTranslation(QualifierTranslator.java:74)
    at org.apache.cayenne.access.trans.SelectTranslator.createSqlString(SelectTranslator.java:129)
    at org.apache.cayenne.access.trans.QueryAssembler.createStatement(QueryAssembler.java:95)
    at org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.java:71)
    at org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:59)
    at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:273)
    at org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:301)
    at org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQueryAction.java:60)
    at org.apache.cayenne.access.DataDomainQueryAction$1.transform(DataDomainQueryAction.java:273)
    at org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:836)
    at org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:270)
    at org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:110)
    at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:746)
    at org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:217)
    at org.apache.cayenne.access.DataContextQueryAction.execute(DataContextQueryAction.java:54)
    at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1387)
    at org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:217)
    at org.apache.cayenne.access.DataContextQueryAction.execute(DataContextQueryAction.java:54)
    at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1387)
    at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:1376)
    at ams.maintabpanes.buchungdetail.SingleBuchungContentPaneCatering.<init>(SingleBuchungContentPaneCatering.java:195)
    at ams.maintabpanes.buchungdetail.BuchungDetailWindowPane.<init>(BuchungDetailWindowPane.java:103)
    at ams.maintabpanes.event.EventTabPane$4.actionPerformed(EventTabPane.java:522)
    at nextapp.echo2.app.button.AbstractButton.fireActionPerformed(AbstractButton.java:135)
    at nextapp.echo2.app.button.AbstractButton$1.actionPerformed(AbstractButton.java:100)
    at nextapp.echo2.app.button.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:70)
    at nextapp.echo2.app.button.DefaultButtonModel.doAction(DefaultButtonModel.java:58)
    at nextapp.echo2.app.button.AbstractButton.doAction(AbstractButton.java:121)
    at nextapp.echo2.app.button.AbstractButton.processInput(AbstractButton.java:506)
    at nextapp.echo2.app.update.ClientUpdateManager.process(ClientUpdateManager.java:116)
    at nextapp.echo2.app.update.UpdateManager.processClientUpdates(UpdateManager.java:89)
    at nextapp.echo2.webcontainer.ContainerSynchronizeService.renderUpdate(ContainerSynchronizeService.java:472)
    at nextapp.echo2.webrender.service.SynchronizeService.service(SynchronizeService.java:279)
    at nextapp.echo2.webrender.WebRenderServlet.process(WebRenderServlet.java:276)
    at nextapp.echo2.webrender.WebRenderServlet.doPost(WebRenderServlet.java:192)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at ams.AMSServlet.service(AMSServlet.java:36)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:356)
    at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:342)
    at org.apache.cayenne.conf.WebApplicationContextFilter.doFilter(WebApplicationContextFilter.java:91)
    at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:334)
    at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:286)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
    at org.mortbay.http.HttpContext.handle(HttpContext.java:1776)
    at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:514)
    at org.mortbay.http.HttpContext.handle(HttpContext.java:1726)
    at org.mortbay.http.HttpServer.service(HttpServer.java:879)
    at org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
    at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:952)
    at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
    at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:196)
    at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
    at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:487)


Well, the only thing I was doing was setting up a select query end performing the query. I received this.

How shall someone solve this issue without having a look into cayenne's sources?
I developed quite a few frameworks for company-internal uses and I am ALWAYS checking, if all possible exceptions are correctly caught and at least giving a possible reasong for an exception. For now, I did not solve the problem but guess, there something wrong in my statement; but even if: The framework should handle this more gently telling me where the problem exactly lies.

Thanks a lot.

Jan


> Date: Mon, 19 Nov 2007 20:16:04 -0500
> Subject: Re: Deletion of obejcts
> From: kmenard@servprise.com
> To: user@cayenne.apache.org
> 
> If you're having another issue, please start a new thread and post the
> relevant code snippets and exception message.  I'll be the first to beat up
> on Cayenne's error messages, so if you can give concrete examples of where
> they fail, I'll try to get them fixed for you.
> 
> 
> On 11/19/07 7:10 PM, "Jan Lendholt" <jl...@hotmail.com> wrote:
> 
> > Thanks all for your replies. I will try that one out (deleting an iterator).
> > 
> > but, yet another problem: Ich use an object and say:
> > object.removeFromTestArray(Test);
> > Afterwards I call Test.getDataContext().commitChanges() to make these changes
> > persistent; but all I get is a "Null Objectid" exception which is yet again an
> > exception which requires a good overview over cayenne's internals; to me and
> > all my people around these error messages cayenne throws are not just a bit
> > intuitive :( 
> > 
> > _________________________________________________________________
> > Neu: Internet Explorer 7 optimiert für MSN!
> > http://optimize.de.msn.com/default.aspx?mkt=de-de
> 
> -- 
> Kevin Menard
> Servprise International, Inc.
> Remote reboot & power control for network equipment
> www.servprise.com              +1 508.892.3823 x308
> 

_________________________________________________________________
Windows Live Fotogalerie: So einfach organisieren Sie Ihre Fotos!
http://get.live.com/photogallery/overview 

Re: Deletion of obejcts

Posted by Kevin Menard <km...@servprise.com>.
If you're having another issue, please start a new thread and post the
relevant code snippets and exception message.  I'll be the first to beat up
on Cayenne's error messages, so if you can give concrete examples of where
they fail, I'll try to get them fixed for you.


On 11/19/07 7:10 PM, "Jan Lendholt" <jl...@hotmail.com> wrote:

> Thanks all for your replies. I will try that one out (deleting an iterator).
> 
> but, yet another problem: Ich use an object and say:
> object.removeFromTestArray(Test);
> Afterwards I call Test.getDataContext().commitChanges() to make these changes
> persistent; but all I get is a "Null Objectid" exception which is yet again an
> exception which requires a good overview over cayenne's internals; to me and
> all my people around these error messages cayenne throws are not just a bit
> intuitive :( 
> 
> _________________________________________________________________
> Neu: Internet Explorer 7 optimiert für MSN!
> http://optimize.de.msn.com/default.aspx?mkt=de-de

-- 
Kevin Menard
Servprise International, Inc.
Remote reboot & power control for network equipment
www.servprise.com              +1 508.892.3823 x308


RE: Deletion of obejcts

Posted by Jan Lendholt <jl...@hotmail.com>.
Thanks all for your replies. I will try that one out (deleting an iterator).

but, yet another problem: Ich use an object and say: object.removeFromTestArray(Test);
Afterwards I call Test.getDataContext().commitChanges() to make these changes persistent; but all I get is a "Null Objectid" exception which is yet again an exception which requires a good overview over cayenne's internals; to me and all my people around these error messages cayenne throws are not just a bit intuitive :( 

_________________________________________________________________
Neu: Internet Explorer 7 optimiert für MSN!
http://optimize.de.msn.com/default.aspx?mkt=de-de

Re: Deletion of obejcts

Posted by Michael Gentry <bl...@gmail.com>.
Sounds like it is just an oversight.

On Nov 19, 2007 3:38 PM, Kevin Menard <km...@servprise.com> wrote:
> This reminds me.  Is there any particular reason that DataContext has
> deleteObjects() while ObjectContext does not?
>
> --
> Kevin

RE: Deletion of obejcts

Posted by Kevin Menard <km...@servprise.com>.
This reminds me.  Is there any particular reason that DataContext has
deleteObjects() while ObjectContext does not?

-- 
Kevin

-----Original Message-----
From: Michael Gentry [mailto:blacknext@gmail.com] 
Sent: Monday, November 19, 2007 3:36 PM
To: user@cayenne.apache.org
Subject: Re: Deletion of obejcts

Hi Jan,

See if the "Deleting in an Iterator" section at:

http://cayenne.apache.org/doc/deleting-objects.html

will help you.

/dev/mrg

Re: Deletion of obejcts

Posted by Michael Gentry <bl...@gmail.com>.
Hi Jan,

See if the "Deleting in an Iterator" section at:

http://cayenne.apache.org/doc/deleting-objects.html

will help you.

/dev/mrg


On Nov 19, 2007 1:48 PM, Jan Lendholt <jl...@hotmail.com> wrote:
> Hey folks,
>
> I got pretty frustrated in the meantime with cayenne, as i think there are happing some pretty ugly thingsin cayenne's internals.
>
> At first, I again need help on deleting objects with relationships.
>
> Let's say I've got one table called "booking" with its entity Booking.
> And I've got another table extras with entity Extras.
>
> The relationship is from booking to Extras one to many (1-n entries in Extra for one booking entry).
> I've set both relationships with delete rule to nullify.
>
> Now, sime pseudo-code:
>
> Booking booking = ...;
>
> List<Extras> extras = booking.getExtrasArray();
>
> for (int i= 0;...)
> {
>     booking.getDataContext().deleteObject(extras.get(i));
>
> }
>
> commitChanges();
>
> Now, the data are deleted from the database.
> But if I do a booking.getExtrasArray(); again, it still contains the deleted objects; it seems as if they were cached or so :-/
> Even an booking.RemoveFromExtras(extras.get(i)) won't work.
>
> Hiow does the deletion work correctly? I really don't understand why cayenne won't manage that automatically, for it would be quite logic to remove deleted objects form the object graph.
>
> Well, some words about the "ugly things": We had some really strange errors coming up which are at the end quite logic, but do not help finding the problem so wen spent about 3 hours to find it.
> We deleted an entity in the modeler and recreated it. Unfortunately, there was a reference missing. So cayenne just threw an index out of bounds exception. I really don't understand such a behaviour either :/ To me, such kind of errors should be handeled and analyzed automatically by a framework, e.g. like spring does. Ok, that's it for now. Hope you still like me :-D
>
>
> Tahnks a lot in advance & kind regards form Hamburg!
>
> Jan
>
>
>
>
> _________________________________________________________________
> Importieren Sie ganz einfach Ihre E-Mail Adressen in den Messenger!
> http://messenger.live.de/community/neuekontakte_adressimport.html

RE: Deletion of obejcts

Posted by Jan Lendholt <jl...@hotmail.com>.
Hi Frederik,

thanks for your reply.

I re-checked everything; I cannot find anything wrong on my model and code.

Your assumption is correct - from From Extra to booking is 1..1.

Thanks! Jan



> Subject: RE: Deletion of obejcts
> Date: Mon, 19 Nov 2007 12:31:30 -0700
> From: fliden@translate.com
> To: user@cayenne.apache.org
> 
> Hi Jan,
> 
> Before assuming there's something wrong with the framework let's take a
> moment to consider that there may be something wrong with the code. :-)
> 
> Deletion is one feature that definitely should work as you would expect.
> Seems the reverse call is working for some reason.
> Review the relationships in the model again and make sure the generated
> objects are up-to-date. I've encountered the same problem before but
> that had to do with some incorrectlty specified obj relationships.
> 
> Btw, I'm assuming you have (1..n)from Booking to Extra. And one to one
> (1..1) from Extra to Booking.
> 
> Fredrik
> 
> 
> -----Original Message-----
> From: Jan Lendholt [mailto:jlendholt@hotmail.com] 
> Sent: Monday, November 19, 2007 11:48 AM
> To: user@cayenne.apache.org
> Subject: Deletion of obejcts
> 
> Hey folks,
> 
> I got pretty frustrated in the meantime with cayenne, as i think there
> are happing some pretty ugly thingsin cayenne's internals.
> 
> At first, I again need help on deleting objects with relationships.
> 
> Let's say I've got one table called "booking" with its entity Booking.
> And I've got another table extras with entity Extras.
> 
> The relationship is from booking to Extras one to many (1-n entries in
> Extra for one booking entry).
> I've set both relationships with delete rule to nullify.
> 
> Now, sime pseudo-code:
> 
> Booking booking = ...;
> 
> List<Extras> extras = booking.getExtrasArray();
> 
> for (int i= 0;...)
> {
>     booking.getDataContext().deleteObject(extras.get(i));
>     
> }
> 
> commitChanges();
> 
> Now, the data are deleted from the database.
> But if I do a booking.getExtrasArray(); again, it still contains the
> deleted objects; it seems as if they were cached or so :-/
> Even an booking.RemoveFromExtras(extras.get(i)) won't work.
> 
> Hiow does the deletion work correctly? I really don't understand why
> cayenne won't manage that automatically, for it would be quite logic to
> remove deleted objects form the object graph.
> 
> Well, some words about the "ugly things": We had some really strange
> errors coming up which are at the end quite logic, but do not help
> finding the problem so wen spent about 3 hours to find it.
> We deleted an entity in the modeler and recreated it. Unfortunately,
> there was a reference missing. So cayenne just threw an index out of
> bounds exception. I really don't understand such a behaviour either :/
> To me, such kind of errors should be handeled and analyzed automatically
> by a framework, e.g. like spring does. Ok, that's it for now. Hope you
> still like me :-D
> 
> 
> Tahnks a lot in advance & kind regards form Hamburg!
> 
> Jan
> 
> 
> 
> 
> _________________________________________________________________
> Importieren Sie ganz einfach Ihre E-Mail Adressen in den Messenger!
> http://messenger.live.de/community/neuekontakte_adressimport.html

_________________________________________________________________
Die neue Version vom Windows Live Messenger ist da!
http://get.live.com/messenger/overview

RE: Deletion of obejcts

Posted by Fredrik Liden <fl...@translate.com>.
Hi Jan,

Before assuming there's something wrong with the framework let's take a
moment to consider that there may be something wrong with the code. :-)

Deletion is one feature that definitely should work as you would expect.
Seems the reverse call is working for some reason.
Review the relationships in the model again and make sure the generated
objects are up-to-date. I've encountered the same problem before but
that had to do with some incorrectlty specified obj relationships.

Btw, I'm assuming you have (1..n)from Booking to Extra. And one to one
(1..1) from Extra to Booking.

Fredrik


-----Original Message-----
From: Jan Lendholt [mailto:jlendholt@hotmail.com] 
Sent: Monday, November 19, 2007 11:48 AM
To: user@cayenne.apache.org
Subject: Deletion of obejcts

Hey folks,

I got pretty frustrated in the meantime with cayenne, as i think there
are happing some pretty ugly thingsin cayenne's internals.

At first, I again need help on deleting objects with relationships.

Let's say I've got one table called "booking" with its entity Booking.
And I've got another table extras with entity Extras.

The relationship is from booking to Extras one to many (1-n entries in
Extra for one booking entry).
I've set both relationships with delete rule to nullify.

Now, sime pseudo-code:

Booking booking = ...;

List<Extras> extras = booking.getExtrasArray();

for (int i= 0;...)
{
    booking.getDataContext().deleteObject(extras.get(i));
    
}

commitChanges();

Now, the data are deleted from the database.
But if I do a booking.getExtrasArray(); again, it still contains the
deleted objects; it seems as if they were cached or so :-/
Even an booking.RemoveFromExtras(extras.get(i)) won't work.

Hiow does the deletion work correctly? I really don't understand why
cayenne won't manage that automatically, for it would be quite logic to
remove deleted objects form the object graph.

Well, some words about the "ugly things": We had some really strange
errors coming up which are at the end quite logic, but do not help
finding the problem so wen spent about 3 hours to find it.
We deleted an entity in the modeler and recreated it. Unfortunately,
there was a reference missing. So cayenne just threw an index out of
bounds exception. I really don't understand such a behaviour either :/
To me, such kind of errors should be handeled and analyzed automatically
by a framework, e.g. like spring does. Ok, that's it for now. Hope you
still like me :-D


Tahnks a lot in advance & kind regards form Hamburg!

Jan




_________________________________________________________________
Importieren Sie ganz einfach Ihre E-Mail Adressen in den Messenger!
http://messenger.live.de/community/neuekontakte_adressimport.html

Re: Deletion of obejcts

Posted by Kevin Menard <km...@servprise.com>.
Hi Jan,

On 11/19/07 1:48 PM, "Jan Lendholt" <jl...@hotmail.com> wrote:

> The relationship is from booking to Extras one to many (1-n entries in Extra
> for one booking entry).
> I've set both relationships with delete rule to nullify.

Are you sure that's correct?  It would seem to me that you would want to
cascade in one direction and do nothing in the other.  I.e., you would
probably want to delete all extras (cascade) if the Booking is deleted, but
do nothing if an Extra is deleted.

-- 
Kevin Menard
Servprise International, Inc.
Remote reboot & power control for network equipment
www.servprise.com              +1 508.892.3823 x308