You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Demetrios Kyriakis <de...@gmail.com> on 2008/10/07 18:59:06 UTC

Any other ROP examples?

Are there any ROP based projects that could be used as example?
I mean some non-trivial examples (not like those from the SVN)

Thank you,

Demetrios.


Re: Any other ROP examples?

Posted by Tarik <ch...@gmail.com>.
Hi Andrus,

Yes I did see that from the jira emails.  I will pick it up and apply it 
as a patch to my cayenne jar.  Thanks very much.

Tarik

On Fri, 10 Oct 2008 4:30 am, Andrus Adamchik wrote:
> BTW, this was fixed on trunk by Andrey yesterday.
>
> Andrus
>
>
> On Oct 9, 2008, at 11:36 AM, Andrus Adamchik wrote:
>
>> Hi Tarik,
>>
>> We have a Jira to fix that... Hopefully we'll get to it rather  sooner 
>> than later.
>>
>> https://issues.apache.org/cayenne/browse/CAY-1103
>>
>> Andrus
>>
>> On Oct 8, 2008, at 7:16 PM, Tarik wrote:
>>
>>> Hey Ari,
>>>
>>> I have a question for you. Have you found any ways to go around the  
>>> fact that context.rollBackChanges() does not work in ROP?  I'm  
>>> building an app and need to fix this.
>>>
>>> The class in charge of rolling back the changes on the client side  
>>> is just a stub that does nothing.
>>>
>>> Tarik
>>>
>>> On Tue, 7 Oct 2008 7:07 pm, Aristedes Maniatis wrote:
>>>>
>>>> On 08/10/2008, at 3:59 AM, Demetrios Kyriakis wrote:
>>>>
>>>>> Are there any ROP based projects that could be used as example?
>>>>> I mean some non-trivial examples (not like those from the SVN)
>>>>
>>>> I have a non-trivial ROP client/server desktop application. But   
>>>> unfortunately the source is not available at this time. I'd be  
>>>> happy  to answer specific questions you might have. Cayenne 3,  
>>>> Jetty 6,  Hessian.
>>>>
>>>> Are you building a web app or a desktop application?
>>>>
>>>> Ari Maniatis
>>>>
>>>>
>>>>
>>>> -------------------------->
>>>> ish
>>>> http://www.ish.com.au
>>>> Level 1, 30 Wilson Street Newtown 2042 Australia
>>>> phone +61 2 9550 5001   fax +61 2 9550 4001
>>>> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>>>
>>
>>

Re: Any other ROP examples?

Posted by Andrus Adamchik <an...@objectstyle.org>.
BTW, this was fixed on trunk by Andrey yesterday.

Andrus


On Oct 9, 2008, at 11:36 AM, Andrus Adamchik wrote:

> Hi Tarik,
>
> We have a Jira to fix that... Hopefully we'll get to it rather  
> sooner than later.
>
> https://issues.apache.org/cayenne/browse/CAY-1103
>
> Andrus
>
> On Oct 8, 2008, at 7:16 PM, Tarik wrote:
>
>> Hey Ari,
>>
>> I have a question for you. Have you found any ways to go around the  
>> fact that context.rollBackChanges() does not work in ROP?  I'm  
>> building an app and need to fix this.
>>
>> The class in charge of rolling back the changes on the client side  
>> is just a stub that does nothing.
>>
>> Tarik
>>
>> On Tue, 7 Oct 2008 7:07 pm, Aristedes Maniatis wrote:
>>>
>>> On 08/10/2008, at 3:59 AM, Demetrios Kyriakis wrote:
>>>
>>>> Are there any ROP based projects that could be used as example?
>>>> I mean some non-trivial examples (not like those from the SVN)
>>>
>>> I have a non-trivial ROP client/server desktop application. But   
>>> unfortunately the source is not available at this time. I'd be  
>>> happy  to answer specific questions you might have. Cayenne 3,  
>>> Jetty 6,  Hessian.
>>>
>>> Are you building a web app or a desktop application?
>>>
>>> Ari Maniatis
>>>
>>>
>>>
>>> -------------------------->
>>> ish
>>> http://www.ish.com.au
>>> Level 1, 30 Wilson Street Newtown 2042 Australia
>>> phone +61 2 9550 5001   fax +61 2 9550 4001
>>> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>>
>
>


Re: Any other ROP examples?

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

We have a Jira to fix that... Hopefully we'll get to it rather sooner  
than later.

https://issues.apache.org/cayenne/browse/CAY-1103

Andrus

On Oct 8, 2008, at 7:16 PM, Tarik wrote:

