Skip to content

Commit

Permalink
#328 deltaspike-data integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Mobe91 authored and beikov committed Jan 17, 2018
1 parent 62b7167 commit 8329058
Show file tree
Hide file tree
Showing 143 changed files with 6,845 additions and 151 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ Blaze-Persistence Spring Data integration dependencies
</dependency>
```

Blaze-Persistence DeltaSpike Data integration

```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>
```

Blaze-Persistence JPA provider integration module dependencies

Hibernate 5.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.blazebit.persistence.view.*;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.blazebit.persistence.impl.springdata.repository.EntityViewRepository;
import com.blazebit.persistence.impl.spring.data.repository.EntityViewRepository;
import ${package}.view.*;

@Repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ there is also a Spring Data integration module which tries to make using entity
=== Setup

To setup the project for Spring Data you have to add dependencies as described in the <<getting-started-setup>> section
and make a beans available for `CriteriaBuilderFactory` and `EntityViewManager` instances as laid out in the <<anchor-environment-spring,Spring environment>> section.
and make beans available for `CriteriaBuilderFactory` and `EntityViewManager` instances as laid out in the <<anchor-environment-spring,Spring environment>> section.

In short, the following Maven dependencies are required

Expand Down Expand Up @@ -77,7 +77,7 @@ Optionally specify a custom basePackage for repository class scanning and a cust
[[spring-data-features]]
=== Features

The integration comes with a convenience base interface `com.blazebit.persistence.impl.springdata.repository.EntityViewRepository`
The integration comes with a convenience base interface `com.blazebit.persistence.spring.data.api.repository.EntityViewRepository`
that you can use for your repository definitions.

Assume we have the following entity view:
Expand Down Expand Up @@ -131,7 +131,7 @@ public class MyCatController {
}
----

Support for https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#specifications[Spring Data Specifications] can be added to an entity view repository by extending from `com.blazebit.persistence.impl.springdata.repository.EntityViewSpecificationExecutor`.
Support for https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#specifications[Spring Data Specifications] can be added to an entity view repository by extending from `com.blazebit.persistence.impl.spring.data.repository.EntityViewSpecificationExecutor`.

[source,java]
----
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[[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 = Person.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.deltaspike.data.api.EntityViewRepository` provides simple base methods.
* `com.balzebit.persistence.impl.deltaspike.data.api.FullEntityViewRepository` adds JPA criteria support to the `com.balzebit.persistence.impl.deltaspike.data.api.EntityViewRepository` interface.

[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%")
).select(PersonView.class).orderAsc(Person_.id).getResultList();
}
}
----
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ include::10_change_model.adoc[]

include::11_spring_data.adoc[]

include::12_metamodel.adoc[]
include::12_deltaspike_data.adoc[]

include::13_configuration.adoc[]
include::13_metamodel.adoc[]

include::14_configuration.adoc[]
2 changes: 1 addition & 1 deletion entity-view/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<artifactId>maven-processor-plugin</artifactId>
<executions>
<execution>
<id>process-resouces</id>
<id>process-resources</id>
<goals>
<goal>process</goal>
</goals>
Expand Down
27 changes: 10 additions & 17 deletions examples/cdi-showcase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,6 @@
<name>Blazebit Persistence Examples CDI Showcase</name>
<artifactId>blaze-persistence-cdi-showcase</artifactId>

<properties>
<version.deltaspike>1.7.1</version.deltaspike>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.deltaspike.distribution</groupId>
<artifactId>distributions-bom</artifactId>
<version>${version.deltaspike}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>javax</groupId>
Expand Down Expand Up @@ -92,7 +76,6 @@
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>2.4.0.Final</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -124,6 +107,16 @@
<groupId>org.apache.deltaspike.cdictrl</groupId>
<artifactId>deltaspike-cdictrl-weld</artifactId>
<scope>runtime</scope>
<exclusions>
<exclusion>
<artifactId>weld-api</artifactId>
<groupId>org.jboss.weld</groupId>
</exclusion>
<exclusion>
<artifactId>jboss-logging</artifactId>
<groupId>org.jboss.logging</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
import org.apache.deltaspike.cdise.api.CdiContainerLoader;
import org.apache.deltaspike.cdise.api.ContextControl;
import org.apache.deltaspike.core.api.provider.BeanProvider;
import org.jboss.weld.bootstrap.spi.Metadata;
import org.jboss.weld.util.ServiceLoader;

import javax.enterprise.context.ApplicationScoped;
import java.util.Iterator;
import java.util.ServiceLoader;

