Any ROP users?

2022-02-11 Thread Aristedes Maniatis
On the heels of the security announcement, there has been discussion on 
removing ROP from the next major Cayenne release after 4.2.


ROP was modelled on a similar Java Client feature in Webobjects/EOF and 
there is nothing else quite like it in other ORMs. The ability to just 
use normal Cayenne operations from the client machine without worrying 
about how those operations get to the server and data objects are returned.


It has some limitations:

* limited security. There is no simple way to add an authorisation layer 
to restrict access to certain objects or fields. Authentication and 
encryption are really simple, but per object authorisation is hard.


* Java client. Although it is possible to write Cayenne in other 
languages, no one has done so. There was some work ages ago on 
Cocoa/Objective C bindings. Java client UI (swing/javaFX) is not popular 
these days.


* upgrading. You need to upgrade the client and server at the same time


But it is really quite neat. Maybe I'm a bit sentimental since I used to 
use it extensively for many years. But I've moved onto react/js/browser 
clients which means that server-client serialisation is now over 
json/swagger/jackson/CXF. Authorisation is now easy and the client UI 
more lovely.



Is anyone using ROP? Should we remove it from the next Cayenne and 
reduce the burden of maintenance?



Ari


On 12/2/2022 8:50am, Aristedes Maniatis wrote:
A patched version of Cayenne 4.1 (or earlier) will not be released 
since we believe there are sufficient ways to avoid the issue and the 
number of people using ROP is likely quite low. Given the security 
model of ROP, it is also most likely used in a scenario where the 
client is trusted. 


Security announcement: CVE-2022-24289

2022-02-11 Thread Aristedes Maniatis

== Environment

A security issue has been discovered in Apache Cayenne ROP. Remote 
Object Persistence (ROP) is an optional component in Cayenne which is a 
Java client library used to execute Cayenne operations (query, insert, 
update, etc) and access the object data map in the client environment.


ROP has two options for serialising data between client and server: 
Hessian and protobuf. It is the older Hessian which is the subject of 
today's security announcement.



== Vulnerability

In Apache Cayenne 4.1 and earlier, running on non-current patch versions 
of Java, an attacker with client access to Cayenne ROP can transmit a 
malicious payload to any vulnerable third-party dependency on the 
server.  This can result in arbitrary code execution.



== Workaround

Do one of the following:

* upgrade to Apache Cayenne 4.2

* upgrade to a patched version of Java (after 6u211, 7u201, 8u191, and 
11.0.1)


* use protobuf instead of hessian serialisation


All versions of Apache Cayenne 4.2 have whitelisting enabled by default 
for the Hessian deserialization.  Later versions of Java also have LDAP 
mitigation in place. Users can either upgrade Java or Apache Cayenne to 
avoid the issue.


LDAP mitigation is present starting in JDK 6u211, 7u201, 8u191, and 
11.0.1 where com.sun.jndi.ldap.object.trustURLCodebase system property 
is set to false by default to prevent JNDI from loading remote code 
through LDAP.



A patched version of Cayenne 4.1 (or earlier) will not be released since 
we believe there are sufficient ways to avoid the issue and the number 
of people using ROP is likely quite low. Given the security model of 
ROP, it is also most likely used in a scenario where the client is trusted.


Our thanks to Panda for discovering and responsibly reporting the issue.


Ari Maniatis

on behalf of the Cayenne PMC



Re: Ordering objects by primary keys

2021-10-30 Thread Aristedes Maniatis
Its old, but still fast and works well: 
https://markmail.org/search/?q=list%3Aorg.apache.cayenne.user+%22db%3A%22


Ari


On 30/10/21 1:01am, Michael Gentry wrote:

Fun fact: I have years worth of Cayenne mailing list content in GMail, but
you can't search for db: in it because GMail uses prefix:term as an
advanced search option and it doesn't know what to do with db: ...


On Thu, Oct 28, 2021 at 2:38 AM giulio.ces...@gmail.com <
giulio.ces...@gmail.com> wrote:


Is there any point in the documentation where this "db:" prefix has been
documented?

Cheers,
Giulio Cesare

On Wed, Oct 27, 2021 at 11:23 PM giulio.ces...@gmail.com <
giulio.ces...@gmail.com> wrote:


It did work! 朗

Thanks Nikita. 

Cheers,

Giulio Cesare


On Wed, Oct 27, 2021 at 7:46 PM Nikita Timofeev <

ntimof...@objectstyle.com>

wrote:


Hi!

You could try to add "db:" prefix to the primary key name.
Something like this: orderBy("db:ARTIST_ID")

On Wed, Oct 27, 2021 at 8:14 PM giulio.ces...@gmail.com
 wrote:

Hello,

I am try to run some BBD tests integrated with Cayenne (succesfully,

so

far).
I am at the point where I can not fully specify the record/object to

select

in the test script, and so I am trying to select the latest object
inserted, matching some lose criteria.

Unfortunately, I don't have a generic "insertion date" in all my

entities;

so the next best think I could think of, is to use the value of the PK
(generated using Postgres sequences) to sort the selected objects

(DESC)

and picking the first match.

To achieve this, I have tried with this code:

String dbEntityName =


context.getEntityResolver().getObjEntity(entityName).getDbEntityName();

ImmutableList orderBy =


context.getEntityResolver().getDbEntity(dbEntityName).getPrimaryKeys().stream()

.map(attribute -> new Ordering(attribute.getName(),

SortOrder.DESCENDING))

.collect(ImmutableList.toImmutableList())
;
BaseDataObject latestInstance =
ObjectSelect.query(clazz).orderBy(orderBy).selectFirst(context);

but I get the following error:
- Can't resolve path component: [{EntityName}.{primaryKeyFieldName}]

I realize that {EntityName} and {primaryKeyFieldName} live in two

separate

contexts (Entities vs DB); but I have no more ideas on how to

progress.

Does anyone have any suggestions on how to do this stunt?

Cheers,
Giulio Cesare



--
Best regards,
Nikita Timofeev





Re: Best Practice for blobs

2019-10-02 Thread Aristedes Maniatis
My solution has been to store the blob in a separate joined table or 
(better) put it in external storage like S3.


Ari

On 3/10/19 9:55am, Lon Varscsak wrote:

Hey all,

I have a blob column in an entity, but I don't want to always actually load
the blob, just on demand (but I still want to be able to see the other
attributes in the entity).  Any best practice here to have the blob be lazy?

Thanks,

Lon



Re: 4.2 modeler change

2019-10-02 Thread Aristedes Maniatis
One advantage of an html/js frontend would be to offer a service on our 
website into which a user could paste their DDL as SQL, and get back:


1. a Cayenne map xml

2. a visual representation of their schema [1]

3. an editor which allows them to make changes

4. The ability to export an updated DDL

5. Some sort of sharing link so they can share and discuss with co-workers


Here's a company I just found doing something similar. 
https://www.dbdesigner.net/



The main advantage of this approach is to give Cayenne greater exposure. 
People come for the tool and walk away with a whole ORM.


I'm ccing this to the dev@ list where it makes more sense.


Ari


[1] Like this 
https://www.mysql.com/common/images/products/MySQL_Workbench_Visual_Design_Mac.png



On 3/10/19 3:20am, Andrus Adamchik wrote:

But thanks for all the replies. That's sort of where I was going with this as 
well.


Re: 4.2 modeler change

2019-10-01 Thread Aristedes Maniatis
JavaFX would be a huge amount of work since almost the entire app would 
be rewritten from scratch. And if there was a reason to do it, that 
reason would probably point toward an html/js front end. There are just 
so many more html/js widgets for object graphs, table views, etc than 
any other UI kit.


And then we'd have Cayenne modeler SaaS!  \s

Back in reality, Swing is going to be here a long time. If you are able 
to submit a PR to run even a basic set of tests on the UI that would be 
great and provide a guide on how to add more over time.



Ari

On 2/10/19 5:36am, Emerson Castañeda wrote:

Last year a got some progresses testing Swing UI using assertj-swing-junit
dependency

Also, I got to run TravisCI successfully, by including  xvfb In order to
run the tests that require a GUI.

Finally, it required 2 additional changes:

1. Modifying Main class on modeler to expose Injector object
2. Include some modifications to the CayenneModelerFrame to set names for
the GUI components to test, since assertj cannot test anonymous instances.

If Swing still being an option, I can open a PR with a full functional use
case of GUI testing using the mentioned stack..

Other way, what would be the desires/goals for diving into JavaFX? so we
could think about at GUI testing strategy covering that path.

Thanks

EmeCas




On Tue, Oct 1, 2019 at 2:51 PM John Huss  wrote:


The way to handle testing for the UI is to write the app in an MVP style,
sort of like this:
https://stackoverflow.com/questions/11367250/concrete-code-example-of-mvp

The gist is to define an interface contract for the view so that you can
replace the actual Swing UI View with a mock while testing.
But that doesn't help much with an existing application that wasn't written
in that style.


On Tue, Oct 1, 2019 at 1:00 AM Andrus Adamchik 
wrote:


Yeah, I was thinking how do we even approach testing of Java UI. Any
suggestions are welcome.

And to complicate things we've been postponing a dive into JavaFX, while
the Swing app keeps adding functionality. So investing effort in a test
framework should take this pending decision into account.

Andrus


On Oct 1, 2019, at 7:11 AM, Aristedes Maniatis 

wrote:

I've been down that path before, trying to test Swing and JavaFX. Its

not easy to do. The best tool I found (and that was about 8 years ago)

was

https://www.froglogic.com/squish/editions/automated-java-gui-testing/

but

I don't know if they have any licensing available for open source

projects.

Emerson, if you have any experience with this, let us know what has

worked for you.


Ari


On 30/9/19 12:21am, Emerson Castañeda wrote:

Wonder if these bugs would be into the kind of things that a good GUI

test

suite for the modeler could prevent.

EmeCas

On Thu, Sep 26, 2019 at 12:08 PM Lon Varscsak 
Okay, cool.  Another bug (I just found) is on the add relationship

dialog

(on object entity) is that it seems to ignore the "delete" rule and

just is

always the default.  Easily worked around by just editing the added
relationship after the fact.

On Thu, Sep 26, 2019 at 12:22 AM Andrus Adamchik <

and...@objectstyle.org>

wrote:


Screenshots are stripped by the list management software, but the
description is pretty clear. I am not using 4.2 myself, but we do

need to

fix it before we release 4.2.M1.

Andrus


On Sep 26, 2019, at 1:08 AM, Lon Varscsak 

wrote:

Hey all,

It looks like when adding a db-relationship in the Modeler

(4.2.M1-SNAPSHOT from today) the potential target entities is not

sorted

(which is only mildly annoying), but doesn't contain any target

entities

outside of the current data map (blocker).  Am i missing something?

Thanks!

-Lon

Here's a screenshot for reference:





Re: 4.2 modeler change

2019-09-30 Thread Aristedes Maniatis
I've been down that path before, trying to test Swing and JavaFX. Its 
not easy to do. The best tool I found (and that was about 8 years ago) 
was 
https://www.froglogic.com/squish/editions/automated-java-gui-testing/ 
but I don't know if they have any licensing available for open source 
projects.


Emerson, if you have any experience with this, let us know what has 
worked for you.



Ari


On 30/9/19 12:21am, Emerson Castañeda wrote:

Wonder if these bugs would be into the kind of things that a good GUI test
suite for the modeler could prevent.

EmeCas

On Thu, Sep 26, 2019 at 12:08 PM Lon Varscsak 
wrote:


Okay, cool.  Another bug (I just found) is on the add relationship dialog
(on object entity) is that it seems to ignore the "delete" rule and just is
always the default.  Easily worked around by just editing the added
relationship after the fact.

On Thu, Sep 26, 2019 at 12:22 AM Andrus Adamchik 
wrote:


Screenshots are stripped by the list management software, but the
description is pretty clear. I am not using 4.2 myself, but we do need to
fix it before we release 4.2.M1.

Andrus


On Sep 26, 2019, at 1:08 AM, Lon Varscsak 

wrote:

Hey all,

It looks like when adding a db-relationship in the Modeler

(4.2.M1-SNAPSHOT from today) the potential target entities is not sorted
(which is only mildly annoying), but doesn't contain any target entities
outside of the current data map (blocker).  Am i missing something?

Thanks!

-Lon

Here's a screenshot for reference:





Re: Problems with Modeler...

2019-05-20 Thread Aristedes Maniatis

On 21/5/19 1:34am, Tony Giaccone wrote:

I've been away for a week and this morning I tried to start the Modeler and
am getting this message:

Unable to load Java Environment

Not sure what's causing this. Anyone have any insights?

$ java -version

java version "1.8.0_121"



I see you are on OSX. The new easiest way to keep this updated for me 
seems to be:


# brew tap AdoptOpenJDK/openjdk
# brew cask install|adoptopenjdk8 |The downside is that this package doesn't include WebStart. But it 
avoids Oracle's mysterious new licensing and is easy to keep up to date. 
I also find # brew install jenv useful to switch between Java versions. Ari







Re: shared cache with memcached

2019-01-29 Thread Aristedes Maniatis

You can integrate any JCache compatible provider.

https://cayenne.apache.org/docs/4.1/cayenne-guide/#ext-jcache


However, think about whether you are best trying to cache the database 
queries or rendered html content. If its possible in your app to do the 
latter, you might get better results.



Ari



On 30/1/19 12:27am, abapseres wrote:

Hello,

I am managing webapp on multiple tomcat servers.

Is there a way to mount a distributed cache architecture with memcached, 
hazelcast or anything else with apache cayenne.

i have been unable to find find some doc about it.


Thank you



Re: In memory DB for unit testing

2018-05-05 Thread Aristedes Maniatis

On 3/5/18 5:59am, Ken Anderson wrote:


We’re thinking about setting up an in-memory database in place of SQL Server 
for doing unit tests.  Does anyone have any experience doing this with Cayenne? 
 Any recommendations or warnings?



We used to use Derby everywhere (in memory) and it worked pretty well. 
dbunit to populate the data. liquibase to generate the schema.


However I recently moved all our tests over to MariaBD for two reasons: 
using a DB which is different to our production DB meant we missed a 
couple of bugs where the SQL db choice had subtle differences. Things 
like case sensitivity of table names.