> Hey Ari,
>
> I have a question for you. Have you found any ways to go around the  
> fact that context.rollBackChanges() does not work in ROP?  I'm  
> building an app and need to fix this.
>
> The class in charge of rolling back the changes on the client side  
> is just a stub that does nothing.
>
> Tarik
>
> On Tue, 7 Oct 2008 7:07 pm, Aristedes Maniatis wrote:
>>
>> On 08/10/2008, at 3:59 AM, Demetrios Kyriakis wrote:
>>
>>> Are there any ROP based projects that could be used as example?
>>> I mean some non-trivial examples (not like those from the SVN)
>>
>> I have a non-trivial ROP client/server desktop application. But   
>> unfortunately the source is not available at this time. I'd be  
>> happy  to answer specific questions you might have. Cayenne 3,  
>> Jetty 6,  Hessian.
>>
>> Are you building a web app or a desktop application?
>>
>> Ari Maniatis
>>
>>
>>
>> -------------------------->
>> ish
>> http://www.ish.com.au
>> Level 1, 30 Wilson Street Newtown 2042 Australia
>> phone +61 2 9550 5001   fax +61 2 9550 4001
>> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>


Re: Any other ROP examples?

Posted by Tarik <ch...@gmail.com>.
Hey Ari,

I have a question for you. Have you found any ways to go around the fact 
that context.rollBackChanges() does not work in ROP?  I'm building an 
app and need to fix this.

The class in charge of rolling back the changes on the client side is 
just a stub that does nothing.

Tarik

On Tue, 7 Oct 2008 7:07 pm, Aristedes Maniatis wrote:
>
> On 08/10/2008, at 3:59 AM, Demetrios Kyriakis wrote:
>
>> Are there any ROP based projects that could be used as example?
>> I mean some non-trivial examples (not like those from the SVN)
>
> I have a non-trivial ROP client/server desktop application. But  
> unfortunately the source is not available at this time. I'd be happy  
> to answer specific questions you might have. Cayenne 3, Jetty 6,  
> Hessian.
>
> Are you building a web app or a desktop application?
>
> Ari Maniatis
>
>
>
> -------------------------->
> ish
> http://www.ish.com.au
> Level 1, 30 Wilson Street Newtown 2042 Australia
> phone +61 2 9550 5001   fax +61 2 9550 4001
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

Re: Any other ROP examples?

Posted by Aristedes Maniatis <ar...@ish.com.au>.
On 08/10/2008, at 9:26 PM, Demetrios Kyriakis wrote:

> I wanted to use DataViewes too because it looks much closer to what  
> I need (from a Swing perspective), but it doesn't look to work with  
> the ROP "transport" style (or maybe I don't get the big picture of  
> how to make it work).

Dataviews are no longer part of the core Cayenne library. We did look  
at using them a while ago, but decided they would not be that helpful  
for our needs. In theory they can reduce the amount of data sent, but  
in practice when using paging, that isn't a problem for even tables  
with lots of columns.


> Does ROP support some sort of "offline work" ? e.g. when for various
> reasons a few minutes the client is disconnected, to be still  
> responsive?

Nothing about ROP works in this way. But you could write your code to  
gracefully deal with the exceptions you will get from the broken  
connection. That will probably be very complex to write robustly:  
think of all the data collision issues you'll have when the connection  
comes online again. I guess it depends on how much of your data is  
read-only.

On the other hand, when using something like Jetty as the servlet  
server, when the connection comes back up it will resume the session  
quite happily as long as the session timeout hasn't elapsed.


> What about the cache-ing strategy on the Client? I mean how smart is  
> it?

Pretty much the same as in single tier, but you can't use SHARED_CACHE  
[1]


> Can this all be configured simply from the Cayenne Modeler like for  
> Cayenne Classic?

Absolutely.


Ari




[1] http://cayenne.apache.org/doc/caching-and-fresh-data.html

-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A



Re: Any other ROP examples?

Posted by Demetrios Kyriakis <de...@gmail.com>.
>> Are there any ROP based projects that could be used as example?
>> I mean some non-trivial examples (not like those from the SVN)
> 
> I have a non-trivial ROP client/server desktop application. But 
> unfortunately the source is not available at this time. I'd be happy to 
> answer specific questions you might have. Cayenne 3, Jetty 6, Hessian.
That's great. Thank you :).

> Are you building a web app or a desktop application?
I'm evaluating ROP for a Swing based application (i.e. some Clients
are Swing based).
(for web applications, ClickFramework + Cayenne Classic looks much 
simpler).

I wanted to use DataViewes too because it looks much closer to what I 
need (from a Swing perspective), but it doesn't look to work with the 
ROP "transport" style (or maybe I don't get the big picture of how to 
make it work).

