You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by urugn urugn <ur...@yahoo.com> on 2007/07/19 01:01:15 UTC

Handling search for null relationship

Hi guys.

Let me start by saying that am very greateful. This
coz of what the cay team has made things simple and
first.

Am just having a small problem which i think might
have a simple solution, but can't figure it out. Am
trying to query from a table T1 that has two objects
T2 and T3 where if one object(lets say T2) is null the
other is not null. Each of this two objects contain a
similar object in them lets say T4 which i want to
access through a search query. Here is the code thats
is in place.



StringBuffer b = new StringBuffer();
        b.append("policy.client.clientName
likeIgnoreCase $clientName ");
        b.append("or marine.client.clientName
likeIgnoreCase $clientName ");
        b.append("and claimDetail.settled = $settled
and claimDetail.recovery = $recovery ");

Expression e1 = Expression.fromString(b.toString());
        java.util.Map map = new java.util.HashMap();
        map.put("clientName", 
searchField.getText().toLowerCase()+"%" );
      Expression e2 = e1.expWithParameters(map);

SelectQuery query = new
SelectQuery(eBrokerClaim.class, e2);
            
            List list = context.performQuery(query);
         ......
        ................

I get the following debug.

02:12:18,888  INFO QueryLogger:423 - --- will run 1
query.
02:12:18,889  INFO QueryLogger:377 - --- transaction
started.
02:12:18,891  INFO QueryLogger:300 - SELECT
t0.CLAIM_ASSESSOR_UNIQUE, t0.CLAIM_PRIORITY_CHEQUE,
t0.CLAIM_CAUSE, t0.CLAIM_NUMBER, t0.CLAIM_TYPE_UNIQUE,
t0.CLAIM_PRIORITY_CREDITNOTE, t0.CLAIM_POST_DATE,
t0.CLAIM_PRIORITY_DV, t0.CLAIM_PRIORITY_HIGH,
t0.CLAIM_ID, t0.CLAIM_PRIORITY_INBOUND,
t0.CLAIM_INSURER_INTIMATION_DATE,
t0.CLAIM_INTIMATION_EMAIL, t0.CLAIM_INTIMATION_FAX,
t0.CLAIM_INTIMATION_LETTER, t0.CLAIM_INTIMATION_PHONE,
t0.CLAIM_INTIMATION_DATE, t0.CLAIM_LETTER_UNIQUE,
t0.CLAIM_LOSS_DATE, t0.CLAIM_LOSS_ESTIMATE,
t0.CLAIM_PRIORITY_LOW, t0.CLAIM_MARINE_UNIQUE,
t0.CLAIM_PRIORITY_MEDIUM, t0.CLAIM_PARTICULAR,
t0.CLAIM_POLICY_UNIQUE, t0.CLAIM_REFERENCE,
t0.CLAIM_REPORTED_BY, t0.CLAIM_REPORTED_TO,
t0.CLAIM_TIME FROM EBROKER.EBROKER_CLAIMS t0,
EBROKER.EBROKER_POLICIES t1, EBROKER.EBROKER_CLIENTS
t2, EBROKER.EBROKER_MARINES t3,
EBROKER.EBROKER_CLIENTS t4,
EBROKER.EBROKER_CLAIMS_DETAILS t5 WHERE
t0.CLAIM_POLICY_UNIQUE = t1.POLICY_ID AND
t1.POLICY_CLIENT_UNIQUE = t2.CLIENT_ID AND
t0.CLAIM_MARINE_UNIQUE = t3.MARINE_ID AND
t3.MARINE_CLIENT_UNIQUE = t4.CLIENT_ID AND t0.CLAIM_ID
= t5.CLAIM_DETAIL_ID AND (((UPPER(t2.CLIENT_NAME) LIKE
UPPER(?)) AND (t0.CLAIM_MARINE_UNIQUE IS NULL)) OR
((t0.CLAIM_POLICY_UNIQUE IS NULL) AND
(UPPER(t4.CLIENT_NAME) LIKE UPPER(?)) AND
(t5.CLAIM_SETTLED = ?) AND (t5.CLAIM_RECOVERY = ?)))
[bind: 'p%', 'p%', 'false', 'false']
02:12:18,897  INFO QueryLogger:351 - === returned 0
rows. - took 7 ms.
02:12:18,898  INFO QueryLogger:384 - +++ transaction
committed.

To explaim the above query.

EBROKER.EBROKER_CLAIMS (eBrokerClaim) is my T1 that is
a child of EBROKER.EBROKER_POLICIES (eBrokerPolicy)
and EBROKER.EBROKER_MARINES (eBrokerMarine) related to
it (lets say T2 and T3 respectively) and T4 would be
EBROKER.EBROKER_CLIENTS (eBrokerClient).


Well i get no result.
My problem which i can actually see it is here. 

WHERE t0.CLAIM_POLICY_UNIQUE = t1.POLICY_ID AND
t1.POLICY_CLIENT_UNIQUE = t2.CLIENT_ID AND
t0.CLAIM_MARINE_UNIQUE = t3.MARINE_ID AND
t3.MARINE_CLIENT_UNIQUE = t4.CLIENT_ID

from the above debug how can i make the second AND sql
statement to be an OR this is beacuse inside
eBrokerClaim, there is no way eBrokerPolicy and
eBrokerMarine can exist together in the same row. One
is null while the other is not null. Both contain
eBrokerClient of which am searching thru DataObject
path names.

What would be the cayenne query statement i should use
to avid querying the policy AND the marine inside the
claim. This brings no result beacuse as i said marine
and policy cant exist together in a claim table row.
Please help

Regards Urugn



       
____________________________________________________________________________________
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. 
http://mobile.yahoo.com/go?refer=1GNXIC

Temporary ID hasn't been replaced on commit

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

I've got a problem with cayenne on insert; the followinh inserts are written 
and then I get an exception:

INFO  QueryLogger: INSERT INTO ACCESS.LEISTUNGEN (BESCHREIBUNG, IDLEISTUNG, 
NAME, PREIS_VK, SCHWUNDGRENZE, UST_VK, VALID_TO, VALID_VON) VALUES (?, ?, ?, 
?, ?, ?, ?, ?)
INFO  QueryLogger: [bind: 'testbeschreibung', 25, 'Leistung', 1.00, NULL, 
19, NULL, NULL]
INFO  QueryLogger: === updated 1 row.
INFO  QueryLogger: +++ transaction committed.
INFO  QueryLogger: --- will run 1 query.
INFO  QueryLogger: --- transaction started.
INFO  QueryLogger: INSERT INTO ACCESS.MAPPING_LEISTUNG_BUCHUNG (ANZAHL, 
BUCHID, IDLEISTUNG) VALUES (?, ?, ?)
INFO  QueryLogger: [bind: 1, 13059, 25]

Exception:

09:53:15.843 WARN!! Exception for /ams?serviceId=Echo.Synchronize
org.apache.cayenne.CayenneRuntimeException: [v.@CAYENNE_VERSION@ 
@CAYENNE_BUILD_DATE@] Temporary ID hasn't been replaced on commit: 
{<ObjectId:MappingLeistungBuchung, TEMP:0000015CBD360096>; new; 
[toLeistungen=>{<ObjectId:Leistungen, IDLEISTUNG=25>}; anzahl=>1; 
toBuchung=>{<ObjectId:Buchung, BUCHID=13059>}]}
	at 
org.apache.cayenne.access.DataDomainSyncBucket.postprocess(DataDomainSyncBucket.java:184)
	at 
org.apache.cayenne.access.DataDomainFlushAction.postprocess(DataDomainFlushAction.java:235)
	at 
org.apache.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushAction.java:142)
	at org.apache.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:810)
	at org.apache.cayenne.access.DataDomain$2.transform(DataDomain.java:781)
	at 
org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:836)
	at org.apache.cayenne.access.DataDomain.onSync(DataDomain.java:778)
	at 
