deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwellm...@apache.org
Subject deltaspike git commit: DELTASPIKE-1045 added CriteriaSupport to (Abstract)FullEntityRepository
Date Wed, 30 Dec 2015 12:44:12 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 5555507fe -> cf3fa2483


DELTASPIKE-1045 added CriteriaSupport to (Abstract)FullEntityRepository

Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/cf3fa248
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/cf3fa248
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/cf3fa248

Branch: refs/heads/master
Commit: cf3fa2483e8556ce47d74906be9c8503a9b692c1
Parents: 5555507
Author: Harald Wellmann <hwellmann@apache.org>
Authored: Wed Dec 30 13:44:07 2015 +0100
Committer: Harald Wellmann <hwellmann@apache.org>
Committed: Wed Dec 30 13:44:07 2015 +0100

----------------------------------------------------------------------
 .../data/api/AbstractFullEntityRepository.java  | 20 +++++++++++---------
 .../data/api/FullEntityRepository.java          |  8 +++++---
 .../impl/handler/FullEntityRepositoryTest.java  | 14 ++++++++++++++
 .../test/service/FullRepositoryAbstract.java    |  6 ++++++
 documentation/src/main/asciidoc/data.adoc       |  5 +++--
 5 files changed, 39 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/cf3fa248/deltaspike/modules/data/api/src/main/java/org/apache/deltaspike/data/api/AbstractFullEntityRepository.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/api/src/main/java/org/apache/deltaspike/data/api/AbstractFullEntityRepository.java
b/deltaspike/modules/data/api/src/main/java/org/apache/deltaspike/data/api/AbstractFullEntityRepository.java
index f3d23b2..64b5e5d 100644
--- a/deltaspike/modules/data/api/src/main/java/org/apache/deltaspike/data/api/AbstractFullEntityRepository.java
+++ b/deltaspike/modules/data/api/src/main/java/org/apache/deltaspike/data/api/AbstractFullEntityRepository.java
@@ -20,17 +20,19 @@ package org.apache.deltaspike.data.api;
 
 import java.io.Serializable;
 
+import org.apache.deltaspike.data.api.criteria.CriteriaSupport;
 
 /**
- * Full Repository base class to be extended by concrete implementations.
- * Unlike {@link AbstractEntityRepository}, this class exposes all methods
- * of the underlying EntityManager.
- *
- * @param <E>   Entity type.
- * @param <PK>  Primary key type.
+ * Full repository base class to be extended by concrete implementations. A convenience class
+ * combining {@code AbstractEntityRepository}, {@code EntityManagerDelegate} and
+ * {@code CriteriaSupport}.
+ * 
+ * @param <E>
+ *            Entity type.
+ * @param <PK>
+ *            Primary key type.
  */