Does ROP support some sort of "offline work" ? e.g. when for various
reasons a few minutes the client is disconnected, to be still responsive?

What about the cache-ing strategy on the Client? I mean how smart is it?
Can this all be configured simply from the Cayenne Modeler like for 
Cayenne Classic?


Thank you,

Demetrios.


Re: Any other ROP examples?

Posted by Aristedes Maniatis <ar...@ish.com.au>.
On 08/10/2008, at 3:59 AM, Demetrios Kyriakis wrote:

> Are there any ROP based projects that could be used as example?
> I mean some non-trivial examples (not like those from the SVN)

I have a non-trivial ROP client/server desktop application. But  
unfortunately the source is not available at this time. I'd be happy  
to answer specific questions you might have. Cayenne 3, Jetty 6,  
Hessian.

Are you building a web app or a desktop application?

Ari Maniatis



-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A



Re: Any other ROP examples?

Posted by Demetrios Kyriakis <de...@gmail.com>.
> Well the JDO -> Cayenne convert I did is for an open source (at 
> sourceforge) application. The latest source is in the sourceforge 
> subversion repository for the strandz project. One of the ways it is 
> non-trivial is that it uses Spring services that also transport back 
> DOs. It requires the latest Cayenne SNAPSHOT. I can get together some 
> instructions for how to get it all going if you like...
That would be very nice :).

Thank you,

Demetrios.


Re: Talking to multiple database types with Cayenne.

Posted by Michael Gentry <bl...@gmail.com>.
Actually, I think I over-simplified earlier.  Each table has a PK
generation strategy, so one could use a sequence (or the
auto-increment) and another could use a PK table, but I hope you
understood hat I was getting at.

RE: Talking to multiple database types with Cayenne.

Posted by Scott Anderson <sa...@airvana.com>.
Mike,

You may change the PK generation strategy at runtime.
http://markmail.org/message/kwyfw3e7pguwle47

-Scott

-----Original Message-----
From: Michael Shea [mailto:mike@nitido.com] 
Sent: Tuesday, October 21, 2008 10:12 AM
To: user@cayenne.apache.org
Subject: Re: Talking to multiple database types with Cayenne.

Hi Andrus,

Thanks for your reply... Of course, this is almost exactly what Cayenne 
is for. I erred in the question I was asking, unfortunately, so I will 
ask it properly this time... =). I really just have a minor question to
ask:

My two database schemas are *almost* identical, but not quite. The MySQL

database creates primary keys on certain tables by using an 
AUTOINCREMENT column. The Oracle database creates primary keys on the 
equivalent tables by using a custom sequence. Is there any way for me to

change the primary key generation strategy depending on which DBMS is in

use? Or will I have to choose a strategy that works equally on both 
Oracle and on MySQL (ie, switch to using the default strategy?).

I would ideally like to continue using the auto-increment columns on 
MySQL, since that intuitively seems like the most efficient method to 
me. I have experimented with customizing the mapping.xml file at runtime

based on which type of database I'll be using, before making any calls 
to cayenne, that seems to work. But it's also pretty hacky, and will 
make maintenance more painful.

Thanks,


Mike Shea.


> Hi Michael,
>
> Cayenne will detect the database type automatically on startup and use

> the right adapter. So yes, use JNDI to abstract connection 
> information, beyond that no need for any extra tricks. You generic 
> Cayenne mapping will just work regardless of the db type.
>
> Andrus
>
>
>
> On Oct 20, 2008, at 11:42 AM, Michael Shea wrote:
>
>> Hi guys,
>>
>> I am working on a project in which I have to support multiple 
>> database types. They do not have to be supported simultaneously - I 
>> need my program to be able to run whether I am using an Oracle 
>> database or a MySQL database (the databases will have the same 
>> schema), but the database type does not change at runtime.
>>
>> I am wondering if there are any best practices or recommendations for

>> how to approach this problem. Currently, I am planning on simply 
>> creating two sets of cayenne configuration files in different 
>> directories (ie, a map.xml and a cayenne.xml file), and just adding 
>> one or the other of these directories to the classpath, depending on 
>> some initial configuration parameters that tell me what type of 
>> database I'm accessing. The datasource is defined via JNDI.
>>
>> Does anyone think that this is a good idea or a bad idea, or have a 
>> better way of doing this? =)  I am using Cayenne 2.0.4.
>>
>> Thanks!
>>
>>
>> Mike Shea.
>>
>


Re: Talking to multiple database types with Cayenne.

Posted by Michael Shea <mi...@nitido.com>.
Hi Michael,

Thanks for your reply. It looks like this is a case where trying to be 
clever has ended up wasting my time and not resulted any real 
performance gains. Oh well, it happens, and I don't have very much work 
to do to remove my customizations =). Thanks for the prompt assistance.

