Skip to content

Commit 75dce51

Browse files
Added JPA module
1 parent 2cb1abb commit 75dce51

File tree

18 files changed

+576
-5
lines changed

18 files changed

+576
-5
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<module>spring-data-eclipse-store</module>
1919
<module>spring-data-eclipse-store-demo</module>
2020
<module>spring-data-eclipse-store-benchmark</module>
21+
<module>spring-data-eclipse-store-jpa</module>
2122
</modules>
2223

2324
<licenses>

spring-data-eclipse-store-jpa/pom.xml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
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>software.xdev</groupId>
8+
<artifactId>spring-data-eclipse-store-jpa</artifactId>
9+
<version>1.0.1-SNAPSHOT</version>
10+
<packaging>jar</packaging>
11+
12+
<inceptionYear>2023</inceptionYear>
13+
14+
<organization>
15+
<name>XDEV Software</name>
16+
<url>https://xdev.software</url>
17+
</organization>
18+
19+
<properties>
20+
<javaVersion>17</javaVersion>
21+
<maven.compiler.release>${javaVersion}</maven.compiler.release>
22+
23+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
24+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
25+
26+
<mainClass>software.xdev.spring.data.eclipse.store.demo.complex.ComplexDemoApplication</mainClass>
27+
28+
<org.springframework.boot.version>3.2.2</org.springframework.boot.version>
29+
</properties>
30+
31+
<dependencyManagement>
32+
<dependencies>
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-dependencies</artifactId>
36+
<version>${org.springframework.boot.version}</version>
37+
<type>pom</type>
38+
<scope>import</scope>
39+
</dependency>
40+
</dependencies>
41+
</dependencyManagement>
42+
43+
<dependencies>
44+
<dependency>
45+
<groupId>org.springframework.boot</groupId>
46+
<artifactId>spring-boot-autoconfigure</artifactId>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.springframework.boot</groupId>
50+
<artifactId>spring-boot-starter-data-jpa</artifactId>
51+
</dependency>
52+
<dependency>
53+
<groupId>software.xdev</groupId>
54+
<artifactId>spring-data-eclipse-store</artifactId>
55+
<version>${project.version}</version>
56+
</dependency>
57+
58+
<dependency>
59+
<groupId>org.apache.logging.log4j</groupId>
60+
<artifactId>log4j-core</artifactId>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.apache.logging.log4j</groupId>
64+
<artifactId>log4j-slf4j2-impl</artifactId>
65+
</dependency>
66+
<dependency>
67+
<groupId>org.springframework.boot</groupId>
68+
<artifactId>spring-boot-autoconfigure</artifactId>
69+
</dependency>
70+
71+
<dependency>
72+
<groupId>org.junit.jupiter</groupId>
73+
<artifactId>junit-jupiter-engine</artifactId>
74+
<scope>test</scope>
75+
</dependency>
76+
<dependency>
77+
<groupId>org.junit.jupiter</groupId>
78+
<artifactId>junit-jupiter-api</artifactId>
79+
<scope>test</scope>
80+
</dependency>
81+
<dependency>
82+
<groupId>org.junit.jupiter</groupId>
83+
<artifactId>junit-jupiter-params</artifactId>
84+
<scope>test</scope>
85+
</dependency>
86+
<dependency>
87+
<groupId>org.springframework</groupId>
88+
<artifactId>spring-test</artifactId>
89+
<scope>test</scope>
90+
</dependency>
91+
</dependencies>
92+
93+
<build>
94+
<finalName>${project.artifactId}</finalName>
95+
96+
<plugins>
97+
<plugin>
98+
<groupId>org.apache.maven.plugins</groupId>
99+
<artifactId>maven-compiler-plugin</artifactId>
100+
<version>3.12.1</version>
101+
<configuration>
102+
<release>${maven.compiler.release}</release>
103+
<compilerArgs>
104+
<arg>-proc:none</arg>
105+
</compilerArgs>
106+
</configuration>
107+
</plugin>
108+
<plugin>
109+
<groupId>org.springframework.boot</groupId>
110+
<artifactId>spring-boot-maven-plugin</artifactId>
111+
<version>${org.springframework.boot.version}</version>
112+
<configuration>
113+
<mainClass>${mainClass}</mainClass>
114+
<jvmArguments>
115+
--add-opens java.base/java.util=ALL-UNNAMED
116+
--add-opens java.base/java.time=ALL-UNNAMED
117+
</jvmArguments>
118+
</configuration>
119+
</plugin>
120+
</plugins>
121+
</build>
122+
<profiles>
123+
<profile>
124+
<id>checkstyle</id>
125+
<build>
126+
<plugins>
127+
<plugin>
128+
<groupId>org.apache.maven.plugins</groupId>
129+
<artifactId>maven-checkstyle-plugin</artifactId>
130+
<version>3.3.1</version>
131+
<dependencies>
132+
<dependency>
133+
<groupId>com.puppycrawl.tools</groupId>
134+
<artifactId>checkstyle</artifactId>
135+
<version>10.12.7</version>
136+
</dependency>
137+
</dependencies>
138+
<configuration>
139+
<configLocation>../.config/checkstyle/checkstyle.xml</configLocation>
140+
</configuration>
141+
<executions>
142+
<execution>
143+
<goals>
144+
<goal>check</goal>
145+
</goals>
146+
</execution>
147+
</executions>
148+
</plugin>
149+
</plugins>
150+
</build>
151+
</profile>
152+
</profiles>
153+
</project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package software.xdev.spring.data.eclipse.store.jpa;
2+
3+
import org.springframework.data.annotation.Id;
4+
5+
6+
public class Customer
7+
{
8+
@Id
9+
private String id;
10+
11+
private final String firstName;
12+
private final String lastName;
13+
14+
public Customer(final String firstName, final String lastName)
15+
{
16+
this.firstName = firstName;
17+
this.lastName = lastName;
18+
}
19+
20+
@Override
21+
public String toString()
22+
{
23+
return String.format(
24+
"Customer[id=%s, firstName='%s', lastName='%s']",
25+
this.id, this.firstName, this.lastName);
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package software.xdev.spring.data.eclipse.store.jpa;
2+
3+
import org.springframework.data.repository.CrudRepository;
4+
5+
6+
public interface CustomerRepository extends CrudRepository<Customer, String>
7+
{
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright 2012-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package software.xdev.spring.data.eclipse.store.jpa;
18+
19+
import org.slf4j.Logger;
20+
import org.slf4j.LoggerFactory;
21+
import org.springframework.boot.CommandLineRunner;
22+
import org.springframework.boot.SpringApplication;
23+
import org.springframework.boot.autoconfigure.SpringBootApplication;
24+
import org.springframework.context.ConfigurableApplicationContext;
25+
26+
import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
27+
28+
29+
@SpringBootApplication
30+
@EnableEclipseStoreRepositories
31+
public class JpaDemoApplication implements CommandLineRunner
32+
{
33+
private static final Logger LOG = LoggerFactory.getLogger(JpaDemoApplication.class);
34+
private final CustomerRepository customerRepository;
35+
private final PetRepository petRepository;
36+
37+
public JpaDemoApplication(final CustomerRepository customerRepository, final PetRepository petRepository)
38+
{
39+
this.customerRepository = customerRepository;
40+
this.petRepository = petRepository;
41+
}
42+
43+
public static void main(final String[] args)
44+
{
45+
final ConfigurableApplicationContext run = SpringApplication.run(JpaDemoApplication.class, args);
46+
run.close();
47+
}
48+
49+
@Override
50+
public void run(final String... args)
51+
{
52+
this.customerRepository.deleteAll();
53+
54+
// save a couple of customers
55+
this.customerRepository.save(new Customer("Stevie", "Nicks"));
56+
this.customerRepository.save(new Customer("Mick", "Fleetwood"));
57+
58+
// fetch all customers
59+
LOG.info("Customers found with findAll():");
60+
this.customerRepository.findAll().forEach(c -> LOG.info(c.toString()));
61+
62+
// save a pet
63+
this.petRepository.save(new Pet("Peter", 2));
64+
65+
// fetch all pets
66+
LOG.info("Pets found with findAll():");
67+
this.petRepository.findAll().forEach(p -> LOG.info(p.toString()));
68+
}
69+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package software.xdev.spring.data.eclipse.store.jpa;
2+
3+
import org.springframework.data.annotation.Id;
4+
5+
6+
public class Pet
7+
{
8+
@Id
9+
private String id;
10+
11+
private String name;
12+
private Integer age;
13+
14+
public Pet()
15+
{
16+
}
17+
18+
public Pet(final String name, final Integer age)
19+
{
20+
this.name = name;
21+
this.age = age;
22+
}
23+
24+
@Override
25+
public String toString()
26+
{
27+
return String.format(
28+
"Pet[id=%s, name='%s', age='%s']",
29+
this.id, this.name, this.age);
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package software.xdev.spring.data.eclipse.store.jpa;
2+
3+
import org.springframework.data.repository.CrudRepository;
4+
5+
6+
public interface PetRepository extends CrudRepository<Pet, String>
7+
{
8+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Configuration name="ConfigTest" status="ERROR" monitorInterval="5">
2+
<Appenders>
3+
<Console name="Console" target="SYSTEM_OUT">
4+
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
5+
</Console>
6+
</Appenders>
7+
<Loggers>
8+
<Logger name="org.eclipse.serializer" level="warn"/>
9+
<Root level="info">
10+
<AppenderRef ref="Console"/>
11+
</Root>
12+
</Loggers>
13+
</Configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.jpa;
17+
18+
import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD;
19+
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
import org.junit.jupiter.api.extension.ExtendWith;
26+
import org.springframework.test.annotation.DirtiesContext;
27+
import org.springframework.test.context.ContextConfiguration;
28+
import org.springframework.test.context.TestPropertySource;
29+
import org.springframework.test.context.junit.jupiter.SpringExtension;
30+
31+
32+
@Retention(RetentionPolicy.RUNTIME)
33+
@Target(ElementType.TYPE)
34+
@ExtendWith(SpringExtension.class)
35+
@ContextConfiguration(classes = {TestConfiguration.class})
36+
@DirtiesContext(classMode = BEFORE_EACH_TEST_METHOD)
37+
@TestPropertySource("/application.properties")
38+
public @interface DefaultTestAnnotations
39+
{
40+
}

0 commit comments

Comments
 (0)