Secondly, MariaDB running in a 4Gb ram disk (/dev/md on FreeBSD) is much 
faster than Derby.



Ari



Cayenne advantages

2017-10-09 Thread Aristedes Maniatis
We are currently rebuilding the Cayenne website and would like to refresh its 
unique selling points. What is it that brought you to Cayenne and kept you 
here? I know there are some EOF escapees who are here because EOF is no longer 
supported, but what positive reasons keep you here rather than moving to a JPA 
or other library?

This is not about denigrating the alternatives but highlighting what Cayenne 
does well and showing new developers why they should try it.

1. If you made a bullet list of your key features (even with only one item!) 
what would it be?

2. If you met a developer at a conference and suggest they try Cayenne, what 
would convince them to try it?


Ari



-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Question on how to properly create parent-child nested dependent objects?

2017-09-19 Thread Aristedes Maniatis
On 19/9/17 11:01PM, Andrew Willerding wrote:
> The CommunicationType object does not yet exist permanently in the database 
> table so how or when does it generate the primary key for the object to be 
> referenced by another object before it is committed?  I was hoping to not 
> have to worry about this as a "high-level" user of Cayenne.


You are right, you don't need to worry about all that. Just create one context 
and save it at the end. Cayenne tracks the relationships between objects with a 
temporary key internally, but you don't need to think about that. Once Caynenne 
commits, everything is assigned proper primary keys and joined.

Ari


-- 
------>
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Order of insert/update/delete operations

2017-08-01 Thread Aristedes Maniatis
On 2/8/17 9:12AM, Lon Varscsak wrote:
> In this case, because it’s an object with the same PK as a previously
> deleted object, technically I’d need deletes to happen for this row
> *first* before
> doing the update.

Are you able to change the schema so you don't have meaningful primary keys 
here?

Ari


-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Cayenne on StackOverflow

2017-04-14 Thread Aristedes Maniatis
On 14/4/17 1:24am, Andrus Adamchik wrote:
> To all Cayenne experts and volunteers on this list:
> 
> As you may know we have quite a bit of traffic on StackOverflow [1]. Usually 
> it is way below the activity level on the user@ list. But it spikes 
> occasionally. E.g. in the last few weeks I am having a hard time keeping up 
> with it. So I'd like to encourage more people to subscribe to 
> "apache-cayenne" tag and help with answering questions. You will get 
> StackOverflow karma in return (yeah, like anyone cares about that :)). But we 
> do care about Apache Cayenne, and this is one of the important things we can 
> do to help our fellow developers. 
> 
> Thanks in advance to anyone who steps in!
> 
> Andrus
> 
> [1] http://stackoverflow.com/questions/tagged/apache-cayenne


Is there a way to subscribe, or do you mean just "check the tag page regularly"?

Ari



-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Fetching lots of objects

2017-03-08 Thread Aristedes Maniatis
On 8/3/17 6:54pm, Musall, Maik wrote:

> regular SelectQuery: 25888 ms for 1291644 objects
> DataRowQuery alone: 14289 ms for 1291644 rows
> DataRowQuery sequential instantiation: 6878 ms for 1291644 objects, sum = 
> 21167
> DataRowQuery parallel instantiation: 7351 ms for 1291644 objects, sum = 21640
> DataRowQuery with iterator: 22484 ms for 1291644 objects
> DataRowQuery with batch iterator of 100 each: 21219 ms for 1291644 objects

What about trying the new M5 release from yesterday and its ability to select 
just the columns you need. You'll just get a list of column data instead of a 
simpler object model, but it might be faster.

Ari



-- 
------>
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Fetching lots of objects

2017-03-07 Thread Aristedes Maniatis
On 7/3/17 8:25am, Musall, Maik wrote:
> Hi all,
> 
> I have a number of statistics functions which need to fetch large amounts of 
> objects. I need the actual DataObjects because that's where the business 
> logic is that I need for the computations.
> 
> Let's say I need to fetch 300.000 objects. Let's also assume the database 
> sits on a fast SSD array and can serve multiple connections easily. I'm 
> assuming in this case the CPU time needed for DataObject instantiation is the 
> main performance constraint. Is that correct?
> 
> If so, how can I speed this up? Could I partition my fetch, and fetch in 
> several threads in parallel into the same ObjectContext? Or is there an 
> easier way to make use of multiple CPU cores for this?


I don't think there is anything in Cayenne that will specifically help you 
here. However if you can partition your search query, the of course you can 
fetch the data in multiple threads in parallel.

You might also want to fetch into DataRows rather than creating object 
entities. I'm not sure if that will make your use case faster, but you could 
try, especially if you don't need all the columns from the db entity.

Ari



-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Generic dictionary data with entities?

2017-02-10 Thread Aristedes Maniatis
On 11/2/17 10:32am, Michael Gentry wrote:
> On Fri, Feb 10, 2017 at 3:08 PM, John Huss <johnth...@gmail.com> wrote:
> 
>> Another option is to create a separate file and put things there, like a
>> properties file or a json document or something.  It's not a bad solution.
>>
> 
> Yeah, I was just answering the question about the CM file itself.  Either
> create or own properties or YAML or similar.
> 
> mrg


I'm pretty sure Cayenne doesn't validate the schema at runtime. So you could 
even add new elements and attributes directly to the XML if you want to forgo a 
GUI editor.

Ari



-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Cayenne and migrations

2017-02-09 Thread Aristedes Maniatis
t; wrote:
>>>>>>
>>>>>>> Hi Hugi,
>>>>>>>
>>>>>>> We manage schema changes outside of Cayenne using Flyway (could also
>>> use
>>>>>>> Liquibase).  Any schema changes we make are updated by hand in Cayenne
>>>>>>> Modeler.  This works fairly well for us and fits in with our automated
>>>>>>> builds/etc.  Perhaps not the answer you were looking for, though!
>>>>>>>
>>>>>>> mrg
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Feb 9, 2017 at 9:21 AM, Hugi Thordarson <h...@karlmenn.is>
>>>>> wrote:
>>>>>>>
>>>>>>>> Hi all.
>>>>>>>> In EOF/WOnder we have the most swesome ERXMigrations to manage
>>> changes
>>>>> in
>>>>>>>> the data model between versions, i.e. upgrades of the schema (and
>>>>>>>> downgrades, if applicable).
>>>>>>>>
>>>>>>>> I see that some years ago there was discussion of an API to handle
>>> this
>>>>>>> in
>>>>>>>> Cayenne ( http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-
>>>>>>>> migrations/ ). but how’s the situation today? Is there something
>>> in/for
>>>>>>>> Cayenne to do this, and if not, what tools are people using to manage
>>>>>>>> versioning of their DB schemas?
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>> - hugi
>>>>>>>
>>>>>
>>>>>
>>>
>>>
> 

-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: cgen triggering through gradle

2017-01-11 Thread Aristedes Maniatis
On 11/1/17 1:29pm, buddha wrote:
> Hi, 
> 
>  
> 
> I’m trying to find out how to trigger cgen using gradle in cayenne. I can 
> find maven example, but not with gradle. Can anyone point me to an example? 

https://github.com/ari/cayenne-gradle

Here's what I put into buildSrc

Ari



-- 
------>
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Schema generation fails in HSQLDB when generating foreign key constraints targeting tables with more than one join

2016-11-10 Thread Aristedes Maniatis
On 11/11/16 9:07am, Hugi Thordarson wrote:
> Do you think it’s okay for us to upgrade? Any HSQLDB expert care to comment?

Not an expert in HSQLDB (I tend to use Derby as my lightweight embedded db of 
choice). But I reckon few people are using HSQLDB for any production purposes, 
so it is really just a simple test environment and you should upgrade it 
without problem. At any rate, we may as well be testing against the latest 
version that has been out for many years.


Ari



-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Erratic AshwoodEntitySorter NPE on Latest Snapshot

2016-10-24 Thread Aristedes Maniatis
On 25/10/16 6:22am, fael wrote:
> The problem still exhibits itself - I've rebuilt Cayenne 4 a couple of times
> - I'm also seeing it manifest with the following exception:

Does the problem go away with an older version of Cayenne, such as the last 
4.0M3 release?

Ari


-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Cayenne with Transaction Manager (Atomikos)

2016-09-20 Thread Aristedes Maniatis
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


Re: Bamboo vs. Jenkins for Cayenne, other projects

2016-09-09 Thread Aristedes Maniatis
On 10/09/2016 12:00am, rzeig...@asuragen.com wrote:
> Sorry for the slightly off-topic post, but the combined wisdom and experience 
> of this group is substantial.
> 
> Cayenne is using Apache’s JIRA + Apache’s Jenkins installs despite the 
> availability of Bamboo infrastructure at Apache. My question: what (if any) 
> are the reasons Cayenne has stayed with Jenkins rather than migrating to 
> bamboo? We have a similar setup locally and are considering a Bamboo 
> migration, but the number of apache projects with JIRA + Jenkins instead of 
> JIRA + Bamboo makes me wonder about Bamboo.

Many years ago I migrated from Bamboo to Jenkins (nee Hudson). I did so for the 
significantly better ecosystem of plugins.

I think the better question is: why would we put effort into moving to Bamboo? 
Does it give us anything we don't have?


Which reminds me: we should fix the excessive logging which kills travis [1]. 
We could get mysql, mariadb, postgresql testing there. I got a bit stuck 
between maven and Cayenne's logging.


[1] https://travis-ci.org/apache/cayenne

Ari



-- 
------>
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: EJBQL limit

2016-08-15 Thread Aristedes Maniatis
Yes, the main (only?) place I've used it myself is for COUNT, SUM type 
features. But I'm interested in what is needed for ObjectSelect to catch up to 
the common use cases. And also where people see the line between SQLTemplate 
and EJBQL.

Ari


On 15/08/2016 5:04pm, Andrus Adamchik wrote:
> EJBQL is more feature rich - aggregation, arithmetic operations, subqueries, 
> functions. So while I rarely use it myself, I can easily see use cases.
> 
> Andrus
> 
> 
>> On Aug 15, 2016, at 9:43 AM, Aristedes Maniatis <a...@maniatis.org> wrote:
>>
>> On 15/08/2016 4:38pm, Andrus Adamchik wrote:
>>>
>>>> On Aug 14, 2016, at 4:39 PM, Hugi Thordarson <h...@karlmenn.is> wrote:
>>>>
>>>> Hi all!
>>>> Does Cayenne’s EJBQL support LIMIT expressions? I see I can set a fetch 
>>>> limit on an EJBQLQuery, but it seems that this will just limit the size of 
>>>> the resultset generated by the query, not the SQL generation (resulting in 
>>>> huge execution times for large queries).
>>>>
>>>> Cheers,
>>>> - hugi
>>>
>>> Yeah, the way it is implemented is not particularly efficient. The limit 
>>> functionality is external to the syntax, and hence doesn't make it to the 
>>> generated SQL. We can either patch EJBQL, or wait for the bright future 
>>> when EJBQL and ObjectSelect and made one :)
>>>
>>> Andrus
>>
>>
>> Out of interest Hugi, why are you using EJBQL? Is this legacy code moved to 
>> Cayenne and this was the easiest way forward? Or are there features of 
>> Cayenne's incomplete EJBQL implementation you like better than the other SQL 
>> Template or ObjectSelect api?
>>
>>
>> Ari
>>
>>
>>
>>
>>
>> -- 
>> -->
>> Aristedes Maniatis
>> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
> 

-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: EJBQL limit

2016-08-15 Thread Aristedes Maniatis
On 15/08/2016 4:38pm, Andrus Adamchik wrote:
> 
>> On Aug 14, 2016, at 4:39 PM, Hugi Thordarson <h...@karlmenn.is> wrote:
>>
>> Hi all!
>> Does Cayenne’s EJBQL support LIMIT expressions? I see I can set a fetch 
>> limit on an EJBQLQuery, but it seems that this will just limit the size of 
>> the resultset generated by the query, not the SQL generation (resulting in 
>> huge execution times for large queries).
>>
>> Cheers,
>> - hugi
> 
> Yeah, the way it is implemented is not particularly efficient. The limit 
> functionality is external to the syntax, and hence doesn't make it to the 
> generated SQL. We can either patch EJBQL, or wait for the bright future when 
> EJBQL and ObjectSelect and made one :)
> 
> Andrus


Out of interest Hugi, why are you using EJBQL? Is this legacy code moved to 
Cayenne and this was the easiest way forward? Or are there features of 
Cayenne's incomplete EJBQL implementation you like better than the other SQL 
Template or ObjectSelect api?


Ari





-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Order of operations?

2016-07-01 Thread Aristedes Maniatis
On 1/07/2016 8:57pm, Andrus Adamchik wrote:
> 
>> On Jun 30, 2016, at 11:04 PM, Aristedes Maniatis <a...@maniatis.org> wrote:
>>
>> 1. The Cayenne model will need to have additional metadata about database 
>> indexes and constraints. I've always liked that idea anyway but lacked the 
>> time to work on it personally. It could open up interesting interactions 
>> with projects like liquibase [1]
> 
> We already have information about relationships (that are essentially FK 
> constraints). Why do we need to know about indexes for ordering purposes?

I was just thinking about db constraints really. For example, a unique index on 
a field (other than the PK) might need to be taken into consideration if you 
were deleting and creating records. The delete has to happen before the create, 
or they need to be coalesced into a single update.

Ari



-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Order of operations?

2016-06-30 Thread Aristedes Maniatis
On 1/07/2016 11:01am, Andrus Adamchik wrote:
> So there are tradeoffs and challenges and this won't be an easy task. But if 
> anyone feels like applying their graph theory knowledge to a non-trivial 
> problem, please speak up :)

Although I don't have a solution, I have three observations/questions:

1. The Cayenne model will need to have additional metadata about database 
indexes and constraints. I've always liked that idea anyway but lacked the time 
to work on it personally. It could open up interesting interactions with 
projects like liquibase [1]

2. Has Hibernate or any other ORM solved this problem in an interesting way? 
[2] Hibernate appears to split "collection deletes/inserts" which I presume 
means "to-many" joined records.

3. Keeping the order that changes are added to the context is another simple 
approach that leaves it up to the developer to get it right in code. It doesn't 
quite tell us what to do with two updates to the same object that are collapsed 
into one, but otherwise it seems sensible as an option.


