Favicon

RE: Trying to set qualifier on a saved query?

Hi Jeff,
 
I updated my 1.2 code base and created a named/cached query and got the same exception as you at the same location.  After a little debugging I discovered there is a bug/omission in the 1.1 and 1.2 baselines that you've stumbled upon.  I'll open up a ticket for this.  For now, please use your workaround.
 
Thanks!
 
/dev/mrg
 
-----Original Message-----
From: Jeff de Vries [mailto:jdevries <at> pfrog.com]
Sent: Wednesday, August 31, 2005 5:11 PM
To: cayenne-user <at> objectstyle.org
Subject: Re: Trying to set qualifier on a saved query?

Thanks for all the help.  For right now I can workaround by just not using the shared cache ...

Jeff

Gentry, Michael (Contractor) wrote:
I don't have any other thoughts at the moment.  My line numbers differ from yours on the stacktrace, so I'll have to update my code baseline tonight and then I can augment one of my test apps to try to duplicate the problem.  If anyone else has ideas, feel free to hop in.  :-)
 
Thanks,
 
/dev/mrg
-----Original Message-----
From: Jeff de Vries [mailto:jdevries <at> pfrog.com]
Sent: Wednesday, August 31, 2005 4:39 PM
To: cayenne-user <at> objectstyle.org
Subject: Re: Trying to set qualifier on a saved query?

I'm positive the name is getting set properly because as I go back and forth changing the "shared cache" value in Modeler, it works when it isn't shared cache and doesn't work when it is shared cache.

This works:
        <query name="NewMakes" factory="org.objectstyle.cayenne.map.SelectQueryBuilder" root="obj-entity" root-name="Make">
                <qualifier><![CDATA[availNew = 1]]></qualifier>
                <ordering ignore-case="true"><![CDATA[name]]></ordering>
        </query>

This doesn't work:
        <query name="NewMakes" factory="org.objectstyle.cayenne.map.SelectQueryBuilder" root="obj-entity" root-name="Make">
                <property name="cayenne.GenericSelectQuery.refreshingObjects" value="false"/>
                <property name="cayenne.GenericSelectQuery.cachePolicy" value="sharedcache"/>
                <qualifier><![CDATA[availNew = 1]]></qualifier>
                <ordering ignore-case="true"><![CDATA[name]]></ordering>
        </query>


Gentry, Michael (Contractor) wrote:
According to my 1.2 code tree (which isn't up to 1.2M5 yet), I see: if (useCache && name == null) throw ... ; // the exception you are seeing The "name" variable is being set by query.getName(). Are you sure your query name is being saved/set? Double-check the saved XML file to ensure the name is saved correctly. Make sure you don't have a typo in the name, too. /dev/mrg -----Original Message----- From: Jeff de Vries [mailto:jdevries <at> pfrog.com] Sent: Wednesday, August 31, 2005 3:19 PM To: cayenne-user <at> objectstyle.org Subject: Re: Trying to set qualifier on a saved query? I made that change, but it didn't make any difference. Here's more detail on the actual error I'm getting: Exception in thread "main" org.objectstyle.cayenne.CayenneRuntimeException: [v.1.2M5 July 22 2005] Caching of unnamed queries is not supported. at org.objectstyle.cayenne.access.DataContextSelectAction.performQuery(Data ContextSelectAction.java:104) at org.objectstyle.cayenne.access.DataContext.performQuery(DataContext.java :1258) at org.objectstyle.cayenne.access.DataContext.performQuery(DataContext.java :1203) Just for grins, I turned "Shared Cache" off, and turned "Refresh Results" back on, and that *does* work. Gentry, Michael (Contractor) wrote:
I haven't done this, but in the modeler, make your qualifier "availNew
=
1" ... -----Original Message----- From: Jeff de Vries [mailto:jdevries <at> pfrog.com] Sent: Wednesday, August 31, 2005 2:09 PM To: cayenne-user <at> objectstyle.org Subject: Trying to set qualifier on a saved query? I'm trying to create a saved "object select query" using Modeler. My object has a boolean field named "availNew". In the "SelectQuery Settings" I'm entering "availNew" into the "Qualifier" text box. (I'm also setting "Shared Cache" and unchecking "Refresh Results" as this is
a small, read-only table). In my code I'm doing: List result = dc.performQuery("MyQuery",false); What happens is I get an exception about "unnamed queries". I have other saved queries that are not using the Qualifier field that are all working fine, so it is something about the qualifier. Thanks, Jeff de Vries
Gili | 1 Sep 2005 06:05
Favicon
Gravatar