org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1226)
	at 
org.apache.cayenne.access.DataContext.onContextFlush(DataContext.java:1184)
	at org.apache.cayenne.access.DataContext.onSync(DataContext.java:1159)
	at 
org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1226)
	at 
org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1130)
	at 
ams.maintabpanes.buchungdetail.SingleBuchungContentPane.speichereZusatzverzehr(SingleBuchungContentPane.java:564)
	at 
ams.maintabpanes.buchungdetail.SingleBuchungContentPane.access$4(SingleBuchungContentPane.java:548)
	at 
ams.maintabpanes.buchungdetail.SingleBuchungContentPane$5.actionPerformed(SingleBuchungContentPane.java:1029)
	at 
nextapp.echo2.app.button.AbstractButton.fireActionPerformed(AbstractButton.java:135)
	at echopointng.ButtonEx$1.actionPerformed(ButtonEx.java:120)
	at 
nextapp.echo2.app.button.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:70)
	at 
echopointng.model.DefaultButtonModelEx.doAction(DefaultButtonModelEx.java:51)
	at echopointng.ButtonEx.processInput(ButtonEx.java:203)
	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:273)
	at 
nextapp.echo2.webrender.WebRenderServlet.doPost(WebRenderServlet.java:189)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	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)



In the sources I see cayenne tries to swap an id, but in fact the table 
MAPPING_LEISTUNG_BUCHUNG has no need to create a key or stuff.