[1] https://github.com/liquibase/liquibase-hibernate for a simplistic approach, 
but we could go much further.

[2] 
http://stackoverflow.com/questions/12616336/how-is-hibernate-deciding-order-of-update-insert-delete

-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Order of operations?

2016-06-22 Thread Aristedes Maniatis
On 23/06/2016 5:25am, Lon Varscsak wrote:
> Okay, I’ve found where it’s at (DataDomainFlushAction.preprocess).  I don’t
> see an easy way to override this, without just forking (which is totally
> doable).  Does anyone know why the default order of operations is INSERT ->
> UPDATE -> DELETE?  Because if there’s no specific reason, it seems like we
> could change this to support DBs that don’t have deferred constraints.  (or
> provide a hook to reorder these)


That's a pretty old piece of code, probably before my time. The history is 
unfortunately broken by a move back in 2013 [1] but it would be interesting to 
go back to the origins of that file and see if any commit message sheds light 
on why that ordering was chosen. It does seem an odd choice, but perhaps there 
was a reason.

Before you fork Cayenne let's see if we can improve this behaviour for the 
entire community.


[1] 
https://github.com/apache/cayenne/commits/b0631deb251f036840d1ca3aee6d4ae50f2441bf/cayenne-server/src/main/java/org/apache/cayenne/access/DataDomainFlushAction.java

-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Order of operations?

2016-06-21 Thread Aristedes Maniatis
On 22/06/2016 11:47am, Lon Varscsak wrote:
> I’m using Sybase where it doesn’t have deferred constraints and it seems
> like Cayenne is doing INSERTS first, but in my case, I want to do DELETES
> -> UPDATES -> INSERTS.  Where can I control this?

I don't know of any approach to solve this, however we deal with it by 
committing the context first with the deletes and then after that for the 
updates/inserts. So two separate context commits. And you can wrap a database 
transaction around all that if you choose.


Ari




-- 
------>
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: NPE on ROP connect after upgrading from 4.0.M2 to 4.0.M3

2016-05-29 Thread Aristedes Maniatis
Right now, you'll need to build from source from master branch. 4.0M3 doesn't 
have these changes. We should cut an M4 once it has settled down.

Ari


On 29/05/2016 2:09pm, Adam Boyle wrote:
> Thanks, I will try to take a look at 4.0.M3 again soon!
> 
> 
> From: Aristedes Maniatis <a...@maniatis.org>
> Sent: Saturday, May 28, 2016 1:06:11 AM
> To: user@cayenne.apache.org
> Subject: Re: NPE on ROP connect after upgrading from 4.0.M2 to 4.0.M3
> 
> On 10/04/2016 3:55pm, Aristedes Maniatis wrote:
>> On 10/04/2016 2:56pm, Adam Boyle wrote:
>>> Ah, I forgot you are using the latest and greatest and not Hessian. Looks 
>>> like I will have to figure this one out on my own for now, or else do a 
>>> build off of master and implement something similar to what you have below.
>>
>> Nah, that's still Hessian. We are currently use a build of trunk from about 
>> 10 March.
>>
>> Our experiments with protocol-buffers are still in the early stages. First 
>> for us is HTTP2 which is coming along well [1]
>>
>> Ari
>>
>> [1] 
>> https://github.com/thinline72/cayenne/commit/91b8985857ee8fb16be1b1cb05bf8c18e074b030
> 
> 
> Adam, if you aren't tracking the dev list, you might like to take a look at 
> the latest changes to Cayenne trunk. Protocol-buffers has now been introduced 
> as a pluggable replacement to Hessian.
> 
> We are yet to do any performance testing in real world apps, but we have high 
> hopes.
> 
> 
> Ari
> 
> 
> 
> 
> --
> -->
> Aristedes Maniatis
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
> 

-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: NPE on ROP connect after upgrading from 4.0.M2 to 4.0.M3

2016-05-27 Thread Aristedes Maniatis
On 10/04/2016 3:55pm, Aristedes Maniatis wrote:
> On 10/04/2016 2:56pm, Adam Boyle wrote:
>> Ah, I forgot you are using the latest and greatest and not Hessian. Looks 
>> like I will have to figure this one out on my own for now, or else do a 
>> build off of master and implement something similar to what you have below.
> 
> Nah, that's still Hessian. We are currently use a build of trunk from about 
> 10 March.
> 
> Our experiments with protocol-buffers are still in the early stages. First 
> for us is HTTP2 which is coming along well [1]
> 
> Ari
> 
> [1] 
> https://github.com/thinline72/cayenne/commit/91b8985857ee8fb16be1b1cb05bf8c18e074b030


Adam, if you aren't tracking the dev list, you might like to take a look at the 
latest changes to Cayenne trunk. Protocol-buffers has now been introduced as a 
pluggable replacement to Hessian.

We are yet to do any performance testing in real world apps, but we have high 
hopes.


Ari




-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: CayenneDataObject validation

2016-05-18 Thread Aristedes Maniatis
On 19/05/2016 7:03am, Lon Varscsak wrote:
> Hey guys, I know about insert/update/delete validation routines, but is
> there a way to write validations for specific attributes so that when
> someone tries to push a value into a property it could be rejected?  I know
> that WO/EOF (Maybe Wonder) had something like this where I could write
> validateMyAttribute methods.

That would be easy to write in the model class. Just override the setter and 
add your own logic.

is that what you had in mind?

Ari



-- 
------>
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: NPE on ROP connect after upgrading from 4.0.M2 to 4.0.M3

2016-04-09 Thread Aristedes Maniatis
On 10/04/2016 2:56pm, Adam Boyle wrote:
> Ah, I forgot you are using the latest and greatest and not Hessian. Looks 
> like I will have to figure this one out on my own for now, or else do a build 
> off of master and implement something similar to what you have below.

Nah, that's still Hessian. We are currently use a build of trunk from about 10 
March.

Our experiments with protocol-buffers are still in the early stages. First for 
us is HTTP2 which is coming along well [1]

Ari

[1] 
https://github.com/thinline72/cayenne/commit/91b8985857ee8fb16be1b1cb05bf8c18e074b030

-- 
------>
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: NPE on ROP connect after upgrading from 4.0.M2 to 4.0.M3

2016-04-09 Thread Aristedes Maniatis
On 10/04/2016 2:39am, Adam Boyle wrote:
> What does your client connection code look like in your ROP setup? Are you 
> using BASIC auth on your server end point?


There's a bit of custom code in the below to show UI dialogs, but you should 
get the general idea...


String value = "Basic " + B64Code.encode(user + ":" +  token + ':' + pass, 
StandardCharsets.ISO_8859_1);

httpClient.start();

Request request  = httpClient.newRequest(currentServer + 
ServletPath.SECURE.path())
.header(REQUEST_HEADER_LOGIN, Boolean.TRUE.toString())
.header("Authorization", value);

if (kickOutConcurrents) {
request.param(REQUEST_HEADER_KICK_OUT, Boolean.TRUE.toString());
}
ContentResponse response = request.send();

switch (response.getStatus()) {
case SC_OK:
break;
case SC_CONFLICT:
logger.warn("Concurrent session detected for user:" + user);
if (showGui) {
showKickOutDialog(user, pass, token, host, port, isSsl, 
clientVersionString);
}
return;
case SC_TOO_MANY_USERS:
logger.warn("Login attempt for user:" + user + " failed, too 
many concurrent users");
resetAndShake("Too many concurrent users", null, showGui, 
false);
return;
default:
logger.warn("Login attempt for user:" + user + " failed, 
response code from server:" + response.getStatus());
resetAndShake("Authentication failed.", null, showGui, false);
return;
}

sessionId = httpClient.getCookieStore().getCookies().stream().filter(c -> 
"JSESSIONID".equals(c.getName())).findFirst().get().getValue();



We also subclass org.apache.cayenne.CayenneContext in order to override 
commitChanges(), performQuery(Query query) and other things and catch some of 
the exceptions we get back in order to show more helpful UI to the users.


Ari



-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: NPE on ROP connect after upgrading from 4.0.M2 to 4.0.M3

2016-04-09 Thread Aristedes Maniatis
efaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:899)
>   at 
> java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:727)
>   at java.awt.Component.dispatchEventImpl(Component.java:4742)
>   at java.awt.Container.dispatchEventImpl(Container.java:2287)
>   at java.awt.Window.dispatchEventImpl(Window.java:2719)
>   at java.awt.Component.dispatchEvent(Component.java:4698)
>   at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
>   at java.awt.EventQueue.access$200(EventQueue.java:103)
>   at java.awt.EventQueue$3.run(EventQueue.java:694)
>   at java.awt.EventQueue$3.run(EventQueue.java:692)
>   at java.security.AccessController.doPrivileged(Native Method)
>   at 
> java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
>   at 
> java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
>   at java.awt.EventQueue$4.run(EventQueue.java:708)
>   at java.awt.EventQueue$4.run(EventQueue.java:706)
>   at java.security.AccessController.doPrivileged(Native Method)
>   at 
> java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
>   at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
>   at 
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
>   at 
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
>   at 
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:154)
>   at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182)
>   at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221)
>   at java.security.AccessController.doPrivileged(Native Method)
>   at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219)
>   at java.awt.Dialog.show(Dialog.java:1082)
>   at java.awt.Component.show(Component.java:1655)
>   at java.awt.Component.setVisible(Component.java:1607)
>   at java.awt.Window.setVisible(Window.java:1014)
>   at java.awt.Dialog.setVisible(Dialog.java:1005)
>   at com.valsphere.vidval.client.gui.GuiLogin.(GuiLogin.java:181)
>   at com.valsphere.vidval.client.Client.initPriv(Client.java:97)
>   at com.valsphere.vidval.client.Client.initialize(Client.java:76)
>   at com.valsphere.vidval.client.gui.GuiMain.doLogin(GuiMain.java:128)
>   at com.valsphere.vidval.client.Main$1.run(Main.java:56)
>   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
>   at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
>   at java.awt.EventQueue.access$200(EventQueue.java:103)
>   at java.awt.EventQueue$3.run(EventQueue.java:694)
>   at java.awt.EventQueue$3.run(EventQueue.java:692)
>   at java.security.AccessController.doPrivileged(Native Method)
>   at 
> java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
>   at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
>   at 
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
>   at 
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
>   at 
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
>   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
>   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
>   at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
> 
> 
> From: Aristedes Maniatis <a...@maniatis.org>
> Sent: Friday, April 8, 2016 8:43 PM
> To: user@cayenne.apache.org
> Subject: Re: NPE on ROP connect after upgrading from 4.0.M2 to 4.0.M3
> 
> The main change in M3 is that we moved to Hessian 4. Are you running a newer 
> client compared to the server end? I'm not sure of the compatibility between 
> the two.
> 
> Ari
> 
> 
> On 9/04/2016 3:28am, Adam Boyle wrote:
>> I'm seeing the following NPE on the client when connecting my ROP client 
>> after upgrading from 4.0.M2 to M3:
>>
>>
>> Apr 08, 2016 1:11:38 PM org.apache.cayenne.remote.hessian.HessianConnection 
>> connect
>> INFO: Connecting to [system:***@http://localhost:8080/vidval/cws] - 
>> dedicated session.
>> Apr 08, 2016 1:11:39 PM org.apache.cayenne.remote.hessian.HessianConnection 
>> connect
>> INFO: Error establishing remote session. URL - 
>> http://localhost:8080/vidval/cws
>> java.lang.NullPointerException
>> at 
>> com.caucho.hessian.client.HessianURLConnectionFactory.ope

Re: NPE on ROP connect after upgrading from 4.0.M2 to 4.0.M3

2016-04-08 Thread Aristedes Maniatis
t; at 
> java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
> at java.awt.EventQueue$4.run(EventQueue.java:708)
> at java.awt.EventQueue$4.run(EventQueue.java:706)
> at java.security.AccessController.doPrivileged(Native Method)
> at 
> java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
> at 
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
> at 
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
> at 
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:154)
> at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182)
> at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219)
> at java.awt.Dialog.show(Dialog.java:1082)
> at java.awt.Component.show(Component.java:1655)
> at java.awt.Component.setVisible(Component.java:1607)
> at java.awt.Window.setVisible(Window.java:1014)
> at java.awt.Dialog.setVisible(Dialog.java:1005)
> at com.valsphere.vidval.client.gui.GuiLogin.(GuiLogin.java:181)
> at com.valsphere.vidval.client.Client.initPriv(Client.java:94)
> at com.valsphere.vidval.client.Client.initialize(Client.java:73)
> at com.valsphere.vidval.client.gui.GuiMain.doLogin(GuiMain.java:128)
> at com.valsphere.vidval.client.Main$1.run(Main.java:56)
> at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
> at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
> at java.awt.EventQueue.access$200(EventQueue.java:103)
> at java.awt.EventQueue$3.run(EventQueue.java:694)
> at java.awt.EventQueue$3.run(EventQueue.java:692)
> at java.security.AccessController.doPrivileged(Native Method)
> at 
> java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
> at 
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
> at 
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
> at 
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
> 
> My code looks like this and was working well in 4.0.M2:
> connection = new HessianConnection(host, userId, 
> String.copyValueOf(password), null);
> channel = new ClientChannel(connection, false, null, true);
> setContext(new CayenneContextWrapper(channel));
> 
> The server console is not reporting any exceptions. I checked 
> http://localhost:8080/vidval/cws in my browser and was able to login with 
> BASIC auth and see the "Hessian Requires POST" message, so not sure what's 
> going on.
> 
> -Adam
> 
> 
> 

-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: ROP: detecting that my client connection has timed out

2016-04-08 Thread Aristedes Maniatis
On 9/04/2016 1:34am, Adam Boyle wrote:
> I'll also see about getting a build from trunk to dig into the latest ROP 
> code. Admittedly back in January I questioned my decision to use Cayenne when 
> I saw that the latest alpha release was from February 2015, so it's a relief 
> to see 4.0.M3 and more commits coming in for ROP :)

Yes, we really should release milestones more often. However trunk is kept very 
stable and I find myself using custom builds from it in production fairly often.

Perhaps if you have any feedback about the new ROP integration bits, we might 
plan for another milestone release sooner rather than later.

Do let us know if you have any questions or suggestions about the new ROP 
integration. Hopefully I'll be moving to HTTP2 in our own application this 
coming week.

Ari


