<?xml version="1.0" encoding="UTF-8"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at
 
 http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "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.   
-->
<chapter id="features_and_limitations">
  <title>Features and Limitations</title>
    
  <section id="Features">
       <title>Salient Features</title>
         <para>
         The primary objective of Slice is to make building distributed database 
         applications with OpenJPA simple. 
         </para>
         <section><title>Transparency</title>
            <para>
              The existing application or the persistent domain model requires 
              <emphasis>no change</emphasis> to upgrade from a single database 
              to a distributed database environment. 
            </para>
         </section>
         <section><title>Custom Data Distribution Policy</title>
            <para>
             User application decides how the newly persistent instances be 
             distributed across multiple database slices. The data
             distribution policy across the slices may be based on the attribute 
             of the data itself. For example, all Customer whose first name begins with
             character 'A' to 'M' will be stored in one database while names
             beginning with 'N' to 'Z' will be stored in another slice. It is
             also common to find data distribution policies based on temporal
             attributes.
             </para>
             <para> 
             Slice tracks the original database for existing instances. When
             an application issues a query, the instances may be loaded from
             from different database slices. This tracking is important as 
             update to any instance gets committed to the appropriate database. 
            </para>
         </section>
         
         <section><title>Heterogeneous Database</title>
            <para> 
              Each slice can be configured independently with its own JDBC 
              driver. Hence data can be distributed across heterogeneous 
              databases. 
            </para>
         </section>
         
         <section><title>Parallel Execution</title>
            <para> 
              All database operations such as query, commit or flush operates
              in parallel across the database slices. 
            </para>
         </section>
         
         <section>
            <title>Sorted Query Result</title>
            <para>
                The query result that includes <code>ORDER BY</code> clause are
                sorted correctly by merging results from each individual slice. 
            </para>
         </section>
         
         <section><title>Distributed Transaction</title>
            <para> 
            The database slices participate in a global transaction provided
            each slice is configured with a XA-complaint JDBC driver, even
            when the persistence unit is configured for <code>RESOURCE_LOCAL</code>
            transaction.
            </para>
            <para>
            <warning>
            If any of the configured slices are non-XA-complaint <emphasis>and</emphasis> 
            the persistence unit is configured for <code>RESOURCE_LOCAL</code>
            transaction then each slice is committed without any two-phase
            commit protocol. If commit on any slice fails, then atomic nature of
            the transaction is not ensured.
            </warning>
            </para>
         </section>   
    </section>
    
    <section id="Limitations">
       <title>Limitations</title>
        
         <section id="collocation_constraint"><title>Collocation Constraint</title>
            <para> 
            No relationship can exist across database slices. In O-R mapping paradigm,
            this translates to the limitation that the closure of an object graph must be 
            <emphasis>collocated</emphasis> in the same database.
            For example, consider a domain model where Person relates to Adress.
            Person X refers to Address A while Person Y refers to Address B. 
            Collocation Constraint means that <emphasis>both</emphasis> X and A 
            must be stored in the same
            database slice. Similarly Y and B must be stored in a single slice.
            </para>
            <para>
            Slice, however, helps to maintain collocation constraint automatically.
            The instances in the closure set of any newly persistent instance 
            reachable via cascaded relationship is stored in the same slice.
            The user-defined distribution policy requires to supply the slice 
            for the root instance only.
            </para>
         </section>
         
         <section><title>No Aggregation</title>
            <para> 
            Slice can not query that includes any aggregate projection such as 
            <code>SUM()</code>, <code>MIN()</code>, <code>AVG</code>.
            </para>
            
         </section>
    </section>
    &homer;
</chapter>
  