Hoe do I tell cayenne not to replace the tempId?

Thanks in advance,

Jan

_________________________________________________________________
Sie suchen E-Mails, Dokumente oder Fotos? Die neue MSN Suche Toolbar mit 
Windows-Desktopsuche liefert in sekundenschnelle Ergebnisse. Jetzt neu! 
http://desktop.msn.de/ Jetzt gratis downloaden!


Re: Temporary objects

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Aug 15, 2007, at 3:39 AM, Jan Lendholt wrote:

> Hi Andrus,
>
> the previous thread has nothing to do with unregistered objects.

Ok - I may need more information on that, like a code sample.

> Ok, not using unregisterObject results in not deleting anything at  
> all :-(

Unregister should never result in deletion of persistence objects.  
This is sort of like "forget object" method. I suggest you do not use  
it at all, and try to figure out why deleteObject doesn't work instead.

> So if I use "deleteObject" it simply deletes my object as required,  
> but the other object which is in state "DELETED" isn't removed as  
> well.

What other object? Maybe a code sample would help.

Andrus



Re: Temporary objects

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

the previous thread has nothing to do with unregistered objects.

Ok, not using unregisterObject results in not deleting anything at all :-( 
So if I use "deleteObject" it simply deletes my object as required, but the 
other object which is in state "DELETED" isn't removed as well.

Thanks a lot,

Jan


>From: Andrus Adamchik <an...@objectstyle.org>
>Reply-To: user@cayenne.apache.org
>To: user@cayenne.apache.org
>Subject: Re: Temporary objects
>Date: Tue, 14 Aug 2007 16:20:18 -0400
>
>Hi Jan,
>
>In any event I would advise against using "unregisterObjects", unless  you 
>are sure there are no remaining cached objects that point to  unregistered 
>objects via a relationship.
>
>So if you are using "unregisterObjects" to save memory, I suggest  simply 
>throwing away the DataContext and replacing it with a new one  (or use 
>Cayenne 3.0M1 that would clean up unused registered objects  for you).
>
>Andrus
>
>P.S. So could you tell whether the problem described in the previous  
>thread is also caused by unregistering?
>
>
>On Aug 14, 2007, at 11:35 AM, Jan Lendholt wrote:
>>Hey Folks,
>>
>>me again with yet another problem which in my opinion seems to me  as a 
>>bag in cayenne.
>>
>>Ok, the situation:
>>
>>Create a dataset A, save (commit) and close the application. Then  open 
>>the application and create a dataset B - do NOT save (commit)  Changes and 
>>delete dataset A and dataset B.
>>Dataset A ist deleted by using context.deleteObject(objA) and  dataset B 
>>ist deleted by unregisterObjects(temp) where temp is a  collection withe 
>>objB in it.
>>
>>Now on the commit of the changes we get an exception:
>>
>>17:22:09.208 WARN!! Exception for /ams?serviceId=Echo.Synchronize
>>java.lang.NullPointerException: Attempt to add null target DataObject.
>>	at org.apache.cayenne.CayenneDataObject.addToManyTarget 
>>(CayenneDataObject.java:263)
>>	at org.apache.cayenne.access.ChildDiffLoader.arcCreated 
>>(ChildDiffLoader.java:111)
>>	at org.apache.cayenne.access.ObjectDiff$ArcOperation.apply 
>>(ObjectDiff.java:428)
>>	at org.apache.cayenne.graph.CompoundDiff.apply(CompoundDiff.java:97)
>>	at org.apache.cayenne.access.ObjectStoreGraphDiff.apply 
>>(ObjectStoreGraphDiff.java:136)
>>	at org.apache.cayenne.access.DataContext.onContextFlush 
>>(DataContext.java:1180)
>>	at org.apache.cayenne.access.DataContext.onSync(DataContext.java: 1159)
>>	at org.apache.cayenne.access.DataContext.flushToParent 
>>(DataContext.java:1226)
>>	at org.apache.cayenne.access.DataContext.commitChanges 
>>(DataContext.java:1130)
>>	at ams.lieferanten.LieferantenCreateWindowPane.actionSave 
>>(LieferantenCreateWindowPane.java:280)
>>	at ams.lieferanten.LieferantenCreateWindowPane.access$4 
>>(LieferantenCreateWindowPane.java:236)
>>	at ams.lieferanten.LieferantenCreateWindowPane$7.actionPerformed 
>>(LieferantenCreateWindowPane.java:489)
>>	at nextapp.echo2.app.button.AbstractButton.fireActionPerformed 
>>(AbstractButton.java:135)
>>	at echopointng.ButtonEx$1.actionPerformed(ButtonEx.java:120)
>>	at nextapp.echo2.app.button.DefaultButtonModel.fireActionPerformed 
>>(DefaultButtonModel.java:70)
>>	at echopointng.model.DefaultButtonModelEx.doAction 
>>(DefaultButtonModelEx.java:51)
>>	at echopointng.ButtonEx.processInput(ButtonEx.java:203)
>>	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:273)
>>	at nextapp.echo2.webrender.WebRenderServlet.doPost 
>>(WebRenderServlet.java:189)
>>	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
>>	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)
>>
>>
>>
>>I tried to track it back and found out, that on unregisterObjects  the 
>>objects are being thrown out of the objectStore. Therefore we  get a Null 
>>value when searching for the object on commit.
>>Now we tried the "deleteObject" method to delete the objB which has  the 
>>state NEW. Neither dataset (objA, objB) is deleted. I am  wondering why.
>>
>>We are just holding some objects temporarily in the samte context  with 
>>alread saved data in the database.
>>
>>Is it a bug?
>>
>>Thanks in advance!
>>
>>
>>Jan
>