And thanks to the whole community here. This mailing list never ceases 
to impress me!


Shea.
> Hi Mike,
>
> I don't think it is an issue of an extra round-trip to the database
> (I'd hope the MySQL JDBC adapter was smart enough to get that value as
> part of the insert).  The more important issue is the number of
> individual inserts that must be done (and possibly updates).  When
> Cayenne knows all of the PKs upfront (using sequences or the PK
> table), it has already assigned all of the PKs to the newly inserted
> objects prior to sending to the DB.  This allows everything to be sent
> over quickly without a lot of back-and-forth communication.  With the
> AUTOINCREMENT scheme, it is more one-at-a-time and generates more
> chatter.  And keep in mind those PKs might need to be assigned to
> other objects, too (as FKs, for example).  This back-and-forth chatter
> is what would slow it down more than anything else.  Of course, if you
> are typically dealing with only inserting one or two records at a
> time, it'll be negligible.
>
> As for the PK batching, it is definitely done globally.  Each
> DataContext will request a PK when it needs one from the PK generator.
>  There is a PK generator per DataNode.  You can have many DataContexts
> all funneling through a single DataNode and PK generator.
>
> Hope that helps.  If not, ask more questions!
>
> Thanks,
>
> /dev/mrg
>
>
> On Tue, Oct 21, 2008 at 11:07 AM, Michael Shea <mi...@nitido.com> wrote:
>   
>> Does getting the primary keys via the Statement.getGeneratedKeys() require
>> an extra round-trip to the database? If not, I would think it wouldn't
>> generate very much overhead, since I'm already sending a statement to the
>> database, and receiving a response. Otherwise, yes, I can definitely see how
>> it would be more efficient to batch primary keys.
>>
>> Questions about Cayenne's primary key batching: Is this done globally,
>> across contexts? Or would each DataContext instance manage its own batch of
>> keys to use?
>>
>> Thanks,
>>
>>
>> Shea.
>>
>>     
>>> Interestingly, using autoincrement in mysql is probably a /hit/ in
>>> performance, compared to the default strategy. Cayenne has to ask mysql what
>>> the id was after every insert.
>>> In the default PK generation scheme, cayenne manages the ids.  Hence,
>>> cayenne can batch ids and not have to talk to the db about every pk for
>>> every object.
>>>
>>> Robert
>>>
>>> On Oct 21, 2008, at 10/219:12 AM , Michael Shea wrote:
>>>
>>>       
>>>> Hi Andrus,
>>>>
>>>> Thanks for your reply... Of course, this is almost exactly what Cayenne
>>>> is for. I erred in the question I was asking, unfortunately, so I will ask
>>>> it properly this time... =). I really just have a minor question to ask:
>>>>
>>>> My two database schemas are *almost* identical, but not quite. The MySQL
>>>> database creates primary keys on certain tables by using an AUTOINCREMENT
>>>> column. The Oracle database creates primary keys on the equivalent tables by
>>>> using a custom sequence. Is there any way for me to change the primary key
>>>> generation strategy depending on which DBMS is in use? Or will I have to
>>>> choose a strategy that works equally on both Oracle and on MySQL (ie, switch
>>>> to using the default strategy?).
>>>>
>>>> I would ideally like to continue using the auto-increment columns on
>>>> MySQL, since that intuitively seems like the most efficient method to me. I
>>>> have experimented with customizing the mapping.xml file at runtime based on
>>>> which type of database I'll be using, before making any calls to cayenne,
>>>> that seems to work. But it's also pretty hacky, and will make maintenance
>>>> more painful.
>>>>
>>>> Thanks,
>>>>
>>>>
>>>> Mike Shea.
>>>>
>>>>
>>>>         
>>>>> Hi Michael,
>>>>>
>>>>> Cayenne will detect the database type automatically on startup and use
>>>>> the right adapter. So yes, use JNDI to abstract connection information,
>>>>> beyond that no need for any extra tricks. You generic Cayenne mapping will
>>>>> just work regardless of the db type.
>>>>>
>>>>> Andrus
>>>>>
>>>>>
>>>>>
>>>>> On Oct 20, 2008, at 11:42 AM, Michael Shea wrote:
>>>>>
>>>>>           
>>>>>> Hi guys,
>>>>>>
>>>>>> I am working on a project in which I have to support multiple database
>>>>>> types. They do not have to be supported simultaneously - I need my program
>>>>>> to be able to run whether I am using an Oracle database or a MySQL database
>>>>>> (the databases will have the same schema), but the database type does not
>>>>>> change at runtime.
>>>>>>
>>>>>> I am wondering if there are any best practices or recommendations for
>>>>>> how to approach this problem. Currently, I am planning on simply creating
>>>>>> two sets of cayenne configuration files in different directories (ie, a
>>>>>> map.xml and a cayenne.xml file), and just adding one or the other of these
>>>>>> directories to the classpath, depending on some initial configuration
>>>>>> parameters that tell me what type of database I'm accessing. The datasource
>>>>>> is defined via JNDI.
>>>>>>
>>>>>> Does anyone think that this is a good idea or a bad idea, or have a
>>>>>> better way of doing this? =)  I am using Cayenne 2.0.4.
>>>>>>
>>>>>> Thanks!
>>>>>>
>>>>>>
>>>>>> Mike Shea.
>>>>>>
>>>>>>             
>>     


