Skip to content

Commit

Permalink
Upgrade guide for 5.0-M1
Browse files Browse the repository at this point in the history
  • Loading branch information
stariy95 committed Sep 11, 2024
1 parent 736461d commit 073ac19
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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
//
// https://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.

== Java Version

Minimum required JDK version is 11 or newer. If your project requires Java 8, you should keep using Cayenne 4.2.
Cayenne 5.0 is fully tested with Java 11, 17 and 21.

== Incompatible Changes

Apache Cayenne 5.0-M1 removes support for a multi-layered stack, so no more Cayenne ROP and all the related client parts.
Moreover, this release renames every part that contains `server` in its name, including the main library.
For all the details please consult `UPGRADE.txt`, as this document only highlights the most impactful changes.

=== Main Library Renaming

Main Cayenne artifact is renamed from `cayenne-server` to `cayenne`, so you need to change your dependencies accordingly

[source,xml]
----
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne</artifactId>
<version>{version}</version>
</dependency>
----

=== Server Runtime and Module Deprecation

`ServerRuntime` is deprecated and replaced by `CayenneRuntime`. As well as `ServerModule` renamed to `CoreModule`.

[source,java]
----
CayenneRuntime runtime = CayenneRuntime.builder()
.addConfig("cayenne-project.xml")
.module(b -> CoreModule.extend(b).setProperty("some_property", "some_value"))
.build();
----

=== New Modules Extenders

Each Cayenne module now provides a module-specific extender created with an "extend(Binder)" method.
It is usually invoked within a lambda that produces a Module, or within an app Module.

[source,java]
----
CayenneRuntime.builder(..)
.addModule(b -> CacheInvalidationModule.extend(b).addHandler(MyHandler.class))
.build();
----

=== Removal of Deprecated Modules

- All modules related to the ROP functionality is completely gone.
That includes `cayenne-rop-server`, `cayenne-client` and other related parts.
- `cayenne-xmpp`, `cayenne-jms` and `cayenne-jgroups` event bridges are removed.
- Finally `cayenne-joda` and `cayenne-web` modules are gone.

=== Removal of Deprecated Code

As always, code deprecated in earlier versions is gone. One notable class removed is `SelectQuery`, so you should use `ObjectSelect` from now on.


Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,56 @@
// the specific language governing permissions and limitations under the
// License.

== Java Version
== New Features

Minimum required JDK version is 11 or newer.
Cayenne 5.0 is fully tested with Java 11, 17 and 21.
=== New Dev Versioning Scheme

== New Features
From now on a snapshot version of Cayenne is a constant value, so the dev version of 5.0 will always be 5.0-SNAPSHOT.
So you can always stay at the bleeding edge of development if needed.

[source,xml]
----
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne</artifactId>
<version>5.0-SNAPSHOT</version>
</dependency>
----

=== New Class Generation UI

The new Class Generation UI in the Cayenne Modeler simplifies configuration, allows multiple `cgen` setups per project,
and includes a template editor.

Custom templates are now part of the project XML configuration and don't require separate setup in either Modeler, or Maven/Gradle plugins.

=== Improved `(not)exists` Queries

In most cases, you don’t need to deal with a subquery for `(not)exists` queries, as it is now directly supported by the Expression API.
That includes `Expression`, expression parser, and Property API.

This feature can handle any expression and spawn several sub-queries per expression if needed.

[source,java]
----
long count = ObjectSelect.query(Artist.class)
.where(Artist.PAINTING_ARRAY.dot(Painting.PAINTING_TITLE).like("painting%").exists())
.selectCount(context);
----

=== Improved SQL Support

`ANY` and `ALL` subqueries are now supported, as well as `case-when` expressions.

[source,java]
----
import static org.apache.cayenne.exp.ExpressionFactory.*;
// ...
Expression caseWhenExp = caseWhen(
List.of((betweenExp("estimatedPrice", 0, 9)),
(betweenExp("estimatedPrice", 10, 20))),
List.of((wrapScalarValue("low")),
(wrapScalarValue("high"))),
wrapScalarValue("error"));
----

Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ a copy of the License at https://www.apache.org/licenses/LICENSE-2.0_#
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._#


This guide highlights the new features and changes introduced in Apache Cayenne 5.0. For a full list of changes consult
RELEASE-NOTES.txt included in Cayenne download. For release-specific upgrade instructions check UPGRADE.txt.

include::_upgrade-guide/changes.adoc[]
include::_upgrade-guide/new-features.adoc[]

0 comments on commit 073ac19

Please sign in to comment.