_________________________________________________________________
Sie suchen E-Mails, Dokumente oder Fotos? Die neue MSN Suche Toolbar mit 
Windows-Desktopsuche liefert in sekundenschnelle Ergebnisse. Jetzt neu! 
http://desktop.msn.de/ Jetzt gratis downloaden!


Re: Temporary objects

Posted by Andrus Adamchik <an...@objectstyle.org>.
Hi Jan,

In any event I would advise against using "unregisterObjects", unless  
you are sure there are no remaining cached objects that point to  
unregistered objects via a relationship.

So if you are using "unregisterObjects" to save memory, I suggest  
simply throwing away the DataContext and replacing it with a new one  
(or use Cayenne 3.0M1 that would clean up unused registered objects  
for you).

Andrus

P.S. So could you tell whether the problem described in the previous  
thread is also caused by unregistering?


On Aug 14, 2007, at 11:35 AM, Jan Lendholt wrote:
> Hey Folks,
>
> me again with yet another problem which in my opinion seems to me  
> as a bag in cayenne.
>
> Ok, the situation:
>
> Create a dataset A, save (commit) and close the application. Then  
> open the application and create a dataset B - do NOT save (commit)  
> Changes and delete dataset A and dataset B.
> Dataset A ist deleted by using context.deleteObject(objA) and  
> dataset B ist deleted by unregisterObjects(temp) where temp is a  
> collection withe objB in it.
>
> Now on the commit of the changes we get an exception:
>
> 17:22:09.208 WARN!! Exception for /ams?serviceId=Echo.Synchronize
> java.lang.NullPointerException: Attempt to add null target DataObject.
> 	at org.apache.cayenne.CayenneDataObject.addToManyTarget 
> (CayenneDataObject.java:263)
> 	at org.apache.cayenne.access.ChildDiffLoader.arcCreated 
> (ChildDiffLoader.java:111)
> 	at org.apache.cayenne.access.ObjectDiff$ArcOperation.apply 
> (ObjectDiff.java:428)
> 	at org.apache.cayenne.graph.CompoundDiff.apply(CompoundDiff.java:97)
> 	at org.apache.cayenne.access.ObjectStoreGraphDiff.apply 
> (ObjectStoreGraphDiff.java:136)
> 	at org.apache.cayenne.access.DataContext.onContextFlush 
> (DataContext.java:1180)
> 	at org.apache.cayenne.access.DataContext.onSync(DataContext.java: 
> 1159)
> 	at org.apache.cayenne.access.DataContext.flushToParent 
> (DataContext.java:1226)
> 	at org.apache.cayenne.access.DataContext.commitChanges 
> (DataContext.java:1130)
> 	at ams.lieferanten.LieferantenCreateWindowPane.actionSave 
> (LieferantenCreateWindowPane.java:280)
> 	at ams.lieferanten.LieferantenCreateWindowPane.access$4 
> (LieferantenCreateWindowPane.java:236)
> 	at ams.lieferanten.LieferantenCreateWindowPane$7.actionPerformed 
> (LieferantenCreateWindowPane.java:489)
> 	at nextapp.echo2.app.button.AbstractButton.fireActionPerformed 
> (AbstractButton.java:135)
> 	at echopointng.ButtonEx$1.actionPerformed(ButtonEx.java:120)
> 	at nextapp.echo2.app.button.DefaultButtonModel.fireActionPerformed 
> (DefaultButtonModel.java:70)
> 	at echopointng.model.DefaultButtonModelEx.doAction 
> (DefaultButtonModelEx.java:51)
> 	at echopointng.ButtonEx.processInput(ButtonEx.java:203)
> 	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:273)
> 	at nextapp.echo2.webrender.WebRenderServlet.doPost 
> (WebRenderServlet.java:189)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> 	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)
>
>
>
> I tried to track it back and found out, that on unregisterObjects  
> the objects are being thrown out of the objectStore. Therefore we  
> get a Null value when searching for the object on commit.
> Now we tried the "deleteObject" method to delete the objB which has  
> the state NEW. Neither dataset (objA, objB) is deleted. I am  
> wondering why.
>
> We are just holding some objects temporarily in the samte context  
> with alread saved data in the database.
>
> Is it a bug?
>
> Thanks in advance!
>
>
> Jan


