Skip to content

Commit 4be4932

Browse files
Dual Storage: Implemented basic structure
1 parent 0a730da commit 4be4932

File tree

8 files changed

+125
-0
lines changed

8 files changed

+125
-0
lines changed

.run/Run Dual Storage Demo.run.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Run Dual Storage Demo" type="Application" factoryName="Application">
3+
<option name="MAIN_CLASS_NAME" value="software.xdev.spring.data.eclipse.store.demo.dual.storage.DualStorageDemoApplication" />
4+
<module name="spring-data-eclipse-store-demo" />
5+
<option name="VM_PARAMETERS" value="--add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED --add-exports java.base/jdk.internal.misc=ALL-UNNAMED" />
6+
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
7+
<extension name="coverage">
8+
<pattern>
9+
<option name="PATTERN" value="software.xdev.*" />
10+
<option name="ENABLED" value="true" />
11+
</pattern>
12+
</extension>
13+
<method v="2">
14+
<option name="Make" enabled="true" />
15+
</method>
16+
</configuration>
17+
</component>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package software.xdev.spring.data.eclipse.store.demo.dual.storage;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.boot.CommandLineRunner;
6+
import org.springframework.boot.SpringApplication;
7+
import org.springframework.boot.autoconfigure.SpringBootApplication;
8+
import org.springframework.context.ConfigurableApplicationContext;
9+
10+
import software.xdev.spring.data.eclipse.store.demo.dual.storage.invoice.Invoice;
11+
import software.xdev.spring.data.eclipse.store.demo.dual.storage.invoice.InvoiceRepository;
12+
import software.xdev.spring.data.eclipse.store.demo.dual.storage.person.Person;
13+
import software.xdev.spring.data.eclipse.store.demo.dual.storage.person.PersonRepository;
14+
15+
16+
@SpringBootApplication
17+
public class DualStorageDemoApplication implements CommandLineRunner
18+
{
19+
private static final Logger LOG = LoggerFactory.getLogger(DualStorageDemoApplication.class);
20+
private final InvoiceRepository invoiceRepository;
21+
private final PersonRepository personRepository;
22+
23+
public DualStorageDemoApplication(
24+
final InvoiceRepository invoiceRepository,
25+
final PersonRepository personRepository)
26+
{
27+
this.invoiceRepository = invoiceRepository;
28+
this.personRepository = personRepository;
29+
}
30+
31+
public static void main(final String[] args)
32+
{
33+
final ConfigurableApplicationContext run = SpringApplication.run(DualStorageDemoApplication.class, args);
34+
run.close();
35+
}
36+
37+
@Override
38+
public void run(final String... args)
39+
{
40+
LOG.info("----Invoices-BeforeDeleteAll----");
41+
this.invoiceRepository.findAll().forEach(i -> LOG.info(i.toString()));
42+
this.invoiceRepository.deleteAll();
43+
44+
LOG.info("----Invoices-AfterDeleteAll----");
45+
this.invoiceRepository.findAll().forEach(i -> LOG.info(i.toString()));
46+
47+
this.invoiceRepository.save(new Invoice("N1", 100.0));
48+
49+
LOG.info("----Persons-BeforeDeleteAll----");
50+
this.personRepository.findAll().forEach(i -> LOG.info(i.toString()));
51+
this.personRepository.deleteAll();
52+
53+
LOG.info("----Persons-AfterDeleteAll----");
54+
this.personRepository.findAll().forEach(i -> LOG.info(i.toString()));
55+
56+
this.personRepository.save(new Person("Stevie", "Nicks"));
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package software.xdev.spring.data.eclipse.store.demo.dual.storage.invoice;
2+
3+
public record Invoice(String id, double sum)
4+
{
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package software.xdev.spring.data.eclipse.store.demo.dual.storage.invoice;
2+
3+
import org.springframework.data.repository.CrudRepository;
4+
5+
6+
public interface InvoiceRepository extends CrudRepository<Invoice, Integer>
7+
{
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package software.xdev.spring.data.eclipse.store.demo.dual.storage.invoice;
2+
3+
import org.springframework.context.annotation.Configuration;
4+
5+
import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
6+
7+
8+
@Configuration
9+
@EnableEclipseStoreRepositories("software.xdev.spring.data.eclipse.store.demo.dual.storage.invoice")
10+
public class PersistenceInvoiceConfiguration
11+
{
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package software.xdev.spring.data.eclipse.store.demo.dual.storage.person;
2+
3+
import org.springframework.context.annotation.Configuration;
4+
5+
import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
6+
7+
8+
@Configuration
9+
@EnableEclipseStoreRepositories("software.xdev.spring.data.eclipse.store.demo.dual.storage.person")
10+
public class PersistencePersonConfiguration
11+
{
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package software.xdev.spring.data.eclipse.store.demo.dual.storage.person;
2+
3+
public record Person(String firstName, String lastName)
4+
{
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package software.xdev.spring.data.eclipse.store.demo.dual.storage.person;
2+
3+
import org.springframework.data.repository.CrudRepository;
4+
5+
6+
public interface PersonRepository extends CrudRepository<Person, Integer>
7+
{
8+
}

0 commit comments

Comments
 (0)