Re: Talking to multiple database types with Cayenne.

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

I don't think it is an issue of an extra round-trip to the database
(I'd hope the MySQL JDBC adapter was smart enough to get that value as
part of the insert).  The more important issue is the number of
individual inserts that must be done (and possibly updates).  When
Cayenne knows all of the PKs upfront (using sequences or the PK
table), it has already assigned all of the PKs to the newly inserted
objects prior to sending to the DB.  This allows everything to be sent
over quickly without a lot of back-and-forth communication.  With the
AUTOINCREMENT scheme, it is more one-at-a-time and generates more
chatter.  And keep in mind those PKs might need to be assigned to
other objects, too (as FKs, for example).  This back-and-forth chatter
is what would slow it down more than anything else.  Of course, if you
are typically dealing with only inserting one or two records at a
time, it'll be negligible.

As for the PK batching, it is definitely done globally.  Each
DataContext will request a PK when it needs one from the PK generator.
 There is a PK generator per DataNode.  You can have many DataContexts
all funneling through a single DataNode and PK generator.

Hope that helps.  If not, ask more questions!

Thanks,

/dev/mrg


On Tue, Oct 21, 2008 at 11:07 AM, Michael Shea <mi...@nitido.com> wrote:
> Does getting the primary keys via the Statement.getGeneratedKeys() require
> an extra round-trip to the database? If not, I would think it wouldn't
> generate very much overhead, since I'm already sending a statement to the
> database, and receiving a response. Otherwise, yes, I can definitely see how
> it would be more efficient to batch primary keys.
>
> Questions about Cayenne's primary key batching: Is this done globally,
> across contexts? Or would each DataContext instance manage its own batch of
> keys to use?
>
> Thanks,
>
>
> Shea.
>
>> Interestingly, using autoincrement in mysql is probably a /hit/ in
>> performance, compared to the default strategy. Cayenne has to ask mysql what
>> the id was after every insert.
>> In the default PK generation scheme, cayenne manages the ids.  Hence,
>> cayenne can batch ids and not have to talk to the db about every pk for
>> every object.
>>
>> Robert
>>
>> On Oct 21, 2008, at 10/219:12 AM , Michael Shea wrote:
>>
>>> Hi Andrus,
>>>
>>> Thanks for your reply... Of course, this is almost exactly what Cayenne
>>> is for. I erred in the question I was asking, unfortunately, so I will ask
>>> it properly this time... =). I really just have a minor question to ask:
>>>
>>> My two database schemas are *almost* identical, but not quite. The MySQL
>>> database creates primary keys on certain tables by using an AUTOINCREMENT
>>> column. The Oracle database creates primary keys on the equivalent tables by
>>> using a custom sequence. Is there any way for me to change the primary key
>>> generation strategy depending on which DBMS is in use? Or will I have to
>>> choose a strategy that works equally on both Oracle and on MySQL (ie, switch
>>> to using the default strategy?).
>>>
>>> I would ideally like to continue using the auto-increment columns on
>>> MySQL, since that intuitively seems like the most efficient method to me. I
>>> have experimented with customizing the mapping.xml file at runtime based on
>>> which type of database I'll be using, before making any calls to cayenne,
>>> that seems to work. But it's also pretty hacky, and will make maintenance
>>> more painful.
>>>
>>> Thanks,
>>>
>>>
>>> Mike Shea.
>>>
>>>
>>>> Hi Michael,
>>>>
>>>> Cayenne will detect the database type automatically on startup and use
>>>> the right adapter. So yes, use JNDI to abstract connection information,
>>>> beyond that no need for any extra tricks. You generic Cayenne mapping will
>>>> just work regardless of the db type.
>>>>
>>>> Andrus
>>>>
>>>>
>>>>
>>>> On Oct 20, 2008, at 11:42 AM, Michael Shea wrote:
>>>>
>>>>> Hi guys,
>>>>>
>>>>> I am working on a project in which I have to support multiple database
>>>>> types. They do not have to be supported simultaneously - I need my program
>>>>> to be able to run whether I am using an Oracle database or a MySQL database
>>>>> (the databases will have the same schema), but the database type does not
>>>>> change at runtime.
>>>>>
>>>>> I am wondering if there are any best practices or recommendations for
>>>>> how to approach this problem. Currently, I am planning on simply creating
>>>>> two sets of cayenne configuration files in different directories (ie, a
>>>>> map.xml and a cayenne.xml file), and just adding one or the other of these
>>>>> directories to the classpath, depending on some initial configuration
>>>>> parameters that tell me what type of database I'm accessing. The datasource
>>>>> is defined via JNDI.
>>>>>
>>>>> Does anyone think that this is a good idea or a bad idea, or have a
>>>>> better way of doing this? =)  I am using Cayenne 2.0.4.
>>>>>
>>>>> Thanks!
>>>>>
>>>>>
>>>>> Mike Shea.
>>>>>
>>>>
>>>
>>
>
>