Temporary objects

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

me again with yet another problem which in my opinion seems to me as a bag 
in cayenne.

Ok, the situation:

Create a dataset A, save (commit) and close the application. Then open the 
application and create a dataset B - do NOT save (commit) Changes and delete 
dataset A and dataset B.
Dataset A ist deleted by using context.deleteObject(objA) and dataset B ist 
deleted by unregisterObjects(temp) where temp is a collection withe objB in 
it.

Now on the commit of the changes we get an exception:

17:22:09.208 WARN!! Exception for /ams?serviceId=Echo.Synchronize
java.lang.NullPointerException: Attempt to add null target DataObject.
	at 
org.apache.cayenne.CayenneDataObject.addToManyTarget(CayenneDataObject.java:263)
	at 
org.apache.cayenne.access.ChildDiffLoader.arcCreated(ChildDiffLoader.java:111)
	at 
org.apache.cayenne.access.ObjectDiff$ArcOperation.apply(ObjectDiff.java:428)
	at org.apache.cayenne.graph.CompoundDiff.apply(CompoundDiff.java:97)
	at 
org.apache.cayenne.access.ObjectStoreGraphDiff.apply(ObjectStoreGraphDiff.java:136)
	at 
org.apache.cayenne.access.DataContext.onContextFlush(DataContext.java:1180)
	at org.apache.cayenne.access.DataContext.onSync(DataContext.java:1159)
	at 
org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1226)
	at 
org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1130)
	at 
ams.lieferanten.LieferantenCreateWindowPane.actionSave(LieferantenCreateWindowPane.java:280)
	at 
ams.lieferanten.LieferantenCreateWindowPane.access$4(LieferantenCreateWindowPane.java:236)
	at 
ams.lieferanten.LieferantenCreateWindowPane$7.actionPerformed(LieferantenCreateWindowPane.java:489)
	at 
nextapp.echo2.app.button.AbstractButton.fireActionPerformed(AbstractButton.java:135)
	at echopointng.ButtonEx$1.actionPerformed(ButtonEx.java:120)
	at 
nextapp.echo2.app.button.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:70)
	at 
echopointng.model.DefaultButtonModelEx.doAction(DefaultButtonModelEx.java:51)
	at echopointng.ButtonEx.processInput(ButtonEx.java:203)
	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:273)
	at 
nextapp.echo2.webrender.WebRenderServlet.doPost(WebRenderServlet.java:189)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	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)



I tried to track it back and found out, that on unregisterObjects the 
objects are being thrown out of the objectStore. Therefore we get a Null 
value when searching for the object on commit.
Now we tried the "deleteObject" method to delete the objB which has the 
state NEW. Neither dataset (objA, objB) is deleted. I am wondering why.

We are just holding some objects temporarily in the samte context with 
alread saved data in the database.

Is it a bug?

Thanks in advance!


Jan

_________________________________________________________________
Sie suchen E-Mails, Dokumente oder Fotos? Die neue MSN Suche Toolbar mit 
Windows-Desktopsuche liefert in sekundenschnelle Ergebnisse. Jetzt neu! 
http://desktop.msn.de/ Jetzt gratis downloaden!


