forked from Blazebit/blaze-persistence
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Blazebit#328 deltaspike-data integration
- Loading branch information
Showing
115 changed files
with
6,117 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
documentation/src/main/asciidoc/entity-view/manual/en_US/12_deltaspike_data.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
[[deltaspike-data-integration]] | ||
== DeltaSpike Data integration | ||
|
||
{projectname} provides an integration with https://deltaspike.apache.org/documentation/data.html[DeltaSpike Data] to create entity view based repositories. | ||
|
||
[[deltaspike-data-setup]] | ||
=== Setup | ||
|
||
To setup the project for DeltaSpike Data you have to add the entity view and CDI integration dependencies as described | ||
in the <<getting-started-setup, getting started>> section along with the integration dependencies for your JPA provider | ||
as described in the link:{core_doc}#maven-setup[core module setup section]. | ||
|
||
In addition, the following Maven dependencies are required: | ||
|
||
[source,xml] | ||
---- | ||
<dependency> | ||
<groupId>com.blazebit</groupId> | ||
<artifactId>blaze-persistence-integration-deltaspike-data-api</artifactId> | ||
<version>${blaze-persistence.version}</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.blazebit</groupId> | ||
<artifactId>blaze-persistence-integration-deltaspike-data-impl</artifactId> | ||
<version>${blaze-persistence.version}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
---- | ||
|
||
You also need to make beans available for `CriteriaBuilderFactory` and `EntityViewManager` as laid out in the | ||
<<anchor-environments-cdi,CDI environment>> section. | ||
|
||
[[deltaspike-data-features]] | ||
=== Features | ||
|
||
To mark a class or an interface as repository, use the DeltaSpike `org.apache.deltaspike.data.api.Repository` annotation. | ||
|
||
[source,java] | ||
---- | ||
@Repository(forEntity = PersonView.class) | ||
public interface PersonViewRepository { | ||
PersonView findAnyByName(String name); | ||
} | ||
---- | ||
|
||
The integration provides the following base interfaces that you may optionally extend to define entity view repositories: | ||
|
||
* `com.balzebit.persistence.impl.deltaspikedata.api.EntityViewRepository` provides simple base methods. | ||
* `com.balzebit.persistence.impl.deltaspikedata.api.CriteriaSupport` adds support for the JPA Criteria API to an entity view | ||
repository. See the https://deltaspike.apache.org/documentation/data.html#_jpa_criteria_api_support[DeltaSpike documentation] | ||
for more details. | ||
* `com.balzebit.persistence.impl.deltaspikedata.api.FullEntityViewRepository` combines the capabilities of the above | ||
interfaces. | ||
|
||
[source,java] | ||
---- | ||
@Repository | ||
public abstract class PersonViewRepository extends FullEntityViewRepository<Person, PersonView, String> { | ||
public abstract PersonView findAnyByName(String name); | ||
public List<PersonView> getPersonsByComplexCondition() { | ||
return criteria().or( | ||
criteria().gt(Person_.position, 3), | ||
criteria().likeIgnoreCase(Person_.name, "john%") | ||
).orderAsc(Person_.id).getResultList(); | ||
} | ||
} | ||
---- |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>blaze-persistence-integration-deltaspike-data</artifactId> | ||
<groupId>com.blazebit</groupId> | ||
<version>1.2.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>blaze-persistence-integration-deltaspike-data-api</artifactId> | ||
|
||
<name>Blazebit Persistence Integration DeltaSpike Data API</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.deltaspike.modules</groupId> | ||
<artifactId>deltaspike-data-module-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax</groupId> | ||
<artifactId>javaee-api</artifactId> | ||
<version>7.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
54 changes: 54 additions & 0 deletions
54
...a/api/src/main/java/com/balzebit/persistence/impl/deltaspikedata/api/CriteriaSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2014 - 2017 Blazebit. | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
package com.balzebit.persistence.impl.deltaspikedata.api; | ||
|
||
import org.apache.deltaspike.data.api.criteria.Criteria; | ||
|
||
import javax.persistence.criteria.JoinType; | ||
|
||
/** | ||
* @author Moritz Becker | ||
* @since 1.2.0 | ||
*/ | ||
public interface CriteriaSupport<E, R> { | ||
|
||
/** | ||
* Create a {@link Criteria} instance. | ||
* | ||
* @return Criteria instance related to the Repository entity class. | ||
*/ | ||
Criteria<E, R> criteria(); | ||
|
||
/** | ||
* Create a {@link Criteria} instance. | ||
* | ||
* @param <T> Type related to the current criteria class. | ||
* @param clazz Class other than the current entity class. | ||
* @return Criteria instance related to a join type of the current entity class. | ||
*/ | ||
<T> Criteria<T, R> where(Class<T> clazz); | ||
|
||
/** | ||
* Create a {@link Criteria} instance with a join type. | ||
* | ||
* @param <T> Type related to the current criteria class. | ||
* @param clazz Class other than the current entity class. | ||
* @param joinType Join type to apply. | ||
* @return Criteria instance related to a join type of the current entity class. | ||
*/ | ||
<T> Criteria<T, R> where(Class<T> clazz, JoinType joinType); | ||
} |
Oops, something went wrong.