Yet another optimistic locking question


	A question about how optimistic locking is currently implemented. Do we 
implement it like this?

1) Lock row
2) Read row
3) Compare read row to DataObject version of row
4) If values mismatch, unlock the row and throw an exception
5) If values match, continue with update and unlock row

	or do we not lock the database at all? If we don't lock it at all, how 
can we ensure that no changes occur after step 3 but before step 5?

Thank you,
Gili
--

-- 
http://www.desktopbeautifier.com/

Gili | 1 Sep 2005 06:39
Favicon
Gravatar

Keyboard navigation added

Hi Andrus,

	I'm the hopes of becoming more proactive with Cayenne I've fixed one of 
the issues I've reported: 
http://objectstyle.org/jira/secure/ViewIssue.jspa?key=CAY-353

	I was wondering whether you could please take a look at another issue I 
reported: http://objectstyle.org/jira/secure/ViewIssue.jspa?key=CAY-358

	I believe it will involve adding new methods to JdbcAdapter and 
MysqlAdapter so I am uncomfortable making this change myself at this 
time. I'd appreciate you taking a look at this because I plan on using 
the dev builds on my machine very soon and mysql issues affect me directly.

	Also, I've got a Netbeans 4.2 project file for Cayenne (I converted the 
Eclipse one). Do I zip all the files up (there are a few of them) and 
attach them to a JIRA issue?

Thank you,
Gili
--

-- 
http://www.desktopbeautifier.com/

Pirola Davide | 1 Sep 2005 14:28
Picon

How to dynamically get Qualifier info from SelectQuery object

Hi,
i want to extract at runtime the quelifier data from a SelectQuery object.

I have a query defined in a datamap xml file:
---------------------------------------------------
<query name="qryStat" factory="org.objectstyle.cayenne.map.SelectQueryBuilder"
root="obj-entity" root-name="stat">
	<qualifier>
		<![CDATA[(USER_ID = $userId)]]>
	</qualifier>
</query>
---------------------------------------------------

I have obtained a SelectQuery:

---------------------------------------------------
SelectQuery qry = (SelectQuery) resolver.getQuery("qryStat");
---------------------------------------------------

How i can retrive the field name used in "where" expression? (USER_ID)
Is possible to get it form a property defined in SelectQuery ?

Thank's
Davide

Favicon

RE: Yet another optimistic locking question

Optimistic locking never locks the row in the database (it is
optimistic).  Read:

http://www.objectstyle.org/confluence/display/CAY/Optimistic+Locking+Exp
lained

It explains how Cayenne can ensure that no changes occurred between the
SELECT and UPDATE phase.  If you still have questions I'll try to answer
them.

Thanks,

/dev/mrg

-----Original Message-----
From: Gili [mailto:cowwoc <at> bbs.darktech.org] 
Sent: Thursday, September 01, 2005 12:06 AM
To: cayenne-user <at> objectstyle.org
Subject: Yet another optimistic locking question

	A question about how optimistic locking is currently
implemented. Do we 
implement it like this?

1) Lock row
2) Read row
3) Compare read row to DataObject version of row
4) If values mismatch, unlock the row and throw an exception
5) If values match, continue with update and unlock row

	or do we not lock the database at all? If we don't lock it at
all, how 
can we ensure that no changes occur after step 3 but before step 5?

Thank you,
Gili
--

-- 
http://www.desktopbeautifier.com/

Mike Kienenberger | 1 Sep 2005 16:42
Picon

Re: How to dynamically get Qualifier info from SelectQuery object

Expression e  = qry.getQualifier() will give you the qualifier
expression that is built from <![CDATA[(USER_ID = $userId)]]>.

