blob: e318de732a18eb339c8654ec7afcb5aa222efccb [file] [log] [blame]
Title: Guide to 1.1 Features
<P>Cayenne version 1.1 introduces a large number of new features and enhancements over 1.0. This chapter lists most of them, providing the links to more detailed information about each feature.</P>
<H3><A name="Guideto1.1Features-DTDAdditions."></A>DTD Additions.</H3>
<P>&quot;cayenne.xml&quot; and &quot;*.map.xml&quot; file formats were updated to support new features. 1.1 DTD files are located here:</P>
<UL>
<LI><A href="guide-to-11-features.data/cayenne-project-1_1.dtd">cayenne-project-1_1.dtd</A></LI>
<LI><A href="guide-to-11-features.data/cayenne-data-map-1_2.dtd">cayenne-data-map-1_2.dtd</A></LI>
<LI><A href="guide-to-11-features.data/cayenne-data-view-1_1.dtd">cayenne-data-view-1_1.dtd</A></LI>
<LI><A href="guide-to-11-features.data/cayenne-driver-1_1.dtd">cayenne-driver-1_1.dtd</A></LI>
</UL>
<DIV class="panelMacro"><TABLE class="warningMacro"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="http://cayenne.apache.org/docs/1.2/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD><B>Upgrade Warning</B><BR>Saving projects with CayenneModeler v.1.1 will render them uneditable with CayenneModeler v.1.0.</TD></TR></TABLE></DIV>
<H3><A name="Guideto1.1Features-AdvancedLocalandDistributedCaching"></A>Advanced Local and Distributed Caching</H3>
<P>Cayenne now provides a way to share its object cache between DataContexts in the same JVM and across JVMs. The following chapters in the user guide describe this feature:</P>
<UL>
<LI><A href="object-caching.html" title="Object Caching">Object Caching</A></LI>
<LI><A href="caching-query-results.html" title="Caching Query Results">Caching Query Results</A></LI>
<LI><A href="caching-lookup-tables.html" title="Caching Lookup Tables">Caching Lookup Tables</A></LI>
</UL>
<H3><A name="Guideto1.1Features-OptimisticLocking"></A>Optimistic Locking</H3>
<P>ObjAttributes and ObjRelationships can be marked to be used for &quot;optimistic&quot; locking. If an corresponding columns of the underlying database row are externally modified, an attempt to save an object results in OptimisticLockingException.</P>
<H3><A name="Guideto1.1Features-DataObjectUtilsaneasywaytomapobjectsbyPK"></A>DataObjectUtils - an easy way to map objects by PK</H3>
<P><A href="dataobjectutils.html" title="DataObjectUtils">DataObjectUtils</A> is an often requested feature for easy retrieval of an object primary key, or locating an object for a known key. It works in a generic way for any type of DataObjects, even if a PK is not a class property.</P>
<H3><A name="Guideto1.1Features-EntityInheritance"></A>Entity Inheritance</H3>
<P>Cayenne now supports entity inheritance for entities rooted in the same DB table (single table inheritance).</P>
<H3><A name="Guideto1.1Features-DataViewsandDVModeler"></A>Data Views and DVModeler</H3>
<P><A href="dataviews.html" title="DataViews">DataViews</A> is a completely new addition to Cayenne. This is a framework and a Swing modeler tool to quickly build Swing applications based on Cayenne.</P>
<H3><A name="Guideto1.1Features-GenericMultithreadedandDistributedEventsMechanism"></A>Generic Multithreaded and Distributed Events Mechanism</H3>
<P>Cayenne now includes a generic <A href="event-package.html" title="Event Package">Event Package</A> &quot;org.objectstyle.cayenne.event&quot; for registering listeners and sending events, both locally and remotely. It supports both blocking and non-blocking listeners and dispatches. Supported remote transports include JMS and JavaGroups.</P>
<H3><A name="Guideto1.1Features-DataObjectsValidation"></A>DataObjects Validation</H3>
<P>DataContext now performs validation of DataObjects before committing them. There is a set of default validation checks being executed, based on the DataMap information. Developers can override DataObject validation methods to provide custom validation checks.</P>
<P>See user guide chapter on <A href="dataobject-validation.html" title="DataObject Validation">object validation</A>.</P>
<H3><A name="Guideto1.1Features-ExpressionAPIEnhancements"></A>Expression API Enhancements</H3>
<P>There is a new expression parser that allows creation of complex expressions from strings (&quot;Expression.fromString(..)&quot;). This greatly reduces the amount of code needed to build an expression.</P>
<P>In-memory evaluation API is improved, and now supports both boolean conditions (via &quot;Expression.match&quot; method) and generic expressions evaluation (via &quot;Expression.evaluate&quot; method), it also includes support for arithmetic operations.</P>
<UL>
<LI><A href="expressions.html" title="Expressions">Expressions</A></LI>
</UL>
<H3><A name="Guideto1.1Features-SQLTemplateADynamicRawSQLQuery"></A>SQLTemplate - A Dynamic Raw SQL Query</H3>
<P>SQLTemplate replaces SqlSelectQuery and SqlModifyQuery and is a scriptable parameterized raw SQL query. It supports DataObjects and other features declared in GenericSelectQuery interface.</P>
<UL>
<LI><A href="sqltemplate-query.html" title="SQLTemplate Query">SQLTemplate Query</A></LI>
<LI><A href="scripting-sqltemplate.html" title="Scripting SQLTemplate">Scripting SQLTemplate</A></LI>
</UL>
<H3><A name="Guideto1.1Features-DataContextAPIforRunningParameterizedNamedQueries"></A>DataContext API for Running Parameterized Named Queries</H3>
<P>DataContext now provides simple API to run SelectQuery, SQLTemplate and ProcedureQuery by name if such queries are mapped via CayenneModeler:</P>
<UL>
<LI><A href="datacontext.html" title="DataContext">DataContext Query API Overview</A></LI>
</UL>
<H3><A name="Guideto1.1Features-SupportforSharedMappingNamespace"></A>Support for Shared Mapping Namespace</H3>
<P>DataDomain now provides a shared mapping namespace. This means that all mapping objects can reference other mapping objects outside their DataMaps. For example two DbEntities can be located in different DataMaps and still have relationships to each other.</P>
<P>Temporary limitation of the shared mapping namespace is that Queries stored in the DataMap can't have a &quot;root&quot; from a different DataMap.</P>
<H3><A name="Guideto1.1Features-SnapshotEvents"></A>SnapshotEvents</H3>
<H3><A name="Guideto1.1Features-DataContextDelegate"></A>DataContextDelegate</H3>
<H3><A name="Guideto1.1Features-EntityRestrictingQualifier"></A>Entity Restricting Qualifier</H3>
<P>ObjEntities now can hold a qualifier expression that is automatically appended to any query qualifiers, thus creating a global data filter for a given entity. This feature is used for inheritance mapping, however it has nothing to do with inheritance as such and can be used all by itself.</P>
<H3><A name="Guideto1.1Features-ExplicitTransactionAPIandContainerManagedTransactions"></A>Explicit Transaction API and Container Managed Transactions</H3>
<P>Cayenne now supports container-managed transactions. As a result it can be used inside EJBs out of the box. It also allows a high degree of transactions customization. The following user guide chapter explains Transactions design and behavior in details:</P>
<UL>
<LI><A href="design.html#Design-CayenneTransactions">Understanding Transactions</A></LI>
</UL>
<H3><A name="Guideto1.1Features-VariousPerformanceEnhancements"></A>Various Performance Enhancements</H3>
<UL>
<LI>Lazy Relationship Creation - when new objects are fetched, their relationships are not initialized immediately; a Fault singleton is used isntead as a placeholder. Of course in the past Cayenne also had &quot;lazy&quot; relationships, meaning that they didn't get resolved via a DB query until accessed. Current optimization goes further - it prevents a number of Java objects (such as empty Lists for to-many relationship, or &quot;hollow&quot; DataObjects for to-ones) from being created until absolutely necessary.</LI>
<LI>To-many relationships do not have to be fully resolved on modification - if an unresolved to-many relationship is modified (i.e. an object is added or removed from it), it is not resolved until the next &quot;read&quot; (i.e. until a call to &quot;size()&quot; or &quot;iterator()&quot; method). This is especially helpful with bi-directional one-to-many relationships. E.g. &quot;painting.addToArtist(artist)&quot; used to trigger the fetch of all paintings that belong to an artist. Not anymore.</LI>
</UL>
<H3><A name="Guideto1.1Features-MoreDatabasesHaveCustomDbAdapters"></A>More Databases Have Custom DbAdapters</H3>
<P>Cayenne features new database adapters:</P>
<UL>
<LI>OpenBase Adapter</LI>
<LI>MS SQL Server Adapter</LI>
</UL>
<H3><A name="Guideto1.1Features-SupportforToOneRelationshipsNotPointingtoaPK."></A>Support for To-One Relationships Not Pointing to a PK.</H3>
<P>Added support for one-to-one relationships between PK and non-PK columns of related tables. In the past this could only be modeled as one-to-many. CayenneModeler will create UNIQUE constraint for a non-PK columns during schema generation.</P>
<H3><A name="Guideto1.1Features-SupportforQueriesinDataMapDTD."></A>Support for Queries in DataMap DTD.</H3>
<P>Queries are made first-class mapping objects. They can be modeled in CayenneModeler and stored in DataMaps. Application code can then reuse such queries.</P>
<UL>
<LI><A href="modeling-queries.html" title="Modeling Queries">Modeling Queries</A></LI>
</UL>
<H3><A name="Guideto1.1Features-NonrefreshingSelectQueries"></A>Non-refreshing Select Queries</H3>
<H3><A name="Guideto1.1Features-CayenneModelerEnhancements."></A>CayenneModeler Enhancements.</H3>
<P>The following is an incomplete list of enhancements: new professional look and feel, preference engine, reenginnering of stored procedures, local DataSources, configurable locations of JDBC drivers, custom class generation templates, etc. A number of Modeler tasks and dialogs have been redesigned and improved to be more user-friendly and consistent.</P>
<P>Also CayenneModeler supports mapping of all the new 1.1 framework features, such as DataMap queries, cache synchronization configuration, etc.</P>