-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: ROP: detecting that my client connection has timed out

2016-04-08 Thread Aristedes Maniatis
On 8/04/2016 3:06pm, Adam Boyle wrote:
> Does anyone know of a better way? Perhaps some advice for this novice 
> enterprise developer?

Also I strongly advise taking a build of Cayenne trunk from after the release 
of 4.0M3. The new ROP refactoring in there is brand new but I've already got it 
in production and it works nicely. Much easier to customise for your needs.

We are currently right now finishing up migration to Jetty HTTP client as an 
option in Cayenne. This will allow us to use HTTP2 and hopefully get better 
performance over high latency connections.



Ari


-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: ROP: detecting that my client connection has timed out

2016-04-08 Thread Aristedes Maniatis
What container are you using on the server? For us, we use Jetty and it is 
simple enough to track sessions there (and store additional data against the 
session such as the database User object). Then use 
https://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpSessionListener.html
 to do something server-side in reaction to a session timeout.

Also look at javax.servlet.Filter. Implement:

public void doFilter(ServletRequest servletRequest, ServletResponse 
servletResponse, FilterChain chain) throws IOException, ServletException {

and you should be able to add something like:

try {
chain.doFilter(request, response);
} catch 
(org.apache.cayenne.remote.service.MissingSessionException ex) {
// session forged or expired or user kicked out
session.invalidate();
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
}

You should be able to catch the 401 error on the client end and do something 
useful with it.


Does that help?

Ari


On 8/04/2016 3:06pm, Adam Boyle wrote:
> Thanks for the response. I could be overlooking it, but I don't see an answer 
> to my central question: how can I detect that the client has timed out? The 
> nature of our application prevents us from using a keep-alive type solution; 
> it is meant to be used in highly regulated environments (which is one of the 
> reasons I chose Cayenne ROP: it provides a way to hide the database details 
> from the users). Even if I could use an auto-reconnect solution, I would 
> still need to be able to detect that the connection has timed out, and I have 
> failed to find a way to actually detect that.
> 
> I suppose that another (less-hacky) way I could approach this would be to 
> logically detect a "timeout" by keeping the actual connection alive and 
> storing login session info in the database and updating it with the current 
> date time every time a Cayenne action is performed. This code would check for 
> a timeout beforehand and prompt the user to re-authenticate before performing 
> said action. The main problem there is maintainability; I'd have to add this 
> check to every place I intend to submit any sort of Cayenne action unless 
> there is a way to hook this sort of check into the ObjectContext.
> 
> Does anyone know of a better way? Perhaps some advice for this novice 
> enterprise developer?
> 
> Thanks again,
> Adam
> 
> 
> From: Aristedes Maniatis <a...@maniatis.org>
> Sent: Friday, April 8, 2016 12:30 AM
> To: user@cayenne.apache.org
> Subject: Re: ROP: detecting that my client connection has timed out
> 
> On 8/04/2016 1:28pm, Adam Boyle wrote:
>> Is there a simple way of detecting that the connection is dead so that I can 
>> prompt the user to reconnect?
> 
> I don't think you need to prompt the user if you keep the user's 
> authentication details in memory. Just create a new session with them.
> 
> 
>> On a related note, what happens to the existing client ObjectContext objects 
>> that are in use if the connection is able to be re-established? Are the 
>> uncommitted PersistentObjects previously created in those contexts lost 
>> forever?
> 
> Those contexts are no longer associated with a session on the server (once 
> your session times out). So you either have to recognise that a user is 
> connecting again after a connection error and give them a handle on the same 
> session id they had last time, or else start a new session and lose the old 
> contexts.
> 
> The problem is: can you be sure the state of those contexts still make sense?
> 
> 
>> The only (hacky) solution I can think of is to actually run a keep-alive 
>> thread to periodically send a low-latency query to Cayenne to keep the ROP 
>> session active and separately track application activity and prompt the user 
>> to enter their password if a certain period of time has passed with no 
>> activity. The problem that I see with an approach like that is that there 
>> are lots of ways that activity could be missed, the application is not truly 
>> timing out, and it really doesn't address the underlying problem which is 
>> that sessions need to time out for a reason and there doesn't seem to be a 
>> way to detect such a timeout.
> 
> Well this is outside Cayenne itself, but part of the reason we recently did 
> the work in trunk (CAY-2065) to untangle Cayenne from Hessian and from the 
> HTTP layer. Then you can manage the session more easily yourself to do 
> whatever you want.
> 
> For example, we have a ping every minute from the client that:
> 
> * keeps the session alive (we do

Re: ROP: detecting that my client connection has timed out

2016-04-07 Thread Aristedes Maniatis
On 8/04/2016 1:28pm, Adam Boyle wrote:
> Is there a simple way of detecting that the connection is dead so that I can 
> prompt the user to reconnect?

I don't think you need to prompt the user if you keep the user's authentication 
details in memory. Just create a new session with them.


> On a related note, what happens to the existing client ObjectContext objects 
> that are in use if the connection is able to be re-established? Are the 
> uncommitted PersistentObjects previously created in those contexts lost 
> forever?

Those contexts are no longer associated with a session on the server (once your 
session times out). So you either have to recognise that a user is connecting 
again after a connection error and give them a handle on the same session id 
they had last time, or else start a new session and lose the old contexts.

The problem is: can you be sure the state of those contexts still make sense?


> The only (hacky) solution I can think of is to actually run a keep-alive 
> thread to periodically send a low-latency query to Cayenne to keep the ROP 
> session active and separately track application activity and prompt the user 
> to enter their password if a certain period of time has passed with no 
> activity. The problem that I see with an approach like that is that there are 
> lots of ways that activity could be missed, the application is not truly 
> timing out, and it really doesn't address the underlying problem which is 
> that sessions need to time out for a reason and there doesn't seem to be a 
> way to detect such a timeout.

Well this is outside Cayenne itself, but part of the reason we recently did the 
work in trunk (CAY-2065) to untangle Cayenne from Hessian and from the HTTP 
layer. Then you can manage the session more easily yourself to do whatever you 
want.

For example, we have a ping every minute from the client that:

* keeps the session alive (we don't want the session to die just because the 
user went to have lunch)
* allows us the keep the server-side session timeout quite low (good to expire 
sessions for users who dropped off the network without a proper logout)
* allows the server to track which users are having network issues

In the last six months we've been doing a bunch of work with ActiveMQ/STOMP 
which might eventually replace that ping. That way we have two way 
server-client communication and the server can quickly see which clients have 
lost network connection without a ping.


Nice to see a fellow Cayenne ROP user. There aren't many of us and it is really 
a very powerful bit of functionality.


Ari



-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Modeling vertical inheritance

2016-03-27 Thread Aristedes Maniatis
On 28/03/2016 6:51am, Simon Farner wrote:
> I am trying to get the book/ebook/paper_book example to work with
> Cayenne Modler 4.0.M3, but it wont validate. This is the third time I
> try this and I really need to get this working now, I am not very keen
> on a road block meeting and switching to another ORM.

If you are new to Cayenne, can I recommend you first work your way through the 
tutorial [1]. That might be an easier way to get started and understand the 
basic ideas.

Ari


[1] https://cayenne.apache.org/docs/4.0/tutorial/

-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Populating a test DB for use with Cayenne

2016-03-19 Thread Aristedes Maniatis
On 16/03/2016 9:31pm, Hugi Thordarson wrote:
> Hi all.
> 
> Just out of curiosity; how are you guys populating your test DBs before 
> running tests? Has anyone written something brilliant to do it with e.g. 
> .yml-files (via Cayenne)? Are you doing it via SQL-scripts? In code perhaps?
> 
> I’m currently creating my test DBs in code (using Cayenne) and it becomes 
> cumbersome when they reach a certain size :).

http://dbunit.sourceforge.net/ will do the trick for you. That combined with 
Derby's in-memory mode.

Ari




-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Cayenne 4.0 M3 Usable for Production

2016-03-05 Thread Aristedes Maniatis
On 5/03/2016 10:28pm, André Koppany wrote:
> Dear Cayenne Team,
> 
> is Cayenne 4.0 Milestone 3 usable for production?
> Are there any points where I should take care of?
> 
> Currently we are using cayenne 3.1.

Yes, very much so. I've been running 4.0M2 in production for a very long time 
both in a tomcat web app and a desktop client/server ROP application. Not a 
single problem.

4.0M3 is new but I expect it to be used by customers of mine within the next 
few weeks.

Mostly the "M" milestone designation is not about reliability. It is more to 
flag that the API might still be in a little bit of flux. When you go from M3 
to M4 you might find a few changes you need to deal with. We'll always 
gracefully deprecate API changes from one major release to another, but within 
milestone some features will just change.

The only example I can think of between M2 and M3 was a change to the new 
fluent style object query ordering. Between M3 and M4 will be a change to how 
you set up ROP. Read the release notes for more information.

Ari




-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Reconnecting automatically after DB downtime

2016-02-29 Thread Aristedes Maniatis
On 29/02/2016 9:53pm, Hugi Thordarson wrote:
> Hi all.
> We had some DB problems last night (MariaDB with the ConnectorJ driver). As 
> soon as I had started the DB back up, our EOF applications were up and 
> running, but the Cayenne apps were still down and required a restart to start 
> running again.
> 
> Is there any way to tell Cayenne to reconnect to the DB after an event like 
> this? 

This should be a property of your JDBC adaptor, not Cayenne. Something like 
autoReconnect=true in the connection string.

Ari




-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: using database generated PK

2015-12-04 Thread Aristedes Maniatis
On 3/12/2015 2:08pm, John Huss wrote:
> The main advantage of a native solution is that you know it works.  If you
> ever used native PK generation the AUTO_PK_SUPPORT table feels very
> kludgy.  It works (I guess?), but it's not ideal.  A native solution is
> faster and simpler.  It handles transactions better.  Most DBs (all?) do PK
> generation outside of transactions, so incrementing the sequence always
> persists regardless of transaction rollbacks or commits.

Thanks for your detailed reply. Transactions (this bug) 
https://issues.apache.org/jira/browse/CAY-2040  are exactly why we want to 
change. Perhaps this is not really a bug, but just a documented reason not to 
use this approach and limitation that would be very hard to work around.


Ari



-- 
------>
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


using database generated PK

2015-12-02 Thread Aristedes Maniatis
I've always used the AUTO_PK_SUPPORT approach to PK generation, all the way 
back from WebObject EOF days many many years ago.

However a recently discovered bug in this approach [1] and how it intersects 
with transactions may require use to think about going over to database 
generated primary keys with a auto-increment column. For developers not using 
an ORM this is pretty common I understand.

What are the downsides to that approach? Is performance, reliability and 
everything else just the same? What problem was AUTO_PK_SUPPORT originally 
designed to solve?

Cheers
Ari


[1] https://issues.apache.org/jira/browse/CAY-2040


-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Generate Classes without cayenne modeler

2015-10-16 Thread Aristedes Maniatis
On 16/10/2015 4:30pm, Dipesh Jain wrote:
> I am using Cayenne Modeler for class generation. I was wondering, can I
> create classes by my self and use it or do I have to depend on Cayenne
> Modeler for class generation ?

Many people use the cgen ant/maven goal to generate classes without using 
modeler. In fact you can build that into your regular build cycle so they are 
always up to date and in sync with the model.

Or you can use something completely different and do it yourself.


Ari
 

-- 
------>
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Is there a canonical method of invoking aggregate functions

2015-09-13 Thread Aristedes Maniatis
On 14/09/2015 5:26am, Hugi Thordarson wrote:
> I've started working on a proposal for the WebObjects-world to migrate 
> Project Wonder to Cayenne,

Sounds great. Its been a long time since I was in the WO world, and although I 
used Project Wonder way back then, I find it hard to remember where EOF stopped 
and Wonder started.

Can you give us a short summary of what features Wonder would bring to a 
Cayenne developer?

Cheers
Ari

-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: How do you update a record with apache cayenne without using select clause

2015-09-11 Thread Aristedes Maniatis
On 12/09/2015 1:32am, Dipesh Jain wrote:
> I am using apache cayenne 3.1. I know of one way to update records in the
> database is to first use select query to find record and then update it,
> but I don't want to use a select query for updating. How can I directly
> update the record? I do not want to use EJBQLQuery or SQL TEMPLETE.

That's a bit like asking "how do I code in Java without using a keyboard?" What 
are you trying to do and why are you trying to do it without the tools the ORM 
gives you?

Ari


-- 
------>
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Query at the time of inserting data using Apache Cayenne

2015-09-09 Thread Aristedes Maniatis
On 10/09/2015 2:11am, Dipesh Jain wrote:
> Person person = new Person();
> person.setFirstName("John");
> person.setLastName("Cross");
> ObjectContext context = BaseContext.getThreadObjectContext();
> context.registerNewObject(person);

Try this instead

DataContext context = (DataContext) BaseContext.getThreadObjectContext();
Person person = context.newObject(Person.class);
person.setFirstName("John");
person.setLastName("Cross");
context.commitChanges();

-- 
-->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Getting the currently active ServerRuntime

2015-08-27 Thread Aristedes Maniatis
On 27/08/2015 6:37pm, Hugi Thordarson wrote:
 I’m writing a Cayenne-based CRUD framework of sorts, in the form of a jar 
 that plugs into Cayenne applications. 

Is there overlap with this: http://nhl.github.io/link-rest/ which was already 
built over the top of Cayenne?

Ari


-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Obtain primary key for DataObject before commitChanges

2015-08-12 Thread Aristedes Maniatis
Interesting. Questions:

* What is the purpose of TransactionObject?

* Is there a performance advantage to TransactionObjectFieldValue with multiple 
rows per change event rather than storing larger json serialised set of changes 
in one record? I mean, I understand that it allows you to ask what changes 
were made to this specific field over time without loading and parsing lots of 
json. But is that how the audit will be used? Will creating 20 times as many 
rows scale better than storing larger text CLOBs?

* How are you grouping changes (eg. if in a single commit a user changes two 
records at once)?

* How do you handle changes to the schema after version data is created?

Ari

On 12/08/2015 6:18pm, Hugi Thordarson wrote:
 For the last few years while using EOF, I’ve been storing changes in the 
 audit log as a map serialized to a String NSPropertyList (the NS* world’s 
 equivalent of JSON). It works fine, but once the log starts to grow, there 
 are performance implications. This time around I’m going for a three table 
 approach that looks something like:
 
 - TransactionObject (reference to object)
 - TransactionObjectLifecycleEvent (user, date and type of action; Insert, 
 Update or Delete)
 - TransactionObjectFieldValue (name of changed attribute along with new 
 value, serialized to a string)
 
 These relate to each other:
 
 TransactionObject — TransactionObjectLifecycleEvent — 
 TransactionObjectFieldValue
 
 I’m currently planning on ignoring relationships in the object graph and just 
 storing actual values of attributes and foreign keys. We’ll see how that 
 works out.
 
 Criticism and ideas for a better implementation are very welcome :).
 
 Cheers,
 - hugi
 
 
 On 12. ágú. 2015, at 00:49, Aristedes Maniatis a...@maniatis.org wrote:

 I'm interested in a different part of the problem you are solving. Other 
 than the relationship data discuss here, how are you storing the actual 
 changes in your audit table? Does your problem just require Bob changed 
 record 23 or are you keeping a complete diff of the changes? If the 
 latter, how are you serialising those changes into the audit log?


 Ari


 On 12/08/2015 8:13am, Hugi Thordarson wrote:
 Thanks for the ideas Mike. After a little mulling, I think your idea of 
 dynamically modeling relationships to the audit table at application 
 startup is the best one I’ve heard so far. I’m going to take a peek down 
 that road tomorrow :)

 Cheers,
 - hugi




 On 10. ágú. 2015, at 14:24, Mike Kienenberger mkien...@gmail.com wrote:

 Not sure if it's clear, but there are two different approaches to your
 problem described.

 1) You can set a foreign relationship to your audit table and let
 Cayenne assign the key at commit.  This is probably the easiest
 especially if you dynamically create the relationships in java code.
 Except for the initialization of these relationships at some point
 (startup or first time you hit the audit code), nothing else has to be
 done and that's the only cayenne-internals code you have to deal
 with.

 2) You can use something like the example code to grab the primary key
 values after cayenne generates them but before the actual database
 query executes.  I doubt that prePersist is early enough, but it might
 be.   Otherwise you will have to go looking for a different hook.
 This requires a lot more knowledge of cayenne internals in my opinion.
 This is also a much harder problem if you're deferring the key
 generation to the database rather than using sequences or some similar
 approach, but Cayenne obviously has a way to handle that now or
 regular foreign key setup for relationships wouldn't work.

 Your third idea of using postPersist has its own problems.  If you
 decide to use a postPersist and set this information in a separate
 commit, then you run the risk of your audit log not being created and
 losing your audit information.   For my environment, that wasn't
 acceptable.   Maybe you could wrap both commits in a single
 transaction -- I'm not certain, but maybe that could work.
 Transaction support either wasn't there back when I was doing this or
 I didn't understand that it could solve my problem back then.


 On Mon, Aug 10, 2015 at 10:13 AM, Hugi Thordarson h...@karlmenn.is wrote:
 Thanks Mike! Although the approach I’m working on is a little different 
 (and meant to be reusable with any Cayenne installation so can’t depend 
 on superclass template modifications), it’s very helpful to see code from 
 other Cayenne folks.

 Cheers,
 - hugi

 // Hugi Thordarson
 // http://www.loftfar.is/ http://www.loftfar.is/
 // s. 895-6688



 On 10. ágú. 2015, at 12:53, Mike Kienenberger mkien...@gmail.com wrote:

 I set up auditing using a different approach in one project many years
 ago back in Cayenne 1.1, and I've continued using it up to this point
 in 3.x.   I generated special setter, addTo, and removeFrom methods as
 well as a create method which created the logger object at that point.

 To get the primary

