Skip to content

Commit

Permalink
Merge 811f7c3 into 7458a9e
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinfotsing committed Apr 5, 2019
2 parents 7458a9e + 811f7c3 commit c06afce
Show file tree
Hide file tree
Showing 7 changed files with 335 additions and 150 deletions.
274 changes: 152 additions & 122 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<artifactId>rsql-jpa</artifactId>
<version>2.0.3-SNAPSHOT</version>
<packaging>jar</packaging>

<!--//////////////////// ABOUT ////////////////////-->
<name>RSQL-JPA</name>
<inceptionYear>2015</inceptionYear>
<description>A application used to translate RSQL nodes to JPA Criteria Query.</description>
<description>A application used to translate RSQL nodes to JPA Criteria Query.</description>
<url>http://github.com/tennaito/rsql-jpa</url>

<!--//////////////////// LICENSE ////////////////////-->
Expand All @@ -20,26 +20,28 @@
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>

<!--//////////////////// DEVELOPER///////////////////-->
<developers>
<developer>
<name>Antonio Rabelo</name>
</developer>
</developers>
<!--//////////////////// SCM ////////////////////-->
<developer>
<name>Antonio Rabelo</name>
</developer>
</developers>

<!--//////////////////// SCM ////////////////////-->
<scm>
<url>https://github.com/tennaito/rsql-jpa/</url>
<connection>scm:git:https://github.com/tennaito/rsql-jpa.git</connection>
<developerConnection>scm:git:https://github.com/tennaito/rsql-jpa.git</developerConnection>
<tag>HEAD</tag>
</scm>
<tag>HEAD</tag>
</scm>

<!--//////////////////// PROPERTIES ////////////////////-->

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<!--//////////////////// DEPENDENCIES ////////////////////-->
Expand All @@ -49,30 +51,30 @@
<dependency>
<groupId>cz.jirutka.rsql</groupId>
<artifactId>rsql-parser</artifactId>
<version>2.0.0</version>
<version>2.1.0</version>
</dependency>

<!-- Unfortunately we don´t have a canonical javax.persistence 2.1 yet -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.1.0</version>
</dependency>
<!-- Unfortunately we don´t have a canonical javax.persistence 2.1 yet -->
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>

<!-- Test scope -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.10.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.15.Final</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.6.0-M3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.7.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -83,7 +85,7 @@
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.10</version>
<version>2.4.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -92,73 +94,73 @@

<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy nexus-staging:release</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.3</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy nexus-staging:release</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.3</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!--
General profile for CI to analyze code coverage.
Expand Down Expand Up @@ -188,7 +190,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.1.201405082137</version>
<version>0.8.3</version>
<executions>
<execution>
<id>prepare-agent</id>
Expand All @@ -206,7 +208,7 @@
</plugin>
</plugins>
</build>
</profile>
</profile>
<!--
Profile for Travis CI to use Coveralls.
-->
Expand All @@ -225,7 +227,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.1.201405082137</version>
<version>0.8.3</version>
<executions>
<!-- Merge execution data for unit and integration tests. -->
<execution>
Expand Down Expand Up @@ -257,30 +259,58 @@
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>2.2.0</version>
<version>2.2.0</version>
</plugin>
</plugins>
</build>
</profile>
</profile>
</profiles>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<compilerArgs>
</compilerArgs>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<!--//////////////////// DISTRIBUTION ////////////////////-->
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<ciManagement>
<system>travis</system>
<url>https://travis-ci.org/tennaito/rsql-jpa</url>
</ciManagement>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/tennaito/rsql-jpa/issues</url>
</issueManagement>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<ciManagement>
<system>travis</system>
<url>https://travis-ci.org/tennaito/rsql-jpa</url>
</ciManagement>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/tennaito/rsql-jpa/issues</url>
</issueManagement>
</project>
20 changes: 17 additions & 3 deletions src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,25 @@ public static <T> Path<?> findPropertyPath(String propertyPath, Path startRoot,
throw new IllegalArgumentException("Unknown property: " + mappedProperty + " from entity " + classMetadata.getJavaType().getName());
}

if (isAssociationType(mappedProperty, classMetadata)) {
//Add Support of ElementCollection which was forgotten in hibernate version 5.2.15.Final
/**
* see org.hibernate.metamodel.internal.isAssociation()
* public boolean isAssociation() {
* return this.getPersistentAttributeType() == PersistentAttributeType.MANY_TO_ONE || this.getPersistentAttributeType() == PersistentAttributeType.ONE_TO_ONE;
* }
*/
if (isAssociationType(mappedProperty, classMetadata) ||
classMetadata.getAttribute(mappedProperty).getPersistentAttributeType() == PersistentAttributeType.ELEMENT_COLLECTION){

Class<?> associationType = findPropertyType(mappedProperty, classMetadata);
String previousClass = classMetadata.getJavaType().getName();
classMetadata = metaModel.managedType(associationType);
LOG.log(Level.INFO, "Create a join between {0} and {1}.", new Object[]{previousClass, classMetadata.getJavaType().getName()});

if (isAssociationType(mappedProperty, classMetadata)) {
classMetadata = metaModel.managedType(associationType);
LOG.log(Level.INFO, "Create a join between {0} and {1}.", new Object[]{previousClass, classMetadata.getJavaType().getName()});
} else {
LOG.log(Level.INFO, "Create a join between {0} and {1}.", new Object[]{previousClass, mappedProperty});
}

if (root instanceof Join) {
root = root.get(mappedProperty);
Expand Down
Loading

0 comments on commit c06afce

Please sign in to comment.