Skip to content

Commit ffba3e3

Browse files
committed
Standard methods ok
0 parents  commit ffba3e3

13 files changed

+617
-0
lines changed

.gitignore

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### JetBrains template
3+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
4+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
5+
6+
# User-specific stuff:
7+
.idea
8+
9+
# Sensitive or high-churn files:
10+
.idea/dataSources.ids
11+
.idea/dataSources.xml
12+
.idea/dataSources.local.xml
13+
.idea/sqlDataSources.xml
14+
.idea/dynamic.xml
15+
.idea/uiDesigner.xml
16+
17+
# Gradle:
18+
.idea/gradle.xml
19+
.idea/libraries
20+
21+
# Mongo Explorer plugin:
22+
.idea/mongoSettings.xml
23+
24+
## File-based project format:
25+
*.iws
26+
*.iml
27+
28+
## Plugin-specific files:
29+
30+
# IntelliJ
31+
/out/
32+
33+
# mpeltonen/sbt-idea plugin
34+
.idea_modules/
35+
36+
# JIRA plugin
37+
atlassian-ide-plugin.xml
38+
39+
# Crashlytics plugin (for Android Studio and IntelliJ)
40+
com_crashlytics_export_strings.xml
41+
crashlytics.properties
42+
crashlytics-build.properties
43+
fabric.properties
44+
### Maven template
45+
target/
46+
pom.xml.tag
47+
pom.xml.releaseBackup
48+
pom.xml.versionsBackup
49+
pom.xml.next
50+
release.properties
51+
dependency-reduced-pom.xml
52+
buildNumber.properties
53+
.mvn/timing.properties
54+