On 9/1/05, Pirola Davide <davide.pirola <at> vtin.it> wrote:
> Hi,
> i want to extract at runtime the quelifier data from a SelectQuery object.
> 
> I have a query defined in a datamap xml file:
> ---------------------------------------------------
> <query name="qryStat" factory="org.objectstyle.cayenne.map.SelectQueryBuilder"
root="obj-entity" root-name="stat">
>         <qualifier>
>                 <![CDATA[(USER_ID = $userId)]]>
>         </qualifier>
> </query>
> ---------------------------------------------------
> 
> I have obtained a SelectQuery:
> 
> ---------------------------------------------------
> SelectQuery qry = (SelectQuery) resolver.getQuery("qryStat");
> ---------------------------------------------------
> 
> How i can retrive the field name used in "where" expression? (USER_ID)
> Is possible to get it form a property defined in SelectQuery ?
> 
> Thank's
> Davide
>

Pirola Davide | 1 Sep 2005 16:56
Picon

RE: How to dynamically get Qualifier info from SelectQuery object

Hi,
i have noticed that if i want to access to a single qualifier: 

<![CDATA[(USER_ID = $userId)]]>

the operand count is 2... the first is "USER_ID" and the second is "$userId".

If i use a multiple qualifier:

<![CDATA[((UserId = $userId) and (Name = $name))]]>

the operand count is always 2... but now the first is "UserId  = $userId" and the second is "Name = $name".

Why this different behavior?
There isn't a standard method to retrive a field name?

thank's
Davide

-----Original Message-----
From: Mike Kienenberger [mailto:mkienenb <at> gmail.com]
Sent: giovedì 1 settembre 2005 16.42
To: cayenne-user <at> objectstyle.org
Subject: Re: How to dynamically get Qualifier info from SelectQuery
object

Expression e  = qry.getQualifier() will give you the qualifier
expression that is built from <![CDATA[(USER_ID = $userId)]]>.

On 9/1/05, Pirola Davide <davide.pirola <at> vtin.it> wrote:
> Hi,
> i want to extract at runtime the quelifier data from a SelectQuery object.
> 
> I have a query defined in a datamap xml file:
> ---------------------------------------------------
> <query name="qryStat" factory="org.objectstyle.cayenne.map.SelectQueryBuilder"
root="obj-entity" root-name="stat">
>         <qualifier>
>                 <![CDATA[(USER_ID = $userId)]]>
>         </qualifier>
> </query>
> ---------------------------------------------------
> 
> I have obtained a SelectQuery:
> 
> ---------------------------------------------------
> SelectQuery qry = (SelectQuery) resolver.getQuery("qryStat");
> ---------------------------------------------------
> 
> How i can retrive the field name used in "where" expression? (USER_ID)
> Is possible to get it form a property defined in SelectQuery ?
> 
> Thank's
> Davide
>

Gili | 1 Sep 2005 17:01
Favicon
Gravatar

Re: Yet another optimistic locking question


	Oh my. It all makes so much more sense now... So if I understand it 
correctly,

1) We store the perceived DB value somewhere
2) We store the cached (maybe modified) value elsewhere
3) When a commit occurs, we compare the objects in 1 and 2, then issue a 
UPDATE only for fields which have changed.

	Cool :) This also sounds quite efficient to me.

Thank you,
Gili

Gentry, Michael (Contractor) wrote:
> Optimistic locking never locks the row in the database (it is
> optimistic).  Read:
> 
> http://www.objectstyle.org/confluence/display/CAY/Optimistic+Locking+Exp
> lained
> 
> It explains how Cayenne can ensure that no changes occurred between the
> SELECT and UPDATE phase.  If you still have questions I'll try to answer
> them.
> 
> Thanks,
> 
> /dev/mrg
> 
> 
> -----Original Message-----
> From: Gili [mailto:cowwoc <at> bbs.darktech.org] 
> Sent: Thursday, September 01, 2005 12:06 AM
> To: cayenne-user <at> objectstyle.org
> Subject: Yet another optimistic locking question
> 
> 
> 
> 	A question about how optimistic locking is currently
> implemented. Do we 
> implement it like this?
> 
> 1) Lock row
> 2) Read row
> 3) Compare read row to DataObject version of row
> 4) If values mismatch, unlock the row and throw an exception
> 5) If values match, continue with update and unlock row
> 
> 	or do we not lock the database at all? If we don't lock it at
> all, how 
> can we ensure that no changes occur after step 3 but before step 5?
> 
> Thank you,
> Gili

--

-- 
http://www.desktopbeautifier.com/

Mike Kienenberger | 1 Sep 2005 17:05
Picon

Re: How to dynamically get Qualifier info from SelectQuery object

That's because Expression isn't a string and a list of arguments.