Re: Obtain primary key for DataObject before commitChanges

2015-08-11 Thread Aristedes Maniatis
)
   {
   primaryKeyOfRecord = (Integer)pkObject;
   }
   }

   if (null == primaryKeyOfRecord)
   {
Iterator pkIterator = pkAttributes.keySet().iterator();
   while (pkIterator.hasNext())
   {
   String primaryKeyName = (String) pkIterator.next();
   Object primaryKeyValue = pkAttributes.get(primaryKeyName);

   if (null == primaryKeysString)
   {
   primaryKeysString = primaryKeyName + = + 
 primaryKeyValue;
   }
   else
   {
   primaryKeysString = primaryKeysString + , +
 primaryKeyName + = + primaryKeyValue;
   }
   }
   }

   if (null != primaryKeyOfRecord)
   {
   auditRecordMap.put(FOREIGN_KEY, primaryKeyOfRecord);
   }
   if (null != primaryKeysString)
   {
   auditRecordMap.put(FKEY_CONDITION, primaryKeysString);
   }
   }
 }



 On Mon, Aug 10, 2015 at 7:27 AM, Aristedes Maniatis a...@maniatis.org 
 wrote:
 On 10/08/2015 8:31pm, Hugi Thordarson wrote:
 Is it possible for me to obtain the primary key for a Cayenne DataObject 
 before committing changes? I’m writing an audit log and I need the key 
 for the object during PrePersist (where I’m constructing the log object).

 How will it have a primary key before the record is written to the 
 database? Or do you want to hang onto the temporary ObjectId and then 
 replace it with the real PK after the commit?

 Ari


 --
 --
 Aristedes Maniatis
 GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

 
 

-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Obtain primary key for DataObject before commitChanges

2015-08-10 Thread Aristedes Maniatis
On 10/08/2015 8:31pm, Hugi Thordarson wrote:
 Is it possible for me to obtain the primary key for a Cayenne DataObject 
 before committing changes? I’m writing an audit log and I need the key for 
 the object during PrePersist (where I’m constructing the log object).

How will it have a primary key before the record is written to the database? Or 
do you want to hang onto the temporary ObjectId and then replace it with the 
real PK after the commit?

Ari


-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Cayenne design Patterns

2015-06-12 Thread Aristedes Maniatis
On 12/06/2015 6:01pm, Andrus Adamchik wrote:
 To summarize, both domain-centric and service-centric architectures have 
 their advantages and downsides. In an ideal world there should be just the 
 right mix of the two. Achieving that can be hard sometimes, and the actual 
 proportion depends on the scope of the system and the tools that you have in 
 your possession. 

I'm really liking Groovy these days. It has a concept of categories which 
allow you to inject additional methods right into your domain objects.

http://docs.groovy-lang.org/latest/html/gapi/groovy/lang/Category.html

I'm still getting my head around how that changes the architecture of systems, 
but the ease of mixing groovy inside Java applications is allowing us to 
explore aspects of this right now. For example, to enhance Cayenne objects when 
passing them into JasperReports for printing.


If Dima is lurking around here, he'll have more to say since I know he is 
liking the groovy approach.

Cheers

Ari

-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: LinkETL - soliciting naming ideas

2015-06-11 Thread Aristedes Maniatis
On 12/06/2015 12:48am, Andrus Adamchik wrote:
 Now we realized that ETL in the name is wrong, as it has data warehouse 
 connotations. So looking for another name for this project. All the most 
 obvious names (e.g. 'datapump) are already taken by various commercial and 
 open source projects. So I figured we may croudsource the name selection :) 
 So asking the community for the naming ideas...

I have a friend who does ETL and it sounds like exactly the sort of thing he'd 
use. Why is ETL not a suitable choice?

Are you wanting something to tie into the LinkREST brand? 

* LinkRouter
* LinkShip
* LinkLoad


Ari



-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: cayenne 4.0

2015-04-27 Thread Aristedes Maniatis
On 28/04/2015 5:57am, Markus Reich wrote:
 looks good, how to I get the dataMap?
 I have two Maps in my Configuration?

ObjectContext - EntityResolver - DataMaps

-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: cayenne 4.0

2015-04-26 Thread Aristedes Maniatis
Something like:

for (DbEntity dbEntity : dataMap.getDbEntities()) {
   dbEntity.setSchema(schema);
}

On 27/04/2015 7:35am, Markus Reich wrote:
 Hi,
 
 is it possible with cayenne 4.0 to use a dynamic data map?
 
 I have following requirement:
 
 I have a db scheme that is fix for all users.
 I habe a second dynamic scheme where the entities are equal, just the
 scheme names is dynamic?
 
 regards
 Meex
 

-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


lightweight object fetching

2015-04-15 Thread Aristedes Maniatis
Cayenne has very nice functionality for paging large lists of objects, so that 
the list is mostly hollow objects which are retrieved in a lazy fashion as they 
are accessed.

This works well to fetch 100,000 contacts in a list and only draw the ones 
visible to the user as they scroll. What works less well is the common use case 
of a list view where you might only want to show several attributes of a large 
record.

So a list of contacts might show just:

* firstName
* lastName
* totalSales

To fetch this data requires a query on contact with a prefetch to invoices. 
Lots of data being loaded from two or more tables and potentially a bit slow.

Some options:

1. Use DataRows. This is simple, but you lose some of the nice modelling/entity 
features from Cayenne. You have to type all the columns yourself.

2. Create a view in the database with just three columns (plus a PK) and create 
a separate read-only Cayenne model which maps to that view. But now you are 
hardcoding your application to a specific database and changing the 
representation is hard.

I want something half way between the two. SQLtemplate to fetch only the 
columns or aggregates I need, but mapped to some sort of read-only lightweight 
Cayenne entity.


Has anyone tried something like this?


Ari



-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Post Fetch Filter?

2015-02-03 Thread Aristedes Maniatis
On 4/02/2015 11:07am, Joe Baldwin wrote:
 Is there a reasonable method to filter a result set (from a SelectQuery) - 
 without re-fetching from the database?  

You are looking for this I think:

https://cayenne.apache.org/docs/3.0/in-memory-evaluation.html


 For example - in analogy, it is possible to sort-order post query.

Well they are just objects, so you can use any standard Java ordering.


Ari



-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Closing Cayennes' DataContext

2015-01-08 Thread Aristedes Maniatis
On 9/01/2015 4:03am, Michael Gentry wrote:
 Also, what kind of load do you have on your system?  Our connection pools
 are rarely larger than 25-50 and work just fine.  10,000 connections smells
 to me of a larger problem.

I agree. I read an interesting article about the tradeoff between queuing and 
threading. That is, if you get lots of requests are you better creating lots 
and lots of threads to handle them all concurrently, or queuing the requests 
(eg. by having a connection pool of only about 30 connections) and handling 
them 30 at a time.

The author of the article I can't right now find was of the opinion that most 
people have way too many connections in their pool. The number of connections 
should be closer (within an order of magnitude) to the number of cores in the 
CPU. For example, mysql creates a separate unix thread for every connection and 
that scales poorly over about 60. I think this is improved in mysql 5.7, but 
I've not tried it. [1]

Ari



[1] http://dev.mysql.com/doc/refman/5.6/en/thread-pool-plugin.html

-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Closing Cayennes' DataContext

2015-01-04 Thread Aristedes Maniatis
I use a connection pool from the application container (tomcat in my case). 
That might give you more choice and flexibility. I presume if you are using 
JSP, then you are using tomcat, jetty or one of their friends.

Ari


On 4/01/2015 3:14pm, jonathan_ms2006 wrote:
 Hi Aristedes,
 
 That's a good tip, from now on I will set MySQL max_connection
 attributes greater than cayennes' connection pool (dataNodeDriver.xml). But
 still I think this will not resolve the issue, there must be a way wherein
 cayennes' DataContext class should strategically close unused database
 connections. 
 
 Lately I was thinking if we can replicate using cayennes' DataContext
 the traditional way of connecting Java to MySQL wherein programmatically
 we're setting the JDBC driver, MySQL login credentials, MySQL port number,
 etc. in a java class and then strategically we close unused or idle
 connection/s to avoid such error as mentioned on this thread.
 
 Also if there's a way where cayennes' DataContext (open connection) can
 be re-used instead opening a new one every time a JSP page loads.? Any ideas
 on this will be much appreciated. :))
 
 Best Regards,
 
 Jonathan
 
 
 
 
 
 
 --
 View this message in context: 
 http://cayenne.195.n3.nabble.com/Closing-Cayennes-DataContext-tp4026629p4026633.html
 Sent from the Cayenne - User mailing list archive at Nabble.com.
 

-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Closing Cayennes' DataContext

2015-01-03 Thread Aristedes Maniatis
10,000 is a pretty high number. The default is about 150. It may be that mysql 
isn't able to cope with that many settings.

Also, you should always have more connections available in your database than 
you configure in your connection pool, otherwise you are going to run into 
problems when you connect to your database for admin purposes, backups, or 
other things.

Ari


On 4/01/2015 1:37am, jonathan_ms2006 wrote:
 Hi Michael,
 
 In my cayenne NodeDriver.xml file, I have configured a connection pool
 that goes like this:
 connectionPool min=1 max=1/. Obviously I allowed 1 maximum
 number or simultaneous connections.
 
 On MySQL server installation directory (my.ini), I have configured
 max_connections attribute to 1 same with my connection pool defined in
 cayennes' dataNodeDriver.xml while the rest of my.ini file attributes are
 not modified upon installation.
 
 Are there other things I missed.? Many thanks.. :))
 
 Best Regards,
 
 Jonathan
 
 
 
 --
 View this message in context: 
 http://cayenne.195.n3.nabble.com/Closing-Cayennes-DataContext-tp4026629p4026631.html
 Sent from the Cayenne - User mailing list archive at Nabble.com.
 

-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Unexpected null value when prefetching with Cayenne.objectForQuery

2014-12-04 Thread Aristedes Maniatis
Did you see the documentation here: 
https://cayenne.apache.org/docs/3.0/advanced-sqltemplate.html

At any rate, I suggest that you don't use SQLTemplate unless you really need 
to. Instead, use a regular SelectQuery where you don't need to craft complex 
SQL. This will keep your code independent of database specifics.

Ari


On 3/12/2014 10:25am, Johannes wrote:
 Hello
 
 I had a problem when query for a entity with Cayenne.objectForQuery in
 the particulare case of receiving null values by addPrefetch on
 Many-to-many fields.
 
 Also postet here:
 
 https://issues.apache.org/jira/browse/CAY-1975
 
 Johannes
 

-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Updating totals in a multi-user environment