/**
* @author Moritz Becker (moritz.becker@gmx.at)
Expand All @@ -44,12 +43,12 @@ public static void main(String[] args) {
contextControl.startContext(ApplicationScoped.class);

ServiceLoader<Showcase> showcaseLoader = ServiceLoader.load(Showcase.class);
Iterator<Metadata<Showcase>> showcaseIterator = showcaseLoader.iterator();
Iterator<Showcase> showcaseIterator = showcaseLoader.iterator();
if (!showcaseIterator.hasNext()) {
throw new RuntimeException("No showcases found");
}
while (showcaseIterator.hasNext()) {
BeanProvider.injectFields(showcaseIterator.next().getValue()).run();
BeanProvider.injectFields(showcaseIterator.next()).run();
}

cdiContainer.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

package com.blazebit.persistence.examples.springdata;
package com.blazebit.persistence.examples.spring.data;

import com.blazebit.persistence.examples.spi.AbstractShowcase;
import com.blazebit.persistence.examples.springdata.data.TestDataGenerator;
import com.blazebit.persistence.examples.springdata.repository.CatRepository;
import com.blazebit.persistence.examples.spring.data.data.TestDataGenerator;
import com.blazebit.persistence.examples.spring.data.repository.CatRepository;

import javax.inject.Inject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

package com.blazebit.persistence.examples.springdata;
package com.blazebit.persistence.examples.spring.data;

import com.blazebit.persistence.impl.springdata.repository.EntityViewRepositoryFactoryBean;
import com.blazebit.persistence.spring.data.impl.repository.EntityViewRepositoryFactoryBean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

Expand All @@ -26,7 +26,7 @@
*/
@Configuration
@EnableJpaRepositories(
basePackages = "com.blazebit.persistence.examples.springdata.repository",
basePackages = "com.blazebit.persistence.examples.spring.data.repository",
entityManagerFactoryRef = "myEmf",
repositoryFactoryBeanClass = EntityViewRepositoryFactoryBean.class)
public class SpringDataShowcaseConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.blazebit.persistence.examples.springdata.data;
package com.blazebit.persistence.examples.spring.data.data;

import com.blazebit.persistence.examples.base.bean.EntityManagerHolder;
import com.blazebit.persistence.examples.base.model.Cat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

package com.blazebit.persistence.examples.springdata.repository;
package com.blazebit.persistence.examples.spring.data.repository;

import com.blazebit.persistence.examples.springdata.view.CatView;
import com.blazebit.persistence.impl.springdata.repository.EntityViewRepository;
import com.blazebit.persistence.examples.spring.data.view.CatView;
import com.blazebit.persistence.spring.data.api.repository.EntityViewRepository;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.blazebit.persistence.examples.springdata.view;
package com.blazebit.persistence.examples.spring.data.view;

import com.blazebit.persistence.examples.base.model.Cat;
import com.blazebit.persistence.view.EntityView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.blazebit.persistence.examples.springdata.view;
package com.blazebit.persistence.examples.spring.data.view;

import com.blazebit.persistence.view.IdMapping;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
# limitations under the License.
#

com.blazebit.persistence.examples.springdata.SpringDataShowcase
com.blazebit.persistence.examples.spring.data.SpringDataShowcase
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">

<bean class="com.blazebit.persistence.examples.springdata.data.TestDataGenerator" />
<bean class="com.blazebit.persistence.examples.spring.data.data.TestDataGenerator" />
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.blazebit.persistence.examples.spring;

import com.blazebit.persistence.examples.spi.Showcase;
import com.blazebit.persistence.impl.springdata.repository.EntityViewRepositoryFactoryBean;
import com.blazebit.persistence.spring.data.impl.repository.EntityViewRepositoryFactoryBean;
import com.blazebit.persistence.view.impl.spring.EnableEntityViews;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.boot.CommandLineRunner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
<bean class="com.blazebit.persistence.examples.basic.data.TestDataGenerator"/>
<bean class="com.blazebit.persistence.examples.cte.data.CatDataAccess"/>
<bean class="com.blazebit.persistence.examples.cte.data.TestDataGenerator"/>
<bean class="com.blazebit.persistence.examples.springdata.data.TestDataGenerator"/>
<bean class="com.blazebit.persistence.examples.spring.data.data.TestDataGenerator"/>

</beans>
2 changes: 1 addition & 1 deletion integration/datanucleus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<artifactId>maven-processor-plugin</artifactId>
<executions>
<execution>
<id>process-resouces</id>
<id>process-resources</id>
<goals>
<goal>process</goal>
</goals>
Expand Down
33 changes: 33 additions & 0 deletions integration/deltaspike-data/api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.deltaspike.modules</groupId>
<artifactId>deltaspike-data-module-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-persistence-entity-view-api</artifactId>
</dependency>
</dependencies>
</project>
Loading

0 comments on commit 8329058

Please sign in to comment.