Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 33651 invoked from network); 2 Mar 2008 19:11:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Mar 2008 19:11:45 -0000 Received: (qmail 88040 invoked by uid 500); 2 Mar 2008 19:11:40 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 88026 invoked by uid 500); 2 Mar 2008 19:11:40 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 88014 invoked by uid 99); 2 Mar 2008 19:11:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Mar 2008 11:11:40 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.78.103.231] (HELO vorsha.objectstyle.org) (208.78.103.231) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 02 Mar 2008 19:11:05 +0000 Received: (qmail 12543 invoked from network); 2 Mar 2008 19:11:14 -0000 Received: from unknown (HELO ?IPv6:::1?) (127.0.0.1) by localhost with SMTP; 2 Mar 2008 19:11:14 -0000 Message-Id: <0048D78D-8E1A-4878-915C-7246F69A0B1F@objectstyle.org> From: Andrus Adamchik To: user@cayenne.apache.org In-Reply-To: <1204478737.14703.6.camel@monceau> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Re: Big list'o questions..... Date: Sun, 2 Mar 2008 21:11:13 +0200 References: <1204478737.14703.6.camel@monceau> X-Mailer: Apple Mail (2.919.2) X-Virus-Checked: Checked by ClamAV on apache.org On Mar 2, 2008, at 7:25 PM, Frits Jalvingh wrote: > > 1. When Cayenne accesses the database, are PreparedStatements used > (and > cached) within a single DataContext? That is: if code causes 100x the > same SQL to be generated and executed (select xxx from yyy where > id=?) > is this prepare once, cached and only executed multiple time or is it > fully created every time? PreparedStatement caching can be configured outside Cayenne at the DataSource level. Cayenne by itself doesn't do PreparedStatement caching and doesn't care about it. > 2. When Cayenne executes updates does it update the entire record or > does it only update the fields that changed? If it's the latter case: > can it be disabled to always update the full record (to allow > for statement caching - if available)? The later. This is not configurable in Cayenne. I strongly suspect that PreparedStatement caching is never a bottleneck in the case of update (and in any event, if we issue a set of different UPDATE queries for each entity, each variation can be cached just as well). If somebody can prove me wrong with some profiling data, we can reconsider the update approach. > 3. The documentation states that when you call rollbackChanges() a > transaction the DataContext state is restored to the state it had > before. Does it do this by using "copies" of the objects it has read > or is the database re-queried? Rollback is a local operation. No DB access is performed. > 4. What happens if data gets commited to the database and a > SQLException > occurs (like "duplicate key", "null in non-null column" etc? > Specifically: > 4.a Is the state of the DataContext once such an error occurs still > usable? Yes. > 4.b Are the values of a persistent object in that DataContext changed > during the commit or rolled back to some earlier state? No, but the user has a choice to do that if he wants. > 4.c Would it be possible to "fix" the values on just the objects that > "failed" in the same context and commit again? Yes. > 5. When using "nested" DataContext, if you commit to the "upper" > DataContext I expect that the changes are only propagated to the > Object > Store in that upper context, not to the database. Is that correct? It can be done both ways. 'commitChangesToParent' vs. 'commitChanges'. > 6. The current implementation uses generated base classes to contain > Cayenne-specific code. JPA implementations need something like > bytecode-generation (proxies) to add code to persistent classes > as JPA-defined classes need no platform-specific base class. So I > assume > that the JPA variant of Cayenne will have something like that. Yes. > Are there > plans to extend this to the Cayenne-specific interface? > I would not want to use JPA because it sucks bigtime, but having clean > classes is a wish. (enhanced) POJO without JPA is in the plans (and partially works already). But this is not a high priority. > 7. The project is currently busy supporting the JPA standard. Is it > the > vision of this project to become a JPA provider mainly and deprecate > the > own interfaces? No, absolutely no plans to deprecate Cayenne API. The goal is to keep both API's on top of the same (existing) Cayenne stack as first class citizens. > 8. If I would select Cayenne for my project I would need to add some > features to it. The reason is that I will access an already-existing > legacy database with lots of oddities like triggers and stuff. > Specifically: > a. I would need to add an alternative version of "Optimistic locking" > where a specific field in the database would hold a timestamp or > version > number. This number should be maintained by Cayenne i.e. incremented > as > soon as Cayenne inserts/updates the record. It would also be used in > the > where for updates/deletes exactly like the current optimistic locking > mechanism to check for changes at that time. We are implementing an auto-incrementing version as a part of JPA alignment. So this is coming. > b. I would need support for database-generated fields at update and > insert time. I must be able to mark fields as "generated at update, > generated at insert or both". Cayenne should retrieve these fields > after inserting/updating a record to keep the Object representation > in-sync with the database. For some databases this would require a > "select after update"; You can achieve that with JPA-like lifecycle callbacks (that are available in Cayenne outside JPA) - POST_UPDATE, POST_PERSIST. > other databases (Oracle, Postgresql) can return > the changed fields in the same statement (insert xxxx returning yyy). Hmm... does it get passed over JDBC back to the client, and if so, do you have a JDBC example? (I know that even the standard callback via 'Statement.getGeneratedKeys()' still doesn't work with many drivers). > c. Both these changes require that all generated fields get copied and > stored within a database commit so that the original values (before > the > commit) can be restored when flushing data to the database fails; this > is needed to keep the DataContext consistent after a commit failure. As far as restoring the DataContext state, Cayenne should be able to that. Andrus