Re: Cayenne and Spring?

2018-01-08 Thread Frank Herrmann
Do you have the Jackson libraries included in your project? They are
normally needed for JSON serialization/deserialization.

On Mon, Jan 8, 2018 at 4:52 PM, Fredrik Widengren <
fredrik.wideng...@gmail.com> wrote:

> Hello,
>
> I'm testing to setup Cayenne with Spring Boot. I have created a simple
> REST service. Spring is working fine with a Hello World example from
> Spring.io.
>
> When I try to send back my cayenne objects that I have generated from
> the Cayenne modeller, I get an exception that it can’t find a JSON
> serializer.
>
> Error:
> Could not write JSON: No serializer found for class
> org.apache.cayenne.tx.TransactionFilter
>
> I have read that a common reason for this is that the class that you
> try to serialize does not have any public getters/setters. The
> generated classes (in the auto package) from the modeller that extends
> CayenneDataObject do have these public getters/setters. The class is
> however abstract, but I'm using the class created by the modeller that
> extends the abstract modeller class.
>
> Anyone that have any experience from Cayenne and Spring that have some
> input?
>
> Many thanks!
>
> /Fredrik
>



-- 
FRANK HERRMANN
SENIOR SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <https://www.modmed.com/>
[image: [ Facebook ]] <https://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <https://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <https://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed> [image: [ Blog ]]
<https://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<https://instagram.com/modernizing_medicine>

[image: [ MOMENTUM 2017 ]] <https://www.eventproducers.events/momentum2017/>


Re: Cayenne with Transaction Manager (Atomikos)

2016-09-23 Thread Frank Herrmann
Thanks Andrus. Fortunately, even with Bitronix, we created a custom
SpringDataSourceFactor for Cayenne that allows Cayenne to participate in a
Spring managed transaction. It looks like that will service me as well for
Atomikos, since Spring is handling the transaction, not Cayenne. I'll let
you know how it works out.

-Frank

On Thu, Sep 22, 2016 at 8:08 PM, Andrus Adamchik <and...@objectstyle.org>
wrote:

> Hi Frank,
>
> As you see, with a few exceptions, Cayenne community just delegates
> transactions to Cayenne and rarely cares about external tx manager. At the
> same time we are quietly improving public transaction API in Cayenne, and I
> am interested to see how that works Atomikos and other tx managers. Please
> keep the list posted on how that goes, and if we can change anything in
> Cayenne to make the integration more seamless, let's discuss on dev@.
>
> Thanks,
> Andrus
>
>
> > On Sep 20, 2016, at 9:30 AM, Frank Herrmann <frank.herrmann@
> modernizingmedicine.com> wrote:
> >
> > Hello all,
> >
> > I was wondering if anyone has had any experience using a transaction
> > manager with Cayenne. Currently, we use Bitronix with a lot of custom,
> > buggy, code wrapped around it. We are in the process of switching to
> > Atomikos. Does anyone have an advice, or better an example, of
> integrating
> > Cayenne with Atomikos (or other transaction manager)?
> >
> > Thanks in advance.
> >
> > -Frank
> >
> > --
> > FRANK HERRMANN
> > SENIOR SOFTWARE ENGINEER
> >
> > T: 561-880-2998 x1563
> >
> > E: frank.herrm...@modmed.com
> >
> >
> >
> > [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> > [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
> [image:
> > [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
> [image:
> > [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
> > Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> > <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> > <http://instagram.com/modernizing_medicine>
>
>


-- 
FRANK HERRMANN
SENIOR SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Re: Cayenne with Transaction Manager (Atomikos)

2016-09-21 Thread Frank Herrmann
Currently we have Bitronix. However, Bitronix hasn't been updated in years
and is dead as a project. We need transaction management because we write
to both a database and a JMS queue (ActiveMQ). We have existing custom code
to allow Cayenne to participate in a Spring managed transaction. I was just
reaching out to see if anyone else has done something similar. We have a
lot of code wrapped around Bitronix to second guess whether to use a local
or global transaction. Most of this functionality is built into Atomikos,
so I have to unravel the code in our system. Basically, I'm covering all my
bases while doing my research into the best approach.



On Tue, Sep 20, 2016 at 7:20 PM, Aristedes Maniatis <a...@maniatis.org>
wrote:

> On 20/09/2016 11:30pm, Frank Herrmann wrote:
> > Hello all,
> >
> > I was wondering if anyone has had any experience using a transaction
> > manager with Cayenne. Currently, we use Bitronix with a lot of custom,
> > buggy, code wrapped around it. We are in the process of switching to
> > Atomikos. Does anyone have an advice, or better an example, of
> integrating
> > Cayenne with Atomikos (or other transaction manager)?
>
>
> I can't answer your question because I've never needed such a setup (or
> maybe I have but didn't know it), but I'm curious about your design choices
> and what it gives you. Are you running two separate databases and using the
> transaction manager to write to both of them, or are you using a
> transaction manager to synchronise a memory cache across your application
> cluster? If the latter, then would Terracotta work for you?
>
> What sort of high availability problem does Atomikos solve?
>
> Cheers
> Ari
>
>
>
> --
> ------>
> Aristedes Maniatis
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>



-- 
FRANK HERRMANN
SENIOR SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Cayenne with Transaction Manager (Atomikos)

2016-09-20 Thread Frank Herrmann
Hello all,

I was wondering if anyone has had any experience using a transaction
manager with Cayenne. Currently, we use Bitronix with a lot of custom,
buggy, code wrapped around it. We are in the process of switching to
Atomikos. Does anyone have an advice, or better an example, of integrating
Cayenne with Atomikos (or other transaction manager)?

Thanks in advance.

-Frank

-- 
FRANK HERRMANN
SENIOR SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Re: Ordering by date on a timestamp field

2016-06-09 Thread Frank Herrmann
Thanks everyone.

Andrus, is SQLSelect in Cayenne 3.1, or is it new in 4.0.

Thanks,

-Frank

On Thu, Jun 9, 2016 at 6:12 AM, Hugi Thordarson <h...@karlmenn.is> wrote:

> Hi Frank,
> we solved this in one of our apps by creating a separate date-only column
> in the DB and mapping it to java.time.LocalTime in our model class. Then we
> just modified the setter for the dateTime value to also set the date-only
> value.
>
> Cheers,
> - hugi
>
> // Hugi Thordarson
> // http://www.loftfar.is/
> // s. 895-6688
>
>
>
> > On 8. jún. 2016, at 20:49, Frank Herrmann <
> frank.herrm...@modernizingmedicine.com> wrote:
> >
> > Views in mysql do not take advantage of indexes. We would like to avoid
> > views and would prefer a Cayenne solution. Also, having a view with a
> > formula is not very efficient, especially when dealing with hundreds of
> > thousands of records.
> >
> > -Frank
> >
> > On Wed, Jun 8, 2016 at 4:42 PM, Adam Boyle <abo...@valsphere.com> wrote:
> >
> >> I can't speak to what Cayenne is able to do solely when using an
> >> ObjectQuery, but from a database perspective it sounds like you want to
> be
> >> using a view that provides the date-only version of your datetime
> column.
> >> Then you could query it just like a table and do your sort on the
> date-only
> >> column. You can probably use the Query object type in your project
> model to
> >> achieve this if you aren't keen on adding SQL objects to your model
> outside
> >> of Cayenne Modeler.
> >>
> >>
> >> -Adam
> >>
> >> 
> >> From: Frank Herrmann <frank.herrm...@modernizingmedicine.com>
> >> Sent: Wednesday, June 8, 2016 4:07:44 PM
> >> To: user@cayenne.apache.org
> >> Subject: Ordering by date on a timestamp field
> >>
> >> Hello all,
> >>
> >> Is there a way in Cayenne, when adding an ordering to a query, to order
> by
> >> only the date portion of a timestamp (including time) field? Basically,
> the
> >> timestamp includes hour, minutes, seconds, etc. I only want to sort on
> the
> >> date portion (month, day, year), or any other such criteria.
> >>
> >> The reason for this is, if we include other fields to sort by, we would
> >> want the second sort field to group on the date, not the full timestamp.
> >>
> >> Thanks,
> >>
> >> -Frank
> >>
> >> --
> >> FRANK HERRMANN
> >> SOFTWARE ENGINEER
> >>
> >> T: 561-880-2998 x1563
> >>
> >> E: frank.herrm...@modmed.com
> >>
> >>
> >>
> >> [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> >> [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
> >> [image:
> >> [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
> >> [image:
> >> [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image:
> [
> >> Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> >> <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> >> <http://instagram.com/modernizing_medicine>
> >>
> >
> >
> >
> > --
> > FRANK HERRMANN
> > SOFTWARE ENGINEER
> >
> > T: 561-880-2998 x1563
> >
> > E: frank.herrm...@modmed.com
> >
> >
> >
> > [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> > [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
> [image:
> > [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
> [image:
> > [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
> > Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> > <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> > <http://instagram.com/modernizing_medicine>
>
>


-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Re: Object Cache and Child Objects - Cayenne 3.1

2016-05-19 Thread Frank Herrmann
Thanks for the quick response. :)

On Thu, May 19, 2016 at 6:19 AM, Andrus Adamchik <and...@objectstyle.org>
wrote:

> Just committed a fix to 3.1 and 4.0 branches:
> https://issues.apache.org/jira/browse/CAY-2084
>
>
> > On May 18, 2016, at 5:27 PM, Frank Herrmann <
> frank.herrm...@modernizingmedicine.com> wrote:
> >
> > Thanks.
> >
> > On Wed, May 18, 2016 at 10:25 AM, Andrus Adamchik <
> and...@objectstyle.org>
> > wrote:
> >
> >> In 4.0 we are using SelectById query that hits query cache, which I am
> >> pretty sure is free of this issue.
> >>
> >> Will need to investigate ObjectIdQuery behavior.
> >>
> >> Andrus
> >>
> >>> On May 18, 2016, at 5:22 PM, Frank Herrmann <
> >> frank.herrm...@modernizingmedicine.com> wrote:
> >>>
> >>> Hi Andrus,
> >>>
> >>> Yes, superclass/subclass. We are using Cayenne.objectForQuery(...);
> >>>
> >>> Specifically,
> >>>
> >>> Cayenne.*objectForQuery*(dataContext, *new* ObjectIdQuery(oid, *false*,
> >>> ObjectIdQuery.*CACHE*));
> >>>
> >>> On Wed, May 18, 2016 at 10:11 AM, Andrus Adamchik <
> >> and...@objectstyle.org>
> >>> wrote:
> >>>
> >>>>> I have a question and an observation. While reading some of the
> Cayenne
> >>>>> code, we've noticed reference to a snapshot cache. Is this the object
> >>>>> cache, or something different?
> >>>>
> >>>> Correct. This is shared object cache.
> >>>>
> >>>>> The issue we are seeing has to do with cayenne objects that are
> >>>>> parents/children of other cayenne objects. For instance, we have a
> User
> >>>>> object, we also have Staff and Patient objects that are children of
> the
> >>>>> User object.
> >>>>
> >>>> By parent/child you mean superclass/subclass?
> >>>>
> >>>>>
> >>>>> What we have seen is that if a developer does a query for a User
> object
> >>>> by
> >>>>> id, the object is retrieved. Cayenne sees that this object is a Staff
> >>>>> object and then stores it in the object cache as a Staff object. The
> >> next
> >>>>> time the user goes to retrieve the User object (by the same id),
> >> Cayenne
> >>>>> does another call to the database, because it cannot find the User
> >> object
> >>>>> in the cache (because it stored it as a Staff object).
> >>>>
> >>>> Could be a bug. Which API are you using? Cayenne.objectForPK(..) ?
> >>>>
> >>>> Andrus
> >>>>
> >>>>
> >>>>
> >>>>> On May 18, 2016, at 4:31 PM, Frank Herrmann <
> >>>> frank.herrm...@modernizingmedicine.com> wrote:
> >>>>>
> >>>>> Hello all,
> >>>>>
> >>>>> I have a question and an observation. While reading some of the
> Cayenne
> >>>>> code, we've noticed reference to a snapshot cache. Is this the object
> >>>>> cache, or something different?
> >>>>>
> >>>>> The issue we are seeing has to do with cayenne objects that are
> >>>>> parents/children of other cayenne objects. For instance, we have a
> User
> >>>>> object, we also have Staff and Patient objects that are children of
> the
> >>>>> User object.
> >>>>>
> >>>>> What we have seen is that if a developer does a query for a User
> object
> >>>> by
> >>>>> id, the object is retrieved. Cayenne sees that this object is a Staff
> >>>>> object and then stores it in the object cache as a Staff object. The
> >> next
> >>>>> time the user goes to retrieve the User object (by the same id),
> >> Cayenne
> >>>>> does another call to the database, because it cannot find the User
> >> object
> >>>>> in the cache (because it stored it as a Staff object).
> >>>>>
> >>>>> Thanks again for the help.
> >>>>>
> >>>>> -Frank
> >>>>>
> >>>>> --
> >>>>> FRANK HERRMANN
> >>>>> SOFTWARE ENGINEER
> >>>>>
> >>>>&g

Re: Object Cache and Child Objects - Cayenne 3.1

2016-05-18 Thread Frank Herrmann
Hi Andrus,

Yes, superclass/subclass. We are using Cayenne.objectForQuery(...);

Specifically,

Cayenne.*objectForQuery*(dataContext, *new* ObjectIdQuery(oid, *false*,
ObjectIdQuery.*CACHE*));

On Wed, May 18, 2016 at 10:11 AM, Andrus Adamchik <and...@objectstyle.org>
wrote:

> > I have a question and an observation. While reading some of the Cayenne
> > code, we've noticed reference to a snapshot cache. Is this the object
> > cache, or something different?
>
> Correct. This is shared object cache.
>
> > The issue we are seeing has to do with cayenne objects that are
> > parents/children of other cayenne objects. For instance, we have a User
> > object, we also have Staff and Patient objects that are children of the
> > User object.
>
> By parent/child you mean superclass/subclass?
>
> >
> > What we have seen is that if a developer does a query for a User object
> by
> > id, the object is retrieved. Cayenne sees that this object is a Staff
> > object and then stores it in the object cache as a Staff object. The next
> > time the user goes to retrieve the User object (by the same id), Cayenne
> > does another call to the database, because it cannot find the User object
> > in the cache (because it stored it as a Staff object).
>
> Could be a bug. Which API are you using? Cayenne.objectForPK(..) ?
>
> Andrus
>
>
>
> > On May 18, 2016, at 4:31 PM, Frank Herrmann <
> frank.herrm...@modernizingmedicine.com> wrote:
> >
> > Hello all,
> >
> > I have a question and an observation. While reading some of the Cayenne
> > code, we've noticed reference to a snapshot cache. Is this the object
> > cache, or something different?
> >
> > The issue we are seeing has to do with cayenne objects that are
> > parents/children of other cayenne objects. For instance, we have a User
> > object, we also have Staff and Patient objects that are children of the
> > User object.
> >
> > What we have seen is that if a developer does a query for a User object
> by
> > id, the object is retrieved. Cayenne sees that this object is a Staff
> > object and then stores it in the object cache as a Staff object. The next
> > time the user goes to retrieve the User object (by the same id), Cayenne
> > does another call to the database, because it cannot find the User object
> > in the cache (because it stored it as a Staff object).
> >
> > Thanks again for the help.
> >
> > -Frank
> >
> > --
> > FRANK HERRMANN
> > SOFTWARE ENGINEER
> >
> > T: 561-880-2998 x1563
> >
> > E: frank.herrm...@modmed.com
> >
> >
> >
> > [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> > [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
> [image:
> > [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
> [image:
> > [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
> > Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> > <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> > <http://instagram.com/modernizing_medicine>
>
>


-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Object Cache and Child Objects - Cayenne 3.1

2016-05-18 Thread Frank Herrmann
Hello all,

I have a question and an observation. While reading some of the Cayenne
code, we've noticed reference to a snapshot cache. Is this the object
cache, or something different?

The issue we are seeing has to do with cayenne objects that are
parents/children of other cayenne objects. For instance, we have a User
object, we also have Staff and Patient objects that are children of the
User object.

What we have seen is that if a developer does a query for a User object by
id, the object is retrieved. Cayenne sees that this object is a Staff
object and then stores it in the object cache as a Staff object. The next
time the user goes to retrieve the User object (by the same id), Cayenne
does another call to the database, because it cannot find the User object
in the cache (because it stored it as a Staff object).

Thanks again for the help.

-Frank

-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Re: Caching Relationship Objects/Queries - Cayenne 3.1

2016-05-17 Thread Frank Herrmann
After digging some more, I think I know what is going on. It is more an
result of your second example.

object2 = // something that fetches object2
object1 = object2.getObject1(); // trips fault, fetches object1
object2 = // refetch object2 from cache
object1 = object2.getObject1(); // trips fault, fetches object1
object2 = // refetch object2 from cache
object1 = object2.getObject1(); // trips fault, fetches object1

The issue stems from the fact that the object2 in the cache is never
updated with the retrieved related objects. So, the next time we fetch
object2 from the object cache, it still have the fault.

-Frank




On Tue, May 17, 2016 at 3:24 PM, Frank Herrmann <
frank.herrm...@modernizingmedicine.com> wrote:

> Thanks. That is pretty much our issue. If I do a prefetch however on
> object1 I everything works as expected. I'll have to dig deeper into our
> code to see what is going on.
>
> On Tue, May 17, 2016 at 2:48 PM, Michael Gentry <blackn...@gmail.com>
> wrote:
>
>> Hi Frank,
>>
>> There might still be something more going on here.
>>
>> When you initially fetch object2 for the first time, the relationship to
>> object1 is a "fault" (assuming you don't prefetch).  When you say
>> object2.getObject1(), Cayenne will trigger the fault resulting in a SELECT
>> statement sent to the DB, which gets populated into object1, which
>> replaces
>> the fault.  The next time you say object2.getObject1(), it should return
>> object1 since the fault is no longer there.  I glossed over a few things
>> there, but I hope you understood my gist.  I'm assuming something has
>> happened to your object2 between the first and second calls to
>> getObject1()
>> which is causing the fault to be re-established and therefore re-tripped.
>>
>> mrg
>>
>>
>>
>> On Tue, May 17, 2016 at 2:29 PM, Frank Herrmann <
>> frank.herrm...@modernizingmedicine.com> wrote:
>>
>> > I believe your first example. Here is some clarification.
>> >
>> > object2 = // something that fetches object2 -- object2 is now in the
>> object
>> > cache
>> > object1 = object2.getObject1(); // makes a call to the database and
>> fetches
>> > object1 -- does not put object1 in the object cache
>> > object1 = object2.getObject1(); // makes another call to the database to
>> > fetch object1, since object1 is not in the object cache
>> >
>> > -Frank
>> >
>> > On Tue, May 17, 2016 at 2:21 PM, Michael Gentry <blackn...@gmail.com>
>> > wrote:
>> >
>> > > Hi Frank,
>> > >
>> > > I'm a little confused by this part:
>> > >
>> > > "If we retrieve Object2 from the database, it is placed in the object
>> > > cache. Afterwards, if we retrieve Object1 via the getter in Object2,
>> > > Object1 is not cached. So, every time we make the request for Object1
>> via
>> > > the getter, another call is made to the database."
>> > >
>> > > Are you saying:
>> > >
>> > > object2 = // something that fetches object2
>> > > object1 = object2.getObject1(); // trips fault, fetches object1
>> > > object1 = object2.getObject1(); // trips fault, fetches object1
>> > >
>> > > Or:
>> > >
>> > > object2 = // something that fetches object2
>> > > object1 = object2.getObject1(); // trips fault, fetches object1
>> > > object2 = // refetch object2 from cache
>> > > object1 = object2.getObject1(); // trips fault, fetches object1
>> > >
>> > > Thanks,
>> > >
>> > > mrg
>> > >
>> > >
>> > > On Tue, May 17, 2016 at 9:32 AM, Frank Herrmann <
>> > > frank.herrm...@modernizingmedicine.com> wrote:
>> > >
>> > > > Hello all,
>> > > >
>> > > > I have a question regarding how Cayenne does caching. Right now, if
>> we
>> > > > retrieve an object from the database via Cayenne, it is placed in
>> the
>> > > > object cache. However, in our experience, if we then retrieve
>> another
>> > > > object via the relationship on the first object, it is not cached.
>> > > >
>> > > > A rough example:
>> > > >
>> > > > public class Object1 {
>> > > > ... misc attributes ...
>> > > > }
>> > > >
>> > > > public class Object2 {
>> > > > ... misc attributes...
&g

Re: Caching Relationship Objects/Queries - Cayenne 3.1

2016-05-17 Thread Frank Herrmann
Thanks. That is pretty much our issue. If I do a prefetch however on
object1 I everything works as expected. I'll have to dig deeper into our
code to see what is going on.

On Tue, May 17, 2016 at 2:48 PM, Michael Gentry <blackn...@gmail.com> wrote:

> Hi Frank,
>
> There might still be something more going on here.
>
> When you initially fetch object2 for the first time, the relationship to
> object1 is a "fault" (assuming you don't prefetch).  When you say
> object2.getObject1(), Cayenne will trigger the fault resulting in a SELECT
> statement sent to the DB, which gets populated into object1, which replaces
> the fault.  The next time you say object2.getObject1(), it should return
> object1 since the fault is no longer there.  I glossed over a few things
> there, but I hope you understood my gist.  I'm assuming something has
> happened to your object2 between the first and second calls to getObject1()
> which is causing the fault to be re-established and therefore re-tripped.
>
> mrg
>
>
>
> On Tue, May 17, 2016 at 2:29 PM, Frank Herrmann <
> frank.herrm...@modernizingmedicine.com> wrote:
>
> > I believe your first example. Here is some clarification.
> >
> > object2 = // something that fetches object2 -- object2 is now in the
> object
> > cache
> > object1 = object2.getObject1(); // makes a call to the database and
> fetches
> > object1 -- does not put object1 in the object cache
> > object1 = object2.getObject1(); // makes another call to the database to
> > fetch object1, since object1 is not in the object cache
> >
> > -Frank
> >
> > On Tue, May 17, 2016 at 2:21 PM, Michael Gentry <blackn...@gmail.com>
> > wrote:
> >
> > > Hi Frank,
> > >
> > > I'm a little confused by this part:
> > >
> > > "If we retrieve Object2 from the database, it is placed in the object
> > > cache. Afterwards, if we retrieve Object1 via the getter in Object2,
> > > Object1 is not cached. So, every time we make the request for Object1
> via
> > > the getter, another call is made to the database."
> > >
> > > Are you saying:
> > >
> > > object2 = // something that fetches object2
> > > object1 = object2.getObject1(); // trips fault, fetches object1
> > > object1 = object2.getObject1(); // trips fault, fetches object1
> > >
> > > Or:
> > >
> > > object2 = // something that fetches object2
> > > object1 = object2.getObject1(); // trips fault, fetches object1
> > > object2 = // refetch object2 from cache
> > > object1 = object2.getObject1(); // trips fault, fetches object1
> > >
> > > Thanks,
> > >
> > > mrg
> > >
> > >
> > > On Tue, May 17, 2016 at 9:32 AM, Frank Herrmann <
> > > frank.herrm...@modernizingmedicine.com> wrote:
> > >
> > > > Hello all,
> > > >
> > > > I have a question regarding how Cayenne does caching. Right now, if
> we
> > > > retrieve an object from the database via Cayenne, it is placed in the
> > > > object cache. However, in our experience, if we then retrieve another
> > > > object via the relationship on the first object, it is not cached.
> > > >
> > > > A rough example:
> > > >
> > > > public class Object1 {
> > > > ... misc attributes ...
> > > > }
> > > >
> > > > public class Object2 {
> > > > ... misc attributes...
> > > > private Object1 object1;
> > > >
> > > > public Object1 getObject1() {
> > > > return object1;
> > > > }
> > > > }
> > > >
> > > > If we retrieve Object2 from the database, it is placed in the object
> > > cache.
> > > > Afterwards, if we retrieve Object1 via the getter in Object2, Object1
> > is
> > > > not cached. So, every time we make the request for Object1 via the
> > > getter,
> > > > another call is made to the database. I have fixed this for
> individual
> > > > instances by using prefetches. However, our application is quite
> large,
> > > and
> > > > I don't like the idea of tracking down case.
> > > >
> > > > Is there some way for Cayenne to place the relationship objects into
> > the
> > > > object cache the first time they are retrieved? We are using EhCache
> > for
> > > > our query caching, so if the object cache is not an options, is
> there

Re: Caching Relationship Objects/Queries - Cayenne 3.1

2016-05-17 Thread Frank Herrmann
I believe your first example. Here is some clarification.

object2 = // something that fetches object2 -- object2 is now in the object
cache
object1 = object2.getObject1(); // makes a call to the database and fetches
object1 -- does not put object1 in the object cache
object1 = object2.getObject1(); // makes another call to the database to
fetch object1, since object1 is not in the object cache

-Frank

On Tue, May 17, 2016 at 2:21 PM, Michael Gentry <blackn...@gmail.com> wrote:

> Hi Frank,
>
> I'm a little confused by this part:
>
> "If we retrieve Object2 from the database, it is placed in the object
> cache. Afterwards, if we retrieve Object1 via the getter in Object2,
> Object1 is not cached. So, every time we make the request for Object1 via
> the getter, another call is made to the database."
>
> Are you saying:
>
> object2 = // something that fetches object2
> object1 = object2.getObject1(); // trips fault, fetches object1
> object1 = object2.getObject1(); // trips fault, fetches object1
>
> Or:
>
> object2 = // something that fetches object2
> object1 = object2.getObject1(); // trips fault, fetches object1
> object2 = // refetch object2 from cache
> object1 = object2.getObject1(); // trips fault, fetches object1
>
> Thanks,
>
> mrg
>
>
> On Tue, May 17, 2016 at 9:32 AM, Frank Herrmann <
> frank.herrm...@modernizingmedicine.com> wrote:
>
> > Hello all,
> >
> > I have a question regarding how Cayenne does caching. Right now, if we
> > retrieve an object from the database via Cayenne, it is placed in the
> > object cache. However, in our experience, if we then retrieve another
> > object via the relationship on the first object, it is not cached.
> >
> > A rough example:
> >
> > public class Object1 {
> > ... misc attributes ...
> > }
> >
> > public class Object2 {
> > ... misc attributes...
> > private Object1 object1;
> >
> > public Object1 getObject1() {
> > return object1;
> > }
> > }
> >
> > If we retrieve Object2 from the database, it is placed in the object
> cache.
> > Afterwards, if we retrieve Object1 via the getter in Object2, Object1 is
> > not cached. So, every time we make the request for Object1 via the
> getter,
> > another call is made to the database. I have fixed this for individual
> > instances by using prefetches. However, our application is quite large,
> and
> > I don't like the idea of tracking down case.
> >
> > Is there some way for Cayenne to place the relationship objects into the
> > object cache the first time they are retrieved? We are using EhCache for
> > our query caching, so if the object cache is not an options, is there a
> way
> > to store these relationships in a short lived query cache?
> >
> > Thanks for the help.
> >
> > -Frank
> >
> > --
> > FRANK HERRMANN
> > SOFTWARE ENGINEER
> >
> > T: 561-880-2998 x1563
> >
> > E: frank.herrm...@modmed.com
> >
> >
> >
> > [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> > [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
> > [image:
> > [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
> > [image:
> > [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
> > Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> > <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> > <http://instagram.com/modernizing_medicine>
> >
>



-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Caching Relationship Objects/Queries - Cayenne 3.1

2016-05-17 Thread Frank Herrmann
Hello all,

I have a question regarding how Cayenne does caching. Right now, if we
retrieve an object from the database via Cayenne, it is placed in the
object cache. However, in our experience, if we then retrieve another
object via the relationship on the first object, it is not cached.

A rough example:

public class Object1 {
... misc attributes ...
}

public class Object2 {
... misc attributes...
private Object1 object1;

public Object1 getObject1() {
return object1;
}
}

If we retrieve Object2 from the database, it is placed in the object cache.
Afterwards, if we retrieve Object1 via the getter in Object2, Object1 is
not cached. So, every time we make the request for Object1 via the getter,
another call is made to the database. I have fixed this for individual
instances by using prefetches. However, our application is quite large, and
I don't like the idea of tracking down case.

Is there some way for Cayenne to place the relationship objects into the
object cache the first time they are retrieved? We are using EhCache for
our query caching, so if the object cache is not an options, is there a way
to store these relationships in a short lived query cache?

Thanks for the help.

-Frank

-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Re: Tracking down a Runtime Relationship - Cayenne 3.1

2016-03-19 Thread Frank Herrmann
Thanks everyone. We were able to pepper some temporary logging in the code
and figure out the relationship. I appreciate all the quick responses.

-Frank

On Thu, Mar 17, 2016 at 10:12 AM, Michael Gentry <blackn...@gmail.com>
wrote:

> Hi Jurgen,
>
> Maybe you are seeing something different than me?  When I have logging
> turned on, I see things like:
>
> org.apache.cayenne.map.EntityResolver added runtime complimentary
> DbRelationship from s_budget_years to p_line_items
> ...
> org.apache.cayenne.map.EntityResolver added runtime complimentary
> ObjRelationship from BudgetYears to LineItem
>
> It doesn't specify the relationship name, though.
>
> mrg
>
>
> On Thu, Mar 17, 2016 at 9:30 AM, <do...@xsinet.co.za> wrote:
>
> >
> >
> > Hi Frank
> >
> > Cayenne logs the runtime relationships it generates when it loads the
> > model into memory.
> >
> > So if you look in the log which it also sends to System.err and search
> > for "runtimeRelationship725" then you will be able to see which entity
> > it's associated with. At least then he'll have a clue as where to begin
> > looking.
> >
> > Regards
> >
> > Jurgen
> >
> > On 2016-03-17 15:02, Frank Herrmann wrote:
> >
> > > Thanks. I passed this along to the developer. We are using version 3.1.
> > >
> > > On Wed, Mar 16, 2016 at 6:29 PM, Michael Gentry <mgen...@masslight.net
> >
> > > wrote:
> > > Hi Frank, I don't have any handy code to do this at the moment, but the
> > approach I would take is to write a utility method to dump the model's
> > source/destination relationship information immediately after loading the
> > model into memory. Then, when you get the validation exception, you can
> > reference that data dump for assistance. mrg PS. What version of Cayenne?
> > On Wed, Mar 16, 2016 at 3:12 PM, Frank Herrmann <
> > frank.herrm...@modernizingmedicine.com> wrote: Hello all, We have a
> > developer here that recently asked for my help and told him I'd reach
> out.
> > He is getting a validation failure error on a runtime relationship
> > (specifically runtimeRelationship725). As these are created during
> runtime,
> > he is setting a break point in the code at the commit to try and figure
> out
> > what object this runtime relationship is attached to. My question is, is
> > there an easy way to pinpoint what object this relationship is attached
> to,
> > or what relationship it is reversing so he can troubleshoot the
> > validation error? Thanks, -Frank -- FRANK HERRMANN SOFTWARE ENGINEER T:
> 561-880-2998
> > x1563 E: frank.herrm...@modmed.com [image: [ Modernizing Medicine ]] <
> > http://www.modmed.com/ [1]> [image: [ Facebook ]] <
> > http://www.facebook.com/modernizingmedicine [2]> [image: [ LinkedIn ]] <
> > http://www.linkedin.com/company/modernizing-medicine/ [3]> [image: [
> > YouTube ]] <http://www.youtube.com/user/modernizingmedicine [4]> [image:
> > [ Twitter ]] <https://twitter.com/modmed_EMA [5]> [image: [ Blog ]] <
> > http://www.modmed.com/BlogBeyondEMR [6]> [image: [ Instagram ]] <
> > http://instagram.com/modernizing_medicine [7]>
> >
> > --
> > FRANK HERRMANN
> > SOFTWARE ENGINEER
> >
> > T: 561-880-2998 x1563
> >
> > E: frank.herrm...@modmed.com
> >
> > [image: [ Modernizing Medicine ]] <http://www.modmed.com/ [1]>
> > [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine [2]>
> > [image:
> > [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/
> > [3]> [image:
> > [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine [4]>
> > [image: [
> > Twitter ]] <https://twitter.com/modmed_EMA [5]> [image: [ Blog ]]
> > <http://www.modmed.com/BlogBeyondEMR [6]> [image: [ Instagram ]]
> > <http://instagram.com/modernizing_medicine [7]>
> >
> >
> >
> > Links:
> > --
> > [1] http://www.modmed.com/
> > [2] http://www.facebook.com/modernizingmedicine
> > [3] http://www.linkedin.com/company/modernizing-medicine/
> > [4] http://www.youtube.com/user/modernizingmedicine
> > [5] https://twitter.com/modmed_EMA
> > [6] http://www.modmed.com/BlogBeyondEMR
> > [7] http://instagram.com/modernizing_medicine
> >
>



-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Re: Tracking down a Runtime Relationship - Cayenne 3.1

2016-03-19 Thread Frank Herrmann
Thanks. I passed this along to the developer. We are using version 3.1.

On Wed, Mar 16, 2016 at 6:29 PM, Michael Gentry <mgen...@masslight.net>
wrote:

> Hi Frank,
>
> I don't have any handy code to do this at the moment, but the approach I
> would take is to write a utility method to dump the model's
> source/destination relationship information immediately after loading the
> model into memory.  Then, when you get the validation exception, you can
> reference that data dump for assistance.
>
> mrg
>
> PS. What version of Cayenne?
>
>
> On Wed, Mar 16, 2016 at 3:12 PM, Frank Herrmann <
> frank.herrm...@modernizingmedicine.com> wrote:
>
> > Hello all,
> >
> > We have a developer here that recently asked for my help and told him I'd
> > reach out. He is getting a validation failure error on a runtime
> > relationship (specifically runtimeRelationship725). As these are created
> > during runtime, he is setting a break point in the code at the commit to
> > try and figure out what object this runtime relationship is attached to.
> My
> > question is, is there an easy way to pinpoint what object this
> relationship
> > is attached to, or what relationship it is reversing so he can
> troubleshoot
> > the validation error?
> >
> > Thanks,
> >
> > -Frank
> >
> > --
> > FRANK HERRMANN
> > SOFTWARE ENGINEER
> >
> > T: 561-880-2998 x1563
> >
> > E: frank.herrm...@modmed.com
> >
> >
> >
> > [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> > [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
> > [image:
> > [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
> > [image:
> > [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
> > Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> > <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> > <http://instagram.com/modernizing_medicine>
> >
>



-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Tracking down a Runtime Relationship - Cayenne 3.1

2016-03-18 Thread Frank Herrmann
Hello all,

We have a developer here that recently asked for my help and told him I'd
reach out. He is getting a validation failure error on a runtime
relationship (specifically runtimeRelationship725). As these are created
during runtime, he is setting a break point in the code at the commit to
try and figure out what object this runtime relationship is attached to. My
question is, is there an easy way to pinpoint what object this relationship
is attached to, or what relationship it is reversing so he can troubleshoot
the validation error?

Thanks,

-Frank

-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Re: QueryCache @CacheGroups Annotation

2016-02-09 Thread Frank Herrmann
Hi Andrus,

One last question on the @CacheGroups annotation. I'm assuming that the
annotation can be used to flush more than one cache group, if necessary.
What is the proper syntax to use? For instance would it be:
@CacheGroups("group1", "group2") ? Or something similar?

-Frank

On Thu, Feb 4, 2016 at 2:23 PM, Frank Herrmann <
frank.herrm...@modernizingmedicine.com> wrote:

> Thanks for the feedback. I think I prefer to keep everything in the
> module, so I'll try the first solution.
>
> -Frank
>
> On Thu, Feb 4, 2016 at 2:16 PM, Andrus Adamchik <and...@objectstyle.org>
> wrote:
>
>> Ah, you are running into an earlier DI limitation. All DI collection item
>> *types* needed to be bound explicitly in DI before you can add them to
>> collections. E.g.:
>>
>>   // this looks a bit ugly, but ensures that CacheInvalidationFilter
>> singleton
>>   // can be referenced as collection/map element
>>
>> binder.bind(CacheInvalidationFilter.class).to(CacheInvalidationFilter.class);
>>
>>   // now that the type is known in DI, we can add it to the filter list
>>
>> binder.bindList(Constants.SERVER_DOMAIN_FILTERS_LIST).add(CacheInvalidationFilter.class);
>>
>> This limitation is resolved in 4.0.M3 per
>> https://issues.apache.org/jira/browse/CAY-2035 , so the first line is no
>> longer needed.
>>
>> >> CacheInvalidationFilter cacheInvalidationFilter = new
>> >> CacheInvalidationFilter();
>> >> cayenneRuntime.getDataDomain().addFilter(cacheInvalidationFilter);
>>
>> This is also a valid solution.
>>
>> Andrus
>>
>>
>> > On Feb 4, 2016, at 6:23 PM, Frank Herrmann <
>> frank.herrm...@modernizingmedicine.com> wrote:
>> >
>> > Hi Andrus,
>> >
>> > Following the documentation, I tried to add the following to the DI
>> Module:
>> >
>> > public class M2CayenneModule implements Module{
>> >> @Override
>> >> public void configure(Binder binder) {
>> >> binder.bind(DataDomain.class).toProvider(M2DataDomainProvider.class);
>> >> binder.bind(QueryCache.class).to(M2EhCacheQueryCache.class);
>> >>
>> >>
>> binder.bindList(Constants.SERVER_DOMAIN_FILTERS_LIST).add(CacheInvalidationFilter.class);
>> >> }
>> >> }
>> >
>> >
>> > However, the following error is generated,
>> >
>> > DI container has no binding for key > > org.apache.cayenne.lifecycle.cache.CacheInvalidationFilter>
>> >
>> > It does seem to work if I use this method, after the runtime is created:
>> >
>> >>
>> >> CacheInvalidationFilter cacheInvalidationFilter = new
>> >> CacheInvalidationFilter();
>> >> cayenneRuntime.getDataDomain().addFilter(cacheInvalidationFilter);
>> >
>> >
>> > Is implementing the CacheInvalidationFilter via DI not available in
>> Cayenne
>> > 3.1?
>> >
>> > Thanks again,
>> >
>> > -Frank
>> >
>> > On Thu, Feb 4, 2016 at 9:41 AM, Frank Herrmann <
>> > frank.herrm...@modernizingmedicine.com> wrote:
>> >
>> >> Thanks again for all the help.
>> >>
>> >> -Frank
>> >>
>> >> On Thu, Feb 4, 2016 at 2:22 AM, Andrus Adamchik <
>> and...@objectstyle.org>
>> >> wrote:
>> >>
>> >>>
>> >>>
>> >>>
>> >>>> On Feb 4, 2016, at 9:33 AM, Andrus Adamchik <and...@objectstyle.org>
>> >>> wrote:
>> >>>>
>> >>>> (Hmm, why don't I copy the above to our docs :))
>> >>>
>> >>> Here it is for 4.0:
>> >>>
>> >>>
>> >>>
>> https://github.com/apache/cayenne/commit/5d3e141a9635dc28ce358d048840e74b76b2b0fd
>> >>>
>> >>> We'll publish it on the site in a few days hopefully..
>> >>>
>> >>> Andrus
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >> FRANK HERRMANN
>> >> SOFTWARE ENGINEER
>> >>
>> >> T: 561-880-2998 x1563
>> >>
>> >> E: frank.herrm...@modmed.com
>> >>
>> >>
>> >>
>> >> [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
>> >> [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
>> [image:
>> >> [ LinkedIn ]] <http://www.linke

Re: QueryCache @CacheGroups Annotation

2016-02-04 Thread Frank Herrmann
Thanks again for all the help.

-Frank

On Thu, Feb 4, 2016 at 2:22 AM, Andrus Adamchik <and...@objectstyle.org>
wrote:

>
>
>
> > On Feb 4, 2016, at 9:33 AM, Andrus Adamchik <and...@objectstyle.org>
> wrote:
> >
> > (Hmm, why don't I copy the above to our docs :))
>
> Here it is for 4.0:
>
>
> https://github.com/apache/cayenne/commit/5d3e141a9635dc28ce358d048840e74b76b2b0fd
>
> We'll publish it on the site in a few days hopefully..
>
> Andrus




-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Re: QueryCache @CacheGroups Annotation

2016-02-04 Thread Frank Herrmann
Thanks for the feedback. I think I prefer to keep everything in the module,
so I'll try the first solution.

-Frank

On Thu, Feb 4, 2016 at 2:16 PM, Andrus Adamchik <and...@objectstyle.org>
wrote:

> Ah, you are running into an earlier DI limitation. All DI collection item
> *types* needed to be bound explicitly in DI before you can add them to
> collections. E.g.:
>
>   // this looks a bit ugly, but ensures that CacheInvalidationFilter
> singleton
>   // can be referenced as collection/map element
>
> binder.bind(CacheInvalidationFilter.class).to(CacheInvalidationFilter.class);
>
>   // now that the type is known in DI, we can add it to the filter list
>
> binder.bindList(Constants.SERVER_DOMAIN_FILTERS_LIST).add(CacheInvalidationFilter.class);
>
> This limitation is resolved in 4.0.M3 per
> https://issues.apache.org/jira/browse/CAY-2035 , so the first line is no
> longer needed.
>
> >> CacheInvalidationFilter cacheInvalidationFilter = new
> >> CacheInvalidationFilter();
> >> cayenneRuntime.getDataDomain().addFilter(cacheInvalidationFilter);
>
> This is also a valid solution.
>
> Andrus
>
>
> > On Feb 4, 2016, at 6:23 PM, Frank Herrmann <
> frank.herrm...@modernizingmedicine.com> wrote:
> >
> > Hi Andrus,
> >
> > Following the documentation, I tried to add the following to the DI
> Module:
> >
> > public class M2CayenneModule implements Module{
> >> @Override
> >> public void configure(Binder binder) {
> >> binder.bind(DataDomain.class).toProvider(M2DataDomainProvider.class);
> >> binder.bind(QueryCache.class).to(M2EhCacheQueryCache.class);
> >>
> >>
> binder.bindList(Constants.SERVER_DOMAIN_FILTERS_LIST).add(CacheInvalidationFilter.class);
> >> }
> >> }
> >
> >
> > However, the following error is generated,
> >
> > DI container has no binding for key  > org.apache.cayenne.lifecycle.cache.CacheInvalidationFilter>
> >
> > It does seem to work if I use this method, after the runtime is created:
> >
> >>
> >> CacheInvalidationFilter cacheInvalidationFilter = new
> >> CacheInvalidationFilter();
> >> cayenneRuntime.getDataDomain().addFilter(cacheInvalidationFilter);
> >
> >
> > Is implementing the CacheInvalidationFilter via DI not available in
> Cayenne
> > 3.1?
> >
> > Thanks again,
> >
> > -Frank
> >
> > On Thu, Feb 4, 2016 at 9:41 AM, Frank Herrmann <
> > frank.herrm...@modernizingmedicine.com> wrote:
> >
> >> Thanks again for all the help.
> >>
> >> -Frank
> >>
> >> On Thu, Feb 4, 2016 at 2:22 AM, Andrus Adamchik <and...@objectstyle.org
> >
> >> wrote:
> >>
> >>>
> >>>
> >>>
> >>>> On Feb 4, 2016, at 9:33 AM, Andrus Adamchik <and...@objectstyle.org>
> >>> wrote:
> >>>>
> >>>> (Hmm, why don't I copy the above to our docs :))
> >>>
> >>> Here it is for 4.0:
> >>>
> >>>
> >>>
> https://github.com/apache/cayenne/commit/5d3e141a9635dc28ce358d048840e74b76b2b0fd
> >>>
> >>> We'll publish it on the site in a few days hopefully..
> >>>
> >>> Andrus
> >>
> >>
> >>
> >>
> >> --
> >> FRANK HERRMANN
> >> SOFTWARE ENGINEER
> >>
> >> T: 561-880-2998 x1563
> >>
> >> E: frank.herrm...@modmed.com
> >>
> >>
> >>
> >> [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> >> [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
> [image:
> >> [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
> [image:
> >> [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image:
> [
> >> Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> >> <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> >> <http://instagram.com/modernizing_medicine>
> >>
> >>
> >
> >
> > --
> > FRANK HERRMANN
> > SOFTWARE ENGINEER
> >
> > T: 561-880-2998 x1563
> >
> > E: frank.herrm...@modmed.com
> >
> >
> >
> > [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> > [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
> [image:
> > [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
> [image:
> > [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
> > Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> > <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> > <http://instagram.com/modernizing_medicine>
>
>


-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Re: QueryCache @CacheGroups Annotation

2016-02-04 Thread Frank Herrmann
Hi Andrus,

Following the documentation, I tried to add the following to the DI Module:

public class M2CayenneModule implements Module{
> @Override
> public void configure(Binder binder) {
> binder.bind(DataDomain.class).toProvider(M2DataDomainProvider.class);
> binder.bind(QueryCache.class).to(M2EhCacheQueryCache.class);
>
> binder.bindList(Constants.SERVER_DOMAIN_FILTERS_LIST).add(CacheInvalidationFilter.class);
> }
> }


However, the following error is generated,

DI container has no binding for key 

It does seem to work if I use this method, after the runtime is created:

>
> CacheInvalidationFilter cacheInvalidationFilter = new
> CacheInvalidationFilter();
> cayenneRuntime.getDataDomain().addFilter(cacheInvalidationFilter);


Is implementing the CacheInvalidationFilter via DI not available in Cayenne
3.1?

Thanks again,

-Frank

On Thu, Feb 4, 2016 at 9:41 AM, Frank Herrmann <
frank.herrm...@modernizingmedicine.com> wrote:

> Thanks again for all the help.
>
> -Frank
>
> On Thu, Feb 4, 2016 at 2:22 AM, Andrus Adamchik <and...@objectstyle.org>
> wrote:
>
>>
>>
>>
>> > On Feb 4, 2016, at 9:33 AM, Andrus Adamchik <and...@objectstyle.org>
>> wrote:
>> >
>> > (Hmm, why don't I copy the above to our docs :))
>>
>> Here it is for 4.0:
>>
>>
>> https://github.com/apache/cayenne/commit/5d3e141a9635dc28ce358d048840e74b76b2b0fd
>>
>> We'll publish it on the site in a few days hopefully..
>>
>> Andrus
>
>
>
>
> --
> FRANK HERRMANN
> SOFTWARE ENGINEER
>
> T: 561-880-2998 x1563
>
> E: frank.herrm...@modmed.com
>
>
>
> [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
> [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
> [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
> Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> <http://instagram.com/modernizing_medicine>
>
>


-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Re: QueryCache @CacheGroups Annotation

2016-02-03 Thread Frank Herrmann
I think I'm beginning to understand. The annotation, along with the
CacheInvalidationFilter, is to flush a particular cache group when changes
are committed to the annotated object.

Is there some documentation for 3.1 or 4.0 for these annotations and query
caching? The latest I can find is the 3.0 documentation.

Thanks again,
-Frank

On Wed, Feb 3, 2016 at 3:57 PM, Frank Herrmann <
frank.herrm...@modernizingmedicine.com> wrote:

> Is the annotation used for the Object Cache then and not the Query Cache?
>
> On Wed, Feb 3, 2016 at 3:10 PM, Frank Herrmann <
> frank.herrm...@modernizingmedicine.com> wrote:
>
>> So, is the CacheGroups annotation used by the query cache at all? If I
>> have to set the cache group via code, then what purpose does the annotation
>> serve?
>>
>> Thanks for the clarification.
>>
>> -Frank
>>
>> On Wed, Feb 3, 2016 at 3:08 PM, Andrus Adamchik <and...@objectstyle.org>
>> wrote:
>>
>>> Ah, I think this is relevant:
>>>
>>> >>>>> If I specify the cache group in the code, i.e.
>>> >>>>> query.setCacheGroups(), everything works fine, and the cache group
>>> is
>>> >>>>> utilized.
>>>
>>> This is needed. This is how Cayenne knows which cache group a query is
>>> associated with.
>>>
>>> Andrus
>>>
>>>
>>>
>>>
>>> > On Feb 3, 2016, at 11:04 PM, Frank Herrmann <
>>> frank.herrm...@modernizingmedicine.com> wrote:
>>> >
>>> > Sure. It takes a few hops to get there but here it is.
>>> >
>>> > The actual search is done in our CayenneGenericDao class. The type
>>> > parameter in this method is the StatusFirm class.
>>> >
>>> > public  List find(Class type, SearchContext searchContext)
>>> >> {
>>> >> DataContext dataContext = getObjectContext();
>>> >> if
>>> (FlushMode.ALWAYS.equals(DataContextUtils.getFlushMode(dataContext)) ||
>>> >> FlushMode.AUTO.equals(DataContextUtils.getFlushMode(dataContext)))
>>> >> flush();
>>> >> Query query = getQuery(type, searchContext);
>>> >> if (!validateContext(searchContext, query))
>>> >> return new ArrayList(0);
>>> >>
>>> >> if(type != null)
>>> >> flushIfNecessary(type, dataContext);
>>> >> List results = null;
>>> >> if(query instanceof SelectQuery)
>>> >> results = (List) doFind((SelectQuery)query, searchContext);
>>> >>
>>> >> else if(query instanceof SQLTemplate)
>>> >> results = (List) doFind((SQLTemplate)query, searchContext, type ==
>>> >> null);
>>> >> else
>>> >> throw new IllegalArgumentException("Query type not supported " +
>>> >> query.getClass());
>>> >>
>>> >> if(type != null && Persistent.class.isAssignableFrom(type))
>>> >> CayenneObjectUtils.addFreshLoaded(dataContext, (List>> >> Persistent>)results);
>>> >> return results;
>>> >> }
>>> >
>>> >
>>> > Here is the getQuery method. At the point where
>>> query.setCacheStrategy() is
>>> > call, the strategy is "CACHE", and it is being cached, just to the
>>> default
>>> > cache group.
>>> >
>>> > private Query getQuery(Class type, SearchContext searchContext)
>>> >> {
>>> >> if (searchContext == null)
>>> >> return new SelectQuery(type);
>>> >>
>>> >> Object path = searchContext.getPath();
>>> >> Map<String, ?> params = searchContext.getParameters();
>>> >> if (params == null)
>>> >> params = Collections.emptyMap();
>>> >> if (path != null)
>>> >> {
>>> >> Query query = resolveQuery(path);
>>> >> if(query instanceof ParameterizedQuery)
>>> >> {
>>> >> query = ((ParameterizedQuery)query).createQuery(params);
>>> >> }
>>> >> return query;
>>> >> }
>>> >> SelectQuery query = new SelectQuery(type);
>>> >> Object oCriteria = searchContext.getCriteria();
>>> >> if (oCriteria instanceof List)
>>> >> {
>>> >> List criteria = (List) searchContext.getCriteria();
>>> >> query.andQualifier(buildQualifiers(criteria, params));
>&g

Re: QueryCache @CacheGroups Annotation

2016-02-03 Thread Frank Herrmann
Is the annotation used for the Object Cache then and not the Query Cache?

On Wed, Feb 3, 2016 at 3:10 PM, Frank Herrmann <
frank.herrm...@modernizingmedicine.com> wrote:

> So, is the CacheGroups annotation used by the query cache at all? If I
> have to set the cache group via code, then what purpose does the annotation
> serve?
>
> Thanks for the clarification.
>
> -Frank
>
> On Wed, Feb 3, 2016 at 3:08 PM, Andrus Adamchik <and...@objectstyle.org>
> wrote:
>
>> Ah, I think this is relevant:
>>
>> >>>>> If I specify the cache group in the code, i.e.
>> >>>>> query.setCacheGroups(), everything works fine, and the cache group
>> is
>> >>>>> utilized.
>>
>> This is needed. This is how Cayenne knows which cache group a query is
>> associated with.
>>
>> Andrus
>>
>>
>>
>>
>> > On Feb 3, 2016, at 11:04 PM, Frank Herrmann <
>> frank.herrm...@modernizingmedicine.com> wrote:
>> >
>> > Sure. It takes a few hops to get there but here it is.
>> >
>> > The actual search is done in our CayenneGenericDao class. The type
>> > parameter in this method is the StatusFirm class.
>> >
>> > public  List find(Class type, SearchContext searchContext)
>> >> {
>> >> DataContext dataContext = getObjectContext();
>> >> if
>> (FlushMode.ALWAYS.equals(DataContextUtils.getFlushMode(dataContext)) ||
>> >> FlushMode.AUTO.equals(DataContextUtils.getFlushMode(dataContext)))
>> >> flush();
>> >> Query query = getQuery(type, searchContext);
>> >> if (!validateContext(searchContext, query))
>> >> return new ArrayList(0);
>> >>
>> >> if(type != null)
>> >> flushIfNecessary(type, dataContext);
>> >> List results = null;
>> >> if(query instanceof SelectQuery)
>> >> results = (List) doFind((SelectQuery)query, searchContext);
>> >>
>> >> else if(query instanceof SQLTemplate)
>> >> results = (List) doFind((SQLTemplate)query, searchContext, type ==
>> >> null);
>> >> else
>> >> throw new IllegalArgumentException("Query type not supported " +
>> >> query.getClass());
>> >>
>> >> if(type != null && Persistent.class.isAssignableFrom(type))
>> >> CayenneObjectUtils.addFreshLoaded(dataContext, (List> >> Persistent>)results);
>> >> return results;
>> >> }
>> >
>> >
>> > Here is the getQuery method. At the point where
>> query.setCacheStrategy() is
>> > call, the strategy is "CACHE", and it is being cached, just to the
>> default
>> > cache group.
>> >
>> > private Query getQuery(Class type, SearchContext searchContext)
>> >> {
>> >> if (searchContext == null)
>> >> return new SelectQuery(type);
>> >>
>> >> Object path = searchContext.getPath();
>> >> Map<String, ?> params = searchContext.getParameters();
>> >> if (params == null)
>> >> params = Collections.emptyMap();
>> >> if (path != null)
>> >> {
>> >> Query query = resolveQuery(path);
>> >> if(query instanceof ParameterizedQuery)
>> >> {
>> >> query = ((ParameterizedQuery)query).createQuery(params);
>> >> }
>> >> return query;
>> >> }
>> >> SelectQuery query = new SelectQuery(type);
>> >> Object oCriteria = searchContext.getCriteria();
>> >> if (oCriteria instanceof List)
>> >> {
>> >> List criteria = (List) searchContext.getCriteria();
>> >> query.andQualifier(buildQualifiers(criteria, params));
>> >> }
>> >> else if (oCriteria instanceof Expression)
>> >> {
>> >> query.andQualifier((Expression) oCriteria);
>> >> }
>> >> else if (oCriteria instanceof Criterion)
>> >> {
>> >> query.andQualifier(cayenneCriteriaAdaptor.adapt((Criterion) oCriteria,
>> >> params));
>> >> }
>> >> else if (oCriteria != null)
>> >> throw new IllegalArgumentException("Criteria type not supported " +
>> >> oCriteria.getClass().getName());
>> >> if (searchContext.getCacheStrategy() != null) {
>> >>
>> >>
>> query.setCacheStrategy(cacheStrategies.get(searchContext.getCacheStrategy()));
>> >> }
>> >> return query;
>> >> }

Re: Using jconsole to monitor Ehcache

2016-02-03 Thread Frank Herrmann
Connecting jconsole to the Tomcat instance wasn't my issue. The
net.sf.ehcache wasn't getting reported to mbeans so I could see how the
cache was being utilized.

I figured it out, however. In my case, we have a Spring environment. I had
to start Ehcache with Spring, then extend EhCacheQueryCache to use the
Spring started Ehcache instance.

Thanks for the reply.

-Frank

On Tue, Feb 2, 2016 at 4:34 PM, Aristedes Maniatis <a...@maniatis.org> wrote:

> On 3/02/2016 5:42am, Frank Herrmann wrote:
> > Hello all,
> >
> > I'm working on switching our query caching to Ehcache. Does anyone know
> how
> > to monitor Ehcache injected into Cayenne via EhCacheQueryCache in
> jconsole?
> >
> > In case it matters, I'm using Cayenne 3.1.
>
>
> I don't think Cayenne factors into this at all. We just add these
> parameters to the command line (starting up tomcat in my case):
>
> -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=7401
> -Dcom.sun.management.jmxremote.ssl=false
> -Dcom.sun.management.jmxremote.authenticate=false
>
>
> I turn off SSL and password because this is just for an internal network,
> but you can adjust those as you need to.
>
>
> Ari
>
>
> --
> ------>
> Aristedes Maniatis
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>



-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Re: QueryCache @CacheGroups Annotation

2016-02-03 Thread Frank Herrmann
Sure. It takes a few hops to get there but here it is.

The actual search is done in our CayenneGenericDao class. The type
parameter in this method is the StatusFirm class.

public  List find(Class type, SearchContext searchContext)
> {
> DataContext dataContext = getObjectContext();
> if (FlushMode.ALWAYS.equals(DataContextUtils.getFlushMode(dataContext)) ||
> FlushMode.AUTO.equals(DataContextUtils.getFlushMode(dataContext)))
> flush();
> Query query = getQuery(type, searchContext);
> if (!validateContext(searchContext, query))
> return new ArrayList(0);
>
> if(type != null)
> flushIfNecessary(type, dataContext);
> List results = null;
> if(query instanceof SelectQuery)
> results = (List) doFind((SelectQuery)query, searchContext);
>
> else if(query instanceof SQLTemplate)
> results = (List) doFind((SQLTemplate)query, searchContext, type ==
> null);
> else
> throw new IllegalArgumentException("Query type not supported " +
> query.getClass());
>
> if(type != null && Persistent.class.isAssignableFrom(type))
> CayenneObjectUtils.addFreshLoaded(dataContext, (List Persistent>)results);
> return results;
> }


Here is the getQuery method. At the point where query.setCacheStrategy() is
call, the strategy is "CACHE", and it is being cached, just to the default
cache group.

private Query getQuery(Class type, SearchContext searchContext)
> {
> if (searchContext == null)
> return new SelectQuery(type);
>
> Object path = searchContext.getPath();
> Map<String, ?> params = searchContext.getParameters();
> if (params == null)
> params = Collections.emptyMap();
> if (path != null)
> {
> Query query = resolveQuery(path);
> if(query instanceof ParameterizedQuery)
> {
> query = ((ParameterizedQuery)query).createQuery(params);
> }
> return query;
> }
> SelectQuery query = new SelectQuery(type);
> Object oCriteria = searchContext.getCriteria();
> if (oCriteria instanceof List)
> {
> List criteria = (List) searchContext.getCriteria();
> query.andQualifier(buildQualifiers(criteria, params));
> }
> else if (oCriteria instanceof Expression)
> {
> query.andQualifier((Expression) oCriteria);
> }
> else if (oCriteria instanceof Criterion)
> {
> query.andQualifier(cayenneCriteriaAdaptor.adapt((Criterion) oCriteria,
> params));
> }
> else if (oCriteria != null)
> throw new IllegalArgumentException("Criteria type not supported " +
> oCriteria.getClass().getName());
> if (searchContext.getCacheStrategy() != null) {
>
> query.setCacheStrategy(cacheStrategies.get(searchContext.getCacheStrategy()));
> }
> return query;
> }



Thanks Andrus.

On Wed, Feb 3, 2016 at 2:14 PM, Andrus Adamchik <and...@objectstyle.org>
wrote:

> Do you have an example of SelectQuery fetching StatusFirms?
>
> Andrus
>
> > On Feb 3, 2016, at 10:12 PM, Frank Herrmann <
> frank.herrm...@modernizingmedicine.com> wrote:
> >
> > Hi Andrus,
> >
> > Thanks for the quick reply. However, adding the filter didn't seem to
> work.
> > Below is my addition of the filter to our runtime.
> >
> > public synchronized static void initialize(String cayenneConfig)
> >> {
> >> if(cayenneRuntime != null) {
> >> return;
> >> }
> >>
> >> if(logger.isInfoEnabled()) {
> >> logger.info("Loading cayenne domain config from " + cayenneConfig);
> >> }
> >>
> >> Module module = new M2CayenneModule();
> >> cayenneRuntime = new ServerRuntime(cayenneConfig, module);
> >>
> >> CacheInvalidationFilter cacheInvalidationFilter = new
> >> CacheInvalidationFilter();
> >> cayenneRuntime.getDataDomain().addFilter(cacheInvalidationFilter);
> >
> >
> > Here is the annotation on an object:
> >
> > @CacheGroups("minimal_cache")
> >> public class StatusFirm extends _StatusFirm implements
> >> com.m2.domain.StatusFirm {
> >> }
> >
> >
> > However, when this object is returned during a find, it uses the default
> > cache group. Like I said, however, if I specify the cache group in the
> > code, it works. So I know ehcache is being used and is configured
> > correctly.
> >
> > Thanks again for the help.
> >
> > -Frank
> >
> >
> >
> > On Wed, Feb 3, 2016 at 1:12 PM, Andrus Adamchik <and...@objectstyle.org>
> > wrote:
> >
> >> Hi Frank,
> >>
> >> For the annotation to get processed, you will need to add
> >> CacheInvalidationFilter to your ServerRuntime. Here is an example:
> >>
> >>
> >>
> https://github.com/and

Re: QueryCache @CacheGroups Annotation

2016-02-03 Thread Frank Herrmann
So, is the CacheGroups annotation used by the query cache at all? If I have
to set the cache group via code, then what purpose does the annotation
serve?

Thanks for the clarification.

-Frank

On Wed, Feb 3, 2016 at 3:08 PM, Andrus Adamchik <and...@objectstyle.org>
wrote:

> Ah, I think this is relevant:
>
> >>>>> If I specify the cache group in the code, i.e.
> >>>>> query.setCacheGroups(), everything works fine, and the cache group is
> >>>>> utilized.
>
> This is needed. This is how Cayenne knows which cache group a query is
> associated with.
>
> Andrus
>
>
>
>
> > On Feb 3, 2016, at 11:04 PM, Frank Herrmann <
> frank.herrm...@modernizingmedicine.com> wrote:
> >
> > Sure. It takes a few hops to get there but here it is.
> >
> > The actual search is done in our CayenneGenericDao class. The type
> > parameter in this method is the StatusFirm class.
> >
> > public  List find(Class type, SearchContext searchContext)
> >> {
> >> DataContext dataContext = getObjectContext();
> >> if (FlushMode.ALWAYS.equals(DataContextUtils.getFlushMode(dataContext))
> ||
> >> FlushMode.AUTO.equals(DataContextUtils.getFlushMode(dataContext)))
> >> flush();
> >> Query query = getQuery(type, searchContext);
> >> if (!validateContext(searchContext, query))
> >> return new ArrayList(0);
> >>
> >> if(type != null)
> >> flushIfNecessary(type, dataContext);
> >> List results = null;
> >> if(query instanceof SelectQuery)
> >> results = (List) doFind((SelectQuery)query, searchContext);
> >>
> >> else if(query instanceof SQLTemplate)
> >> results = (List) doFind((SQLTemplate)query, searchContext, type ==
> >> null);
> >> else
> >> throw new IllegalArgumentException("Query type not supported " +
> >> query.getClass());
> >>
> >> if(type != null && Persistent.class.isAssignableFrom(type))
> >> CayenneObjectUtils.addFreshLoaded(dataContext, (List >> Persistent>)results);
> >> return results;
> >> }
> >
> >
> > Here is the getQuery method. At the point where query.setCacheStrategy()
> is
> > call, the strategy is "CACHE", and it is being cached, just to the
> default
> > cache group.
> >
> > private Query getQuery(Class type, SearchContext searchContext)
> >> {
> >> if (searchContext == null)
> >> return new SelectQuery(type);
> >>
> >> Object path = searchContext.getPath();
> >> Map<String, ?> params = searchContext.getParameters();
> >> if (params == null)
> >> params = Collections.emptyMap();
> >> if (path != null)
> >> {
> >> Query query = resolveQuery(path);
> >> if(query instanceof ParameterizedQuery)
> >> {
> >> query = ((ParameterizedQuery)query).createQuery(params);
> >> }
> >> return query;
> >> }
> >> SelectQuery query = new SelectQuery(type);
> >> Object oCriteria = searchContext.getCriteria();
> >> if (oCriteria instanceof List)
> >> {
> >> List criteria = (List) searchContext.getCriteria();
> >> query.andQualifier(buildQualifiers(criteria, params));
> >> }
> >> else if (oCriteria instanceof Expression)
> >> {
> >> query.andQualifier((Expression) oCriteria);
> >> }
> >> else if (oCriteria instanceof Criterion)
> >> {
> >> query.andQualifier(cayenneCriteriaAdaptor.adapt((Criterion) oCriteria,
> >> params));
> >> }
> >> else if (oCriteria != null)
> >> throw new IllegalArgumentException("Criteria type not supported " +
> >> oCriteria.getClass().getName());
> >> if (searchContext.getCacheStrategy() != null) {
> >>
> >>
> query.setCacheStrategy(cacheStrategies.get(searchContext.getCacheStrategy()));
> >> }
> >> return query;
> >> }
> >
> >
> >
> > Thanks Andrus.
> >
> > On Wed, Feb 3, 2016 at 2:14 PM, Andrus Adamchik <and...@objectstyle.org>
> > wrote:
> >
> >> Do you have an example of SelectQuery fetching StatusFirms?
> >>
> >> Andrus
> >>
> >>> On Feb 3, 2016, at 10:12 PM, Frank Herrmann <
> >> frank.herrm...@modernizingmedicine.com> wrote:
> >>>
> >>> Hi Andrus,
> >>>
> >>> Thanks for the quick reply. However, adding the filter didn't seem to
> >> work.
> >>> Below is my addition of

Using jconsole to monitor Ehcache

2016-02-02 Thread Frank Herrmann
Hello all,

I'm working on switching our query caching to Ehcache. Does anyone know how
to monitor Ehcache injected into Cayenne via EhCacheQueryCache in jconsole?

In case it matters, I'm using Cayenne 3.1.

Thanks for the help.

-Frank

-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrm...@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>


Re: Cayenne 3.1 - Error using cgen ant task

2016-01-26 Thread Frank Herrmann
Thanks. It is working now.

-Frank

On Tue, Jan 26, 2016 at 1:28 PM, Andrus Adamchik <and...@objectstyle.org>
wrote:

> Yep. Looks like cayenne-project-3.1.jar is missing in Frank's taskdef
> classpath. It can be downloaded from here:
>
>
> http://search.maven.org/#artifactdetails|org.apache.cayenne|cayenne-project|3.1|jar
>
> http://search.maven.org/remotecontent?filepath=org/apache/cayenne/cayenne-project/3.1/cayenne-project-3.1.jar
>
> And we probably need to add it to the downloadable distro (as many of us
> are Maven users and are getting dependencies "for free", I guess this went
> unnoticed).
>
> Andrus
>
> > On Jan 26, 2016, at 9:15 PM, Mike Kienenberger <mkien...@gmail.com>
> wrote:
> >
> > It's probably a classpath issue with your taskdef.
> >
> > For instance, this is what mine looks like:
> >
> >
> >
> >
> > > ="${lib-build.dir}/cayenne-project-3.1B3-SNAPSHOT.jar"/>
> >
> > > ="${lib.dir}/cayenne-server-3.1B3-SNAPSHOT-patched.jar"/>
> >
> >
> >    
> >
> >
> >
> >
> >
> > > classname="org.apache.cayenne.tools.CayenneGeneratorTask">
> >
> >
> >
> >
> >
> > On Tue, Jan 26, 2016 at 1:03 PM, Frank Herrmann
> > <frank.herrm...@modernizingmedicine.com> wrote:
> >> I'm experimenting with using the cgen ant task to generate our objects.
> >> However, it is producing this error. Is this a known bug, or am I doing
> >> something wrong?
> >>
> >> Thanks for the help.
> >>
> >> -Frank
> >>
> >> Cayenne Version: 3.1
> >>
> >> Ant target:
> >>
> >> 
> >>>  >>>destDir=""
> >>>makepairs="true"
> >>>template="scripts/cayenne-template-subclass.vm"
> >>>supertemplate="scripts/cayenne-template-superclass.vm"
> >>>superpkg="src/com/m2/data/auto">
> >>> 
> >>> 
> >>
> >>
> >> Error produced:
> >>
> >> frank-herrmann-mbp:ema frank.herrmann$ ant generate-cayenne-objects
> >>> Buildfile: /Users/frank.herrmann/git/ema/build.xml
> >>> generate-cayenne-objects:
> >>> [cgen] Generating class file:
> >>> /Users/frank.herrmann/git/ema/com/m2/data/AsyncJob.java
> >>> [cgen] Generating superclass file:
> >>> /Users/frank.herrmann/git/ema/src/com/m2/data/auto/_AuditEventLog.java
> >>> BUILD FAILED
> >>> /Users/frank.herrmann/git/ema/build.xml:2648:
> >>> org.apache.velocity.exception.MethodInvocationException: Invocation of
> >>> method 'formatVariableName' in  class
> org.apache.cayenne.gen.StringUtils
> >>> threw exception class java.lang.NoClassDefFoundError :
> >>> org/apache/cayenne/project/validation/NameValidationHelper
> >>> at
> >>>
> org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:309)
> >>> at
> >>>
> org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:207)
> >>> at
> >>>
> org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:250)
> >>> at
> >>>
> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:94)
> >>> at
> >>>
> org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:109)
> >>> at
> >>>
> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:94)
> >>> at
> org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:344)
> >>> at
> >>>
> org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:153)
> >>> at
> >>>
> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:271)
> >>> at org.apache.velocity.Template.merge(Template.java:296)
> >>> at
> >>>
> org.apache.cayenne.gen.ClassGenerationAction.execute(ClassGenerationAction.java:239)
> >>> at
> >>>
> org.apache.cayenne.gen.ClassGenerationAction.execute(ClassGenerationAction.java:211)
> >>> at
> >>>
> org.apache.cayenne.tools.CayenneGeneratorTask.execute(CayenneGeneratorTask.java:130)
> >>> at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
> >>> at sun.reflect.Gene