Re: Talking to multiple database types with Cayenne.

Posted by Michael Shea <mi...@nitido.com>.
Does getting the primary keys via the Statement.getGeneratedKeys() 
require an extra round-trip to the database? If not, I would think it 
wouldn't generate very much overhead, since I'm already sending a 
statement to the database, and receiving a response. Otherwise, yes, I 
can definitely see how it would be more efficient to batch primary keys.

Questions about Cayenne's primary key batching: Is this done globally, 
across contexts? Or would each DataContext instance manage its own batch 
of keys to use?

Thanks,


Shea.

> Interestingly, using autoincrement in mysql is probably a /hit/ in 
> performance, compared to the default strategy. Cayenne has to ask 
> mysql what the id was after every insert.
> In the default PK generation scheme, cayenne manages the ids.  Hence, 
> cayenne can batch ids and not have to talk to the db about every pk 
> for every object.
>
> Robert
>
> On Oct 21, 2008, at 10/219:12 AM , Michael Shea wrote:
>
>> Hi Andrus,
>>
>> Thanks for your reply... Of course, this is almost exactly what 
>> Cayenne is for. I erred in the question I was asking, unfortunately, 
>> so I will ask it properly this time... =). I really just have a minor 
>> question to ask:
>>
>> My two database schemas are *almost* identical, but not quite. The 
>> MySQL database creates primary keys on certain tables by using an 
>> AUTOINCREMENT column. The Oracle database creates primary keys on the 
>> equivalent tables by using a custom sequence. Is there any way for me 
>> to change the primary key generation strategy depending on which DBMS 
>> is in use? Or will I have to choose a strategy that works equally on 
>> both Oracle and on MySQL (ie, switch to using the default strategy?).
>>
>> I would ideally like to continue using the auto-increment columns on 
>> MySQL, since that intuitively seems like the most efficient method to 
>> me. I have experimented with customizing the mapping.xml file at 
>> runtime based on which type of database I'll be using, before making 
>> any calls to cayenne, that seems to work. But it's also pretty hacky, 
>> and will make maintenance more painful.
>>
>> Thanks,
>>
>>
>> Mike Shea.
>>
>>
>>> Hi Michael,
>>>
>>> Cayenne will detect the database type automatically on startup and 
>>> use the right adapter. So yes, use JNDI to abstract connection 
>>> information, beyond that no need for any extra tricks. You generic 
>>> Cayenne mapping will just work regardless of the db type.
>>>
>>> Andrus
>>>
>>>
>>>
>>> On Oct 20, 2008, at 11:42 AM, Michael Shea wrote:
>>>
>>>> Hi guys,
>>>>
>>>> I am working on a project in which I have to support multiple 
>>>> database types. They do not have to be supported simultaneously - I 
>>>> need my program to be able to run whether I am using an Oracle 
>>>> database or a MySQL database (the databases will have the same 
>>>> schema), but the database type does not change at runtime.
>>>>
>>>> I am wondering if there are any best practices or recommendations 
>>>> for how to approach this problem. Currently, I am planning on 
>>>> simply creating two sets of cayenne configuration files in 
>>>> different directories (ie, a map.xml and a cayenne.xml file), and 
>>>> just adding one or the other of these directories to the classpath, 
>>>> depending on some initial configuration parameters that tell me 
>>>> what type of database I'm accessing. The datasource is defined via 
>>>> JNDI.
>>>>
>>>> Does anyone think that this is a good idea or a bad idea, or have a 
>>>> better way of doing this? =)  I am using Cayenne 2.0.4.
>>>>
>>>> Thanks!
>>>>
>>>>
>>>> Mike Shea.
>>>>
>>>
>>
>