2014-10-31 Thread Aristedes Maniatis
On 31/10/2014 8:58pm, Hugi Thordarson wrote:
 Once again, I’m looking into migrating to Cayenne from EOF :). One question 
 though: Our code depends heavily on raw row fetching (data rows) that 
 traverses relationships. I haven’t looked much at the Cayenne code, but do 
 you believe adding support for this to Cayenne would be a huge undertaking? 
 Or does Cayenne perhaps provide an alternative method to achieve the same 
 results?

I'm not sure if I'm understanding correctly, but do you want to prefetch joins 
and create regular Java objects with all the joins pulled in for performance?

Or are you talking about raw data rows which are just giant maps of key-values 
with data pulled from across joins?

If that later, perhaps you can create a database view and map that to a Cayenne 
entity for read-only access. But I don't quite see the point (other than 
supporting your legacy code).

Ari


-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Cayenne+jasper reports

2014-10-30 Thread Aristedes Maniatis
For many projects you'll put the database connection details into JNDI and have 
Cayenne and anything else get it from there. Of course you might like to give 
Jasper a read-only connection.

Alternatively we wrote a layer which has Jasper access the data model through 
Cayenne. A bit of work, but it gave us some nice advantages. JasperReports can 
access javabeans as a data source.

Ari


On 31/10/2014 1:30pm, René Aravena wrote:
 With cayenne 3.1, as I can get the connection to the database to pass it to
 jasperreports?
 
 René
 

-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


ApacheCon Budapest CFP closes June 25

2014-06-12 Thread Aristedes Maniatis
As you may be aware, ApacheCon will be held this year in Budapest, on
November 17-23. (See http://apachecon.eu for more info.)

The Call For Papers for that conference is still open, but will be
closing soon. We need all kinds of talks - deep technical talks, hands-on
tutorials, introductions for beginners, or case studies about the
awesome stuff you're doing with Cayenne.

Please consider submitting a proposal, at
http://events.linuxfoundation.org//events/apachecon-europe/program/cfp

Thanks!
Ari Maniatis


-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Issue with distinct 3.1

2013-11-12 Thread Aristedes Maniatis
On 13/11/2013 3:59am, Ramiro Aparicio wrote:

 I am really not sure if current behaviour without distinct is ok, but at 
 least it works for me.

Cayenne returns a collection of objects that will never have duplicates. In 
fact you can choose whether the results return as a Set, List or Map.

Ari





-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Removing use shared cache option

2013-11-03 Thread Aristedes Maniatis
We experimented with that option and unticking it caused expected behaviour 
that was quite hard to understand. Particularly in how it inter-related to the 
object cache. Dima is the person who knows all the details of that experiment.

I certainly remember thinking to myself never uncheck that option.

Ari



On 4/11/2013 5:36pm, Andrus Adamchik wrote:
 Hi everyone,
 
 I’ve been considering removing support for “Use Shared Cache” checkbox from 
 the Modeler and for the corresponding code in the framework. This is about a 
 strategy for a *snapshot* cache that is used to save a DB trip when resolving 
 to-one relationships or checking a previously committed state of a modified 
 object. The alternative (i.e. when it is unchecked, and a per-context cache 
 is used) is not very useful IMO and the need to support both strategies 
 results in lots of dirty code. 
 
 Now I am wondering have anyone ever unchecked that checkbox, and if so, what 
 was the reason?
 
 Also if you have no idea what I am talking about, it also answers my question 
 :)
 
 Thanks,
 Andrus
 

-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: RelationshipQuery

2013-10-02 Thread Aristedes Maniatis
On 3/10/13 12:50am, do...@xsinet.co.za wrote:
 Anyway with reference to question 1. performQuery returns a list, but I
 need the Map  ?


1. Open cayenne modeler

2. Choose the Java entity you want

3. Go to relationships and click on the relationship you want to model

4. Click the little I in the toolbar at the top

5. In the ObjRelationship inspector now open, change the collection type to 
List, Collection, Map, or Set.


Ari



-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Cayenne modeler (multiple windows)

2013-08-07 Thread Aristedes Maniatis
Hi Tony

That's brilliant. The process is really quite simple. Firstly, let's take this 
conversation over to the dev list (and just reply to that list).

Next, make sure you are working from the trunk code in svn [1] or use github if 
you prefer [2]. The end results of work should then ideally be either some 
patches on github which can be reviewed, or a single patch file against svn. 
Obviously it is important that you put the appropriate Apache license headers 
into any files you create, so that your work can be merged.

Regards
Ari


[1] http://svn.apache.org/repos/asf/cayenne/main/trunk/
[2] https://github.com/apache/cayenne/tree/trunk



On 8/08/13 12:49pm, Tony Giaccone wrote:
 If you're looking for an engineer to do this work. I'd be willing to put
 some time into it. I'd need some guidance what to modify, but I'd be
 willing to commit to do the work. I used to work with Mike Gentry, so he
 can vouch for my engineering skills, such as they are.
 
 Tony
 
 
 On Wed, Aug 7, 2013 at 6:43 AM, Andrus Adamchik and...@objectstyle.orgwrote:
 
 Not extremely hard, but this is certainly not a 2 hour project.


 On Aug 7, 2013, at 12:25 PM, Tony Giaccone t...@giaccone.org wrote:

 How hard would it be to modify the modeler to do that?


 Tony


 On Tue, Aug 6, 2013 at 7:44 AM, Andrus Adamchik and...@objectstyle.org
 wrote:

 FWIW, I'd also like to be able to open multiple projects, although for a
 different reason. I have a number of projects in a single system that
 I'd
 like to work with simultaneously.

 Andrus

 On Aug 6, 2013, at 2:39 PM, Tony Giaccone tgiacc...@gmail.com wrote:

 Yeah it's possible, but.. The whole point of the modeler is to shield
 people from having to hand edit XML and because the modeler does that so
 well it means that average developers aren't familiar with the XML
 structure and options.

 Being able to open two models at the same time seems like a pretty
 reasonable thing to be able to do.

 Tony

 On Aug 6, 2013, at 1:18 AM, Aristedes Maniatis a...@maniatis.org
 wrote:

 Don't forget that the model is just XML, so you can diff that
 directly.
 And applications like Oxygen can diff XML ignoring whitespace and
 changes
 in element ordering.

 Ari

 On 6/08/13 2:17pm, Tony Giaccone wrote:
 One thing that became very clear is that it would be really nice,
 really,
 really nice to be able to open two (or more) projects in the modeler
 at the
 same time. It's exceptionally difficult to do comparisons between
 attributes and relationships in two different models when you have to
 close
 one model to open the other. I ended up doing screen captures to
 compare
 one to the live open project. This worked but was exceptionally
 painful.

 --
 --
 Aristedes Maniatis
 GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A





 

-- 
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Which Cayenne Version to use ?

2013-07-23 Thread Aristedes Maniatis

On 23/07/13 5:57pm, Malcolm Edgar wrote:

The quality of Cayenne is extremely high, so I am not concerned about the
label we give the release, but I want understand peoples experience with
3.1, is it ready for prime time?


I've been using 3.1 in production ever since 3.1M1. We are just now thinking 
about getting 3.2M1 into our development so that we move it into production in 
the next three months. This is for six web applications and one ROP Swing 
application used by about 300 internal people in total across multiple 
organisations (plus taking 250,000 enrolments per year from the general public).

We've had a small number of issues in Cayenne, but almost always us bumping up 
against features we'd like to have rather than bugs.

Ari


--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


caching questions

2013-07-01 Thread Aristedes Maniatis

Hi Andrus

I know you have been looking at this offline, but I thought I'd raise this here 
in public to see if others can also help shed light on a difficult area to 
completely understand in Cayenne. Perhaps this conversation can also help us 
improve the docs. I'd like to better understand the interactions between the 
DataRowStore and the ObjectStore.

Here is how I understand the Cayenne object cache:

1. There is a checkbox in the modeler at the top level for use shared cache. 
If that checkbox is ticked, then a single DataRowStore (a LRU map) is created, shared 
between all contexts. If not, a separate DataRowStore is created every time you create a 
new context.

2. Each context has its own ObjectStore for keeping the actual objects (the 
snapshot), and another copy of the object with any changes made in that 
context. Any queries to the database fill the DataRowStore first, and then the 
objects are constructed in to the ObjectStore.

3. When a commit is made to Context A, the ObjectStore linked to context A has 
a bunch of changes in it. Those changes are pushed into the DataRowStore, and 
then into the database. Events are are sent to update the snapshot copy of 
objects held in all other ObjectStores.

4. These events can even be sent to another Java VM, but we'll ignore that for 
now.

5. The modeler has a field called Size of object cache. This refers to the 
size of the DataRowStore map as a count of objects. Because the rows could be 1kB or 1Mb 
each, it is impossible to predict how large this cache will grow to, but it will get 
bigger and smaller over time.

6. If use shared cache is NOT ticked, then this size is used for *each* of 
the DataRowStore maps. This means that the memory usage will grow very rapidly as you add 
new contexts and fill them with data. 100 contexts, each loaded with a query that fetches 
the same 10Mb of data, will contain 1000Mb of DataRowStore memory usage.

6. If a DataRow is not held in the DataRowStore (eg, because it was pushed out 
of the map by newer data) then an event is NOT sent to the other contexts to 
notify them that the object was updated when context A is committed. Instead 
stale data is left in those other contexts.

7. Assuming the query cache is disabled, a query against the database will 
fetch brand new objects into the DataRowStore and potentially update all the 
snapshots of all ObjectStores which contain a copy of those records.

8. A relationship join (painting.getArtist()) might find a record in the 
DataRowStore and pull it into the ObjectStore without ever going back to the 
database.

9. If the query cache is hit, then the results may already be found in the 
DataRowStore. If so, the the ObjectStore snapshot is updated from these 
DataRows if any of those objects are not already found in the ObjectStore.


So, my questions:

A. What is the use case of separate DataRowStores per context? It appears to be a worse 
possible scenario in every case I can think of, with no upside. The label use 
shared cache gives the impression that you are trading memory usage for staleness 
of data, but that does not appear to be the case.

B. Is it an intrinsic feature of this system that a cache miss in the 
DataRowStore causes no event to be sent to other ObjectStores, or is that a 
bug? This means that setting the 'size of object cache' in the modeler to 0 
results in a lot of stale data.

C. Will a cache miss in the DataRowStore cause Cayenne to refetch that object 
from the database before it then tries to commit the changes to that object.



Have I captured the above notes correctly?


Cheers
Ari





--
--
Aristedes 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: Scale out

2013-05-30 Thread Aristedes Maniatis

On 30/05/13 4:33pm, Andrus Adamchik wrote:

* Don't try to sync individual objects. You can't cluster that well (whatever 
Terracotta might claim, there are issues beyond transferring object state).


Yes, and one more thing to think about: what happens when you upgrade an 
instance on your cluster to a new version of the application. You'll end up 
with serialisation errors for objects which are different versions as they are 
synced between instances. So you will need to end up with at least two groups 
of clusters, each with their own backing cache, and upgrade each group as a set.

This is the same problem as having distributed sessions (rather than sticky 
sessions) and I've not ever found a good solution for it. But with a 
distributed cache the problem is even worse.


Ari


--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Scale out

2013-05-29 Thread Aristedes Maniatis

On 29/05/13 8:14pm, Christian Grobmeier wrote:

My concern is the Cayenne caching mostly. What if
App1 is doing an update and the next requests select from App2?


No one can answer this other than you. What does happen?

Are you writing an ecommerce system where data has to be fresh to the 
millisecond? Or does data need to be consistent per user/session? If the 
latter, sticky sessions will help you. If the former, you may need to remove 
the cache entirely or use a distributed cache like Terracotta [1]

From my own experience with distributed caching, it can get very complicated 
very quickly. Luckily we were able to avoid all caching in the critical parts 
of the application, and plenty of non-distributed caching in the other parts 
where performance was critical but 20 minutes of staleness was OK.

Ari


[1] 
http://www.ehcache.org/documentation/2.4/terracotta/distributed-caching-with-terracotta

--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: ROP security

2013-05-16 Thread Aristedes Maniatis

On 17/05/13 1:01am, John Huss wrote:

Here's some code we started on to do this kind of thing.  It never made it
to production, but it was close.  This just defines some methods that can
be overridden to implement security based on your specific requirements.

https://www.dropbox.com/s/g247uxpalps5xse/AuthHessianService.java


Thanks that very interesting.




One thing I have found cumbersome is inspecting SelectQuery objects to
figure out what they are - because SelectQuery.getRoot() returns plain
Object you have to screw around to figure out what it really is.  Also
inspecting the qualifier is a little difficult, but generally that's not a
great idea anyway - better to just add things to the qualifier even if it
results in duplicate clauses.



In my case I also want to prevent users from deleting objects they should not 
be able to. So I can deal with that with a mixture of validation rules in the 
entities themselves and preventing SQLtemplate from being able to be used from 
the client.


Ari





John

On Wed, May 15, 2013 at 6:49 PM, Aristedes Maniatis a...@ish.com.au wrote:


We have a ROP Cayenne application we'd like to lock down a bit more
tightly. In particular, in a situation where we don't trust the client
application hasn't been hacked, we'd like to restrict certain activity from
the client. I'm thinking of:

1. preventing SQLTemplate/EJBQL queries completely
2. adding entity listeners to catch certain write behaviour (we can't do a
lot about reading data since that's easy to do at the controller level, on
the client, but pretty hard to construct rules at the model level on the
server)
3. creating 'partial' object entities which are missing some attributes.
Sort of hollow, but only hollow on some attributes.


Has anyone attempted anything similar to the above? (2) should be easy
enough, but not sure about the other requirements.


Cheers
Ari




--
--
Aristedes 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





--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


ROP security

2013-05-15 Thread Aristedes Maniatis

We have a ROP Cayenne application we'd like to lock down a bit more tightly. In 
particular, in a situation where we don't trust the client application hasn't 
been hacked, we'd like to restrict certain activity from the client. I'm 
thinking of:

1. preventing SQLTemplate/EJBQL queries completely
2. adding entity listeners to catch certain write behaviour (we can't do a lot 
about reading data since that's easy to do at the controller level, on the 
client, but pretty hard to construct rules at the model level on the server)
3. creating 'partial' object entities which are missing some attributes. Sort 
of hollow, but only hollow on some attributes.