It's a hierarchical struture.  You're actually working with three Expressions.

AndExpression contains the userid Expression and the name Expression

On 9/1/05, Pirola Davide <davide.pirola <at> vtin.it> wrote:
> Hi,
> i have noticed that if i want to access to a single qualifier:
> 
> <![CDATA[(USER_ID = $userId)]]>
> 
> the operand count is 2... the first is "USER_ID" and the second is "$userId".
> 
> If i use a multiple qualifier:
> 
> <![CDATA[((UserId = $userId) and (Name = $name))]]>
> 
> the operand count is always 2... but now the first is "UserId  = $userId" and the second is "Name = $name".
> 
> Why this different behavior?
> There isn't a standard method to retrive a field name?
> 
> thank's
> Davide
> 
> 
> 
> 
> 
> -----Original Message-----
> From: Mike Kienenberger [mailto:mkienenb <at> gmail.com]
> Sent: giovedì 1 settembre 2005 16.42
> To: cayenne-user <at> objectstyle.org
> Subject: Re: How to dynamically get Qualifier info from SelectQuery
> object
> 
> 
> Expression e  = qry.getQualifier() will give you the qualifier
> expression that is built from <![CDATA[(USER_ID = $userId)]]>.
> 
> 
> 
> On 9/1/05, Pirola Davide <davide.pirola <at> vtin.it> wrote:
> > Hi,
> > i want to extract at runtime the quelifier data from a SelectQuery object.
> >
> > I have a query defined in a datamap xml file:
> > ---------------------------------------------------
> > <query name="qryStat" factory="org.objectstyle.cayenne.map.SelectQueryBuilder"
root="obj-entity" root-name="stat">
> >         <qualifier>
> >                 <![CDATA[(USER_ID = $userId)]]>
> >         </qualifier>
> > </query>
> > ---------------------------------------------------
> >
> > I have obtained a SelectQuery:
> >
> > ---------------------------------------------------
> > SelectQuery qry = (SelectQuery) resolver.getQuery("qryStat");
> > ---------------------------------------------------
> >
> > How i can retrive the field name used in "where" expression? (USER_ID)
> > Is possible to get it form a property defined in SelectQuery ?
> >
> > Thank's
> > Davide
> >
>

Mike Kienenberger | 1 Sep 2005 17:07
Picon

Re: Yet another optimistic locking question

Yeah, it's basically an atomic db operation that says UPDATE set
values WHERE all fields marked for optimistic locking haven't changed
values from the last time we read them.

On 9/1/05, Gili <cowwoc <at> bbs.darktech.org> wrote:
> 
>         Oh my. It all makes so much more sense now... So if I understand it
> correctly,
> 
> 1) We store the perceived DB value somewhere
> 2) We store the cached (maybe modified) value elsewhere
> 3) When a commit occurs, we compare the objects in 1 and 2, then issue a
> UPDATE only for fields which have changed.
> 
>         Cool :) This also sounds quite efficient to me.
> 
> Thank you,
> Gili
> 
> Gentry, Michael (Contractor) wrote:
> > Optimistic locking never locks the row in the database (it is
> > optimistic).  Read:
> >
> > http://www.objectstyle.org/confluence/display/CAY/Optimistic+Locking+Exp
> > lained
> >
> > It explains how Cayenne can ensure that no changes occurred between the
> > SELECT and UPDATE phase.  If you still have questions I'll try to answer
> > them.
> >
> > Thanks,
> >
> > /dev/mrg
> >
> >
> > -----Original Message-----
> > From: Gili [mailto:cowwoc <at> bbs.darktech.org]
> > Sent: Thursday, September 01, 2005 12:06 AM
> > To: cayenne-user <at> objectstyle.org
> > Subject: Yet another optimistic locking question
> >
> >
> >
> >       A question about how optimistic locking is currently
> > implemented. Do we
> > implement it like this?
> >
> > 1) Lock row
> > 2) Read row
> > 3) Compare read row to DataObject version of row
> > 4) If values mismatch, unlock the row and throw an exception
> > 5) If values match, continue with update and unlock row
> >
> >       or do we not lock the database at all? If we don't lock it at
> > all, how
> > can we ensure that no changes occur after step 3 but before step 5?
> >
> > Thank you,
> > Gili
> 
> --
> http://www.desktopbeautifier.com/
>


Gmane