-public abstract class AbstractFullEntityRepository<E, PK extends Serializable>
-    extends AbstractEntityRepository<E, PK>
-    implements EntityManagerDelegate<E>
+public abstract class AbstractFullEntityRepository<E, PK extends Serializable> extends
+    AbstractEntityRepository<E, PK> implements EntityManagerDelegate<E>, CriteriaSupport<E>
 {
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/cf3fa248/deltaspike/modules/data/api/src/main/java/org/apache/deltaspike/data/api/FullEntityRepository.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/api/src/main/java/org/apache/deltaspike/data/api/FullEntityRepository.java
b/deltaspike/modules/data/api/src/main/java/org/apache/deltaspike/data/api/FullEntityRepository.java
index 11910ad..c6fc7c3 100644
--- a/deltaspike/modules/data/api/src/main/java/org/apache/deltaspike/data/api/FullEntityRepository.java
+++ b/deltaspike/modules/data/api/src/main/java/org/apache/deltaspike/data/api/FullEntityRepository.java
@@ -20,14 +20,16 @@ package org.apache.deltaspike.data.api;
 
 import java.io.Serializable;
 
+import org.apache.deltaspike.data.api.criteria.CriteriaSupport;
+
 /**
- * Full repository interface, including all methods not exposed by the base repository
- * interface.
+ * Full repository interface. A convenience class combining {@code EntityRepository},
+ * {@code EntityManagerDelegate} and {@code CriteriaSupport}.
  * 
  * @param <E>   Entity type.
  * @param <PK>  Primary key type.
  */
 public interface FullEntityRepository<E, PK extends Serializable> 
-    extends EntityRepository<E, PK>, EntityManagerDelegate<E>
+    extends EntityRepository<E, PK>, EntityManagerDelegate<E>, CriteriaSupport<E>
 {
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/cf3fa248/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/FullEntityRepositoryTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/FullEntityRepositoryTest.java
b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/FullEntityRepositoryTest.java
index 6d20c7e..277ff49 100644
--- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/FullEntityRepositoryTest.java
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/FullEntityRepositoryTest.java
@@ -197,6 +197,20 @@ public class FullEntityRepositoryTest extends TransactionalTestCase
         assertEquals(simple.getId(), fetch.getId());
     }
 
+    @Test
+    public void should_find_by_criteria() throws Exception
+    {
+        // given
+        Simple simple = new Simple("criteria");
+        
+        // when
+        simple = repoAbstract.saveAndFlush(simple);
+        Simple fetch = repoAbstract.fetchByName("criteria");
+
+        // then
+        assertEquals(simple.getId(), fetch.getId());
+    }
+
     @Override
     protected EntityManager getEntityManager()
     {

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/cf3fa248/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/FullRepositoryAbstract.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/FullRepositoryAbstract.java
b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/FullRepositoryAbstract.java
index b5f31af..e5ebb1e 100644
--- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/FullRepositoryAbstract.java
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/FullRepositoryAbstract.java
@@ -21,6 +21,7 @@ package org.apache.deltaspike.data.test.service;
 import org.apache.deltaspike.data.api.AbstractFullEntityRepository;
 import org.apache.deltaspike.data.api.Repository;
 import org.apache.deltaspike.data.test.domain.Simple;
+import org.apache.deltaspike.data.test.domain.Simple_;
 
 @Repository
 public abstract class FullRepositoryAbstract
@@ -35,4 +36,9 @@ public abstract class FullRepositoryAbstract
     {
         return entityName();
     }
+
+    public Simple fetchByName(String name)
+    {
+        return criteria().eq(Simple_.name, name).getOptionalResult();
+    }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/cf3fa248/documentation/src/main/asciidoc/data.adoc
----------------------------------------------------------------------
diff --git a/documentation/src/main/asciidoc/data.adoc b/documentation/src/main/asciidoc/data.adoc
index f14d34a..1c14bbb 100644
--- a/documentation/src/main/asciidoc/data.adoc
+++ b/documentation/src/main/asciidoc/data.adoc
@@ -314,7 +314,8 @@ public interface PersonRepository extends EntityRepository<Person,
Long>, Entity
 }
 -------------------------------------------------------------------------------------------------------
 
-This is equivalent to extending the `FullEntityRepository` interface:
+Alternatively, you can extend the `FullEntityRepository` interface which is a short-hand
for extending
+all of `EntityRepository`, `EntityManagerDelegate` and `CriteriaSupport`.
 
 [source,java]
 -------------------------------------------------------------------------------------------------------
@@ -326,7 +327,7 @@ public interface PersonRepository extends FullEntityRepository<Person,
Long>
 -------------------------------------------------------------------------------------------------------
 
 For abstract classes, there is a convenience base class `AbstractFullEntityRepository` which
also
-implements `EntityManagerDelegate` and thus exposes most `EntityManager` methods:
+implements `EntityManagerDelegate` and `CriteriaSupport` and thus exposes most `EntityManager`
methods:
 
 [source,java]
 -------------------------------------------------------------------------------------------------------


Mime
View raw message