FAQ
Hello,

I created an Object Select Query in the Modeller which selects * from
table Vehicles. The query has a qualifier (plate = $plate). In Result
Caching I selected Shared Cache and unchecked the checkbox Refresh
Results.

I wrote the following code:

Map params = new HashMap();
params.put("plate", "koz-6657");

List allVehicles = context.performQuery("selectVehicles",
false);
List specificVehicle = context.performQuery("selectVehicles",
params, false);

I noticed that the first call of performQuery stores the retrieved
Vehicle Objects in cache.
But the second call, instead of getting the specific vehicle from cache
it sends a query to the database.

Why is this happening? Shouldn't it first look in cache?

Thank you,
Nikos Paraschou

Search Discussions

  • Andrus Adamchik at Apr 21, 2009 at 10:21 am
    Shouldn't it first look in cache?

    Yes it should. Are you using the same set of parameters in both cases?
    And also which version of Cayenne is this?

    Andrus

    On Apr 21, 2009, at 12:28 PM, Nikos Paraschou wrote:

    Hello,

    I created an Object Select Query in the Modeller which selects * from
    table Vehicles. The query has a qualifier (plate = $plate). In Result
    Caching I selected Shared Cache and unchecked the checkbox Refresh
    Results.

    I wrote the following code:

    Map params = new HashMap();
    params.put("plate", "koz-6657");

    List allVehicles = context.performQuery("selectVehicles",
    false);
    List specificVehicle = context.performQuery("selectVehicles",
    params, false);

    I noticed that the first call of performQuery stores the retrieved
    Vehicle Objects in cache.
    But the second call, instead of getting the specific vehicle from
    cache
    it sends a query to the database.

    Why is this happening? Shouldn't it first look in cache?

    Thank you,
    Nikos Paraschou
  • Nikos Paraschou at Apr 21, 2009 at 10:50 am
    Στις 21-04-2009, ημέρα Τρι, και ώρα 13:21 +0300, ο/η Andrus Adamchik
    έγραψε:
    Shouldn't it first look in cache?

    Yes it should. Are you using the same set of parameters in both cases?
    In the first case I am just calling the query "selectVehicles" which is
    stored in DataMap without defining any parameters. All vehicles are
    returned.

    In the second case I want to retrieve a specific vehicle so I define the
    parameter plate

    params.put("plate", "koz-6657") and call

    performQuery("selectVehicles", params, false);

    The second call doesn't retrieve the requested vehicle from the cache
    but instead, it sends a query to the DB.

    Why is this happening? Is it normal?

    And also which version of Cayenne is this?
    I am using Cayenne 2.0.4.
    Andrus

    On Apr 21, 2009, at 12:28 PM, Nikos Paraschou wrote:

    Hello,

    I created an Object Select Query in the Modeller which selects * from
    table Vehicles. The query has a qualifier (plate = $plate). In Result
    Caching I selected Shared Cache and unchecked the checkbox Refresh
    Results.

    I wrote the following code:

    Map params = new HashMap();
    params.put("plate", "koz-6657");

    List allVehicles = context.performQuery("selectVehicles",
    false);
    List specificVehicle = context.performQuery("selectVehicles",
    params, false);

    I noticed that the first call of performQuery stores the retrieved
    Vehicle Objects in cache.
    But the second call, instead of getting the specific vehicle from
    cache
    it sends a query to the database.

    Why is this happening? Shouldn't it first look in cache?

    Thank you,
    Nikos Paraschou
  • Andrus Adamchik at Apr 21, 2009 at 11:00 am
    Yes, this is normal. Altering parameters changes the query, so in two
    case you end up with two different queries behind the scenes, each
    cached separately.

    Andrus

    On Apr 21, 2009, at 1:50 PM, Nikos Paraschou wrote:
    Στις 21-04-2009, ημέρα Τρι, και ώρα 13:21 +0300, ο/
    η Andrus Adamchik
    έγραψε:
    Shouldn't it first look in cache?

    Yes it should. Are you using the same set of parameters in both
    cases?
    In the first case I am just calling the query "selectVehicles" which
    is
    stored in DataMap without defining any parameters. All vehicles are
    returned.

    In the second case I want to retrieve a specific vehicle so I define
    the
    parameter plate

    params.put("plate", "koz-6657") and call

    performQuery("selectVehicles", params, false);

    The second call doesn't retrieve the requested vehicle from the cache
    but instead, it sends a query to the DB.

    Why is this happening? Is it normal?

    And also which version of Cayenne is this?
    I am using Cayenne 2.0.4.
    Andrus

    On Apr 21, 2009, at 12:28 PM, Nikos Paraschou wrote:

    Hello,

    I created an Object Select Query in the Modeller which selects *
    from
    table Vehicles. The query has a qualifier (plate = $plate). In
    Result
    Caching I selected Shared Cache and unchecked the checkbox Refresh
    Results.

    I wrote the following code:

    Map params = new HashMap();
    params.put("plate", "koz-6657");

    List allVehicles = context.performQuery("selectVehicles",
    false);
    List specificVehicle = context.performQuery("selectVehicles",
    params, false);

    I noticed that the first call of performQuery stores the retrieved
    Vehicle Objects in cache.
    But the second call, instead of getting the specific vehicle from
    cache
    it sends a query to the database.

    Why is this happening? Shouldn't it first look in cache?

    Thank you,
    Nikos Paraschou
  • Nikos Paraschou at Apr 21, 2009 at 11:48 am
    Στις 21-04-2009, ημέρα Τρι, και ώρα 13:58 +0300, ο/η Andrus Adamchik
    έγραψε:
    Yes, this is normal. Altering parameters changes the query, so in two
    case you end up with two different queries behind the scenes, each
    cached separately.
    It is clear now. Thank you for helping.

    Nikos

    Andrus

    On Apr 21, 2009, at 1:50 PM, Nikos Paraschou wrote:
    Στις 21-04-2009, ημέρα Τρι, και ώρα 13:21 +0300, ο/
    η Andrus Adamchik
    έγραψε:
    Shouldn't it first look in cache?

    Yes it should. Are you using the same set of parameters in both
    cases?
    In the first case I am just calling the query "selectVehicles" which
    is
    stored in DataMap without defining any parameters. All vehicles are
    returned.

    In the second case I want to retrieve a specific vehicle so I define
    the
    parameter plate

    params.put("plate", "koz-6657") and call

    performQuery("selectVehicles", params, false);

    The second call doesn't retrieve the requested vehicle from the cache
    but instead, it sends a query to the DB.

    Why is this happening? Is it normal?

    And also which version of Cayenne is this?
    I am using Cayenne 2.0.4.
    Andrus

    On Apr 21, 2009, at 12:28 PM, Nikos Paraschou wrote:

    Hello,

    I created an Object Select Query in the Modeller which selects *
    from
    table Vehicles. The query has a qualifier (plate = $plate). In
    Result
    Caching I selected Shared Cache and unchecked the checkbox Refresh
    Results.

    I wrote the following code:

    Map params = new HashMap();
    params.put("plate", "koz-6657");

    List allVehicles = context.performQuery("selectVehicles",
    false);
    List specificVehicle = context.performQuery("selectVehicles",
    params, false);

    I noticed that the first call of performQuery stores the retrieved
    Vehicle Objects in cache.
    But the second call, instead of getting the specific vehicle from
    cache
    it sends a query to the database.

    Why is this happening? Shouldn't it first look in cache?

    Thank you,
    Nikos Paraschou

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedApr 21, '09 at 9:28a
activeApr 21, '09 at 11:48a
posts5
users2
websitecayenne.apache.org

People

Translate

site design / logo © 2022 Grokbase