Return-Path: X-Original-To: apmail-cayenne-commits-archive@www.apache.org Delivered-To: apmail-cayenne-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5CF81DEAD for ; Thu, 20 Dec 2012 08:06:54 +0000 (UTC) Received: (qmail 9068 invoked by uid 500); 20 Dec 2012 08:06:54 -0000 Delivered-To: apmail-cayenne-commits-archive@cayenne.apache.org Received: (qmail 9021 invoked by uid 500); 20 Dec 2012 08:06:53 -0000 Mailing-List: contact commits-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list commits@cayenne.apache.org Received: (qmail 8993 invoked by uid 99); 20 Dec 2012 08:06:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Dec 2012 08:06:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Dec 2012 08:06:48 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8024E23888CD; Thu, 20 Dec 2012 08:06:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1424358 - in /cayenne/main/trunk/docs/docbook: cayenne-guide/src/docbkx/ css/ getting-started-rop/src/docbkx/ getting-started/src/docbkx/ stylesheets/ upgrade-guide/src/docbkx/ Date: Thu, 20 Dec 2012 08:06:27 -0000 To: commits@cayenne.apache.org From: aadamchik@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121220080628.8024E23888CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: aadamchik Date: Thu Dec 20 08:06:26 2012 New Revision: 1424358 URL: http://svn.apache.org/viewvc?rev=1424358&view=rev Log: CAY-1733 update docs patch by Ilya Drabenia Added: cayenne/main/trunk/docs/docbook/css/highlight.css cayenne/main/trunk/docs/docbook/stylesheets/highlight.xsl Modified: cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/customizing-cayenne-runtime.xml cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/expressions.xml cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/including-cayenne-in-project.xml cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/orderings.xml cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/performance-tuning.xml cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/persistent-objects-objectcontext.xml cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/queries.xml cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/starting-cayenne.xml cayenne/main/trunk/docs/docbook/css/cayenne-doc.css cayenne/main/trunk/docs/docbook/getting-started-rop/src/docbkx/authentification.xml cayenne/main/trunk/docs/docbook/getting-started-rop/src/docbkx/client-code.xml cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/delete.xml cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/object-context.xml cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/persistent-objects.xml cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/select-query.xml cayenne/main/trunk/docs/docbook/stylesheets/common-customizations.xsl cayenne/main/trunk/docs/docbook/stylesheets/html.xsl cayenne/main/trunk/docs/docbook/upgrade-guide/src/docbkx/new-features.xml Modified: cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/customizing-cayenne-runtime.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/customizing-cayenne-runtime.xml?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/customizing-cayenne-runtime.xml (original) +++ cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/customizing-cayenne-runtime.xml Thu Dec 20 08:06:26 2012 @@ -34,13 +34,13 @@ To have a working DI container, we need three things: service interfaces and classes, a module that describes service bindings, a container that loads the module, and resolves the depedencies. Let's start with service interfaces and - classes:public interface Service1 { + classes:public interface Service1 { public String getString(); -}public interface Service2 { +}public interface Service2 { public int getInt(); } A service implementation using instance variable - injection:public class Service1Impl implements Service1 { + injection:public class Service1Impl implements Service1 { @Inject private Service2 service2; @@ -49,7 +49,7 @@ } }Same thing, but using constructor - injection:public class Service1Impl implements Service1 { + injection:public class Service1Impl implements Service1 { private Service2 service2; @@ -61,7 +61,7 @@ return service2.getInt() + "_Service1Impl"; } } -public class Service2Impl implements Service2 { +public class Service2Impl implements Service2 { private int i; public int getInt() { @@ -77,7 +77,7 @@ object representing service interface. Here is a module that binds Service1 and Service2 to corresponding default implementations: - public class Module1 implements Module { + public class Module1 implements Module { public void configure(Binder binder) { binder.bind(Service1.class).to(Service1Impl.class); @@ -87,22 +87,22 @@ Once we have at least one module, we can create a DI container. org.apache.cayenne.di.Injector is the container class in - Cayenne:Injector injector = DIBootstrap.createInjector(new Module1()); + Cayenne:Injector injector = DIBootstrap.createInjector(new Module1()); Now that we have created the container, we can obtain services from it and call their - methods:Service1 s1 = injector.getInstance(Service1.class); + methods:Service1 s1 = injector.getInstance(Service1.class); for (int i = 0; i < 5; i++) { System.out.println("S1 String: " + s1.getString()); } This outputs the following lines, demonstrating that s1 was Service1Impl and Service2 injected into it was - Service2Impl:0_Service1Impl + Service2Impl:0_Service1Impl 1_Service1Impl 2_Service1Impl 3_Service1Impl 4_Service1Impl There are more flavors of bindings: - // binding to instance - allowing user to create and configure instance + // binding to instance - allowing user to create and configure instance // inside the module class binder.bind(Service2.class).toInstance(new Service2Impl()); @@ -140,7 +140,7 @@ binder.bind(Key.get(Service2.class, "i2" etc. Another useful scope is "no scope", meaning that every time a container is asked to provide a service instance for a given key, a new instance will be created and - returned:binder.bind(Service2.class).to(Service2Impl.class).withoutScope();Users + returned:binder.bind(Service2.class).to(Service2Impl.class).withoutScope();Users can also create their own scopes, e.g. a web application request scope or a session scope. Most often than not custom scopes can be created as instances of org.apache.cayenne.di.spi.DefaultScope with startup and shutdown @@ -173,7 +173,7 @@ binder.bind(Key.get(Service2.class, "i2" public void configure(Binder binder) { // customizations go here... } -}Module extensions = new MyExtensionsModule(); +}Module extensions = new MyExtensionsModule(); ServerRuntime runtime = new ServerRuntime("com/example/cayenne-mydomain.xml", extensions);
@@ -206,13 +206,13 @@ ServerRuntime runtime = may contribute an instance of custom DbAdapterDetector to a org.apache.cayenne.configuration.server.DefaultDbAdapterFactory.detectors list: - public class MyDbAdapterDetector implements DbAdapterDetector { + public class MyDbAdapterDetector implements DbAdapterDetector { public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException { // check if we support this database and retun custom adapter ... } } - // since build-in list for this key is a singleton, repeated + // since build-in list for this key is a singleton, repeated // calls to 'bindList' will return the same instance binder.bindList(DefaultDbAdapterFactory.DETECTORS_LIST) .add(MyDbAdapterDetector.class); @@ -233,7 +233,7 @@ binder.bindList(DefaultDbAdapterFactory. implementation of this service is provided by MapQueryCacheProvider. But if we want to use EhCacheQueryCache (a Cayenne wrapper for the EhCache framework), we can define it like - this:binder.bind(QueryCache.class).to(EhCacheQueryCache.class); + this:binder.bind(QueryCache.class).to(EhCacheQueryCache.class);
Modified: cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/expressions.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/expressions.xml?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/expressions.xml (original) +++ cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/expressions.xml Thu Dec 20 08:06:26 2012 @@ -195,7 +195,7 @@ Expression qualifier1 = template.expWith general examples and some gotchas. The following code recreates the expression from the previous chapter, but now using expression - API:// String expression: name like 'A%' and price < 1000 + API:// String expression: name like 'A%' and price < 1000 Expression e1 = ExpressionFactory.likeExp(Painting.NAME_PROPERTY, "A%"); Expression e2 = ExpressionFactory.lessExp(Painting.PRICE_PROPERTY, 1000); Expression finalExp = e1.andExp(e2); This @@ -211,7 +211,7 @@ Expression finalExp = e1.andExp(e2);

Expression matchAllExp(String path, Collection values) + needed:Expression matchAllExp(String path, Collection values) Expression matchAllExp(String path, Object... values)
"Path" argument to both of these methods can use a split character (a pipe symbol '|') instead of dot to indicate that relationship following a path should be split into a @@ -227,16 +227,16 @@ Expression matchAllExp(String path, Obje is done by the database engine. However the same expressions can also be used for accessing object properties, calculating values, in-memory filtering. Checking whether an object satisfies an - expression:Expression e = ExpressionFactory.inExp(User.NAME_PROPERTY, "John", "Bob"); + expression:Expression e = ExpressionFactory.inExp(User.NAME_PROPERTY, "John", "Bob"); User user = ... if(e.match(user)) { ... }Reading property - value:Expression e = Expression.fromString(User.NAME_PROPERTY); + value:Expression e = Expression.fromString(User.NAME_PROPERTY); String name = e.evaluate(user); Filtering a list of - objects:Expression e = ExpressionFactory.inExp(User.NAME_PROPERTY, "John", "Bob"); + objects:Expression e = ExpressionFactory.inExp(User.NAME_PROPERTY, "John", "Bob"); List<User> unfiltered = ... List<User> filtered = e.filterObjects(unfiltered); Modified: cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/including-cayenne-in-project.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/including-cayenne-in-project.xml?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/including-cayenne-in-project.xml (original) +++ cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/including-cayenne-in-project.xml Thu Dec 20 08:06:26 2012 @@ -65,6 +65,7 @@ By creating custom templates, you can use cgen to generate other output (such as web pages, reports, specialized code templates) based on DataMap information. +
@@ -94,6 +95,8 @@
cgen required parameters
+
+
@@ -210,7 +213,9 @@ package. -
cgen optional parameters
Example - a typical class generation scenario, where pairs of classes are + +
+ Example - a typical class generation scenario, where pairs of classes are generated, and superclasses are placed in a separate package: <plugin> <groupId>org.apache.cayenne.plugins</groupId> Modified: cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/orderings.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/orderings.xml?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/orderings.xml (original) +++ cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/orderings.xml Thu Dec 20 08:06:26 2012 @@ -4,11 +4,11 @@ Orderings An Ordering object defines how a list of objects should be ordered. Orderings are essentially path expressions combined with a sorting strategy. Creating an Ordering: - Ordering o = new Ordering(Painting.NAME_PROPERTY, SortOrder.ASENDING); + Ordering o = new Ordering(Painting.NAME_PROPERTY, SortOrder.ASENDING);
Like expressions, orderings are translated into SQL as parts of queries (and the sorting occurs in the database). Also like expressions, orderings can be used in memory, naturally - to sort - objects:Ordering o = new Ordering(Painting.NAME_PROPERTY, SortOrder.ASCENDING_INSENSITIVE); + objects:Ordering o = new Ordering(Painting.NAME_PROPERTY, SortOrder.ASCENDING_INSENSITIVE); List<Painting> list = ... o.orderList(list);Note that unlike filtering with Expressions, ordering is performed in-place. This list object is Modified: cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/performance-tuning.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/performance-tuning.xml?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/performance-tuning.xml (original) +++ cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/performance-tuning.xml Thu Dec 20 08:06:26 2012 @@ -10,7 +10,7 @@ chapter, as it is a powerful performance optimization method. Another common application of prefetching is for refreshing stale object relationships. Prefetching example: - SelectQuery query = new SelectQuery(Artist.class); + SelectQuery query = new SelectQuery(Artist.class); // this instructs Cayenne to prefetch one of Artist's relationships query.addPrefetch("paintings"); @@ -20,9 +20,9 @@ query.addPrefetch("paintings"); List<Artist> artists = context.performQuery(query); All types of relationships can be preftetched - to-one, to-many, flattened. A prefetch can span multiple relationships: - query.addPrefetch("paintings.gallery"); + query.addPrefetch("paintings.gallery");
A query can have multiple - prefetches:query.addPrefetch("paintings"); + prefetches:query.addPrefetch("paintings"); query.addPrefetch("paintings.gallery"); If a query is fetching DataRows, all "disjoint" prefetches are ignored, only "joint" prefetches are executed (see prefetching semantics discussion below for what disjoint and @@ -35,14 +35,14 @@ query.addPrefetch("paintings.gallery"); query root objects with related objects fully resolved. However semantics can affect preformance, in some cases significantly. There are 3 types of prefetch semantics, all defined as constants in - org.apache.cayenne.query.PrefetchTreeNode:PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS + org.apache.cayenne.query.PrefetchTreeNode:PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS PrefetchTreeNode.DISJOINT_PREFETCH_SEMANTICS PrefetchTreeNode.DISJOINT_BY_ID_PREFETCH_SEMANTICS Each query has a default prefetch semantics, so generally users do not have to worry about changing it, except when performance is a concern, or a few special cases when a default sematics can't produce the correct result. SelectQuery uses DISJOINT_PREFETCH_SEMANTICS by default. Semantics can be changed as - follows:SelectQuery query = new SelectQuery(Artist.class); + follows:SelectQuery query = new SelectQuery(Artist.class); query.addPrefetch("paintings").setSemantics( PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS); There's no limitation on mixing different types of semantics in the same Modified: cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/persistent-objects-objectcontext.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/persistent-objects-objectcontext.xml?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/persistent-objects-objectcontext.xml (original) +++ cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/persistent-objects-objectcontext.xml Thu Dec 20 08:06:26 2012 @@ -7,7 +7,7 @@ ObjectContext is an interface that users normally work with to access the database. It provides the API to execute database operations and to manage persistent objects. A context is obtained from the - ServerRuntime:ObjectContext context = runtime.getContext(); + ServerRuntime:ObjectContext context = runtime.getContext(); The call above creates a new instance of ObjectContext that can access the database via this runtime. ObjectContext is a single "work area" in Cayenne, storing persistent objects. ObjectContext guarantees that for each database row with a unique ID it will contain at @@ -94,7 +94,7 @@ One of the first things users usually want to do with an ObjectContext is to select some objects from a database. This is done by calling "performQuery" - method:SelectQuery query = new SelectQuery(Artist.class); + method:SelectQuery query = new SelectQuery(Artist.class); List<Artist> artists = context.performQuery(query);We'll discuss queries in some detail in the following chapters. The example above is self-explanatory - we create a SelectQuery that matches all Artist objects present in @@ -103,34 +103,34 @@ List<Artist> artists = context.perfor database. For such queries ObjectContext provides "performGenericQuery"method. While not nearly as commonly-used as "performQuery", it is nevertheless important in some situations. - E.g.:Collection<Query> queries = ... // multiple queries that need to be run together + E.g.:Collection<Query> queries = ... // multiple queries that need to be run together QueryChain query = new QueryChain(queries); QueryResponse response = context.performGenericQuery(query); An application might modify selected objects. E.g.: - Artist selectedArtist = artists.get(0); + Artist selectedArtist = artists.get(0); selectedArtist.setName("Dali"); The first time the object property is changed, the object's state is automatically set to "MODIFIED" by Cayenne. Cayenne tracks all in-memory changes until a user calls "commitChanges":context.commitChanges();At + >commitChanges":context.commitChanges();At this point all in-memory changes are analyzed and a minimal set of SQL statements is issued in a single transaction to synchronize the database with the in-memory state. In our example "commitChanges" commits just one object, but generally it can be any number of objects. If instead of commit, we wanted to reset all changed objects to the previously committed state, we'd call rollbackChanges - instead:context.rollbackChanges(); + instead:context.rollbackChanges(); "newObject" method call creates a persistent object and sets its state to - "NEW":Artist newArtist = context.newObject(Artist.class); + "NEW":Artist newArtist = context.newObject(Artist.class); newArtist.setName("Picasso"); It will only exist in memory until "commitChanges" is issued. On commit Cayenne might generate a new primary key (unless a user set it explicitly, or a PK was inferred from a relationship) and issue an INSERT SQL statement to permanently store the object. deleteObjects method takes one or more Persistent objects and marks them as - "DELETED":context.deleteObjects(artist1); + "DELETED":context.deleteObjects(artist1); context.deleteObjects(artist2, artist3, artist4);Additionally "deleteObjects" processes all delete rules modeled for the affected objects. This may result in implicitly deleting or modifying extra related objects. Same as insert and @@ -143,11 +143,11 @@ context.deleteObjects(artist2, artist3, common operation. E.g. to improve performance a user might utilize a single shared context to select and cache data, and then occasionally transfer some selected objects to another context to modify and commit - them:ObjectContext editingContext = runtime.getContext(); + them:ObjectContext editingContext = runtime.getContext(); Artist localArtist = editingContext.localObject(artist); Often an appliction needs to inspect mapping metadata. This information is stored in the EntityResolver object, accessible via the - ObjectContext:EntityResolver resolver = objectContext.getEntityResolver(); + ObjectContext:EntityResolver resolver = objectContext.getEntityResolver(); Here we discussed the most commonly used subset of the ObjectContext API. There are other useful methods, e.g. those allowing to inspect registered objects state en bulk, etc. Check the latest JavaDocs for details. @@ -158,12 +158,12 @@ Artist localArtist = editingContext.loca "org.apache.cayenne.Cayenne") that builds on ObjectContext API to provide a number of very common operations. E.g. get a primary key (most entities do not model PK as an object property) - :long pk = Cayenne.longPKForObject(artist); + :long pk = Cayenne.longPKForObject(artist); It also provides the reverse operation - finding an object given a known - PK:Artist artist = Cayenne.objectForPK(context, Artist.class, 34579); + PK:Artist artist = Cayenne.objectForPK(context, Artist.class, 34579); If a query is expected to return 0 or 1 object, Cayenne helper class can be used to find this object. It throws an exception if more than one object matched the - query:Artist artist = (Artist) Cayenne.objectForQuery(context, new SelectQuery(Artist.class)); + query:Artist artist = (Artist) Cayenne.objectForQuery(context, new SelectQuery(Artist.class)); Feel free to explore Cayenne class API for other useful methods.
@@ -185,18 +185,18 @@ Artist localArtist = editingContext.loca separate JVM and communicates with its parent via a web service. ROP is discussed in details in the following chapters. Here we concentrate on the same-VM nesting. To create a nested context, use an instance of ServerRuntime, passing it the desired - parent:ObjectContext parent = runtime.getContext(); + parent:ObjectContext parent = runtime.getContext(); ObjectContext nested = runtime.getContext((DataChannel) parent);From here a nested context operates just like a regular context (you can perform queries, create and delete objects, etc.). The only difference is that commit and rollback operations can either be limited to synchronization with the parent, or cascade all the way to the - database:// merges nested context changes into the parent context + database:// merges nested context changes into the parent context nested.commitChangesToParent(); // regular 'commitChanges' cascades commit through the chain // of parent contexts all the way to the database -nested.commitChanges();// unrolls all local changes, getting context in a state identical to parent +nested.commitChanges();// unrolls all local changes, getting context in a state identical to parent nested.rollbackChangesLocally(); // regular 'rollbackChanges' cascades rollback through the chain of contexts @@ -215,17 +215,17 @@ nested.rollbackChanges(); When creating a new generic object, either cast your ObjectContext to DataContext (that provides "newObject(String)" API), or provide your object with an explicit - ObjectId:DataObject generic = ((DataContext) context).newObject("GenericEntity");DataObject generic = new CayenneDataObject(); + ObjectId:DataObject generic = ((DataContext) context).newObject("GenericEntity");DataObject generic = new CayenneDataObject(); generic.setObjectId(new ObjectId("GenericEntity")); context.registerNewObject(generic);SelectQuery for generic object should be created passing entity name String in constructor, instead of a Java - class:SelectQuery query = new SelectQuery("GenericEntity");Use + class:SelectQuery query = new SelectQuery("GenericEntity");Use DataObject API to access and modify properties of a generic - object:String name = (String) generic.readProperty("name"); + object:String name = (String) generic.readProperty("name"); generic.writeProperty("name", "New Name");This is how an application can obtain entity name of a generic - object:String entityName = generic.getObjectId().getEntityName(); + object:String entityName = generic.getObjectId().getEntityName();
Transactions @@ -243,7 +243,7 @@ generic.writeProperty("name", "New Name" If you are using an EJB container (or some other JTA environment), you'll likely need to switch Cayenne runtime into "external transactions mode". This is either done in the Modeler (check DataDomain > 'Container-Managed Transactions' checkbox), or in the - code:runtime.getDataDomain().setUsingExternalTransactions(true);In + code:runtime.getDataDomain().setUsingExternalTransactions(true);In this case Cayenne assumes that JDBC Connections obtained by runtime whenever that might happen are all coming from a transactional DataSource managed by the container. In this case Cayenne does not attempt to commit or rollback the connections, leaving it up to @@ -253,7 +253,7 @@ generic.writeProperty("name", "New Name" rolled back together in case of failure. This can be done with an explicit thread-bound transaction that surrounds a set of operations. Application is responsible for committing or rolling it - back:Transaction tx = runtime.getDataDomain().createTransaction(); + back:Transaction tx = runtime.getDataDomain().createTransaction(); Transaction.bindThreadTransaction(tx); try { Modified: cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/queries.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/queries.xml?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/queries.xml (original) +++ cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/queries.xml Thu Dec 20 08:06:26 2012 @@ -25,7 +25,7 @@ SelectQuery SelectQuery is the most commonly used query in user applications. It returns a list of persistent objects of a certain type specified in the - query:SelectQuery query = new SelectQuery(Artist.class); + query:SelectQuery query = new SelectQuery(Artist.class); List<Artist> objects = context.performQuery(query);This returned all rows in the "ARTIST" table. If the logs were turned on, you might see the following SQL @@ -35,7 +35,7 @@ INFO: === returned 5 row. - took 5 ms.SelectQuery query = new SelectQuery(Artist.class, + SelectQuery query = new SelectQuery(Artist.class, ExpressionFactory.likeExp(Artist.NAME_PROPERTY, "Pablo%")); List<Artist> objects = context.performQuery(query);The SQL will look different this Modified: cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/starting-cayenne.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/starting-cayenne.xml?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/starting-cayenne.xml (original) +++ cayenne/main/trunk/docs/docbook/cayenne-guide/src/docbkx/starting-cayenne.xml Thu Dec 20 08:06:26 2012 @@ -7,7 +7,7 @@ In runtime Cayenne is accessed via org.apache.cayenne.configuration.server.ServerRuntime. ServerRuntime is created simply by calling a - constructor:ServerRuntime runtime = + constructor:ServerRuntime runtime = new ServerRuntime("com/example/cayenne-project.xml"); The parameter you pass to the constructor is a location of the main project file. Location is a '/'-separated path (same path separator is used on UNIX and Windows) that is @@ -21,15 +21,15 @@ discussed in "Customizing Cayenne Runtime" chapter. Here we'll just show an example of how an application might replace a default implementation of a built-in Cayenne service (in this case - QueryCache) with a different - class:public class MyExtensionsModule implements Module { + class:public class MyExtensionsModule implements Module { public void configure(Binder binder) { binder.bind(QueryCache.class).to(EhCacheQueryCache.class); } -}Module extensions = new MyExtensionsModule(); +}Module extensions = new MyExtensionsModule(); ServerRuntime runtime = new ServerRuntime("com/example/cayenne-project.xml", extensions); It is a good idea to shut down the runtime when it is no longer needed, usually before the - application itself is shutdown: runtime.shutdown();When + application itself is shutdown: runtime.shutdown();When a runtime object has the same scope as the application, this may not be always necessary, however in some cases it is essential, and is generally considered a good practice. E.g. in a web container hot redeploy of a webapp will cause resource leaks and @@ -41,7 +41,7 @@ ServerRuntime runtime = projects and merge them together in a single configuration. This way different parts of a database can be mapped independenlty from each other (even by different software providers), and combined in runtime when assembling an application. Doing it is as easy - as passing multiple project locations to ServerRuntime constructor:ServerRuntime runtime = + as passing multiple project locations to ServerRuntime constructor:ServerRuntime runtime = new ServerRuntime(new String[] { "com/example/cayenne-project.xml", "org/foo/cayenne-library1.xml", @@ -121,7 +121,7 @@ ServerRuntime runtime = parameter. When the application runs, all HTTP requests matching the filter url-pattern will have access to a session-scoped ObjectContext like - this:ObjectContext context = BaseContext.getThreadObjectContext();Of + this:ObjectContext context = BaseContext.getThreadObjectContext();Of course the ObjectContext scope, and other behavior of the Cayenne runtime can be customized via dependency injection. For this another filter init parameter called "extra-modules" is used. "extra-modules" is a comma or space-separated list of class Modified: cayenne/main/trunk/docs/docbook/css/cayenne-doc.css URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/css/cayenne-doc.css?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/css/cayenne-doc.css (original) +++ cayenne/main/trunk/docs/docbook/css/cayenne-doc.css Thu Dec 20 08:06:26 2012 @@ -0,0 +1,113 @@ +@IMPORT url("highlight.css"); + +html { + padding: 0pt; + margin: 0pt; +} + +body { + margin-left: 10%; + margin-right: 10%; + font-family: Arial, Sans-serif; +} + +div { + margin: 0pt; +} + +p { + text-align: justify; +} + +hr { + border: 1px solid gray; + background: gray; +} + +h1,h2,h3,h4 { + color: #234623; + font-family: Arial, Sans-serif; +} + +pre { + line-height: 1.0; + color: black; + + -moz-tab-size: 4; + -o-tab-size: 4; + tab-size: 4; +} + +pre.programlisting { + font-size: 10pt; + padding: 7pt 3pt; + border: 1pt solid black; + background: #eeeeee; + clear: both; +} + +div.table { + margin: 1em; + padding: 0.5em; + text-align: center; +} + +table[frame=void] { + display: table; + width: 100%; + border: 1px black solid; + border-collapse: collapse; + border-spacing: 0; +} + +table[frame=void] td { + padding-left: 7px; + padding-right: 7px; + border: 1px black solid; +} + +table[frame=void] th { + padding-left: 7px; + padding-right: 7px; + border: 1px black solid; +} + +.sidebar { + float: right; + margin: 10px 0 10px 30px; + padding: 10px 20px 20px 20px; + width: 33%; + border: 1px solid black; + background-color: #F4F4F4; + font-size: 14px; +} + +.mediaobject { + padding-top: 30px; + padding-bottom: 30px; +} + +.legalnotice { + font-family: Verdana, Arial, helvetica, sans-serif; + font-size: 12px; + font-style: italic; +} + +p.releaseinfo { + font-size: 100%; + font-weight: bold; + font-family: Verdana, Arial, helvetica, sans-serif; + padding-top: 10px; +} + +p.pubdate { + font-size: 120%; + font-weight: bold; + font-family: Verdana, Arial, helvetica, sans-serif; +} + +span.productname { + font-size: 200%; + font-weight: bold; + font-family: Verdana, Arial, helvetica, sans-serif; +} \ No newline at end of file Added: cayenne/main/trunk/docs/docbook/css/highlight.css URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/css/highlight.css?rev=1424358&view=auto ============================================================================== --- cayenne/main/trunk/docs/docbook/css/highlight.css (added) +++ cayenne/main/trunk/docs/docbook/css/highlight.css Thu Dec 20 08:06:26 2012 @@ -0,0 +1,35 @@ +/* + code highlight CSS resemblign the Eclipse IDE default color schema + @author Costin Leau +*/ + +.hl-keyword { + color: #7F0055; + font-weight: bold; +} + +.hl-comment { + color: #3F5F5F; + font-style: italic; +} + +.hl-multiline-comment { + color: #3F5FBF; + font-style: italic; +} + +.hl-tag { + color: #3F7F7F; +} + +.hl-attribute { + color: #7F007F; +} + +.hl-value { + color: #2A00FF; +} + +.hl-string { + color: #2A00FF !important; +} \ No newline at end of file Modified: cayenne/main/trunk/docs/docbook/getting-started-rop/src/docbkx/authentification.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/getting-started-rop/src/docbkx/authentification.xml?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/getting-started-rop/src/docbkx/authentification.xml (original) +++ cayenne/main/trunk/docs/docbook/getting-started-rop/src/docbkx/authentification.xml Thu Dec 20 08:06:26 2012 @@ -83,7 +83,7 @@
Running Client with Basic Authentication If you run the client without any changes, you'll get the following error: - org.apache.cayenne.remote.hessian.HessianConnection connect + org.apache.cayenne.remote.hessian.HessianConnection connect INFO: Connecting to [http://localhost:8080/tutorial/cayenne-service] - dedicated session. org.apache.cayenne.remote.hessian.HessianConnection connect INFO: Error establishing remote session. URL - http://localhost:8080/tutorial/cayenne-service; @@ -115,7 +115,7 @@ Caused by: java.net.HttpRetryException: ... 4 more Which is exactly what you'd expect, as the client is not authenticating itself. So change the line in Main.java where we obtained an ROP connection to this: - ClientConnection connection = new HessianConnection( + ClientConnection connection = new HessianConnection( "http://localhost:8080/tutorial/cayenne-service", "cayenne-user", "secret", null); Try running again, and everything should work as before. Obviously in production Modified: cayenne/main/trunk/docs/docbook/getting-started-rop/src/docbkx/client-code.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/getting-started-rop/src/docbkx/client-code.xml?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/getting-started-rop/src/docbkx/client-code.xml (original) +++ cayenne/main/trunk/docs/docbook/getting-started-rop/src/docbkx/client-code.xml Thu Dec 20 08:06:26 2012 @@ -11,7 +11,7 @@ ObjectContext. Let's start by creating an empty Main class with the standard main() method in the client project: - package org.example.cayenne.persistent.client; + package org.example.cayenne.persistent.client; public class Main { @@ -21,7 +21,7 @@ public class Main { } Now the part that is actually different from regular Cayenne - establishing the server connection and obtaining the ObjectContext: - ClientConnection connection = new HessianConnection("http://localhost:8080/tutorial/cayenne-service"); + ClientConnection connection = new HessianConnection("http://localhost:8080/tutorial/cayenne-service"); DataChannel channel = new ClientChannel(connection, false, new DefaultEventManager(), false); ObjectContext context = new CayenneContext(channel); Note that the "channel" can be used to create as many peer ObjectContexts as needed @@ -31,7 +31,7 @@ ObjectContext context = new CayenneConte connection (or channel, or context). So now let's do the same persistent operaions that we did in the first tutorial "Main" class. Let's start by creating and saving some objects: - // creating new Artist + // creating new Artist Artist picasso = context.newObject(Artist.class); picasso.setName("Pablo Picasso"); @@ -55,7 +55,7 @@ stein.setGallery(metropolitan); // saving all the changes above context.commitChanges(); Now let's select them back: - // SelectQuery examples + // SelectQuery examples SelectQuery select1 = new SelectQuery(Painting.class); List<Painting> paintings1 = context.performQuery(select1); @@ -64,7 +64,7 @@ Expression qualifier2 = ExpressionFactor SelectQuery select2 = new SelectQuery(Painting.class, qualifier2); List<Painting> paintings2 = context.performQuery(select2); Now, delete: - Expression qualifier = ExpressionFactory.matchExp(Artist.NAME_PROPERTY, + Expression qualifier = ExpressionFactory.matchExp(Artist.NAME_PROPERTY, "Pablo Picasso"); SelectQuery selectToDelete = new SelectQuery(Artist.class, qualifier); Artist picasso = (Artist) DataObjectUtils.objectForQuery(context, Modified: cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/delete.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/delete.xml?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/delete.xml (original) +++ cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/delete.xml Thu Dec 20 08:06:26 2012 @@ -37,11 +37,11 @@ more common way in Cayenne (or ORM in general) is to get a hold of the object first, and then delete it via the context. Let's use utility class Cayenne to find an artist: - Expression qualifier = ExpressionFactory.matchExp(Artist.NAME_PROPERTY, "Pablo Picasso"); + Expression qualifier = ExpressionFactory.matchExp(Artist.NAME_PROPERTY, "Pablo Picasso"); SelectQuery select = new SelectQuery(Artist.class, qualifier); Artist picasso = (Artist) Cayenne.objectForQuery(context, select); Now let's delete the artist: - if (picasso != null) { + if (picasso != null) { context.deleteObject(picasso); context.commitChanges(); } Modified: cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/object-context.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/object-context.xml?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/object-context.xml (original) +++ cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/object-context.xml Thu Dec 20 08:06:26 2012 @@ -14,7 +14,7 @@ Create a standard "main" method to make it a runnable - class:package org.example.cayenne; + class:package org.example.cayenne; public class Main { @@ -27,7 +27,7 @@ public class Main { The first thing you need to be able to access the database is to create a ServerRuntime object (which is essentially a wrapper around Cayenne stack) and use it to obtain an instance of an - ObjectContext.package org.example.cayenne; + ObjectContext.package org.example.cayenne; import org.apache.cayenne.ObjectContext; import org.apache.cayenne.configuration.server.ServerRuntime; Modified: cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/persistent-objects.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/persistent-objects.xml?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/persistent-objects.xml (original) +++ cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/persistent-objects.xml Thu Dec 20 08:06:26 2012 @@ -18,7 +18,7 @@ Let's for instance add a utility method to the Artist class that sets Artist date of birth, taking a string argument for the date. It will be preserved even if the model changes later: - package org.example.cayenne.persistent; + package org.example.cayenne.persistent; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -60,13 +60,13 @@ public class Artist extends _Artist { role="bold">must be registered with DataContext to be persisted and to allow setting relationships with other objects. Add this code to the "main" method of the Main class: - Artist picasso = context.newObject(Artist.class); + Artist picasso = context.newObject(Artist.class); picasso.setName("Pablo Picasso"); picasso.setDateOfBirthString("18811025"); Note that at this point "picasso" object is only stored in memory and is not saved in the database. Let's continue by adding a Metropolitan Museum "Gallery" object and a few Picasso "Paintings": - Gallery metropolitan = context.newObject(Gallery.class); + Gallery metropolitan = context.newObject(Gallery.class); metropolitan.setName("Metropolitan Museum of Art"); Painting girl = context.newObject(Painting.class); @@ -78,13 +78,13 @@ stein.setName("Gertrude Stein"); - picasso.addToPaintings(girl); + picasso.addToPaintings(girl); picasso.addToPaintings(stein); girl.setGallery(metropolitan); stein.setGallery(metropolitan); Now lets save all five new objects, in a single method call: - context.commitChanges(); + context.commitChanges(); Now you can run the application again as described in the previous chapter. The new output will show a few actual DB operations: org.apache.cayenne.configuration.XMLDataChannelDescriptorLoader load Modified: cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/select-query.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/select-query.xml?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/select-query.xml (original) +++ cayenne/main/trunk/docs/docbook/getting-started/src/docbkx/select-query.xml Thu Dec 20 08:06:26 2012 @@ -16,7 +16,7 @@ Select all paintings (the code, and the log output it generates): - SelectQuery select1 = new SelectQuery(Painting.class); + SelectQuery select1 = new SelectQuery(Painting.class); List paintings1 = context.performQuery(select1); INFO: SELECT t0.GALLERY_ID, t0.ARTIST_ID, t0.NAME, t0.ID FROM PAINTING t0 INFO: === returned 2 rows. - took 18 ms. @@ -25,7 +25,7 @@ INFO: === returned 2 rows. - took 18 ms. Select paintings that start with "gi", ignoring case: - Expression qualifier2 = ExpressionFactory.likeIgnoreCaseExp( + Expression qualifier2 = ExpressionFactory.likeIgnoreCaseExp( Painting.NAME_PROPERTY, "gi%"); SelectQuery select2 = new SelectQuery(Painting.class, qualifier2); @@ -40,7 +40,7 @@ INFO: === returned 1 row. - took 18 ms.< ExpressionFactory): - Calendar c = new GregorianCalendar(); + Calendar c = new GregorianCalendar(); c.set(c.get(Calendar.YEAR) - 100, 0, 1, 0, 0, 0); Expression qualifier3 = Expression.fromString("artist.dateOfBirth < $date"); Modified: cayenne/main/trunk/docs/docbook/stylesheets/common-customizations.xsl URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/stylesheets/common-customizations.xsl?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/stylesheets/common-customizations.xsl (original) +++ cayenne/main/trunk/docs/docbook/stylesheets/common-customizations.xsl Thu Dec 20 08:06:26 2012 @@ -21,7 +21,9 @@ - + + + 1 Added: cayenne/main/trunk/docs/docbook/stylesheets/highlight.xsl URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/stylesheets/highlight.xsl?rev=1424358&view=auto ============================================================================== --- cayenne/main/trunk/docs/docbook/stylesheets/highlight.xsl (added) +++ cayenne/main/trunk/docs/docbook/stylesheets/highlight.xsl Thu Dec 20 08:06:26 2012 @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Modified: cayenne/main/trunk/docs/docbook/stylesheets/html.xsl URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/stylesheets/html.xsl?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/stylesheets/html.xsl (original) +++ cayenne/main/trunk/docs/docbook/stylesheets/html.xsl Thu Dec 20 08:06:26 2012 @@ -15,22 +15,29 @@ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations - under the License. + under the License. --> - + + version="1.0"> + + - - UTF-8 + + + UTF-8 + + + 0 + + + 0 + + 1 + + 1 - - 0 - - 0 - - 1 - 1 Modified: cayenne/main/trunk/docs/docbook/upgrade-guide/src/docbkx/new-features.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/docbook/upgrade-guide/src/docbkx/new-features.xml?rev=1424358&r1=1424357&r2=1424358&view=diff ============================================================================== --- cayenne/main/trunk/docs/docbook/upgrade-guide/src/docbkx/new-features.xml (original) +++ cayenne/main/trunk/docs/docbook/upgrade-guide/src/docbkx/new-features.xml Thu Dec 20 08:06:26 2012 @@ -64,7 +64,7 @@
Bootstrapping Cayenne in Various Environments Here is a simple example of starting a server-side Cayenne stack: - ServerRuntime runtime = new ServerRuntime("cayenne-UntitledDomain.xml"); + ServerRuntime runtime = new ServerRuntime("cayenne-UntitledDomain.xml"); For more detailed examples check the tutorials and other documentation.
@@ -95,7 +95,7 @@ scale well to complex applications, and 3.0 API for mapping the listeners is hard to use. In 3.1 you can annotate listener methods and register multiple callback methods with a single call. - // declare a listener with annotated methods + // declare a listener with annotated methods class MyListener { @PostLoad(Entity1.class) @PostPersist(Entity1.class) @@ -111,7 +111,7 @@ runtime.getChannel().getEntityResolver() Moreover, unlike JPA annotations, Cayenne allows to attach a listener to a set of entities not known to the listener upfront, but that are all annotated with some custom annotation: - class MyListener { + class MyListener { @PostLoad(entityAnnotations = CustomAnnotation.class) void postLoad(Object object) { .... @@ -126,7 +126,7 @@ runtime.getChannel().getEntityResolver() Filters are widely used by "cayenne-lifecyle" extensions and allow to build powerful custom object lifecycle-aware code. To install a filter, the following API is used: - class MyFilter implement DataChannelFilter { .. } + class MyFilter implement DataChannelFilter { .. } MyFilter filter = new MyFilter(); ServerRuntime runtime = .. @@ -135,7 +135,7 @@ runtime.getDataDomain().addFilter(filter that certain operations can be triggered by Cayenne inside the scope of filter's onQuery() or onSync() methods. To ensure annotated methods are invoked, filter registration should be combined with listener registration: - MyFilter filter = new MyFilter(); + MyFilter filter = new MyFilter(); ServerRuntime runtime = .. runtime.getDataDomain().addFilter(filter); runtime.getDataDomain().getEntityResolver().getCallbackRegistry().addListener(filter);