Has anyone attempted anything similar to the above? (2) should be easy enough, 
but not sure about the other requirements.


Cheers
Ari




--
--
Aristedes 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: Relationship

2013-04-23 Thread Aristedes Maniatis

So what you are doing is creating a polymorphic join. One Cayenne way to model 
this is with inheritance and I've discussed this approach before:

http://markmail.org/message/6xdboo2ygrcmp6p3

Ari

On 23/04/13 11:21pm, Markus Reich wrote:

ok, e.g. I have a table comments with following columns
ID   = Unique key of table comments
OBJECT  = Not null, identifies the entity the comment is for
OBJECTID   = Not null, key of the entity
COMMENT  = Comments as VARCHAR

example data
1  ORDER  12345  This is a comment for order 12345
2  ORDER  56789  This is a comment for order 56789
3  BILLING 1  This is a comment for the billing 1

Now there's a table orders and a table billings (both have a unique ID
column), so I want relationships like
SELECT * FROM order JOIN comments ON comments.OBJECT = 'ORDER' AND
comments.ID = order.ID
and
SELECT * FROM billings JOIN comments ON comments.OBJECT = 'BILLING' AND
comments.ID = billing.ID

Meex









2013/4/23 Mike Kienenberger mkien...@gmail.com


I don't quite understand the question you are asking.

Can you give us an example of what you are trying to do with your
comment table?   Some code using your desired mapping would be best.


On Tue, Apr 23, 2013 at 12:49 AM, Markus Reich
markus.re...@markusreich.at wrote:

Hi,

with the wonderful Cayenne Modeler it's possible to easily create

relations

between DB entities.
In my case I have a central table for comments, with a key specifying the
content.
No I need to map this key field to a constant literal, as I know it is

just

possible to join fields with fields of the target entity :-(
Is there a workaround (I don't like to make a lot of views an join them

;-))


regards
Meex








--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Multiple isolated cayenne runtimes... (Cayenne = 3.1)

2013-04-22 Thread Aristedes Maniatis

I agree, multi-tenant databases are easy to implement with a qualifier in the 
model.  Here is a previous similar conversation.

   http://cayenne.195.n3.nabble.com/Multi-tenancy-Implementation-td4024468.html

Ari


On 21/04/13 1:32am, Bob Harner wrote:

A quick and possibly unwelcome answer: *don't* have a different database
for each project. That is almost always a bad idea, IMHO -- completely
unscalable and ten times more work over the life of the app. Have only a
single database, possibly with sharding if needed..

Think of it this way: Google doesn't have a different database for each
Gmail user.
On Apr 20, 2013 4:40 AM, Daniel Scheibe dscheib...@googlemail.com wrote:


All,

what would a possible scenario of running multiple isolated Cayenne
instances, actually quite the opposite of grouping multiple nodes under a
domain. Let's say i have multiple datasources all pointing to different
databases on different servers where every 'project' is completely isolated
from all others, there is no shared data between those. At first sight i
was asking myself if i should just setup and run multiple ServerRuntimes,
would this even be possible? Would this be a valid approach?

The configuration of 0..n projects should possibly be changeable at
runtime too with a higher level 'ProjectManager' that i would have to
implement to steer the runtimes.

Thanks for your thoughts!

Cheers,
Daniel






--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: cayenne in central repo?

2013-04-15 Thread Aristedes Maniatis

On 16/04/13 3:28pm, Robert Zeigler wrote:

So I just checked the central maven repo for cayenne and the latest version 
there is 3.1M3… but we're voting on 3.2M1, which ought to mean that 3.1 has 
been released. Is 3.1 available in any maven repo?



3.1 has not yet been released. We are moving toward the final betas and 
hopefully any public bug reports will get it polished off soon.

3.1 is in its own branch so trunk is tracking toward 3.2.

Ari



--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Docs evolving

2013-02-22 Thread Aristedes Maniatis

On 22/02/13 8:51pm, Erlend Birkenes wrote:

2013/2/21 Aristedes Maniatis a...@maniatis.org


On 22/02/13 12:04am, Andrus Adamchik wrote:


Good question. I am not even sure who maintains this Fisheye instance.
Ari, do you know maybe?



I set it up years ago. I'll go a see if it needs poking.



Thanks. It is linked to from JIRA so I think it should be kept up to date.



From what I can see that entire instance of Fisheye stopped indexing new 
content several weeks ago. It isn't just our project.

I tried to notify them, but their public Jira instance has a problem that 
prevents me logging in... I think their sysadmins are having a bad week and 
need a bit of time.

Ari




--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


partially hollow objects

2013-02-14 Thread Aristedes Maniatis

In our Cayenne ROP application we have some tables with very large BLOB fields. 
We want to be able to fetch the remaining columns to the client, without the 
BLOBs. I am after some ideas on how to best approach this:


1. Create two tables and two Cayenne Java entities to match

Cons: makes the code and database messy since we are dealing with one-to-one 
relationships where there isn't really any logical relation


2. Create one database table and use single-table inheritance: the superclass 
(say 'Painting') has all the fields and the subclass ('PaintingInfo') only the 
lightweight fields

Cons: the code is still messy since casting a PaintingInfo to Painting (should 
you want to view the BLOB) isn't really possible. You would have to get the PK 
and then perform another full fetch on the parent. And I'd be concerned about 
having two objects in memory at the same time which point to the same data, but 
aren't synchronised to each other.


3. Devise some mechanism for Cayenne to have not just hollow objects (like what 
happens with paged queries) but hollow attributes. Then we only lazily fetch 
the attribute data when it is needed (if at all). This could be ROP specific 
(that is, the BLOB attributes are fully fetched from the database but not sent 
to the client until needed) or perhaps this approach would also be useful in a 
non-ROP environment for lazily loading columns.



Any thoughts from people who have run into similar issues? I'd like to avoid 
DataRows and all that since that just makes the code really messy again.



Ari



--
--
Aristedes 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: hazelcast - serialVersionUID or not?

2013-02-05 Thread Aristedes Maniatis

On 6/02/13 2:19am, Tore Halset wrote:

Should we add serialVersionUID to our CayenneDataObject subclasses or not? So 
far, I have added it to some of the CDOs.. It is working fine, but upgrades to 
a new version that might change the generated serialVersionUID might lead to 
java.io.InvalidClassException ... local class incompatible error.

So, what is best practice for serializing CDOs across changes to the class?



Doesn't this just depend on which error you'd like to get:

option 1: change the serial number when the classes change in some way: you get 
InvalidClassException. Your code can catch this and invalidate the session.

option 2: don't change the serial number and hope that Java will unserialise 
your class properly even if you have made a change to the class attributes. 
From my experience this tends to work just fine if you only add attributes and 
breaks horribly if you change or remove any. But from what I remember, you get 
a InvalidClassException anyway.


To my mind, setting the serialVersionUID to some fixed arbitrary number and 
never changing it has no real downsides unless you need to detect subtle 
changes to the class and deliberately throw an exception when the session is 
'upgraded'. And if you use sticky sessions then the user will be moved from the 
old instance to the new only when you shut down the old one (and then not 
randomly back to another old instance).


How are you finding hazelcast? I tinkered with Terracotta but never got it into 
production.

Ari


--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: spatial operations with selectQuery

2013-01-29 Thread Aristedes Maniatis

On 29/01/13 8:54pm, Rafael López Torres wrote:

SQLTemplate sqlQuery = new SQLTemplate(
 Recinto.class,
 SELECT 
 + #result('t1.ID_RECINTO_ALFANUM' 'Long' '' 
'toRecintoAlfanum.ID_RECINTO_ALFANUM'), 
 + #result('t2.ID_RECINTO_GEOM' 'Long' '' 
'toRecintoGeom.ID_RECINTO_GEOM'), 
 + #result('t2.SD_GEOM' 
'com.vividsolutions.jts.geom.Geometry' ) 
 + FROM SGPCD_RECINTOS t0, SGPCD_RECINTOS_ALFNUM t1, 
SGPCD_RECINTOS_GEOM t2 
 + WHERE t0.ID_RECINTO_ALFANUM = t1.ID_RECINTO_ALFANUM 
AND 
 +  t0.ID_RECINTO_GEOM = t2.ID_RECINTO_GEOM AND 
 + t0.IU_IL_RECINTO=23747616);


 sqlQuery.addPrefetch(toRecintoAlfanum);


Someone else who uses SQLtemplates more than me might be able to correct me on 
this, but I don't think prefetch is going to work along with SQLtemplate. It is 
designed to work with a normal Cayenne query and probably isn't going to be 
able to munge the SQL to add the extra join. The error message could be clearer 
though.

I don't know MS-SQL, but could you achieve a similar result by using a view and 
then a SelectQuery? Alternatively you might be able to edit the database 
adapter to support additional data types.


Ari


--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Add ActiveRecord support to Cayenne

2012-12-26 Thread Aristedes Maniatis

On 23/12/12 3:52pm, Дробеня Илья wrote:

 From my estimates - we spent on development ~ 1 week, if
during year this feature do not will be used by anybody - we may remove it.
What do you think?


Sure, as long as you keep this as a wrapper outside of Cayenne itself. Although 
measuring usage in an open source library is extremely hard, there is value is 
creating more options for users.

Perhaps I misunderstood your idea... would your wrapper create a singleton 
Context that lives for the life of the application or one per persisted object?

Ari

--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Add ActiveRecord support to Cayenne

2012-12-26 Thread Aristedes Maniatis

On 26/12/12 11:40am, Andrus Adamchik wrote:

Ilya's point that we discussed a bit offline was that AR-like design is more 
object-oriented, with object providing all operations on themselves. The context will be 
taken from the current thread (something we already provide). One piece of theory behind 
it is a reference to the Fowler's criticism of anemic domain 
model:http://en.wikipedia.org/wiki/Anemic_domain_model  .