Re: Talking to multiple database types with Cayenne.

Posted by Robert Zeigler <ro...@gmail.com>.
Interestingly, using autoincrement in mysql is probably a /hit/ in  
performance, compared to the default strategy. Cayenne has to ask  
mysql what the id was after every insert.
In the default PK generation scheme, cayenne manages the ids.  Hence,  
cayenne can batch ids and not have to talk to the db about every pk  
for every object.

Robert

On Oct 21, 2008, at 10/219:12 AM , Michael Shea wrote:

> Hi Andrus,
>
> Thanks for your reply... Of course, this is almost exactly what  
> Cayenne is for. I erred in the question I was asking, unfortunately,  
> so I will ask it properly this time... =). I really just have a  
> minor question to ask:
>
> My two database schemas are *almost* identical, but not quite. The  
> MySQL database creates primary keys on certain tables by using an  
> AUTOINCREMENT column. The Oracle database creates primary keys on  
> the equivalent tables by using a custom sequence. Is there any way  
> for me to change the primary key generation strategy depending on  
> which DBMS is in use? Or will I have to choose a strategy that works  
> equally on both Oracle and on MySQL (ie, switch to using the default  
> strategy?).
>
> I would ideally like to continue using the auto-increment columns on  
> MySQL, since that intuitively seems like the most efficient method  
> to me. I have experimented with customizing the mapping.xml file at  
> runtime based on which type of database I'll be using, before making  
> any calls to cayenne, that seems to work. But it's also pretty  
> hacky, and will make maintenance more painful.
>
> Thanks,
>
>
> Mike Shea.
>
>
>> Hi Michael,
>>
>> Cayenne will detect the database type automatically on startup and  
>> use the right adapter. So yes, use JNDI to abstract connection  
>> information, beyond that no need for any extra tricks. You generic  
>> Cayenne mapping will just work regardless of the db type.
>>
>> Andrus
>>
>>
>>
>> On Oct 20, 2008, at 11:42 AM, Michael Shea wrote:
>>
>>> Hi guys,
>>>
>>> I am working on a project in which I have to support multiple  
>>> database types. They do not have to be supported simultaneously -  
>>> I need my program to be able to run whether I am using an Oracle  
>>> database or a MySQL database (the databases will have the same  
>>> schema), but the database type does not change at runtime.
>>>
>>> I am wondering if there are any best practices or recommendations  
>>> for how to approach this problem. Currently, I am planning on  
>>> simply creating two sets of cayenne configuration files in  
>>> different directories (ie, a map.xml and a cayenne.xml file), and  
>>> just adding one or the other of these directories to the  
>>> classpath, depending on some initial configuration parameters that  
>>> tell me what type of database I'm accessing. The datasource is  
>>> defined via JNDI.
>>>
>>> Does anyone think that this is a good idea or a bad idea, or have  
>>> a better way of doing this? =)  I am using Cayenne 2.0.4.
>>>
>>> Thanks!
>>>
>>>
>>> Mike Shea.
>>>
>>
>


Re: Talking to multiple database types with Cayenne.

Posted by Michael Shea <mi...@nitido.com>.
Hi Andrus,

Thanks for your reply... Of course, this is almost exactly what Cayenne 
is for. I erred in the question I was asking, unfortunately, so I will 
ask it properly this time... =). I really just have a minor question to ask:

My two database schemas are *almost* identical, but not quite. The MySQL 
database creates primary keys on certain tables by using an 
AUTOINCREMENT column. The Oracle database creates primary keys on the 
equivalent tables by using a custom sequence. Is there any way for me to 
change the primary key generation strategy depending on which DBMS is in 
use? Or will I have to choose a strategy that works equally on both 
Oracle and on MySQL (ie, switch to using the default strategy?).

I would ideally like to continue using the auto-increment columns on 
MySQL, since that intuitively seems like the most efficient method to 
me. I have experimented with customizing the mapping.xml file at runtime 
based on which type of database I'll be using, before making any calls 
to cayenne, that seems to work. But it's also pretty hacky, and will 
make maintenance more painful.

Thanks,


Mike Shea.