pom.xml

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.cosium.spring.data</groupId>
8+
<artifactId>spring-data-jpa-entity-graph</artifactId>
9+
<version>1.11.00-SNAPSHOT</version>
10+
11+
<properties>
12+
<source.level>1.6</source.level>
13+
<spring.data.jpa>1.11.0.BUILD-SNAPSHOT</spring.data.jpa>
14+
<eclipselink>2.6.2</eclipselink>
15+
<querydsl>4.1.3</querydsl>
16+
</properties>
17+
18+
<dependencies>
19+
<dependency>
20+
<groupId>org.springframework.data</groupId>
21+
<artifactId>spring-data-jpa</artifactId>
22+
<version>${spring.data.jpa}</version>
23+
<scope>provided</scope>
24+
</dependency>
25+
<dependency>
26+
<groupId>org.eclipse.persistence</groupId>
27+
<artifactId>org.eclipse.persistence.jpa</artifactId>
28+
<version>${eclipselink}</version>
29+
<optional>true</optional>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>com.querydsl</groupId>
34+
<artifactId>querydsl-apt</artifactId>
35+
<version>${querydsl}</version>
36+
<scope>provided</scope>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>com.querydsl</groupId>
41+
<artifactId>querydsl-jpa</artifactId>
42+
<version>${querydsl}</version>
43+
<optional>true</optional>
44+
</dependency>
45+
</dependencies>
46+
47+
<build>
48+
<pluginManagement>
49+
<plugins>
50+
<plugin>
51+
<groupId>org.apache.maven.plugins</groupId>
52+
<artifactId>maven-compiler-plugin</artifactId>
53+
<version>3.3</version>
54+
<configuration>
55+
<source>${source.level}</source>
56+
<target>${source.level}</target>
57+
</configuration>
58+
</plugin>
59+
<plugin>
60+
<groupId>org.apache.maven.plugins</groupId>
61+
<artifactId>maven-source-plugin</artifactId>
62+
<version>3.0.0</version>
63+
</plugin>
64+
<plugin>
65+
<groupId>org.apache.maven.plugins</groupId>
66+
<artifactId>maven-javadoc-plugin</artifactId>
67+
<version>2.10.3</version>
68+
<configuration>
69+
<failOnError>false</failOnError>
70+
</configuration>
71+
</plugin>
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-deploy-plugin</artifactId>
75+
<version>2.8.2</version>
76+
</plugin>
77+
<plugin>
78+
<groupId>org.apache.maven.plugins</groupId>
79+
<artifactId>maven-surefire-plugin</artifactId>
80+
<version>2.19.1</version>
81+
</plugin>
82+
<plugin>
83+
<groupId>org.apache.maven.plugins</groupId>
84+
<artifactId>maven-release-plugin</artifactId>
85+
<version>2.5</version>
86+
<configuration>
87+
<pushChanges>false</pushChanges>
88+
<localCheckout>true</localCheckout>
89+
</configuration>
90+
</plugin>
91+
</plugins>
92+
</pluginManagement>
93+
<plugins>
94+
<plugin>
95+
<groupId>org.apache.maven.plugins</groupId>
96+
<artifactId>maven-compiler-plugin</artifactId>
97+
<configuration>
98+
<source>${source.level}</source>
99+
<target>${source.level}</target>
100+
</configuration>
101+
</plugin>
102+
<plugin>
103+
<groupId>org.apache.maven.plugins</groupId>
104+
<artifactId>maven-source-plugin</artifactId>
105+
<executions>
106+
<execution>
107+
<id>attach-sources</id>
108+
<goals>
109+
<goal>jar</goal>
110+
</goals>
111+
</execution>
112+
</executions>
113+
</plugin>
114+
<plugin>
115+
<groupId>org.apache.maven.plugins</groupId>
116+
<artifactId>maven-javadoc-plugin</artifactId>
117+
<configuration>
118+
<failOnError>false</failOnError>
119+
</configuration>
120+
</plugin>
121+
</plugins>
122+
</build>
123+
124+
<organization>
125+
<name>Cosium</name>
126+
<url>http://www.cosium.com</url>
127+
</organization>
128+
129+
<developers>
130+
<developer>
131+
<id>reda-alaoui</id>
132+
<name>Réda Housni Alaoui</name>
133+
<email>[email protected]</email>
134+
<url>https://github.com/reda-alaoui</url>
135+
</developer>
136+
</developers>
137+
138+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.cosium.spring.data.jpa.entity.graph.domain;
2+
3+
import org.springframework.util.Assert;
4+
5+
/**
6+
* Created on 22/11/16.
7+
*
8+
* @author Reda.Housni-Alaoui
9+
*/
10+
public abstract class AbstractEntityGraph implements EntityGraph{
11+
12+
private EntityGraphType type = EntityGraphType.FETCH;
13+
14+
public AbstractEntityGraph(){}
15+
16+
public AbstractEntityGraph(EntityGraphType type){
17+
Assert.notNull(type);
18+
this.type = type;
19+
}
20+
21+
@Override
22+
public EntityGraphType getType() {
23+
return type;
24+
}
25+
26+
public void setType(EntityGraphType type) {
27+
Assert.notNull(type);
28+
this.type = type;
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.cosium.spring.data.jpa.entity.graph.domain;
2+
3+
import java.util.Collections;
4+
import java.util.List;
5+
6+
/**
7+
* Created on 22/11/16.
8+
*
9+
* @author Reda.Housni-Alaoui
10+
*/
11+
public class DynamicEntityGraph extends AbstractEntityGraph {
12+
13+
private final List<String> attributePaths;
14+
15+
public DynamicEntityGraph(List<String> attributePaths){
16+
this.attributePaths = Collections.unmodifiableList(attributePaths);
17+
}
18+
19+
public DynamicEntityGraph(EntityGraphType type, List<String> attributePaths){
20+
super(type);
21+
this.attributePaths = Collections.unmodifiableList(attributePaths);
22+
}
23+
24+
@Override
25+
public List<String> getAttributePaths() {
26+
return attributePaths;
27+
}
28+
29+
@Override
30+
public final String getName() {
31+
return null;
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.cosium.spring.data.jpa.entity.graph.domain;
2+
3+
import java.util.List;
4+
5+
/**
6+
* Created on 22/11/16.
7+
*
8+
* @author Reda.Housni-Alaoui
9+
*/
10+
public interface EntityGraph {
11+
12+
/**
13+
* @return The type of the entity graph. Can't be null.
14+
*/
15+
EntityGraphType getType();
16+
17+
/**
18+
* @return The name to use to retrieve the EntityGraph. May be null or empty
19+
*/
20+
String getName();
21+
22+
/**
23+
* @return The attribute paths. May be null.
24+
*/
25+
List<String> getAttributePaths();
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.cosium.spring.data.jpa.entity.graph.domain;
2+
3+
/**
4+
* Created on 22/11/16.
5+
*
6+
* @author Reda.Housni-Alaoui
7+
*/
8+
public enum EntityGraphType {
9+
LOAD("javax.persistence.loadgraph"),
10+
FETCH("javax.persistence.fetchgraph");
11+
12+
private final String key;
13+
14+
private EntityGraphType(String value) {
15+
this.key = value;
16+
}
17+
18+
public String getKey() {
19+
return key;
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.cosium.spring.data.jpa.entity.graph.domain;
2+
3+
/**
4+
* Created on 22/11/16.
5+
*
6+
* @author Reda.Housni-Alaoui
7+
*/
8+
public class EntityGraphUtils {
9+
10+
public static EntityGraph fromName(String name){
11+
return new NamedEntityGraph(name);
12+
}
13+
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.cosium.spring.data.jpa.entity.graph.domain;
2+
3+
import java.util.List;
4+
5+
import org.springframework.util.Assert;
6+
7+
/**
8+
* Created on 22/11/16.
9+
*
10+
* @author Reda.Housni-Alaoui
11+
*/
12+
public class NamedEntityGraph extends AbstractEntityGraph {
13+
14+
private final String name;
15+
16+
public NamedEntityGraph(EntityGraphType type, String name) {
17+
super(type);
18+
Assert.hasLength(name);
19+
this.name = name;
20+
}
21+
22+
public NamedEntityGraph(String name){
23+
Assert.hasLength(name);
24+
this.name = name;
25+
}
26+
27+
@Override
28+
public String getName() {
29+
return name;
30+
}
31+
32+
@Override
33+
public final List<String> getAttributePaths() {
34+
return null;
35+
}
36+
37+
}

0 commit comments

Comments
 (0)