You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2018/09/24 13:37:43 UTC
[1/3] cayenne git commit: Docs update
Repository: cayenne
Updated Branches:
refs/heads/master fd8dbc6da -> 199f516a2
Docs update
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/2de98ce8
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/2de98ce8
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/2de98ce8
Branch: refs/heads/master
Commit: 2de98ce8a19421794b3146e2c2c471b8aa17c623
Parents: c935314
Author: Arseni Bulatski <an...@gmail.com>
Authored: Mon Sep 24 15:00:18 2018 +0300
Committer: Arseni Bulatski <an...@gmail.com>
Committed: Mon Sep 24 15:00:18 2018 +0300
----------------------------------------------------------------------
README.md | 6 +++
.../asciidoc/_cayenne-guide/part5/jCache.adoc | 45 +++++++++++++++++++-
.../_getting-started-db-first/part1-setup.adoc | 10 ++---
.../part2-rr-setup.adoc | 28 ++++++------
.../part3-filtering.adoc | 10 ++---
.../part3-updating-model.adoc | 32 +++++++-------
.../part4-java-code.adoc | 2 +-
7 files changed, 91 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2de98ce8/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 2143262..bac9bd8 100644
--- a/README.md
+++ b/README.md
@@ -178,6 +178,12 @@ compile cayenne.dependency('server')
```java
ServerRuntime cayenneRuntime = ServerRuntime.builder()
.addConfig("cayenne-demo.xml")
+ .dataSource(DataSourceBuilder
+ .url("jdbc:mysql://localhost:3306/cayenne_demo")
+ .driver("com.mysql.jdbc.Driver")
+ .userName("username")
+ .password("password")
+ .build())
.build();
```
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2de98ce8/docs/asciidoc/cayenne-guide/src/docs/asciidoc/_cayenne-guide/part5/jCache.adoc
----------------------------------------------------------------------
diff --git a/docs/asciidoc/cayenne-guide/src/docs/asciidoc/_cayenne-guide/part5/jCache.adoc b/docs/asciidoc/cayenne-guide/src/docs/asciidoc/_cayenne-guide/part5/jCache.adoc
index 993b418..00a3e7f 100644
--- a/docs/asciidoc/cayenne-guide/src/docs/asciidoc/_cayenne-guide/part5/jCache.adoc
+++ b/docs/asciidoc/cayenne-guide/src/docs/asciidoc/_cayenne-guide/part5/jCache.adoc
@@ -47,6 +47,49 @@ To use JCache provider in your app you need to include this module and caching p
For advanced configuration and management please use provider specific options and tools.
+JCache module supports custom configuration files for cache managers.
+[source, java]
+----
+ServerRuntime.builder()
+ .addModule(module ->
+ JCacheModule
+ .contributeJCacheProviderConfig(module, "cache-config.xml"));
+----
+
+Also JCache module supports contribution of preconfigured cache manager.
+
+[source, java]
+----
+ServerRuntime.builder()
+ .addModule(module ->
+ module.bind(CacheManager.class).toInstance(customCacheManager));
+----
+
NOTE: You can read about using cache in Cayenne in xref:caching[this] chapter.
-You may else be interested in <<Cache invalidation extension>>.
\ No newline at end of file
+You may else be interested in <<Cache invalidation extension>>.
+
+===== Ehcache setup example
+Here is an example of using `ehcache` as cache manager.
+
+First you need to include `ehcache` dependency:
+[source, XML,subs="verbatim,attributes"]
+----
+<dependency>
+ <groupId>org.ehcache</groupId>
+ <artifactId>ehcache</artifactId>
+ <version>{ehcache-version}</version>
+</dependency>
+----
+
+If you need custom configuration you can contribute configuration file to JCache module:
+
+[source, java]
+----
+ServerRuntime.builder()
+ .addModule(module ->
+ JCacheModule
+ .contributeJCacheProviderConfig(module, "file:/ehcache.xml"));
+----
+
+As a result you will have `ehcache` manager as your default cache manager.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2de98ce8/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part1-setup.adoc
----------------------------------------------------------------------
diff --git a/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part1-setup.adoc b/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part1-setup.adoc
index 59a5862..e3f34e8 100644
--- a/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part1-setup.adoc
+++ b/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part1-setup.adoc
@@ -41,11 +41,11 @@ You can create test database with any tools you comfortable with, here is full D
[source,sql]
----
CREATE SCHEMA IF NOT EXISTS cayenne_demo; USE cayenne_demo;
-CREATE TABLE ARTIST (DATE_OF_BIRTH DATE NULL, ID INT NOT NULL AUTO_INCREMENT, NAME VARCHAR(200) NULL, PRIMARY KEY (ID)) ENGINE=InnoDB;
-CREATE TABLE GALLERY (ID INT NOT NULL AUTO_INCREMENT, NAME VARCHAR(200) NULL, PRIMARY KEY (ID)) ENGINE=InnoDB;
-CREATE TABLE PAINTING (ARTIST_ID INT NULL, GALLERY_ID INT NULL, ID INT NOT NULL AUTO_INCREMENT, NAME VARCHAR(200) NULL, PRIMARY KEY (ID)) ENGINE=InnoDB;
-ALTER TABLE PAINTING ADD FOREIGN KEY (ARTIST_ID) REFERENCES ARTIST (ID) ON DELETE CASCADE;
-ALTER TABLE PAINTING ADD FOREIGN KEY (GALLERY_ID) REFERENCES GALLERY (ID) ON DELETE CASCADE;
+CREATE TABLE artist (DATE_OF_BIRTH DATE NULL, ID INT NOT NULL AUTO_INCREMENT, NAME VARCHAR(200) NULL, PRIMARY KEY (ID)) ENGINE=InnoDB;
+CREATE TABLE gallery (ID INT NOT NULL AUTO_INCREMENT, NAME VARCHAR(200) NULL, PRIMARY KEY (ID)) ENGINE=InnoDB;
+CREATE TABLE painting (ARTIST_ID INT NULL, GALLERY_ID INT NULL, ID INT NOT NULL AUTO_INCREMENT, NAME VARCHAR(200) NULL, PRIMARY KEY (ID)) ENGINE=InnoDB;
+ALTER TABLE painting ADD FOREIGN KEY (ARTIST_ID) REFERENCES artist (ID) ON DELETE CASCADE;
+ALTER TABLE painting ADD FOREIGN KEY (GALLERY_ID) REFERENCES gallery (ID) ON DELETE CASCADE;
----
You can save it to `cayenne_demo.sql` file and import to your database with following command:
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2de98ce8/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part2-rr-setup.adoc
----------------------------------------------------------------------
diff --git a/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part2-rr-setup.adoc b/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part2-rr-setup.adoc
index d48f6cf..63a1ef5 100644
--- a/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part2-rr-setup.adoc
+++ b/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part2-rr-setup.adoc
@@ -77,25 +77,25 @@ If everything was setup properly you should see output like this:
...
[INFO] +++ Connecting: SUCCESS.
[INFO] Detected and installed adapter: org.apache.cayenne.dba.mysql.MySQLAdapter
-[INFO] Table: cayenne_demo.ARTIST
-[INFO] Table: cayenne_demo.GALLERY
-[INFO] Table: cayenne_demo.PAINTING
-[INFO] Db Relationship : toOne (PAINTING.GALLERY_ID, GALLERY.ID)
-[INFO] Db Relationship : toMany (GALLERY.ID, PAINTING.GALLERY_ID)
-[INFO] Db Relationship : toOne (PAINTING.ARTIST_ID, ARTIST.ID)
-[INFO] Db Relationship : toMany (ARTIST.ID, PAINTING.ARTIST_ID)
+[INFO] Table: cayenne_demo.artist
+[INFO] Table: cayenne_demo.gallery
+[INFO] Table: cayenne_demo.painting
+[INFO] Db Relationship : toOne (painting.GALLERY_ID, gallery.ID)
+[INFO] Db Relationship : toMany (gallery.ID, painting.GALLERY_ID)
+[INFO] Db Relationship : toOne (painting.ARTIST_ID, artist.ID)
+[INFO] Db Relationship : toMany (artist.ID, painting.ARTIST_ID)
[INFO]
[INFO] Map file does not exist. Loaded db model will be saved into '~/work/cayenne/db-first-tutorial/src/main/resources/datamap.map.xml'
[INFO]
[INFO] Detected changes:
-[INFO] Create Table ARTIST
-[INFO] Create Table PAINTING
-[INFO] Create Table GALLERY
+[INFO] Create Table artist
+[INFO] Create Table painting
+[INFO] Create Table gallery
[INFO]
-[WARNING] Can't find ObjEntity for PAINTING
-[WARNING] Db Relationship (Db Relationship : toMany (ARTIST.ID, PAINTING.ARTIST_ID)) will have GUESSED Obj Relationship reflection.
-[WARNING] Can't find ObjEntity for GALLERY
-[WARNING] Db Relationship (Db Relationship : toOne (PAINTING.GALLERY_ID, GALLERY.ID)) will have GUESSED Obj Relationship reflection.
+[WARNING] Can't find ObjEntity for painting
+[WARNING] Db Relationship (Db Relationship : toMany (artist.ID, painting.ARTIST_ID)) will have GUESSED Obj Relationship reflection.
+[WARNING] Can't find ObjEntity for gallery
+[WARNING] Db Relationship (Db Relationship : toOne (painting.GALLERY_ID, gallery.ID)) will have GUESSED Obj Relationship reflection.
[INFO] Migration Complete Successfully.
----
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2de98ce8/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part3-filtering.adoc
----------------------------------------------------------------------
diff --git a/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part3-filtering.adoc b/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part3-filtering.adoc
index 97d5d35..045a28f 100644
--- a/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part3-filtering.adoc
+++ b/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part3-filtering.adoc
@@ -20,10 +20,10 @@ Final part of our tutorial is about fine-tuning what you load from DB into your
Let's add some information to our database, that we don't need in our model:
[source,sql]
----
-CREATE TABLE cayenne_demo.LEGACY_PAINTING_INFO (ID INT NOT NULL AUTO_INCREMENT, INFO VARCHAR(255) NULL, PAINTING_ID INT NOT NULL, PRIMARY KEY (ID)) ENGINE=InnoDB;
-ALTER TABLE cayenne_demo.ARTIST ADD COLUMN __service_column INT;
-ALTER TABLE cayenne_demo.GALLERY ADD COLUMN __service_column INT;
-ALTER TABLE cayenne_demo.PAINTING ADD COLUMN __service_column INT;
+CREATE TABLE cayenne_demo.legacy_painting_info (ID INT NOT NULL AUTO_INCREMENT, INFO VARCHAR(255) NULL, PAINTING_ID INT NOT NULL, PRIMARY KEY (ID)) ENGINE=InnoDB;
+ALTER TABLE cayenne_demo.artist ADD COLUMN __service_column INT;
+ALTER TABLE cayenne_demo.gallery ADD COLUMN __service_column INT;
+ALTER TABLE cayenne_demo.painting ADD COLUMN __service_column INT;
----
==== Configure filtering
@@ -31,7 +31,7 @@ ALTER TABLE cayenne_demo.PAINTING ADD COLUMN __service_column INT;
Now we need to tell `cdbimport` what we don't need in our model, for that we'll just add following into ``<configuration>`` section:
[source,xml]
----
-<excludeTable>LEGACY_PAINTING_INFO</excludeTable>
+<excludeTable>legacy_painting_info</excludeTable>
<excludeColumn>__service_column</excludeColumn>
----
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2de98ce8/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part3-updating-model.adoc
----------------------------------------------------------------------
diff --git a/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part3-updating-model.adoc b/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part3-updating-model.adoc
index 9198790..c3c1abd 100644
--- a/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part3-updating-model.adoc
+++ b/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part3-updating-model.adoc
@@ -22,9 +22,9 @@ no problem we can simply run `cdbimport` again and all changes will be loaded to
We use following SQL script to alter our demo database:
[source,sql]
----
-CREATE TABLE cayenne_demo.PAINTING_INFO (INFO VARCHAR(255) NULL, PAINTING_ID INT NOT NULL, PRIMARY KEY (PAINTING_ID)) ENGINE=InnoDB;
-ALTER TABLE cayenne_demo.GALLERY ADD COLUMN FOUNDED_DATE DATE;
-ALTER TABLE cayenne_demo.PAINTING_INFO ADD FOREIGN KEY (PAINTING_ID) REFERENCES cayenne_demo.PAINTING (ID);
+CREATE TABLE cayenne_demo.painting_info (INFO VARCHAR(255) NULL, PAINTING_ID INT NOT NULL, PRIMARY KEY (PAINTING_ID)) ENGINE=InnoDB;
+ALTER TABLE cayenne_demo.gallery ADD COLUMN FOUNDED_DATE DATE;
+ALTER TABLE cayenne_demo.painting_info ADD FOREIGN KEY (PAINTING_ID) REFERENCES cayenne_demo.painting (ID);
----
==== Run cdbimport
@@ -37,21 +37,21 @@ $ mvn cayenne:cdbimport
You should see output similar to this:
----
...
-[INFO] Table: cayenne_demo.ARTIST
-[INFO] Table: cayenne_demo.GALLERY
-[INFO] Table: cayenne_demo.PAINTING
-[INFO] Table: cayenne_demo.PAINTING_INFO
-[INFO] Db Relationship : toOne (PAINTING_INFO.PAINTING_ID, PAINTING.ID)
-[INFO] Db Relationship : toOne (PAINTING.ID, PAINTING_INFO.PAINTING_ID)
-[INFO] Db Relationship : toOne (PAINTING.GALLERY_ID, GALLERY.ID)
-[INFO] Db Relationship : toMany (GALLERY.ID, PAINTING.GALLERY_ID)
-[INFO] Db Relationship : toOne (PAINTING.ARTIST_ID, ARTIST.ID)
-[INFO] Db Relationship : toMany (ARTIST.ID, PAINTING.ARTIST_ID)
+[INFO] Table: cayenne_demo.artist
+[INFO] Table: cayenne_demo.gallery
+[INFO] Table: cayenne_demo.painting
+[INFO] Table: cayenne_demo.painting_info
+[INFO] Db Relationship : toOne (painting_info.PAINTING_ID, painting.ID)
+[INFO] Db Relationship : toOne (painting.ID, painting_info.PAINTING_ID)
+[INFO] Db Relationship : toOne (painting.GALLERY_ID, gallery.ID)
+[INFO] Db Relationship : toMany (gallery.ID, painting.GALLERY_ID)
+[INFO] Db Relationship : toOne (painting.ARTIST_ID, artist.ID)
+[INFO] Db Relationship : toMany (artist.ID, painting.ARTIST_ID)
[INFO]
[INFO] Detected changes:
-[INFO] Create Table PAINTING_INFO
-[INFO] Add Column GALLERY.FOUNDED_DATE
-[INFO] Add Relationship paintingInfo PAINTING->PAINTING_INFO.PAINTING_ID
+[INFO] Create Table painting_info
+[INFO] Add Column gallery.FOUNDED_DATE
+[INFO] Add Relationship paintingInfo painting->painting_info.PAINTING_ID
[INFO]
[INFO] Migration Complete Successfully.
----
http://git-wip-us.apache.org/repos/asf/cayenne/blob/2de98ce8/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part4-java-code.adoc
----------------------------------------------------------------------
diff --git a/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part4-java-code.adoc b/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part4-java-code.adoc
index 029bd29..92dcf3e 100644
--- a/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part4-java-code.adoc
+++ b/docs/asciidoc/getting-started-db-first/src/docs/asciidoc/_getting-started-db-first/part4-java-code.adoc
@@ -104,7 +104,7 @@ In the console you'll see output similar to this, indicating that Cayenne stack
...
[main] INFO org.apache.cayenne.datasource.DriverDataSource - +++ Connecting: SUCCESS.
[main] INFO org.apache.cayenne.log.JdbcEventLogger - --- transaction started.
-[main] INFO org.apache.cayenne.log.JdbcEventLogger - INSERT INTO cayenne_demo.ARTIST (DATE_OF_BIRTH, NAME) VALUES (?, ?)
+[main] INFO org.apache.cayenne.log.JdbcEventLogger - INSERT INTO cayenne_demo.artist (DATE_OF_BIRTH, NAME) VALUES (?, ?)
[main] INFO org.apache.cayenne.log.JdbcEventLogger - [bind: 1->DATE_OF_BIRTH:NULL, 2->NAME:'Picasso']
[main] INFO org.apache.cayenne.log.JdbcEventLogger - Generated PK: ARTIST.ID = 2
[main] INFO org.apache.cayenne.log.JdbcEventLogger - === updated 1 row.
[2/3] cayenne git commit: Merge PR #321
Posted by nt...@apache.org.
Merge PR #321
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/8d3e021c
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/8d3e021c
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/8d3e021c
Branch: refs/heads/master
Commit: 8d3e021c97bb298494458d65f4d50ffe96670a43
Parents: fd8dbc6 2de98ce
Author: Nikita Timofeev <st...@gmail.com>
Authored: Mon Sep 24 16:26:35 2018 +0300
Committer: Nikita Timofeev <st...@gmail.com>
Committed: Mon Sep 24 16:26:35 2018 +0300
----------------------------------------------------------------------
README.md | 6 +++
.../asciidoc/_cayenne-guide/part5/jCache.adoc | 45 +++++++++++++++++++-
.../_getting-started-db-first/part1-setup.adoc | 10 ++---
.../part2-rr-setup.adoc | 28 ++++++------
.../part3-filtering.adoc | 10 ++---
.../part3-updating-model.adoc | 32 +++++++-------
.../part4-java-code.adoc | 2 +-
7 files changed, 91 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
[3/3] cayenne git commit: Docs example cleanup
Posted by nt...@apache.org.
Docs example cleanup
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/199f516a
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/199f516a
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/199f516a
Branch: refs/heads/master
Commit: 199f516a26aea9e0e940a93e39ccfaa9e931eef5
Parents: 8d3e021
Author: Nikita Timofeev <st...@gmail.com>
Authored: Mon Sep 24 16:37:27 2018 +0300
Committer: Nikita Timofeev <st...@gmail.com>
Committed: Mon Sep 24 16:37:27 2018 +0300
----------------------------------------------------------------------
.../src/docs/asciidoc/_cayenne-guide/part5/jCache.adoc | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cayenne/blob/199f516a/docs/asciidoc/cayenne-guide/src/docs/asciidoc/_cayenne-guide/part5/jCache.adoc
----------------------------------------------------------------------
diff --git a/docs/asciidoc/cayenne-guide/src/docs/asciidoc/_cayenne-guide/part5/jCache.adoc b/docs/asciidoc/cayenne-guide/src/docs/asciidoc/_cayenne-guide/part5/jCache.adoc
index 00a3e7f..90a838d 100644
--- a/docs/asciidoc/cayenne-guide/src/docs/asciidoc/_cayenne-guide/part5/jCache.adoc
+++ b/docs/asciidoc/cayenne-guide/src/docs/asciidoc/_cayenne-guide/part5/jCache.adoc
@@ -51,9 +51,9 @@ JCache module supports custom configuration files for cache managers.
[source, java]
----
ServerRuntime.builder()
- .addModule(module ->
+ .addModule(binder ->
JCacheModule
- .contributeJCacheProviderConfig(module, "cache-config.xml"));
+ .contributeJCacheProviderConfig(binder, "cache-config.xml"));
----
Also JCache module supports contribution of preconfigured cache manager.
@@ -61,8 +61,8 @@ Also JCache module supports contribution of preconfigured cache manager.
[source, java]
----
ServerRuntime.builder()
- .addModule(module ->
- module.bind(CacheManager.class).toInstance(customCacheManager));
+ .addModule(binder ->
+ binder.bind(CacheManager.class).toInstance(customCacheManager));
----
NOTE: You can read about using cache in Cayenne in xref:caching[this] chapter.
@@ -87,9 +87,9 @@ If you need custom configuration you can contribute configuration file to JCache
[source, java]
----
ServerRuntime.builder()
- .addModule(module ->
+ .addModule(binder ->
JCacheModule
- .contributeJCacheProviderConfig(module, "file:/ehcache.xml"));
+ .contributeJCacheProviderConfig(binder, "file:/ehcache.xml"));
----
As a result you will have `ehcache` manager as your default cache manager.
\ No newline at end of file