Re: Handling search for null relationship

Posted by Mike Kienenberger <mk...@gmail.com>.
And this would end up looking something like this:

StringBuffer b = new StringBuffer();
       b.append("policy+.client.clientName
likeIgnoreCase $clientName ");
       b.append("or marine+.client.clientName
likeIgnoreCase $clientName ");
       b.append("and claimDetail.settled = $settled
and claimDetail.recovery = $recovery ");

The "+" would indicate potentially null outer join clauses.


On 8/3/07, Mike Kienenberger <mk...@gmail.com> wrote:
> I'm pretty sure what you're doing is going to require an outer join.
>
> You'd need to be running Cayenne 1.2 with the outer join patch.
> Either that or you'll have to write the query using a raw sql
> template.
>
>
> On 7/18/07, urugn urugn <ur...@yahoo.com> wrote:
> > Hi guys.
> >
> > Let me start by saying that am very greateful. This
> > coz of what the cay team has made things simple and
> > first.
> >
> > Am just having a small problem which i think might
> > have a simple solution, but can't figure it out. Am
> > trying to query from a table T1 that has two objects
> > T2 and T3 where if one object(lets say T2) is null the
> > other is not null. Each of this two objects contain a
> > similar object in them lets say T4 which i want to
> > access through a search query. Here is the code thats
> > is in place.
> >
> >
> >
> > StringBuffer b = new StringBuffer();
> >         b.append("policy.client.clientName
> > likeIgnoreCase $clientName ");
> >         b.append("or marine.client.clientName
> > likeIgnoreCase $clientName ");
> >         b.append("and claimDetail.settled = $settled
> > and claimDetail.recovery = $recovery ");
> >
> > Expression e1 = Expression.fromString(b.toString());
> >         java.util.Map map = new java.util.HashMap();
> >         map.put("clientName",
> > searchField.getText().toLowerCase()+"%" );
> >       Expression e2 = e1.expWithParameters(map);
> >
> > SelectQuery query = new
> > SelectQuery(eBrokerClaim.class, e2);
> >
> >             List list = context.performQuery(query);
> >          ......
> >         ................
> >
> > I get the following debug.
> >
> > 02:12:18,888  INFO QueryLogger:423 - --- will run 1
> > query.
> > 02:12:18,889  INFO QueryLogger:377 - --- transaction
> > started.
> > 02:12:18,891  INFO QueryLogger:300 - SELECT
> > t0.CLAIM_ASSESSOR_UNIQUE, t0.CLAIM_PRIORITY_CHEQUE,
> > t0.CLAIM_CAUSE, t0.CLAIM_NUMBER, t0.CLAIM_TYPE_UNIQUE,
> > t0.CLAIM_PRIORITY_CREDITNOTE, t0.CLAIM_POST_DATE,
> > t0.CLAIM_PRIORITY_DV, t0.CLAIM_PRIORITY_HIGH,
> > t0.CLAIM_ID, t0.CLAIM_PRIORITY_INBOUND,
> > t0.CLAIM_INSURER_INTIMATION_DATE,
> > t0.CLAIM_INTIMATION_EMAIL, t0.CLAIM_INTIMATION_FAX,
> > t0.CLAIM_INTIMATION_LETTER, t0.CLAIM_INTIMATION_PHONE,
> > t0.CLAIM_INTIMATION_DATE, t0.CLAIM_LETTER_UNIQUE,
> > t0.CLAIM_LOSS_DATE, t0.CLAIM_LOSS_ESTIMATE,
> > t0.CLAIM_PRIORITY_LOW, t0.CLAIM_MARINE_UNIQUE,
> > t0.CLAIM_PRIORITY_MEDIUM, t0.CLAIM_PARTICULAR,
> > t0.CLAIM_POLICY_UNIQUE, t0.CLAIM_REFERENCE,
> > t0.CLAIM_REPORTED_BY, t0.CLAIM_REPORTED_TO,
> > t0.CLAIM_TIME FROM EBROKER.EBROKER_CLAIMS t0,
> > EBROKER.EBROKER_POLICIES t1, EBROKER.EBROKER_CLIENTS
> > t2, EBROKER.EBROKER_MARINES t3,
> > EBROKER.EBROKER_CLIENTS t4,
> > EBROKER.EBROKER_CLAIMS_DETAILS t5 WHERE
> > t0.CLAIM_POLICY_UNIQUE = t1.POLICY_ID AND
> > t1.POLICY_CLIENT_UNIQUE = t2.CLIENT_ID AND
> > t0.CLAIM_MARINE_UNIQUE = t3.MARINE_ID AND
> > t3.MARINE_CLIENT_UNIQUE = t4.CLIENT_ID AND t0.CLAIM_ID
> > = t5.CLAIM_DETAIL_ID AND (((UPPER(t2.CLIENT_NAME) LIKE
> > UPPER(?)) AND (t0.CLAIM_MARINE_UNIQUE IS NULL)) OR
> > ((t0.CLAIM_POLICY_UNIQUE IS NULL) AND
> > (UPPER(t4.CLIENT_NAME) LIKE UPPER(?)) AND
> > (t5.CLAIM_SETTLED = ?) AND (t5.CLAIM_RECOVERY = ?)))
> > [bind: 'p%', 'p%', 'false', 'false']
> > 02:12:18,897  INFO QueryLogger:351 - === returned 0
> > rows. - took 7 ms.
> > 02:12:18,898  INFO QueryLogger:384 - +++ transaction
> > committed.
> >
> > To explaim the above query.
> >
> > EBROKER.EBROKER_CLAIMS (eBrokerClaim) is my T1 that is
> > a child of EBROKER.EBROKER_POLICIES (eBrokerPolicy)
> > and EBROKER.EBROKER_MARINES (eBrokerMarine) related to
> > it (lets say T2 and T3 respectively) and T4 would be
> > EBROKER.EBROKER_CLIENTS (eBrokerClient).
> >
> >
> > Well i get no result.
> > My problem which i can actually see it is here.
> >
> > WHERE t0.CLAIM_POLICY_UNIQUE = t1.POLICY_ID AND
> > t1.POLICY_CLIENT_UNIQUE = t2.CLIENT_ID AND
> > t0.CLAIM_MARINE_UNIQUE = t3.MARINE_ID AND
> > t3.MARINE_CLIENT_UNIQUE = t4.CLIENT_ID
> >
> > from the above debug how can i make the second AND sql
> > statement to be an OR this is beacuse inside
> > eBrokerClaim, there is no way eBrokerPolicy and
> > eBrokerMarine can exist together in the same row. One
> > is null while the other is not null. Both contain
> > eBrokerClient of which am searching thru DataObject
> > path names.
> >
> > What would be the cayenne query statement i should use
> > to avid querying the policy AND the marine inside the
> > claim. This brings no result beacuse as i said marine
> > and policy cant exist together in a claim table row.
> > Please help
> >
> > Regards Urugn
> >
> >
> >
> >
> > ____________________________________________________________________________________
> > Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more.
> > http://mobile.yahoo.com/go?refer=1GNXIC
> >
>

Re: Handling search for null relationship

Posted by Mike Kienenberger <mk...@gmail.com>.
I'm pretty sure what you're doing is going to require an outer join.

You'd need to be running Cayenne 1.2 with the outer join patch.
Either that or you'll have to write the query using a raw sql
template.


On 7/18/07, urugn urugn <ur...@yahoo.com> wrote:
> Hi guys.
>
> Let me start by saying that am very greateful. This
> coz of what the cay team has made things simple and
> first.
>
> Am just having a small problem which i think might
> have a simple solution, but can't figure it out. Am
> trying to query from a table T1 that has two objects
> T2 and T3 where if one object(lets say T2) is null the
> other is not null. Each of this two objects contain a
> similar object in them lets say T4 which i want to
> access through a search query. Here is the code thats
> is in place.
>
>
>
> StringBuffer b = new StringBuffer();
>         b.append("policy.client.clientName
> likeIgnoreCase $clientName ");
>         b.append("or marine.client.clientName
> likeIgnoreCase $clientName ");
>         b.append("and claimDetail.settled = $settled
> and claimDetail.recovery = $recovery ");
>
> Expression e1 = Expression.fromString(b.toString());
>         java.util.Map map = new java.util.HashMap();
>         map.put("clientName",
> searchField.getText().toLowerCase()+"%" );
>       Expression e2 = e1.expWithParameters(map);
>
> SelectQuery query = new
> SelectQuery(eBrokerClaim.class, e2);
>
>             List list = context.performQuery(query);
>          ......
>         ................
>
> I get the following debug.
>
> 02:12:18,888  INFO QueryLogger:423 - --- will run 1
> query.
> 02:12:18,889  INFO QueryLogger:377 - --- transaction
> started.
> 02:12:18,891  INFO QueryLogger:300 - SELECT
> t0.CLAIM_ASSESSOR_UNIQUE, t0.CLAIM_PRIORITY_CHEQUE,
> t0.CLAIM_CAUSE, t0.CLAIM_NUMBER, t0.CLAIM_TYPE_UNIQUE,
> t0.CLAIM_PRIORITY_CREDITNOTE, t0.CLAIM_POST_DATE,
> t0.CLAIM_PRIORITY_DV, t0.CLAIM_PRIORITY_HIGH,
> t0.CLAIM_ID, t0.CLAIM_PRIORITY_INBOUND,
> t0.CLAIM_INSURER_INTIMATION_DATE,
> t0.CLAIM_INTIMATION_EMAIL, t0.CLAIM_INTIMATION_FAX,
> t0.CLAIM_INTIMATION_LETTER, t0.CLAIM_INTIMATION_PHONE,
> t0.CLAIM_INTIMATION_DATE, t0.CLAIM_LETTER_UNIQUE,
> t0.CLAIM_LOSS_DATE, t0.CLAIM_LOSS_ESTIMATE,
> t0.CLAIM_PRIORITY_LOW, t0.CLAIM_MARINE_UNIQUE,
> t0.CLAIM_PRIORITY_MEDIUM, t0.CLAIM_PARTICULAR,
> t0.CLAIM_POLICY_UNIQUE, t0.CLAIM_REFERENCE,
> t0.CLAIM_REPORTED_BY, t0.CLAIM_REPORTED_TO,
> t0.CLAIM_TIME FROM EBROKER.EBROKER_CLAIMS t0,
> EBROKER.EBROKER_POLICIES t1, EBROKER.EBROKER_CLIENTS
> t2, EBROKER.EBROKER_MARINES t3,
> EBROKER.EBROKER_CLIENTS t4,
> EBROKER.EBROKER_CLAIMS_DETAILS t5 WHERE
> t0.CLAIM_POLICY_UNIQUE = t1.POLICY_ID AND
> t1.POLICY_CLIENT_UNIQUE = t2.CLIENT_ID AND
> t0.CLAIM_MARINE_UNIQUE = t3.MARINE_ID AND
> t3.MARINE_CLIENT_UNIQUE = t4.CLIENT_ID AND t0.CLAIM_ID
> = t5.CLAIM_DETAIL_ID AND (((UPPER(t2.CLIENT_NAME) LIKE
> UPPER(?)) AND (t0.CLAIM_MARINE_UNIQUE IS NULL)) OR
> ((t0.CLAIM_POLICY_UNIQUE IS NULL) AND
> (UPPER(t4.CLIENT_NAME) LIKE UPPER(?)) AND
> (t5.CLAIM_SETTLED = ?) AND (t5.CLAIM_RECOVERY = ?)))
> [bind: 'p%', 'p%', 'false', 'false']
> 02:12:18,897  INFO QueryLogger:351 - === returned 0
> rows. - took 7 ms.
> 02:12:18,898  INFO QueryLogger:384 - +++ transaction
> committed.
>
> To explaim the above query.
>
> EBROKER.EBROKER_CLAIMS (eBrokerClaim) is my T1 that is
> a child of EBROKER.EBROKER_POLICIES (eBrokerPolicy)
> and EBROKER.EBROKER_MARINES (eBrokerMarine) related to
> it (lets say T2 and T3 respectively) and T4 would be
> EBROKER.EBROKER_CLIENTS (eBrokerClient).
>
>
> Well i get no result.
> My problem which i can actually see it is here.
>
> WHERE t0.CLAIM_POLICY_UNIQUE = t1.POLICY_ID AND
> t1.POLICY_CLIENT_UNIQUE = t2.CLIENT_ID AND
> t0.CLAIM_MARINE_UNIQUE = t3.MARINE_ID AND
> t3.MARINE_CLIENT_UNIQUE = t4.CLIENT_ID
>
> from the above debug how can i make the second AND sql
> statement to be an OR this is beacuse inside
> eBrokerClaim, there is no way eBrokerPolicy and
> eBrokerMarine can exist together in the same row. One
> is null while the other is not null. Both contain
> eBrokerClient of which am searching thru DataObject
> path names.
>
> What would be the cayenne query statement i should use
> to avid querying the policy AND the marine inside the
> claim. This brings no result beacuse as i said marine
> and policy cant exist together in a claim table row.
> Please help
>
> Regards Urugn
>
>
>
>
> ____________________________________________________________________________________
> Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more.
> http://mobile.yahoo.com/go?refer=1GNXIC
>