I find this quite interesting. One problem we are trying to solve on our 
project right now is bringing together logic between the client and server 
entities in a ROP system. Because Cayenne entities inherit from different 
superclasses (what's with that?), it is very hard to keep the business logic in 
a one place.

Anemic models are all very well, but what do you do with the code? It seems 
that all the options available to us aren't terribly convenient to use. We 
either end up with zillions of interfaces or lots of static methods.

AR is the opposite of anemic. All the Rails projects I've seen tend to throw 
lots of code into the model. But because Ruby uses duck-typing instead of 
interfaces, things don't get quite so messy. Even searching is rooted in the 
model classes:

   Artist.find(:name, bob).sort(:age)

or something like that.

Ari

--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Add ActiveRecord support to Cayenne

2012-12-26 Thread Aristedes Maniatis

On 26/12/12 6:48pm, Дробеня Илья wrote:

This is the best OOP design. And for me need to separate context only when
we need anvanced features that do not possible in current design.


Let's take:

a.delete()
b.delete()
a.commitChanges()

Are there two separate contexts there so I committed only the 'a' deletion? Or 
is there one shared context across the application, so I committed both 
deletions?

b.newInstance();
a.setFriend(b);
a.commitChanges();

Will that work in your API? Do I need to commit b first? What if I have a 
foreign key constraint?


The idea of the fluent query API (as per Rails) is very attractive. The idea of 
hiding Context not as much (to me). In Rails lots of code looks like this:

ActiveRecord::Base.transaction do
  b.save
  a.friend = b
  a.save
end

Although a Cayenne context is more than just a transaction, it also solves the 
problem that Rails would use a transaction for. How will you do that?



Ari


--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Add ActiveRecord support to Cayenne

2012-12-23 Thread Aristedes Maniatis

On 20/12/12 4:18am, Andrus Adamchik wrote:

Now in Ruby (which I barely know) I suppose ActiveRecord is such a great RAD 
technology, because when you control the DB, you can sort of avoid (or 
minimize) the*mapping*  step.


To an extent. ActiveRecord (and most of Rails) is configuration by convention. So, 
primary keys are always named id. Foreign keys have special names pointing to 
the table. You can add something similar to annotations to the persisted entities if you 
want to change the defaults.

Interestingly, there is still a schema.rb which looks just like a dictionary 
for the database entities (including indexes). Rails generates it for you from 
the database as you work, but it is still there.


In Cayenne you still need to do the mapping. Once you did it, our current or 
planned API could be as friendly as it gets.


There is a lot to be learnt from ActiveRecord's fluent API. So easy to read and 
very concise. Some of that clean API comes from the abilities of Ruby itself 
(which Java cannot accomplish).

But I can't quite see the point of hiding the concept of Contexts from the 
user. Most users new to Cayenne will understand what 'database transaction' 
means and quickly understand Context as a similar idea. If we hide context from 
the user in this API, does this throw an exception? Or is localObject() 
implicit in every setter?

Artist a = Artist.newInstance();
a.setName(Bob);
a.save()

Painting p = Painting.newInstance();
p.setArtist(a);
p.save();



Ari


--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Problem in fetching the data from multiple tables with relationships.

2012-12-14 Thread Aristedes Maniatis

On 13/12/12 7:32pm, Sampath Uppula wrote:

Please look at the following solution... I had implemented for similar scenario.
In the below code, I am able to fetch all the data from the relationships tables. But the 
problem is I am forced to hardcode the return types (ListRole ListLOB ...).
Because of that I am not able to develop a strategic solution.

In other words the requirement is,
Depends on the requirement, columns in the criteria and columns in the fetch 
will be different. How can I achieve this using cayenne?
Hope you understand my problem now.


Not really. You asked for a solution to a problem which was fetching data and 
following relations. Note that your prefetches are not needed, they are only a 
way to improve performance in some situations.

Nothing in Cayenne forces you to specify the specific entity in the generics. You can 
treat the List as PersistentObject and handle it how you choose.


Ari



--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Fetching and processing a large amount of objects

2012-12-12 Thread Aristedes Maniatis

On 13/12/12 12:18am, Simon Schneider wrote:

Hi list,

my task is to fetch and process a large amount of objects. Reading the 
documentation my best choice
seemed to do a dataContext.performIteratedQuery(query). The problem is that I 
get a Java Heap Space
error, on executing this statement. Now it seems to me the problem is that 
performIteratedQuery loads
all data into a ResultSet.
My question is how to handle such cases, is there any best practice? Would it 
be ok to use a paginated
query. Then unregistering processed objects from the DataContext they belong to 
and also removing
them from the array that resulted from the paginated query.


By the time you step through to the end of the results, even with a paginated 
query you will have read every object into RAM. However paginated queries are a 
really convenient way to fetch even millions of rows where you don't 
necessarily want to access every object (eg. when you want to display a 
scrollable list of results and you only need to resolve the objects you can see 
in the current viewport).

As Michael says, an option is to read in the data in batches into different 
Contexts.

Ari
 


--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Problem in fetching the data from multiple tables with relationships.

2012-12-12 Thread Aristedes Maniatis

If you really want to use Cayenne for the power it gives you, rather than 
writing SQL, I recommend you work your way through the tutorials. Yes, you can 
use SQLTemplate. No, that's probably not what you want to do here.

At its heart, your query is just um.ID = 112. Start by making that work in 
Cayenne using a simple select query. Just fetch one um object. And then follow 
the relations from that object to the other objects and properties you need.

resultUM.getUA().getRole()

And remember, that rarely in Cayenne will you want to fetch or query on primary 
keys. Yes, it will sometimes be needed, but mostly you let Cayenne handle that 
for you behind the scenes.


Ari



On 13/12/12 6:14pm, Sampath Uppula wrote:

Hi John,
Thanks for the reply.
For the below query, can you provide a sample using SQLTemplate?

1. how to use the SQLTemplate to execute the below query?
SELECT um.ID,
um.FIRST_NAME,
um.LAST_NAME,
ua.ROLE_ID,
tt.TASK_ASSIGNED_DATE,
tt.TASK_CLOSED_DATE,
tt.TASK_MASTER_ID
   FROM t_user_master um,
t_user_allocation_details ua,
t_task_assignment_detail ta,
t_task_transaction_detail tt
  WHERE um.ID = ua.USER_ID
AND ta.USER_ID = um.ID
AND ta.TASK_TRANSACTION_ID = tt.ID
AND um.ID = 112;
2. how to read the data from the result set or List?

Appreciate your help.

Thanks,
Sampath Uppula



-Original Message-
From: John Huss [mailto:johnth...@gmail.com]
Sent: Thursday, December 13, 2012 2:50 AM
To: user@cayenne.apache.org
Subject: Re: Problem in fetching the data from multiple tables with 
relationships.

I'm not really sure what your question is.  Cayenne will fetch all of the
fields that are modeled and turn them into objects.  And you can add
prefetching paths to your SelectQuery to pre-fetch the related objects,
otherwise they will be loaded when accessed.  If you want to write your own
SQL and get a HashMap of the data you can use SQLTemplate instead of
SelectQuery.

John

Disclaimer:
  This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy 
statement, you may review the policy at a 
href=http://www.techmahindra.com/Disclaimer.html;http://www.techmahindra.com/Disclaimer.html/a 
externally and a 
href=http://tim.techmahindra.com/tim/disclaimer.html;http://tim.techmahindra.com/tim/disclaimer.html/a
 internally within Tech 
Mahindra.



--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Date cast exception

2012-11-26 Thread Aristedes Maniatis

Could you try grabbing the source of Cayenne and running the test suite in Java 
8? I don't know what any of the developers has tried that yet. There have 
certainly been inconsistencies in the past in the JDBC libraries between 
different versions of Java.

https://cayenne.apache.org/building-cayenne.html


I see that JSR-310 [1] is finally scheduled to land in Java 8. I wonder if that 
is related to your problem?


Ari


[1] https://github.com/ThreeTen/threeten


On 26/11/12 8:35pm, do...@xsinet.co.za wrote:

Over the weekend I tried running my app with jdk1.8 ea and found that some
of the methods (in the auto package classes) that return a sql.Date then
throw a class cast exception complaining that it can't cast util.Date to
sql.Date !?

However the app works fine in jdk1.7 ?

It appears that the different java versions are returning a different
object for readProperty:

jdk1.7  returns  sql.Date
jdk1.8  returns  util.Date

Has anybody experienced something like this ?

Thanks.



--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: adding new columns to table

2012-11-24 Thread Aristedes Maniatis

Also liquibase is really good, especially if you support multiple database 
types.

Ari


On 25/11/12 9:08am, Juan José Gil wrote:

wouldn't be better to use something like flyway? http://flywaydb.org/


2012/11/24 John Huss johnth...@gmail.com


There is an experimental library in the cayenne-sandbox you could try:
http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-migrations/

I'm using it in production, but your mileage may vary.  The migrations are
not automatically generated (except for the initial database) but they are
easy to write.


On Sat, Nov 24, 2012 at 10:59 AM, emeka okafor emeka_1...@yahoo.com
wrote:


Is there a cayenne way to modifying a databse table? Like a way for
cayenne to generate a migration class that can be run when when my schema
changes.






--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: check for changes before commit

2012-11-23 Thread Aristedes Maniatis

On 23/11/12 10:22pm, devnull2...@gmx.de wrote:

BTW: Where could I find the schema for the map?
The link on the cayenne website doesn't work:
http://cayenne.apache.org/schema/3.0/modelMap.html
-- Not Found
Same forhttp://cayenne.apache.org/schema/3.0/modelMap.xsd


H good catch. That needs to be added to our site again. It was lost in 
the CMS transition.


Ari



--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: check for changes before commit

2012-11-23 Thread Aristedes Maniatis

On 23/11/12 10:30pm, Aristedes Maniatis wrote:

On 23/11/12 10:22pm, devnull2...@gmx.de wrote:

BTW: Where could I find the schema for the map?
The link on the cayenne website doesn't work:
http://cayenne.apache.org/schema/3.0/modelMap.html
-- Not Found
Same forhttp://cayenne.apache.org/schema/3.0/modelMap.xsd


H good catch. That needs to be added to our site again. It was lost in 
the CMS transition.



Fixed.


Ari


--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: testing with cayenne

2012-11-10 Thread Aristedes Maniatis

On 10/11/12 10:04am, emeka okafor wrote:

New cayenne user here. I am trying to use cayenne as the orm for an application 
and I was wondering how you guys write your unit test? do you test with a real 
database or do you have predefined mock objectcontext and son on to be able to 
write performant test?


One approach that can work is http://www.dbunit.org/ with an in memory database 
like Derby. Basically it makes it easy to fire up a database, inject a bunch of 
known data and then run your tests.


Ari



--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Cayenne website

2012-11-08 Thread Aristedes Maniatis

The Cayenne website is all shiny and new! Yes it looks the same on the outside, 
but is now generated in a whole new way using the Apache CMS system.

What does that mean to you, the user of Cayenne? Well, not too much. However if 
you see any missing images or broken links, or anything else, please let us 
know and we'll get them fixed.

You can now use https://cayenne.apache.org for all your browsing pleasure, for 
a secure and encrypted experience.


Cheers

Ari


--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: setToOneTarget not works for two transient objects (3.1B1)

2012-11-07 Thread Aristedes Maniatis

It all depends. One usage pattern is to create a long lived read-only context 
which handles the bulk of data in the application which is not editable by users. Then 
you'll use localObject to copy objects into a new context as needed (perhaps a shopping 
basket in a web application).

In my thick client ROP application, we have one shared context used for all the 
list views (not editable). But when a user double clicks on a row, we create a 
new editing context into which they will save any changes. They might have 10 
windows open at once, so we we have 10 contexts. When they save a window, we 
save the context and throw the whole thing away.

We also create child contexts for 'sheets'. (Think OSX style dialogs which are 
modal within a window).

For web applications, having a single context which lasts as long as the 
session is probably quite a common pattern.

Ari



On 7/11/12 8:31pm, Garth Keesler wrote:

Is the general case that a context typically lasts as long as the transaction, 
gets discarded, and a new one is created for the next transaction or is it 
dependent on usage in the program? For example, a web app as discussed here 
discards contexts based on user interactions while a thick client app would 
tend to reuse the same context.

Just curious...
Garth

On 11/07/2012 12:51 AM, Aristedes Maniatis wrote:

On 7/11/12 4:57pm, Alexey Katorgin wrote:


You should always create a context and then create objects within that context

using the methods Cayenne

gives you. This is different to the undecorated POJO that Hibernate allows you

to create.


Ari




I develop a web-app and if I will create entities bounded to a dataContext, and
after user has leaved the page (by browser navigation buttons, closing the tab,
etc.) such entities will stay uncommitted and may be in inconsistency state
(user has not filled all required fields). And on the next commit this objects
will be committed and raise validation exception.

It is the reason why I want to use unbounded dataObjects.

So I've decide to use transient objects not bounded to any dataContext. In this
case such object just be removed by garbage collector after user leaved page
unexpectedly. And where user will click OK, such objects will be manually
attached to a dataContext and committed.

It makes my code less clearly if can't set relationships between transient
objects. Because I need to create additional temporary lists to store all
transient entities and iterate its to register to a dataContext before
committing.


What is the best practice for this use case?



Typically you bind a context to the user session so that the user can continue 
to navigate through the site and not lose the work they have done but not yet 
saved. For example, they may assemble a shopping basket, contact details and 
payment information. Then you commit the whole thing atomically at the end.

Don't think of a data context as something you create when you are ready to 
save. Think of it as a big bucket into which you put all the objects you are 
working with. At the end, throw it away and make a new one, or commit it to the 
database. For more complex arrangements read up on how to create parent/child 
contexts, but you don't need to do that here. Start simple.

Make as many contexts as you need to have buckets of different information.


Ari






--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: setToOneTarget not works for two transient objects (3.1B1)

2012-11-07 Thread Aristedes Maniatis

On 7/11/12 9:42pm, Garth Keesler wrote:

Interesting. So your ROP App is shared read, per user write. Right? In that 
case, can multiple users be changing the same object from the read-only context 
or do you move the object to the dedicated writable context?


In this case, we take a copy of the object (or just fetch a fresh copy from the 
database) into a new context.



This would seem to place the work of concurrency back on the database, correct? 
Is this a requirement with Cayenne, much as it was with Ibatis (now Mybatis)? I 
guess my REAL question is this: Is Cayenne designed to be an Object Manager or 
an Object Relational Mapper, particularly in the ROP environment where multiple 
users interact with the same server app simultaneously?



I don't really understand the question, but in any complex system you need to 
think about data caching and staleness of data plus concurrency issues. Will 
you optimistically lock your objects or add a pessimistic locking strategy?  
The tools are all there to solve these issues, but the solutions depend on your 
needs.


Ari





I've done a lot of reading about Cayenne but this remains unclear to me.

Thanx,
Garth

On 11/07/2012 04:22 AM, Aristedes Maniatis wrote:

It all depends. One usage pattern is to create a long lived read-only context 
which handles the bulk of data in the application which is not editable by users. Then 
you'll use localObject to copy objects into a new context as needed (perhaps a shopping 
basket in a web application).

In my thick client ROP application, we have one shared context used for all the 
list views (not editable). But when a user double clicks on a row, we create a 
new editing context into which they will save any changes. They might have 10 
windows open at once, so we we have 10 contexts. When they save a window, we 
save the context and throw the whole thing away.

We also create child contexts for 'sheets'. (Think OSX style dialogs which are 
modal within a window).

For web applications, having a single context which lasts as long as the 
session is probably quite a common pattern.

Ari



On 7/11/12 8:31pm, Garth Keesler wrote:

Is the general case that a context typically lasts as long as the transaction, 
gets discarded, and a new one is created for the next transaction or is it 
dependent on usage in the program? For example, a web app as discussed here 
discards contexts based on user interactions while a thick client app would 
tend to reuse the same context.

Just curious...
Garth

On 11/07/2012 12:51 AM, Aristedes Maniatis wrote:

On 7/11/12 4:57pm, Alexey Katorgin wrote:


You should always create a context and then create objects within that context

using the methods Cayenne

gives you. This is different to the undecorated POJO that Hibernate allows you

to create.


Ari




I develop a web-app and if I will create entities bounded to a dataContext, and
after user has leaved the page (by browser navigation buttons, closing the tab,
etc.) such entities will stay uncommitted and may be in inconsistency state
(user has not filled all required fields). And on the next commit this objects
will be committed and raise validation exception.

It is the reason why I want to use unbounded dataObjects.

So I've decide to use transient objects not bounded to any dataContext. In this
case such object just be removed by garbage collector after user leaved page
unexpectedly. And where user will click OK, such objects will be manually
attached to a dataContext and committed.

It makes my code less clearly if can't set relationships between transient
objects. Because I need to create additional temporary lists to store all
transient entities and iterate its to register to a dataContext before
committing.


What is the best practice for this use case?



Typically you bind a context to the user session so that the user can continue 
to navigate through the site and not lose the work they have done but not yet 
saved. For example, they may assemble a shopping basket, contact details and 
payment information. Then you commit the whole thing atomically at the end.

Don't think of a data context as something you create when you are ready to 
save. Think of it as a big bucket into which you put all the objects you are 
working with. At the end, throw it away and make a new one, or commit it to the 
database. For more complex arrangements read up on how to create parent/child 
contexts, but you don't need to do that here. Start simple.

Make as many contexts as you need to have buckets of different information.


Ari










--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


Re: Class Relation vs Foreign Key

2012-11-06 Thread Aristedes Maniatis

On 6/11/12 9:05pm, Garth Keesler wrote:

Should/must the name used when defining a relation between classes in Modeler 
be the same as the name used when defining a foreign key in the database? As a 
follow-up, does Cayenne even use FKs or does it depend on its own class 
definitions and indexes in the database to accomplish this?  This is in 
hand-coded class definitions instead of generating the classes from the 
database schema. If FKs are used, how is the correlation between relations and 
foreign keys made or does Cayenne depend on the database software to use the 
appropriate foreign key automagically?



A Foreign Key in a database is usually nothing more than an index with a 
constraint. That is, there is nothing special about the key other than some 
constraint to prevent invalid data creeping in.

Cayenne uses whichever keys you define in the model in order to define its 
joins and it doesn't know anything about the constraints you added to the SQL 
database. You don't need to tell the database about these keys at all, although 
it is usually a good idea to have validation (constraints) both in Cayenne and 
in the database itself. And of course if you don't have an index in the 
database at all, the joins may be quite slow.

Remember that when you start using inheritance in Cayenne, the concept of a 
join between Java objects will no longer map to a simple join between a FK and 
PK in two tables. But Cayenne takes care of everything for you.


Ari



--
--
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


  1   2   3   4   >