> Hi Michael,
>
> Cayenne will detect the database type automatically on startup and use 
> the right adapter. So yes, use JNDI to abstract connection 
> information, beyond that no need for any extra tricks. You generic 
> Cayenne mapping will just work regardless of the db type.
>
> Andrus
>
>
>
> On Oct 20, 2008, at 11:42 AM, Michael Shea wrote:
>
>> Hi guys,
>>
>> I am working on a project in which I have to support multiple 
>> database types. They do not have to be supported simultaneously - I 
>> need my program to be able to run whether I am using an Oracle 
>> database or a MySQL database (the databases will have the same 
>> schema), but the database type does not change at runtime.
>>
>> I am wondering if there are any best practices or recommendations for 
>> how to approach this problem. Currently, I am planning on simply 
>> creating two sets of cayenne configuration files in different 
>> directories (ie, a map.xml and a cayenne.xml file), and just adding 
>> one or the other of these directories to the classpath, depending on 
>> some initial configuration parameters that tell me what type of 
>> database I'm accessing. The datasource is defined via JNDI.
>>
>> Does anyone think that this is a good idea or a bad idea, or have a 
>> better way of doing this? =)  I am using Cayenne 2.0.4.
>>
>> Thanks!
>>
>>
>> Mike Shea.
>>
>


Re: Talking to multiple database types with Cayenne.

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

Cayenne will detect the database type automatically on startup and use  
the right adapter. So yes, use JNDI to abstract connection  
information, beyond that no need for any extra tricks. You generic  
Cayenne mapping will just work regardless of the db type.

Andrus



On Oct 20, 2008, at 11:42 AM, Michael Shea wrote:

> Hi guys,
>
> I am working on a project in which I have to support multiple  
> database types. They do not have to be supported simultaneously - I  
> need my program to be able to run whether I am using an Oracle  
> database or a MySQL database (the databases will have the same  
> schema), but the database type does not change at runtime.
>
> I am wondering if there are any best practices or recommendations  
> for how to approach this problem. Currently, I am planning on simply  
> creating two sets of cayenne configuration files in different  
> directories (ie, a map.xml and a cayenne.xml file), and just adding  
> one or the other of these directories to the classpath, depending on  
> some initial configuration parameters that tell me what type of  
> database I'm accessing. The datasource is defined via JNDI.
>
> Does anyone think that this is a good idea or a bad idea, or have a  
> better way of doing this? =)  I am using Cayenne 2.0.4.
>
> Thanks!
>
>
> Mike Shea.
>


Talking to multiple database types with Cayenne.

Posted by Michael Shea <mi...@nitido.com>.
Hi guys,

I am working on a project in which I have to support multiple database 
types. They do not have to be supported simultaneously - I need my 
program to be able to run whether I am using an Oracle database or a 
MySQL database (the databases will have the same schema), but the 
database type does not change at runtime.

I am wondering if there are any best practices or recommendations for 
how to approach this problem. Currently, I am planning on simply 
creating two sets of cayenne configuration files in different 
directories (ie, a map.xml and a cayenne.xml file), and just adding one 
or the other of these directories to the classpath, depending on some 
initial configuration parameters that tell me what type of database I'm 
accessing. The datasource is defined via JNDI.

Does anyone think that this is a good idea or a bad idea, or have a 
better way of doing this? =)  I am using Cayenne 2.0.4.

Thanks!


Mike Shea.

Re: Any other ROP examples?

Posted by Chris Murphy <ch...@strandz.org>.
Here are the instructions for getting a Cayenne ROP/Spring application 
going:

http://www.strandz.org/CayenneROPExample.html

It is recently converted from a JDO application.

Hope it helps - Chris Murphy

Chris Murphy wrote:
>
> Hi Demetrios,
>
> Well the JDO -> Cayenne convert I did is for an open source (at 
> sourceforge) application. The latest source is in the sourceforge 
> subversion repository for the strandz project. One of the ways it is 
> non-trivial is that it uses Spring services that also transport back 
> DOs. It requires the latest Cayenne SNAPSHOT. I can get together some 
> instructions for how to get it all going if you like...
>
> - Chris
>
> Demetrios Kyriakis wrote:
>> Are there any ROP based projects that could be used as example?
>> I mean some non-trivial examples (not like those from the SVN)
>>
>> Thank you,
>>
>> Demetrios.
>>
>>
>>
>

-- 
Seaweed Software Pty Ltd,
http://www.strandz.org


Re: Any other ROP examples?

Posted by Chris Murphy <ch...@strandz.org>.
Hi Demetrios,

Well the JDO -> Cayenne convert I did is for an open source (at 
sourceforge) application. The latest source is in the sourceforge 
subversion repository for the strandz project. One of the ways it is 
non-trivial is that it uses Spring services that also transport back 
DOs. It requires the latest Cayenne SNAPSHOT. I can get together some 
instructions for how to get it all going if you like...

- Chris

Demetrios Kyriakis wrote:
> Are there any ROP based projects that could be used as example?
> I mean some non-trivial examples (not like those from the SVN)
>
> Thank you,
>
> Demetrios.
>
>
>

-- 
Seaweed Software Pty Ltd,
http://www.strandz.org