diff --git a/APPLICATIONS/EmbededSolar/pom.xml b/APPLICATIONS/EmbededSolar/pom.xml
new file mode 100644
index 00000000..634c1631
--- /dev/null
+++ b/APPLICATIONS/EmbededSolar/pom.xml
@@ -0,0 +1,76 @@
+
+
+
+ 4.0.0
+
+ EmbededSolar
+ EmbededSolar
+ 1.0-SNAPSHOT
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.0.5.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ solr-core
+ org.apache.solr
+ 8.8.2
+
+
+
+ org.apache.solr
+ solr-solrj
+ 5.5.0
+
+
+
+
+
+
+ org.springframework.data
+ spring-data-solr
+ 2.0.5.RELEASE
+
+
+
+ org.apache.jackrabbit
+ oak-solr-embedded
+ 0.7
+
+
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
\ No newline at end of file
diff --git a/APPLICATIONS/EmbededSolar/src/main/java/com/espark/adarsh/ApplicationMain.java b/APPLICATIONS/EmbededSolar/src/main/java/com/espark/adarsh/ApplicationMain.java
new file mode 100644
index 00000000..d4fbbcf4
--- /dev/null
+++ b/APPLICATIONS/EmbededSolar/src/main/java/com/espark/adarsh/ApplicationMain.java
@@ -0,0 +1,173 @@
+package com.espark.adarsh;
+
+import org.apache.jackrabbit.oak.plugins.index.solr.embedded.EmbeddedSolrServerProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.embedded.SolrServerConfiguration;
+import org.apache.lucene.search.Query;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+//import org.apache.solr.client.solrj.impl.HttpSolrClient.Builder;
+import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.client.solrj.impl.XMLResponseParser;
+import org.apache.solr.core.CoreContainer;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Primary;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.data.solr.core.SolrTemplate;
+import org.springframework.data.solr.server.support.HttpSolrClientFactory;
+import org.xml.sax.SAXException;
+
+import javax.annotation.PostConstruct;
+import javax.xml.parsers.ParserConfigurationException;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+@SpringBootApplication
+public class ApplicationMain {
+
+ @Value("${solr.core.name}")
+ private String coreName;
+
+ @Autowired
+ ApplicationContext applicationContext;
+
+ Resource resource = null;
+
+ @PostConstruct
+ public void init() throws Exception {
+ resource = this.applicationContext.getResource("classpath:/solr/oak");
+ if (!resource.exists()) {
+ throw new FileNotFoundException("Solr Configuration Not Found");
+ }
+ System.setProperty("oak.data.dir", resource.getURL().getPath() + File.separator + "data");
+ System.setProperty("oak.core.name", coreName);
+ }
+
+ public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException {
+ SpringApplication.run(ApplicationMain.class, args);
+
+ }
+
+ @Bean
+ public SolrClient createSolrServer() throws Exception {
+ CoreContainer coreContainer = new CoreContainer(resource.getURL().getPath());
+ coreContainer.load();
+ EmbeddedSolrServer server = new EmbeddedSolrServer(coreContainer, coreName);
+ return server;
+ }
+
+
+
+ /* @Bean
+ public EmbeddedSolrServer createEmbeddedSolrServer() {
+ String targetLocation = ApplicationMain.class
+ .getProtectionDomain().getCodeSource().getLocation().getFile() + "/..";
+ String solrHome = targetLocation + "/classes/solrembeded";
+ // Note that the following property could be set through JVM level arguments too
+ System.setProperty("solr.solr.home", solrHome);
+ CoreContainer coreContainer = new CoreContainer(solrHome);
+ coreContainer.load();
+ EmbeddedSolrServer server = new EmbeddedSolrServer(coreContainer, "solrembeded");
+ return server;
+ }
+
+*/
+
+ /* @Bean
+ public EmbeddedSolrServerProvider embeddedSolrServerProvider() {
+ EmbeddedSolrServerProvider embeddedSolrServerProvider=null;
+ try {
+ *//* SolrServerConfiguration solrServerConfiguration = new SolrServerConfiguration("target/solr","target/solr/solr
+ * .xml", "oak");
+ EmbeddedSolrServerProvider embeddedSolrServerProvider = new EmbeddedSolrServerProvider(solrServerConfiguration);
+ SolrServer solrServer = embeddedSolrServerProvider.getSolrServer();*//*
+
+ Resource resource = this.applicationContext.getResource("classpath:/solr/oak");
+ if(!resource.exists()) {
+ throw new FileNotFoundException("Solr Configuration Not Found");
+ }
+
+ String path = resource.getFile().getPath();
+ EmbeddedSolrServerConfiguration embeddedSolrServerConfiguration=new EmbeddedSolrServerConfiguration(path,
+ "oak");
+ embeddedSolrServerProvider = new EmbeddedSolrServerProvider(embeddedSolrServerConfiguration);
+ } catch (Exception e) {
+ log.error("label=EmbeddedSolrSearchIndexConfigure exception={}",e);
+ }
+ return embeddedSolrServerProvider;
+ }*/
+
+
+ /* @Bean
+ public EmbeddedSolrServer server() {
+try {
+ SolrServerConfiguration solrServerConfiguration = new SolrServerConfiguration("target/solr","target/solr/solr
+ .xml", "oak");
+ EmbeddedSolrServerProvider embeddedSolrServerProvider = new EmbeddedSolrServerProvider(solrServerConfiguration);
+ embeddedSolrServerProvider.getSolrServer();
+
+ File resource = new File("/Users/akumar38/Desktop/EmbededSolar/src/main/resources/solr/data");
+ Path dataPath = Paths.get("/Users/akumar38/Desktop/EmbededSolar/src/main/resources/solr/data");
+ EmbeddedSolrServer server = new EmbeddedSolrServer(dataPath,"embedded-core");
+ return server;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+
+ return null;
+ }*/
+
+
+
+
+
+ /* public HttpSolrClient solrClient(@Autowired HttpSolrServer solrServer) {
+ *//*HttpSolrClient.Builder builder = new HttpSolrClient.Builder("http://localhost:8983/solrembeded");
+ return builder.build();*//*
+
+ HttpSolrClient httpSolrClient=new HttpSolrClient("http://localhost:8983/solr");
+ return httpSolrClient;
+ }
+
+
+ public SolrTemplate solrTemplate(@Autowired HttpSolrClient client) throws Exception {
+ return new SolrTemplate(client);
+ }*/
+
+
+
+ /* public HttpSolrServer createHttpSolrServer() {
+ String url = "http://localhost:8983/solr";
+ HttpSolrServer server = new HttpSolrServer(url);
+ server.setMaxRetries(1); // defaults to 0. > 1 not recommended.
+ server.setConnectionTimeout(5000); // 5 seconds to establish TCP
+ // Setting the XML response parser is only required for cross
+ // version compatibility and only when one side is 1.4.1 or
+ // earlier and the other side is 3.1 or later.
+ server.setParser(new XMLResponseParser()); // binary parser is used by default
+ // The following settings are provided here for completeness.
+ // They will not normally be required, and should only be used
+ // after consulting javadocs to know whether they are truly required.
+ server.setSoTimeout(1000); // socket read timeout
+ server.setDefaultMaxConnectionsPerHost(100);
+ server.setMaxTotalConnections(100);
+ server.setFollowRedirects(false); // defaults to false
+ // allowCompression defaults to false.
+ // Server side must support gzip or deflate for this to have any effect.
+ server.setAllowCompression(true);
+ return server;
+ }*/
+
+}
diff --git a/APPLICATIONS/EmbededSolar/src/main/java/com/espark/adarsh/controller/ApplicationController.java b/APPLICATIONS/EmbededSolar/src/main/java/com/espark/adarsh/controller/ApplicationController.java
new file mode 100644
index 00000000..16093ed1
--- /dev/null
+++ b/APPLICATIONS/EmbededSolar/src/main/java/com/espark/adarsh/controller/ApplicationController.java
@@ -0,0 +1,49 @@
+package com.espark.adarsh.controller;
+
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.client.solrj.response.UpdateResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.solr.core.SolrTemplate;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+public class ApplicationController {
+
+ /* @Autowired
+ private SolrTemplate solrTemplate;
+
+ @PostMapping("/data")
+ public @ResponseBody UpdateResponse saveData(@RequestBody Map data){
+ return solrTemplate.saveBean(data);
+ }
+
+ @GetMapping("/data/{id}")
+ public Map getData(@PathVariable("id") String id){
+ return this.solrTemplate.getById(id, HashMap.class);
+ }*/
+
+ @Autowired
+ private SolrClient solrServer;
+
+ @GetMapping("/data")
+ public long getData() throws Exception {
+ SolrQuery query = new SolrQuery();
+ query.setQuery("*:*");
+ QueryResponse resp = solrServer.query(query);
+ long numDocs = resp.getResults().getNumFound();
+ return numDocs;
+ }
+}
diff --git a/APPLICATIONS/EmbededSolar/src/main/resources/application.properties b/APPLICATIONS/EmbededSolar/src/main/resources/application.properties
new file mode 100644
index 00000000..6ae0340c
--- /dev/null
+++ b/APPLICATIONS/EmbededSolar/src/main/resources/application.properties
@@ -0,0 +1 @@
+solr.core.name=oak
\ No newline at end of file
diff --git a/APPLICATIONS/EmbededSolar/src/main/resources/logback.xml b/APPLICATIONS/EmbededSolar/src/main/resources/logback.xml
new file mode 100644
index 00000000..c06135c8
--- /dev/null
+++ b/APPLICATIONS/EmbededSolar/src/main/resources/logback.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+ %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/conf/lang/stopwords_en.txt b/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/conf/lang/stopwords_en.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/conf/protwords.txt b/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/conf/protwords.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/conf/schema.xml b/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/conf/schema.xml
new file mode 100644
index 00000000..d1f42a67
--- /dev/null
+++ b/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/conf/schema.xml
@@ -0,0 +1,113 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/conf/solrconfig.xml b/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/conf/solrconfig.xml
new file mode 100644
index 00000000..134fa134
--- /dev/null
+++ b/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/conf/solrconfig.xml
@@ -0,0 +1,59 @@
+
+
+
+ 6.2.1
+
+ ${oak.data.dir}
+
+
+
+
+ single
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1000
+ 5000
+
+
+
+
+ solr
+
+ solrconfig.xml
+ schema.xml
+
+ q=solr&version=2.0&start=0&rows=0
+
+
+ server-enabled
+
+
+
\ No newline at end of file
diff --git a/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/conf/synonyms.txt b/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/conf/synonyms.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/core.properties b/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/core.properties
new file mode 100644
index 00000000..3329f73a
--- /dev/null
+++ b/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/core.properties
@@ -0,0 +1 @@
+name=oak
\ No newline at end of file
diff --git a/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/solr.xml b/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/solr.xml
new file mode 100644
index 00000000..95f667e6
--- /dev/null
+++ b/APPLICATIONS/EmbededSolar/src/main/resources/solr/oak/solr.xml
@@ -0,0 +1,21 @@
+
+
+
+ 127.0.0.1
+ 8983
+ solr
+ 15000
+ true
+
+
+
+ 10
+ 10
+
+
+
+
+ ${oak.core.name}
+
+
\ No newline at end of file
diff --git a/APPLICATIONS/EsparkSpringBootFileUload/pom.xml b/APPLICATIONS/EsparkSpringBootFileUload/pom.xml
new file mode 100644
index 00000000..2793abd9
--- /dev/null
+++ b/APPLICATIONS/EsparkSpringBootFileUload/pom.xml
@@ -0,0 +1,44 @@
+
+
+ 4.0.0
+
+ espark-spring-boot-file-upload
+ espark-spring-boot-file-upload
+ 1.0-SNAPSHOT
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.2.RELEASE
+
+
+
+ 1.8
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
\ No newline at end of file
diff --git a/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/Application.java b/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/Application.java
new file mode 100644
index 00000000..33cdc123
--- /dev/null
+++ b/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/Application.java
@@ -0,0 +1,16 @@
+package com.espark.adarsh;
+
+/**
+ * Created by adarsh_k on 5/18/2017.
+ */
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class Application {
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+
+}
\ No newline at end of file
diff --git a/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/exception/StorageException.java b/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/exception/StorageException.java
new file mode 100644
index 00000000..22460a3a
--- /dev/null
+++ b/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/exception/StorageException.java
@@ -0,0 +1,12 @@
+package com.espark.adarsh.exception;
+
+public class StorageException extends RuntimeException {
+
+ public StorageException(String message) {
+ super(message);
+ }
+
+ public StorageException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/exception/StorageFileNotFoundException.java b/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/exception/StorageFileNotFoundException.java
new file mode 100644
index 00000000..427ca8d2
--- /dev/null
+++ b/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/exception/StorageFileNotFoundException.java
@@ -0,0 +1,12 @@
+package com.espark.adarsh.exception;
+
+public class StorageFileNotFoundException extends StorageException {
+
+ public StorageFileNotFoundException(String message) {
+ super(message);
+ }
+
+ public StorageFileNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
\ No newline at end of file
diff --git a/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/storage/FileSystemStorageService.java b/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/storage/FileSystemStorageService.java
new file mode 100644
index 00000000..08b2e638
--- /dev/null
+++ b/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/storage/FileSystemStorageService.java
@@ -0,0 +1,88 @@
+package com.espark.adarsh.storage;
+
+import com.espark.adarsh.exception.StorageException;
+import com.espark.adarsh.exception.StorageFileNotFoundException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.UrlResource;
+import org.springframework.stereotype.Service;
+import org.springframework.util.FileSystemUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.stream.Stream;
+
+@Service
+public class FileSystemStorageService implements StorageService {
+
+ private final Path rootLocation;
+
+ @Autowired
+ public FileSystemStorageService(StorageProperties properties) {
+ this.rootLocation = Paths.get(properties.getLocation());
+ }
+
+ @Override
+ public void store(MultipartFile file) {
+ try {
+ if (file.isEmpty()) {
+ throw new StorageException("Failed to store empty file " + file.getOriginalFilename());
+ }
+ Files.copy(file.getInputStream(), this.rootLocation.resolve(file.getOriginalFilename()));
+ } catch (IOException e) {
+ throw new StorageException("Failed to store file " + file.getOriginalFilename(), e);
+ }
+ }
+
+ @Override
+ public Stream loadAll() {
+ try {
+ return Files.walk(this.rootLocation, 1)
+ .filter(path -> !path.equals(this.rootLocation))
+ .map(path -> this.rootLocation.relativize(path));
+ } catch (IOException e) {
+ throw new StorageException("Failed to read stored files", e);
+ }
+
+ }
+
+ @Override
+ public Path load(String filename) {
+ return rootLocation.resolve(filename);
+ }
+
+ @Override
+ public Resource loadAsResource(String filename) {
+ try {
+ Path file = load(filename);
+ Resource resource = new UrlResource(file.toUri());
+ if(resource.exists() || resource.isReadable()) {
+ return resource;
+ }
+ else {
+ throw new StorageFileNotFoundException("Could not read file: " + filename);
+
+ }
+ } catch (MalformedURLException e) {
+ throw new StorageFileNotFoundException("Could not read file: " + filename, e);
+ }
+ }
+
+ @Override
+ public void deleteAll() {
+ FileSystemUtils.deleteRecursively(rootLocation.toFile());
+ }
+
+ @Override
+ public void init() {
+ try {
+ Files.createDirectory(rootLocation);
+ } catch (IOException e) {
+ throw new StorageException("Could not initialize storage", e);
+ }
+ }
+}
diff --git a/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/storage/StorageProperties.java b/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/storage/StorageProperties.java
new file mode 100644
index 00000000..20dbb3ef
--- /dev/null
+++ b/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/storage/StorageProperties.java
@@ -0,0 +1,23 @@
+package com.espark.adarsh.storage;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties("storage")
+public class StorageProperties {
+
+ /**
+ * Folder location for storing files
+ */
+ private String location = "C:\\ADARSHKUMAR\\spring_boot\\EsparkSpringBootFileUload\\upload";
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+}
diff --git a/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/storage/StorageService.java b/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/storage/StorageService.java
new file mode 100644
index 00000000..88d3940d
--- /dev/null
+++ b/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/storage/StorageService.java
@@ -0,0 +1,23 @@
+package com.espark.adarsh.storage;
+
+import org.springframework.core.io.Resource;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.nio.file.Path;
+import java.util.stream.Stream;
+
+public interface StorageService {
+
+ void init();
+
+ void store(MultipartFile file);
+
+ Stream loadAll();
+
+ Path load(String filename);
+
+ Resource loadAsResource(String filename);
+
+ void deleteAll();
+
+}
diff --git a/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/web/FileUploadController.java b/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/web/FileUploadController.java
new file mode 100644
index 00000000..bcdc88ed
--- /dev/null
+++ b/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/com/espark/adarsh/web/FileUploadController.java
@@ -0,0 +1,74 @@
+package com.espark.adarsh.web;
+
+/**
+ * Created by adarsh_k on 5/18/2017.
+ */
+
+import com.espark.adarsh.exception.StorageFileNotFoundException;
+import com.espark.adarsh.storage.StorageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.Resource;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import java.io.IOException;
+import java.util.stream.Collectors;
+
+@Controller
+public class FileUploadController {
+
+ private final StorageService storageService;
+
+ @Autowired
+ public FileUploadController(StorageService storageService) {
+ this.storageService = storageService;
+ }
+
+ @GetMapping("/")
+ public String listUploadedFiles(Model model) throws IOException {
+
+ model.addAttribute("files", storageService
+ .loadAll()
+ .map(path ->
+ MvcUriComponentsBuilder
+ .fromMethodName(FileUploadController.class, "serveFile", path.getFileName().toString())
+ .build().toString())
+ .collect(Collectors.toList()));
+
+ return "uploadForm";
+ }
+
+ @GetMapping("/files/{filename:.+}")
+ @ResponseBody
+ public ResponseEntity serveFile(@PathVariable String filename) {
+
+ Resource file = storageService.loadAsResource(filename);
+ return ResponseEntity
+ .ok()
+ .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\""+file.getFilename()+"\"")
+ .body(file);
+ }
+
+ @PostMapping("/")
+ public String handleFileUpload(@RequestParam("file") MultipartFile file,
+ RedirectAttributes redirectAttributes) {
+
+ storageService.store(file);
+ redirectAttributes.addFlashAttribute("message",
+ "You successfully uploaded " + file.getOriginalFilename() + "!");
+
+ return "redirect:/";
+ }
+
+ @ExceptionHandler(StorageFileNotFoundException.class)
+ public ResponseEntity handleStorageFileNotFound(StorageFileNotFoundException exc) {
+ return ResponseEntity.notFound().build();
+ }
+
+}
\ No newline at end of file
diff --git a/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/help/help.txt b/APPLICATIONS/EsparkSpringBootFileUload/src/main/java/help/help.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/APPLICATIONS/EsparkSpringBootFileUload/src/main/resources/application.properties b/APPLICATIONS/EsparkSpringBootFileUload/src/main/resources/application.properties
new file mode 100644
index 00000000..09a638e7
--- /dev/null
+++ b/APPLICATIONS/EsparkSpringBootFileUload/src/main/resources/application.properties
@@ -0,0 +1,4 @@
+spring.http.multipart.max-file-size=128KB
+spring.http.multipart.max-request-size=128KB
+com.espark.adarsh.storage.StorageProperties.storage=/
+com.espark.adarsh.storage.StorageProperties.upload-dir=/
\ No newline at end of file
diff --git a/APPLICATIONS/EsparkSpringBootFileUload/src/main/resources/templates/uploadForm.html b/APPLICATIONS/EsparkSpringBootFileUload/src/main/resources/templates/uploadForm.html
new file mode 100644
index 00000000..bb481928
--- /dev/null
+++ b/APPLICATIONS/EsparkSpringBootFileUload/src/main/resources/templates/uploadForm.html
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/APPLICATIONS/EsparkSpringBootFileUload/src/test/java/com/espark/adarsh/test/FileUploadTests.java b/APPLICATIONS/EsparkSpringBootFileUload/src/test/java/com/espark/adarsh/test/FileUploadTests.java
new file mode 100644
index 00000000..1e41f398
--- /dev/null
+++ b/APPLICATIONS/EsparkSpringBootFileUload/src/test/java/com/espark/adarsh/test/FileUploadTests.java
@@ -0,0 +1,71 @@
+package com.espark.adarsh.test;
+
+/**
+ * Created by adarsh_k on 5/18/2017.
+ */
+
+import com.espark.adarsh.exception.StorageFileNotFoundException;
+import com.espark.adarsh.storage.StorageService;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.mock.web.MockMultipartFile;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.servlet.MockMvc;
+
+import java.nio.file.Paths;
+import java.util.stream.Stream;
+
+import static org.mockito.BDDMockito.given;
+import static org.mockito.BDDMockito.then;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.fileUpload;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+
+@RunWith(SpringRunner.class)
+@AutoConfigureMockMvc
+@SpringBootTest
+public class FileUploadTests {
+
+ @Autowired
+ private MockMvc mvc;
+
+ @MockBean
+ private StorageService storageService;
+
+ @Test
+ public void shouldListAllFiles() throws Exception {
+ given(this.storageService.loadAll())
+ .willReturn(Stream.of(Paths.get("first.txt"), Paths.get("second.txt")));
+
+ this.mvc.perform(get("/"))
+ .andExpect(status().isOk())
+ .andExpect(model().attribute("files",
+ Matchers.contains("http://localhost/files/first.txt", "http://localhost/files/second.txt")));
+ }
+
+ @Test
+ public void shouldSaveUploadedFile() throws Exception {
+ MockMultipartFile multipartFile =
+ new MockMultipartFile("file", "test.txt", "text/plain", "Spring Framework".getBytes());
+ this.mvc.perform(fileUpload("/").file(multipartFile))
+ .andExpect(status().isFound())
+ .andExpect(header().string("Location", "/"));
+
+ then(this.storageService).should().store(multipartFile);
+ }
+
+ @Test
+ public void should404WhenMissingFile() throws Exception {
+ given(this.storageService.loadAsResource("test.txt"))
+ .willThrow(StorageFileNotFoundException.class);
+
+ this.mvc.perform(get("/files/test.txt"))
+ .andExpect(status().isNotFound());
+ }
+
+}
\ No newline at end of file
diff --git a/APPLICATIONS/README.md b/APPLICATIONS/README.md
new file mode 100644
index 00000000..3f4fd8d6
--- /dev/null
+++ b/APPLICATIONS/README.md
@@ -0,0 +1,743 @@
+
+OWNER : ADARSH KUMAR
+
+EMAIL : ADARSHKUMARSINGH83@GMAIL.COM
+
+**[Espark Youtube Spring Boot ](https://www.youtube.com/playlist?list=PLBH_SvM38ibHFj5ulvAobbYbd9dOiIAOW)**
+
+ESPARK SPRING BOOT EXAMPLES
+-------------------------------------
+
+* ### EmbededSolar
+> description:
+> .
+> .
+> .
+
+* ### SpringBootSecurityHsSqlDbExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-cloudconfig-example
+> description:
+> .
+> .
+> .
+
+* ### EsparkSpringBootFileUload
+> description:
+> .
+> .
+> .
+
+* ### SpringBootSecurityMongoDbExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-conditions
+> description:
+> .
+> .
+> .
+
+* ### SpringBootSocialFbAndGitLoginExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-contact-validation
+> description:
+> .
+> .
+> .
+
+* ### SpringBootSolr
+> description:
+> .
+> .
+> .
+
+* ### springboot-custom-auto-configuration
+> description:
+> .
+> .
+> .
+
+* ### SpringBootSwaggerExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-custom-module
+> description:
+> .
+> .
+> .
+
+* ### SPRING-BOOT-ELASIC-MQ
+> description:
+> .
+> .
+> .
+
+* ### SpringBootTokenAuthenticatoinHibernateExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-custom-yml
+> description:
+> .
+> .
+> .
+
+* ### SPRINGBOOT-JPA-SAMPLES
+> description:
+> .
+> .
+> .
+
+* ### SpringBootTomcatSSLServerExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-custominterceptor
+> description:
+> .
+> .
+> .
+
+* ### SpringBootAopExample
+> description:
+> .
+> .
+> .
+
+* ### SpringBootTomcatServerExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-docker-maven
+> description:
+> .
+> .
+> .
+
+* ### SpringBootBasicExample
+> description:
+> .
+> .
+> .
+
+SpringBootWebMvcJspExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-dropwizard
+> description:
+> .
+> .
+> .
+
+* ### SpringBootCasandraBasicExample
+> description:
+> .
+> .
+> .
+
+* ### SpringBootWebMvcProfileExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-espark-json
+> description:
+> .
+> .
+> .
+
+* ### SpringBootEmbeddedLdapExample
+> description:
+> .
+> .
+> .
+
+* ### SpringBootZuulProxyServerExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-gradle-standalone
+> description:
+> .
+> .
+> .
+
+* ### SpringBootEmbidedKafkaExample
+> description:
+> .
+> .
+> .
+
+* ### SpringSecurityBootDaoAuthenticationExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-gradle-web
+> description:
+> .
+> .
+> .
+
+* ### SpringBootExternalLdapExample
+> description:
+> .
+> .
+> .
+
+* ### SpringSecurityMvcEmbeddedLdap
+> description:
+> .
+> .
+> .
+
+* ### springboot-groovy-java
+> description:
+> .
+> .
+> .
+
+* ### SpringBootFileUploadExample
+> description:
+> .
+> .
+> .
+
+* ### SpringSolarExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-h2-jpa
+> description:
+> .
+> .
+> .
+
+* ### SpringBootHibernateExample
+> description:
+> .
+> .
+> .
+
+* ### SpringbootJackRabbit
+> description:
+> .
+> .
+> .
+
+* ### springboot-hibrenate-plugin
+> description:
+> .
+> .
+> .
+
+* ### SpringBootInMemoSecurityExample
+> description:
+> .
+> .
+> .
+
+* ### completable-future-async
+> description:
+> .
+> .
+> .
+
+* ### springboot-import-selector
+> description:
+> .
+> .
+> .
+
+* ### SpringBootJerseyExample
+> description:
+> .
+> .
+> .
+
+* ### custom-annotation-processing
+> description:
+> .
+> .
+> .
+
+* ### springboot-inmemo-hazelcast-cache
+> description:
+> .
+> .
+> .
+
+* ### SpringBootJettySSLServerExample
+> description:
+> .
+> .
+> .
+
+* ### custom-module-starter
+> description:
+> .
+> .
+> .
+
+* ### springboot-jelasticsearch-restclient
+> description:
+> .
+> .
+> .
+
+* ### SpringBootJettyServerExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-kinesis
+> description:
+> .
+> .
+> .
+
+* ### SpringBootJpaExample
+> description:
+> .
+> .
+> .
+
+* ### elsatic-mq
+> description:
+> .
+> .
+> .
+
+* ### springboot-maven-profiling
+> description:
+> .
+> .
+> .
+
+* ### SpringBootJpaMongoExample
+> description:
+> .
+> .
+> .
+
+* ### espark-jsonschema-validation
+> description:
+> .
+> .
+> .
+
+* ### springboot-messges
+> description:
+> .
+> .
+> .
+
+* ### SpringBootJpaOneToOneMappingExample
+> description:
+> .
+> .
+> .
+
+* ### logback-runtime-change
+> description:
+> .
+> .
+> .
+
+* ### springboot-mock-test
+> description:
+> .
+> .
+> .
+
+* ### SpringBootJsonXmlRequestResponseExample
+> description:
+> .
+> .
+> .
+
+* ### product-information-system
+> description:
+> .
+> .
+> .
+
+* ### springboot-mocketo
+> description:
+> .
+> .
+> .
+
+* ### SpringBootJspJettyExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-module-gradle
+> description:
+> .
+> .
+> .
+
+* ### SpringBootJspTomcatExample
+> description:
+> .
+> .
+> .
+
+* ### solr-client-query-example
+> description:
+> .
+> .
+> .
+
+* ### springboot-multimodule-gradle
+> description:
+> .
+> .
+> .
+
+* ### SpringBootMockitoExmaple
+> description:
+> .
+> .
+> .
+
+* ### sprinboot-sqs-elastic-queue
+> description:
+> .
+> .
+> .
+
+* ### springboot-neo4j-docker
+> description:
+> .
+> .
+> .
+
+* ### SpringBootMultiContextExample
+> description:
+> .
+> .
+> .
+
+* ### spring-boot-admin
+> description:
+> .
+> .
+> .
+
+* ### springboot-nginx-docker
+> description:
+> .
+> .
+> .
+
+* ### SpringBootMvcAndRestExample
+> description:
+> .
+> .
+> .
+
+* ### spring-boot-hystrix
+> description:
+> .
+> .
+> .
+
+* ### springboot-react
+> description:
+> .
+> .
+> .
+
+* ### SpringBootMvcAndRestSecurityExample
+> description:
+> .
+> .
+> .
+
+* ### spring-boot-reference.pdf
+> description:
+> .
+> .
+> .
+
+* ### springboot-react-restcall
+> description:
+> .
+> .
+> .
+
+* ### SpringBootMvcJspSecurityExample
+> description:
+> .
+> .
+> .
+
+* ### spring-cloud-stream-kafka-master
+> description:
+> .
+> .
+> .
+
+* ### springboot-restart-programatically
+> description:
+> .
+> .
+> .
+
+* ### SpringBootMvcSecurityExample
+> description:
+> .
+> .
+> .
+
+* ### spring-data-jpa-postgresql
+> description:
+> .
+> .
+> .
+
+* ### springboot-server-hazelcast-cache
+> description:
+> .
+> .
+> .
+
+* ### SpringBootOAuthExample
+> description:
+> .
+> .
+> .
+
+* ### spring-framework-reference.pdf
+> description:
+> .
+> .
+> .
+
+* ### springboot-ssl
+> description:
+> .
+> .
+> .
+
+* ### SpringBootParallelAsynchronousCallExample
+> description:
+> .
+> .
+> .
+
+* ### spring-kafka-producer-consumer
+> description:
+> .
+> .
+> .
+
+* ### springboot-swagger-yml
+> description:
+> .
+> .
+> .
+
+* ### SpringBootParallelAsynchronousCallServer&Client
+> description:
+> .
+> .
+> .
+
+* ### spring-mvc-annoation
+> description:
+> .
+> .
+> .
+
+* ### springboot-vault
+> description:
+> .
+> .
+> .
+
+* ### SpringBootProfileExample
+> description:
+> .
+> .
+> .
+
+* ### spring-reflection
+> description:
+> .
+> .
+> .
+
+* ### springboot-version
+> description:
+> .
+> .
+> .
+
+* ### SpringBootProfileTest
+> description:
+> .
+> .
+> .
+
+* ### springboot-annotation-module
+> description:
+> .
+> .
+> .
+
+* ### springboot-web-rest
+> description:
+> .
+> .
+> .
+
+* ### SpringBootRabbitMqExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-async-example
+> description:
+> .
+> .
+> .
+
+* ### springboot-wiremock
+> description:
+> .
+> .
+> .
+
+* ### SpringBootRestMvcExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-awssqs-elasticmq
+> description:
+> .
+> .
+> .
+
+* ### springboot-xml-jsonparsing
+> description:
+> .
+> .
+> .
+
+* ### SpringBootRestMvcSecurityExample
+> description:
+> .
+> .
+> .
+* ### springboot-batch
+> description:
+> .
+> .
+> .
+
+* ### springboot-zipkin-sleuth
+> description:
+> .
+> .
+> .
+
+* ### SpringBootSecurityDaoAuthenticationExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-batch-example
+> description:
+> .
+> .
+> .
+
+* ### springbootautoconfiguraiton.txt
+> description:
+> .
+> .
+> .
+
+* ### SpringBootSecurityHibernateExample
+> description:
+> .
+> .
+> .
+
+* ### springboot-cassandra
+> description:
+> .
+> .
+> .
+
+* ### springboot-logs
+> description: \
+> . sample application which demo the
+> . different log configuraiton like rolling file appender
+> . and sluth configuraitons for tracid and spanid
+
+* ### springboot-elasticsearch
+> description: \
+> . spring boot sample to connect to the elastic search
+> . and elastic search is spinned using docker and kibina to
+> . view the elastic search connect indexed on the elastic search
+
+* ### springboot-ssl-server-client
+> description: \
+> spring boot self signed certificate configure rest server \
+> spring boot self signed certificate configure rest template client \
+
+* ### [springboot-redis-cache](https://github.com/adarshkumarsingh83/spring_boot/tree/master/springboot-redis-cache)
+> description: \
+> . spring boot sample to connect to the redis Cache \
+> . it used spring data project which has repositories \
+> . to perform the curd operation on the redis cache
+
+* ### [springboot-embedded-hazelcast-cache](https://github.com/adarshkumarsingh83/spring_boot/tree/master/springboot-embedded-hazelcast-cache)
+> description: \
+> spring boot hazel cast embedded cache example \
+> where data is stored in cache and retived from cache\
+> management-center help to connect to the cache and give indepth
+
+* ### [springboot-haproxy](https://github.com/adarshkumarsingh83/spring_boot/tree/master/springboot-haproxy)
+> description: \
+> spring boot haproxy sample with load balancing example \
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/help.txt b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/help.txt
new file mode 100644
index 00000000..e4734a1a
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/help.txt
@@ -0,0 +1,3 @@
+$ mvn clean package
+$ mvn spring-boot:run
+$ curl -H "Content-Type:application/json" -X POST http://localhost:8080/api/message -d '{"data":"espark message from client"}'
\ No newline at end of file
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/.gitignore b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/.gitignore
new file mode 100644
index 00000000..a2a3040a
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/document/help.txt b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/document/help.txt
new file mode 100644
index 00000000..5ddab0e2
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/document/help.txt
@@ -0,0 +1,7 @@
+
+$ mvn clean package
+
+$ mvn spring-boot:run
+
+# post message
+$ curl -H "Content-Type:application/json" -X POST http://localhost:8080/api/message -d '{"data":"espark message from client"}'
\ No newline at end of file
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/pom.xml b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/pom.xml
new file mode 100644
index 00000000..1a19bd78
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/pom.xml
@@ -0,0 +1,88 @@
+
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.6.RELEASE
+
+
+ com.espark.adarsh
+ springboot-elastic-mq-client
+ 0.0.1-SNAPSHOT
+ springboot-elastic-mq-client
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.elasticmq
+ elasticmq-rest-sqs_2.11
+ 0.10.1
+
+
+
+ org.springframework.cloud
+ spring-cloud-aws-messaging
+ 2.2.1.RELEASE
+
+
+
+ com.amazonaws
+ amazon-sqs-java-messaging-lib
+ 1.0.3
+
+
+
+ javax.jms
+ javax.jms-api
+ 2.0.1
+
+
+
+ org.springframework
+ spring-jms
+ 4.3.3.RELEASE
+
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/ApplicationMain.java b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/ApplicationMain.java
new file mode 100644
index 00000000..1c7b85d8
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/ApplicationMain.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ApplicationMain {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ApplicationMain.class, args);
+ }
+
+}
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/bean/MessageBean.java b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/bean/MessageBean.java
new file mode 100644
index 00000000..4cb7d9cb
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/bean/MessageBean.java
@@ -0,0 +1,23 @@
+package com.espark.adarsh.bean;
+
+import java.io.Serializable;
+
+public class MessageBean implements Serializable {
+
+ private T data;
+
+ public T getData() {
+ return data;
+ }
+
+ public void setData(T data) {
+ this.data = data;
+ }
+
+ @Override
+ public String toString() {
+ return "MessageBean{" +
+ "data=" + data.toString() +
+ '}';
+ }
+}
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/config/ElasticMqConfig.java b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/config/ElasticMqConfig.java
new file mode 100644
index 00000000..2499538c
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/config/ElasticMqConfig.java
@@ -0,0 +1,61 @@
+package com.espark.adarsh.config;
+
+import com.amazon.sqs.javamessaging.ProviderConfiguration;
+import com.amazon.sqs.javamessaging.SQSConnectionFactory;
+import com.amazonaws.auth.BasicAWSCredentials;
+import com.amazonaws.services.sqs.AmazonSQSClient;
+import com.espark.adarsh.handler.SqsListenerExceptionHandler;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.elasticmq.rest.sqs.SQSRestServer;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
+import org.springframework.jms.core.JmsTemplate;
+import org.springframework.jms.support.destination.DynamicDestinationResolver;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.Session;
+
+@Slf4j
+@Configuration
+public class ElasticMqConfig {
+
+ private SQSRestServer server;
+ private static final String mqEndpoint = "http://localhost:9324";
+
+ @Bean(name = "connection")
+ public ConnectionFactory mqConnectionFactory() {
+ AmazonSQSClient amazonSQSClient = new AmazonSQSClient(new BasicAWSCredentials("x", "x"));
+ amazonSQSClient.setEndpoint(mqEndpoint);
+ return new SQSConnectionFactory(new ProviderConfiguration(), amazonSQSClient);
+ }
+
+ @Bean
+ @Autowired
+ public DefaultJmsListenerContainerFactory jmsListenerContainerFactory(
+ @Qualifier("connection") ConnectionFactory connectionFactory
+ , SqsListenerExceptionHandler sqsListenerExceptionHandler) {
+ DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
+ factory.setConnectionFactory(connectionFactory);
+ factory.setDestinationResolver(new DynamicDestinationResolver());
+ factory.setConcurrency("1-3");
+ factory.setErrorHandler(sqsListenerExceptionHandler);
+ factory.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
+ return factory;
+ }
+
+ @Bean
+ @Autowired
+ public JmsTemplate sqsJmsTemplate(ConnectionFactory connectionFactory) {
+ return new JmsTemplate(connectionFactory);
+ }
+
+ @Bean
+ public ObjectMapper objectMapper(){
+ return new ObjectMapper();
+ }
+
+}
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/consumer/ApplicationConsumer.java b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/consumer/ApplicationConsumer.java
new file mode 100644
index 00000000..f702b85e
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/consumer/ApplicationConsumer.java
@@ -0,0 +1,38 @@
+package com.espark.adarsh.consumer;
+
+import com.espark.adarsh.bean.MessageBean;
+import com.espark.adarsh.util.CompressionUtil;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jms.annotation.JmsListener;
+import org.springframework.jms.core.JmsTemplate;
+import org.springframework.messaging.handler.annotation.Headers;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.util.Map;
+
+@Slf4j
+@Service
+public class ApplicationConsumer {
+
+ @Autowired
+ ObjectMapper objectMapper;
+
+ @Autowired
+ CompressionUtil compressionUtil;
+
+ @JmsListener(destination = "${epsark.queue.consumer:WORK-LOCAL-CONSUMING}")
+ void onMessageReceived(byte[] message, @Headers Map headers) throws IOException {
+
+ if (message != null && message.length != 0) {
+ String json = this.compressionUtil.decompress(message);
+ MessageBean messageBean = this.objectMapper.readValue(json, new TypeReference() {
+ });
+ log.info("label=onMessageReceived() ", messageBean.getData());
+ }
+ }
+
+}
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/handler/SqsListenerExceptionHandler.java b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/handler/SqsListenerExceptionHandler.java
new file mode 100644
index 00000000..1d9737e1
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/handler/SqsListenerExceptionHandler.java
@@ -0,0 +1,17 @@
+package com.espark.adarsh.handler;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+import org.springframework.util.ErrorHandler;
+
+@Slf4j
+@Component
+public class SqsListenerExceptionHandler implements ErrorHandler {
+
+ @Override
+ public void handleError(Throwable t) {
+ log.error("label=handler exception={}", t.getLocalizedMessage());
+ }
+}
+
+
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/publisher/ApplicationPublisher.java b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/publisher/ApplicationPublisher.java
new file mode 100644
index 00000000..284dc220
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/publisher/ApplicationPublisher.java
@@ -0,0 +1,49 @@
+package com.espark.adarsh.publisher;
+
+import com.espark.adarsh.bean.MessageBean;
+import com.espark.adarsh.util.CompressionUtil;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.jms.core.JmsTemplate;
+import org.springframework.jms.core.MessageCreator;
+import org.springframework.stereotype.Service;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
+import java.io.IOException;
+
+@Slf4j
+@Service
+public class ApplicationPublisher {
+
+ @Autowired
+ ObjectMapper objectMapper;
+
+ @Autowired
+ JmsTemplate jmsTemplate;
+
+ @Autowired
+ CompressionUtil compressionUtil;
+
+ @Value("${epsark.queue.producer:WORK-LOCAL-PRODUCING}")
+ String workLocalQueue;
+
+
+ public String sendMessage(MessageBean messageBean) throws IOException {
+ String message = objectMapper.writeValueAsString(messageBean);
+ byte[] compressedData = compressionUtil.compress(message);
+ jmsTemplate.send(workLocalQueue, new MessageCreator() {
+ @Override
+ public Message createMessage(Session session) throws JMSException {
+ Message jmsMessage = session.createObjectMessage(compressedData);
+ jmsMessage.setStringProperty("traceId", System.nanoTime() + "");
+ return jmsMessage;
+ }
+ });
+ return "MESSAGE SEND SUCCESSFUL";
+ }
+
+}
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/util/CompressionUtil.java b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/util/CompressionUtil.java
new file mode 100644
index 00000000..c28de669
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/util/CompressionUtil.java
@@ -0,0 +1,36 @@
+package com.espark.adarsh.util;
+
+import org.springframework.stereotype.Component;
+
+import java.io.*;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+@Component
+public class CompressionUtil {
+
+ public String decompress(byte[] compressed) throws IOException {
+ ByteArrayInputStream bis = new ByteArrayInputStream(compressed);
+ GZIPInputStream gis = new GZIPInputStream(bis);
+ BufferedReader br = new BufferedReader(new InputStreamReader(gis, "UTF-8"));
+ StringBuilder sb = new StringBuilder();
+ String line;
+ while ((line = br.readLine()) != null) {
+ sb.append(line);
+ }
+ br.close();
+ gis.close();
+ bis.close();
+ return sb.toString();
+ }
+
+ public byte[] compress(String data) throws IOException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length());
+ GZIPOutputStream gzip = new GZIPOutputStream(bos);
+ gzip.write(data.getBytes());
+ gzip.close();
+ byte[] compressed = bos.toByteArray();
+ bos.close();
+ return compressed;
+ }
+}
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/web/ApplicationController.java b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/web/ApplicationController.java
new file mode 100644
index 00000000..a86ffaf2
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/java/com/espark/adarsh/web/ApplicationController.java
@@ -0,0 +1,25 @@
+package com.espark.adarsh.web;
+
+import com.espark.adarsh.bean.MessageBean;
+import com.espark.adarsh.publisher.ApplicationPublisher;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@RestController
+@RequestMapping("/api")
+public class ApplicationController {
+
+ @Autowired
+ private ApplicationPublisher publisher;
+
+ @PostMapping("/message")
+ public String postMessage(@RequestBody MessageBean messageBean) throws Exception {
+ log.info("label=postMessage() messageBean={}", messageBean);
+ return this.publisher.sendMessage(messageBean);
+ }
+}
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/resources/application.properties b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/resources/application.properties
new file mode 100644
index 00000000..7f2a6691
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/main/resources/application.properties
@@ -0,0 +1,7 @@
+logging.level.com.espark.adarsh=DEBUG
+logging.level.root=DEBUG
+
+
+epsark.queue.consumer=WORK-LOCAL-CONSUMING
+epsark.queue.producer=WORK-LOCAL-CONSUMING
+#epsark.queue.producer=WORK-LOCAL-PRODUCING
\ No newline at end of file
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/test/java/com/espark/adarsh/SpringbootElasicmqApplicationTests.java b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/test/java/com/espark/adarsh/SpringbootElasicmqApplicationTests.java
new file mode 100644
index 00000000..17250856
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-client/src/test/java/com/espark/adarsh/SpringbootElasicmqApplicationTests.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class SpringbootElasicmqApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/.gitignore b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/.gitignore
new file mode 100644
index 00000000..a2a3040a
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/pom.xml b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/pom.xml
new file mode 100644
index 00000000..d70ad22d
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/pom.xml
@@ -0,0 +1,75 @@
+
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.6.RELEASE
+
+
+ com.espark.adarsh
+ springboot-elastic-mq-server
+ 0.0.1-SNAPSHOT
+ springboot-elastic-mq-server
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.elasticmq
+ elasticmq-rest-sqs_2.11
+ 0.10.1
+
+
+
+ org.springframework.cloud
+ spring-cloud-aws-messaging
+ 2.2.1.RELEASE
+
+
+
+ com.amazonaws
+ aws-java-sdk-sqs
+ 1.11.763
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/src/main/java/com/espark/adarsh/ApplicationMain.java b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/src/main/java/com/espark/adarsh/ApplicationMain.java
new file mode 100644
index 00000000..1c7b85d8
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/src/main/java/com/espark/adarsh/ApplicationMain.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ApplicationMain {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ApplicationMain.class, args);
+ }
+
+}
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/src/main/java/com/espark/adarsh/config/ElasticMqConfig.java b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/src/main/java/com/espark/adarsh/config/ElasticMqConfig.java
new file mode 100644
index 00000000..c038cdd7
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/src/main/java/com/espark/adarsh/config/ElasticMqConfig.java
@@ -0,0 +1,35 @@
+package com.espark.adarsh.config;
+
+import com.amazonaws.auth.BasicAWSCredentials;
+import com.amazonaws.services.sqs.AmazonSQSClient;
+import lombok.extern.slf4j.Slf4j;
+import org.elasticmq.rest.sqs.SQSRestServer;
+import org.elasticmq.rest.sqs.SQSRestServerBuilder;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+@Slf4j
+@Component
+public class ElasticMqConfig {
+
+ private SQSRestServer server;
+ private static final String endpoint = "http://localhost:9324";
+
+ @PostConstruct
+ public void init() {
+ log.info("label=init() executed ");
+ server = SQSRestServerBuilder.withPort(9324).withInterface("localhost").start();
+ AmazonSQSClient amazonSQSClient = new AmazonSQSClient(new BasicAWSCredentials("x", "x"));
+ amazonSQSClient.setEndpoint(endpoint);
+ amazonSQSClient.createQueue("WORK-LOCAL-CONSUMING");
+ amazonSQSClient.createQueue("WORK-LOCAL-PRODUCING");
+ }
+
+ @PreDestroy
+ public void destroy() {
+ log.info("label=destroy() executed ");
+ server.stopAndGetFuture();
+ }
+}
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/src/main/resources/application.properties b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/src/main/resources/application.properties
new file mode 100644
index 00000000..9a3581ac
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/src/main/resources/application.properties
@@ -0,0 +1,3 @@
+logging.level.com.espark.adarsh=TRACE
+logging.level.root=DEBUG
+server.port=8181
diff --git a/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/src/test/java/com/espark/adarsh/SpringbootElasicmqApplicationTests.java b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/src/test/java/com/espark/adarsh/SpringbootElasicmqApplicationTests.java
new file mode 100644
index 00000000..17250856
--- /dev/null
+++ b/APPLICATIONS/SPRING-BOOT-ELASIC-MQ/springboot-elastic-mq-server/src/test/java/com/espark/adarsh/SpringbootElasicmqApplicationTests.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class SpringbootElasicmqApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/.gitignore b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/.gitignore
new file mode 100644
index 00000000..780dc9cf
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/.gitignore
@@ -0,0 +1,34 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+/*.DS_Store
+*.DS_Store
+*/.DS_Store
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/README.md b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/README.md
new file mode 100644
index 00000000..6d28d1e0
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/README.md
@@ -0,0 +1,16 @@
+
+# spring boot h2-db
+
+### to build the application
+* $ mvn clean package
+
+### To Run the application
+* $ mvn spring-boot:run
+
+### log into the homepage of db
+* http://localhost:8080/h2-console
+```
+username, pwd , dburl and db driver class is mentioned in application.properties file
+```
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/pom.xml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/pom.xml
new file mode 100644
index 00000000..409c4ae9
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/pom.xml
@@ -0,0 +1,65 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.6.RELEASE
+
+
+ com.espark.adarsh
+ springboot-h2-db
+ 0.0.1-SNAPSHOT
+ springboot-h2-db
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.h2database
+ h2
+ runtime
+ 1.4.199
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+ junit
+ junit
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/ApplicationMain.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/ApplicationMain.java
new file mode 100644
index 00000000..1c7b85d8
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/ApplicationMain.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ApplicationMain {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ApplicationMain.class, args);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/entity/Employee.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/entity/Employee.java
new file mode 100644
index 00000000..57a3e3de
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/entity/Employee.java
@@ -0,0 +1,64 @@
+package com.espark.adarsh.entity;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "employee")
+public class Employee {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+ private String firstName;
+ private String lastName;
+ private String career;
+
+ public Employee() {
+ }
+
+ public Employee(String firstName, String lastName, String career) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.career = career;
+ }
+
+ public Employee(Long id, String firstName, String lastName, String career) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.career = career;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getCareer() {
+ return career;
+ }
+
+ public void setCareer(String career) {
+ this.career = career;
+ }
+}
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/exception/EmployeeNotFoundException.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/exception/EmployeeNotFoundException.java
new file mode 100644
index 00000000..5a452947
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/exception/EmployeeNotFoundException.java
@@ -0,0 +1,22 @@
+package com.espark.adarsh.exception;
+
+public class EmployeeNotFoundException extends RuntimeException{
+ public EmployeeNotFoundException() {
+ }
+
+ public EmployeeNotFoundException(String message) {
+ super(message);
+ }
+
+ public EmployeeNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public EmployeeNotFoundException(Throwable cause) {
+ super(cause);
+ }
+
+ public EmployeeNotFoundException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
new file mode 100644
index 00000000..e37cce1a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
@@ -0,0 +1,9 @@
+package com.espark.adarsh.respository;
+
+import com.espark.adarsh.entity.Employee;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface EmployeeRepository extends CrudRepository {
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/service/DataInitService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/service/DataInitService.java
new file mode 100644
index 00000000..db7ba9c3
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/service/DataInitService.java
@@ -0,0 +1,27 @@
+package com.espark.adarsh.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.jdbc.datasource.init.DatabasePopulator;
+import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils;
+import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.sql.DataSource;
+
+@Service
+public class DataInitService {
+
+
+ @Autowired
+ DataSource dataSource;
+
+ @PostConstruct
+ public void init() {
+ Resource initSchema = new ClassPathResource("data.sql");
+ DatabasePopulator databasePopulator = new ResourceDatabasePopulator(initSchema);
+ DatabasePopulatorUtils.execute(databasePopulator, dataSource);
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/web/EmployeeController.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/web/EmployeeController.java
new file mode 100644
index 00000000..59a2bf6a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/java/com/espark/adarsh/web/EmployeeController.java
@@ -0,0 +1,50 @@
+package com.espark.adarsh.web;
+
+import com.espark.adarsh.entity.Employee;
+import com.espark.adarsh.exception.EmployeeNotFoundException;
+import com.espark.adarsh.respository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
+
+@RestController
+public class EmployeeController {
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ @GetMapping("/employees")
+ public List getAllEmployee() {
+ List employeeList = new LinkedList<>();
+ this.employeeRepository.findAll().forEach(employee -> employeeList.add(employee));
+ return employeeList;
+ }
+
+ @GetMapping("/employee/{id}")
+ public Employee getEmployee(@PathVariable("id") Long id) {
+ return this.employeeRepository.findById(id)
+ .orElseThrow(()-> new EmployeeNotFoundException("employee not found"));
+ }
+
+ @DeleteMapping("/employee/{id}")
+ public Employee removeEmployee(@PathVariable("id") Long id) {
+ Employee employee = this.employeeRepository.findById(id)
+ .orElseThrow(()-> new EmployeeNotFoundException("employee not found"));
+ this.employeeRepository.deleteById(id);
+ return employee;
+ }
+
+ @PostMapping("/employee")
+ public Employee saveEmployee(@RequestBody Employee employee) {
+ return this.employeeRepository.save(employee);
+ }
+
+ @PutMapping("/employee/{id}")
+ public Employee updateEmployee(@PathVariable("id") Long id, @RequestBody Employee employee) {
+ return this.employeeRepository.save(employee);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/resources/application.properties b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/resources/application.properties
new file mode 100644
index 00000000..cc398596
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/resources/application.properties
@@ -0,0 +1,12 @@
+
+
+spring.datasource.url=jdbc:h2:mem:testdb
+spring.datasource.driverClassName=org.h2.Driver
+spring.datasource.username=root
+spring.datasource.password=root
+spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
+
+
+
+#spring.datasource.url=jdbc:h2:file:/data/demo
+spring.h2.console.enabled=true
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/resources/data.sql b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/resources/data.sql
new file mode 100644
index 00000000..d29927be
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/main/resources/data.sql
@@ -0,0 +1,14 @@
+DROP TABLE IF EXISTS employee;
+
+CREATE TABLE employee (
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ first_name VARCHAR(250) NOT NULL,
+ last_name VARCHAR(250) NOT NULL,
+ career VARCHAR(250) DEFAULT NULL
+);
+
+INSERT INTO employee (first_name, last_name, career) VALUES
+ ('adarsh', 'kumar', 'It'),
+ ('radha', 'singh', 'IT'),
+ ('sonu', 'singh', 'IT'),
+ ('amit', 'kumar', 'Finance');
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/test/java/com/espark/adarsh/SpringbootH2DbApplicationTests.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/test/java/com/espark/adarsh/SpringbootH2DbApplicationTests.java
new file mode 100644
index 00000000..a946a93b
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-h2-db/src/test/java/com/espark/adarsh/SpringbootH2DbApplicationTests.java
@@ -0,0 +1,16 @@
+package com.espark.adarsh;
+
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ApplicationMain.class)
+class SpringbootH2DbApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/.gitignore b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/.gitignore
new file mode 100644
index 00000000..a2a3040a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/document/help.txt b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/document/help.txt
new file mode 100644
index 00000000..7e07d6b8
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/document/help.txt
@@ -0,0 +1,8 @@
+# to build the app
+$ mvn clean package
+
+#to execute the app
+$ mvn spring-boot:run
+
+# to test the url
+$ curl http://localhost:8080/api/employees
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/pom.xml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/pom.xml
new file mode 100644
index 00000000..11e65dce
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/pom.xml
@@ -0,0 +1,74 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.6.RELEASE
+
+
+ com.espark.adarsh
+ springboot-hikari-connection-pool
+ 0.0.1-SNAPSHOT
+ springboot-hikari-connection-pool
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.apache.tomcat
+ tomcat-jdbc
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.h2database
+ h2
+ runtime
+
+
+ com.zaxxer
+ HikariCP
+ 3.3.1
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/.DS_Store
new file mode 100644
index 00000000..b6e3c7ab
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/.DS_Store
new file mode 100644
index 00000000..2bca5fb2
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/.DS_Store
new file mode 100644
index 00000000..df639e6b
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/.DS_Store
new file mode 100644
index 00000000..01142280
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/HikariConnectionPoolApplicationMain.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/HikariConnectionPoolApplicationMain.java
new file mode 100644
index 00000000..6b5d230d
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/HikariConnectionPoolApplicationMain.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class HikariConnectionPoolApplicationMain {
+
+ public static void main(String[] args) {
+ SpringApplication.run(HikariConnectionPoolApplicationMain.class, args);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/entity/Employee.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/entity/Employee.java
new file mode 100644
index 00000000..4f7c25dc
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/entity/Employee.java
@@ -0,0 +1,55 @@
+package com.espark.adarsh.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.validation.constraints.Email;
+import java.io.Serializable;
+import java.util.Date;
+
+@Setter
+@Getter
+@Entity
+@Table(name = "employee")
+public class Employee implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ protected Long id;
+
+ @NotNull
+ @Size(max = 65)
+ @Column(name = "first_name")
+ protected String firstName;
+
+ @Size(max = 65)
+ @Column(name = "last_name")
+ protected String lastName;
+
+ @NotNull
+ @Email
+ @Size(max = 100)
+ @Column(unique = true)
+ protected String email;
+
+ @Temporal(TemporalType.DATE)
+ @Column(name = "dob")
+ protected Date dob;
+
+
+ public Employee() {
+ }
+
+ public Employee(@NotNull @Size(max = 65) String firstName
+ , @Size(max = 65) String lastName
+ , @NotNull @Email @Size(max = 100) String email
+ , Date dob) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.email = email;
+ this.dob = dob;
+ }
+
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/repository/EmployeeRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/repository/EmployeeRepository.java
new file mode 100644
index 00000000..4836b194
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/repository/EmployeeRepository.java
@@ -0,0 +1,10 @@
+package com.espark.adarsh.repository;
+
+import com.espark.adarsh.entity.Employee;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface EmployeeRepository extends JpaRepository {
+
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/service/EmployeeService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/service/EmployeeService.java
new file mode 100644
index 00000000..4e888dff
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/service/EmployeeService.java
@@ -0,0 +1,19 @@
+package com.espark.adarsh.service;
+
+import com.espark.adarsh.entity.Employee;
+import com.espark.adarsh.repository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class EmployeeService {
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ public List getEmployees() {
+ return employeeRepository.findAll();
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/util/DatabaseInit.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/util/DatabaseInit.java
new file mode 100644
index 00000000..0ee75368
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/util/DatabaseInit.java
@@ -0,0 +1,36 @@
+package com.espark.adarsh.util;
+
+import com.espark.adarsh.entity.Employee;
+import com.espark.adarsh.repository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import java.util.Calendar;
+
+@Component
+public class DatabaseInit {
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+
+ @PostConstruct
+ public void init(){
+ Calendar adarshDob = Calendar.getInstance();
+ adarshDob.set(2020, 1, 1);
+ Employee adarsh = new Employee("Adarsh"
+ , "Singh"
+ , "adarsh@espark"
+ , adarshDob.getTime());
+ adarsh = employeeRepository.save(adarsh);
+
+ Calendar radhaDob = Calendar.getInstance();
+ radhaDob.set(2020, 1, 1);
+ Employee radha = new Employee("Radha"
+ , "Singh"
+ , "radha@espark"
+ , radhaDob.getTime());
+ radha = employeeRepository.save(radha);
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/web/EmployeeController.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/web/EmployeeController.java
new file mode 100644
index 00000000..1162714b
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/java/com/espark/adarsh/web/EmployeeController.java
@@ -0,0 +1,22 @@
+package com.espark.adarsh.web;
+
+import java.util.List;
+import com.espark.adarsh.entity.Employee;
+import com.espark.adarsh.service.EmployeeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/api")
+public class EmployeeController {
+
+ @Autowired
+ EmployeeService employeeService;
+
+ @GetMapping("/employees")
+ public List getEmployees() {
+ return this.employeeService.getEmployees();
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/resources/application.yml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/resources/application.yml
new file mode 100644
index 00000000..32e31a33
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/main/resources/application.yml
@@ -0,0 +1,30 @@
+server:
+ port: 8080
+
+spring:
+ application:
+ name: springboot-hikari
+ datasource:
+ url: jdbc:h2:mem:testdb
+ username: root
+ password: root
+ driver-class-name: org.h2.Driver
+ type: com.zaxxer.hikari.HikariDataSource
+ hikari:
+ connection-timeout: 20000 #maximum number of milliseconds that a client will wait for a connection
+ minimum-idle: 10 #minimum number of idle connections maintained by HikariCP in a connection pool
+ maximum-pool-size: 10 #maximum pool size
+ idle-timeout: 10000 #maximum idle time for connection
+ max-lifetime: 1000 # maximum lifetime in milliseconds of a connection in the pool after it is closed.
+ auto-commit: true #default auto-commit behavior.
+ h2:
+ console:
+ enabled: true
+ jpa:
+ database-platform: org.hibernate.dialect.H2Dialect
+ hibernate:
+ ddl-auto: update
+ show-sql: true
+ properties:
+ hibernate:
+ format_sql: true
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/test/java/com/espark/adarsh/HikariConnectionPoolApplicationMainTests.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/test/java/com/espark/adarsh/HikariConnectionPoolApplicationMainTests.java
new file mode 100644
index 00000000..c6c8fe76
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-hikari-connection-pool/src/test/java/com/espark/adarsh/HikariConnectionPoolApplicationMainTests.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class HikariConnectionPoolApplicationMainTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/.gitignore b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/.gitignore
new file mode 100644
index 00000000..a2a3040a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/document/help.txt b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/document/help.txt
new file mode 100644
index 00000000..1baca1ed
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/document/help.txt
@@ -0,0 +1,12 @@
+
+# to build
+$ mvn clean package
+
+#to run
+$ mvn spring-boot:run
+
+$ curl http://localhost:8080/api/employee
+$ curl http://localhost:8080/api/employee-project
+
+## h2 db console url
+http://localhost:8080/h2-console
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/pom.xml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/pom.xml
new file mode 100644
index 00000000..73f54793
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/pom.xml
@@ -0,0 +1,63 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.6.RELEASE
+
+
+ com.espark.adarsh
+ springboot-jpa-many-to-many-bidirectional
+ 0.0.1-SNAPSHOT
+ springboot-jpa-many-to-many-bidirectional
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.h2database
+ h2
+ runtime
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/ApplicationMain.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/ApplicationMain.java
new file mode 100644
index 00000000..1c7b85d8
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/ApplicationMain.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ApplicationMain {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ApplicationMain.class, args);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/bean/EmployeeBean.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/bean/EmployeeBean.java
new file mode 100644
index 00000000..553b283c
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/bean/EmployeeBean.java
@@ -0,0 +1,37 @@
+package com.espark.adarsh.bean;
+
+import com.espark.adarsh.entities.Employee;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class EmployeeBean extends Employee implements Serializable {
+
+ private List projectsBeans;
+
+ public EmployeeBean() {
+ }
+
+ public EmployeeBean(Employee employee) {
+ this.id = employee.getId();
+ this.firstName = employee.getFirstName();
+ this.lastName = employee.getLastName();
+ this.email = employee.getEmail();
+ this.dob = employee.getDob();
+ this.projectsBeans = null;
+ }
+
+ public EmployeeBean(Employee employee, List list) {
+ this.id = employee.getId();
+ this.firstName = employee.getFirstName();
+ this.lastName = employee.getLastName();
+ this.email = employee.getEmail();
+ this.dob = employee.getDob();
+ this.projectsBeans = list;
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/bean/ProjectsBean.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/bean/ProjectsBean.java
new file mode 100644
index 00000000..41dd1524
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/bean/ProjectsBean.java
@@ -0,0 +1,48 @@
+package com.espark.adarsh.bean;
+
+import com.espark.adarsh.entities.Projects;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class ProjectsBean extends Projects
+ implements Serializable {
+
+ List employeeBeanList;
+
+ public ProjectsBean() {
+ }
+
+ public ProjectsBean(Projects projects) {
+ this.id = projects.getId();
+ this.phoneNumber = projects.getPhoneNumber();
+ this.start = projects.getStart();
+ this.end = projects.getEnd();
+ this.address1 = projects.getAddress1();
+ this.address2 = projects.getAddress2();
+ this.street = projects.getStreet();
+ this.city = projects.getCity();
+ this.state = projects.getState();
+ this.country = projects.getCountry();
+ this.zipCode = projects.getZipCode();
+ }
+
+ public ProjectsBean(Projects projects, List employee) {
+ this.id = projects.getId();
+ this.phoneNumber = projects.getPhoneNumber();
+ this.start = projects.getStart();
+ this.end = projects.getEnd();
+ this.address1 = projects.getAddress1();
+ this.address2 = projects.getAddress2();
+ this.street = projects.getStreet();
+ this.city = projects.getCity();
+ this.state = projects.getState();
+ this.country = projects.getCountry();
+ this.zipCode = projects.getZipCode();
+ this.employeeBeanList = employee;
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/Employee.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/Employee.java
new file mode 100644
index 00000000..e4a3c3df
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/Employee.java
@@ -0,0 +1,78 @@
+package com.espark.adarsh.entities;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.validation.constraints.Email;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+
+@Setter
+@Getter
+@Entity
+@Table(name = "employee")
+public class Employee implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ protected Long id;
+
+ @NotNull
+ @Size(max = 65)
+ @Column(name = "first_name")
+ protected String firstName;
+
+ @Size(max = 65)
+ @Column(name = "last_name")
+ protected String lastName;
+
+ @Enumerated(EnumType.STRING)
+ @Column(length = 10)
+ protected Gender gender;
+
+ @NotNull
+ @Email
+ @Size(max = 100)
+ @Column(unique = true)
+ protected String email;
+
+ @Temporal(TemporalType.DATE)
+ @Column(name = "dob")
+ protected Date dob;
+
+ @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
+ @JoinTable(
+ name = "employee_project",
+ joinColumns = {@JoinColumn(name = "employee_id")},
+ inverseJoinColumns = {@JoinColumn(name = "project_id")}
+ )
+ private List projects = new LinkedList<>();
+
+ public Employee() {
+ }
+
+ public Employee(@NotNull @Size(max = 65) String firstName
+ , @Size(max = 65) String lastName
+ , Gender gender
+ , @NotNull @Email @Size(max = 100) String email
+ , Date dob) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.gender = gender;
+ this.email = email;
+ this.dob = dob;
+ }
+
+ public void setProject(Projects project) {
+ if (this.projects != null) {
+ projects.add(project);
+ } else {
+ this.projects = Arrays.asList(project);
+ }
+ }
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/Gender.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/Gender.java
new file mode 100644
index 00000000..71f78d64
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/Gender.java
@@ -0,0 +1,6 @@
+package com.espark.adarsh.entities;
+
+public enum Gender {
+ MALE,
+ FEMALE
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/Projects.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/Projects.java
new file mode 100644
index 00000000..9d4cbfec
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/Projects.java
@@ -0,0 +1,98 @@
+package com.espark.adarsh.entities;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.persistence.*;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+
+@Setter
+@Getter
+@Entity
+@Table(name = "projects")
+public class Projects implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ protected Long id;
+
+ @Size(max = 100)
+ protected String name;
+
+ @Column(name = "phone_number")
+ @Size(max = 15)
+ protected String phoneNumber;
+
+ @Temporal(TemporalType.DATE)
+ @Column(name = "start")
+ protected Date start;
+
+ @Temporal(TemporalType.DATE)
+ @Column(name = "end")
+ protected Date end;
+
+ @Size(max = 100)
+ protected String address1;
+
+ @Size(max = 100)
+ protected String address2;
+
+ @Size(max = 100)
+ protected String street;
+
+ @Size(max = 100)
+ protected String city;
+
+ @Size(max = 100)
+ protected String state;
+
+ @Size(max = 100)
+ protected String country;
+
+ @Column(name = "zip_code")
+ @Size(max = 32)
+ protected String zipCode;
+
+ @ManyToMany(mappedBy = "projects", cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
+ private List employees = new LinkedList<>();
+
+ public Projects() {
+
+ }
+
+ public Projects(@Size(max = 100) String name
+ , @Size(max = 15) String phoneNumber
+ , Date start
+ , Date end
+ , @Size(max = 100) String address1
+ , @Size(max = 100) String address2
+ , @Size(max = 100) String street
+ , @Size(max = 100) String city
+ , @Size(max = 100) String state
+ , @Size(max = 100) String country
+ , @Size(max = 32) String zipCode) {
+ this.name = name;
+ this.phoneNumber = phoneNumber;
+ this.start = start;
+ this.end = end;
+ this.address1 = address1;
+ this.address2 = address2;
+ this.street = street;
+ this.city = city;
+ this.state = state;
+ this.country = country;
+ this.zipCode = zipCode;
+ }
+
+ public void setEmployee(Employee employees) {
+ if (this.employees != null) {
+ this.employees.add(employees);
+ } else {
+ this.employees = Arrays.asList(employees);
+ }
+ }
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
new file mode 100644
index 00000000..9e2ffbc2
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
@@ -0,0 +1,10 @@
+package com.espark.adarsh.respository;
+
+import com.espark.adarsh.entities.Employee;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface EmployeeRepository extends JpaRepository {
+
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/respository/ProjectsRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/respository/ProjectsRepository.java
new file mode 100644
index 00000000..de8544a3
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/respository/ProjectsRepository.java
@@ -0,0 +1,10 @@
+package com.espark.adarsh.respository;
+
+import com.espark.adarsh.entities.Projects;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface ProjectsRepository extends JpaRepository {
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/service/DbInitService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/service/DbInitService.java
new file mode 100644
index 00000000..7a310c0f
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/service/DbInitService.java
@@ -0,0 +1,107 @@
+package com.espark.adarsh.service;
+
+import com.espark.adarsh.entities.Gender;
+import com.espark.adarsh.entities.Employee;
+import com.espark.adarsh.entities.Projects;
+import com.espark.adarsh.respository.ProjectsRepository;
+import com.espark.adarsh.respository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.sql.DataSource;
+import java.util.Arrays;
+import java.util.Calendar;
+
+@Service
+public class DbInitService {
+
+
+ @Autowired
+ DataSource dataSource;
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ @Autowired
+ ProjectsRepository projectsRepository;
+
+ @PostConstruct
+ public void init() {
+
+ Calendar proj1Start = Calendar.getInstance();
+ proj1Start.set(2001, 1, 1);
+ Calendar proj1End = Calendar.getInstance();
+ proj1End.set(2010, 1, 1);
+ Projects projectsOne = new Projects(
+ "project1"
+ , "+1-1122334455"
+ , proj1Start.getTime()
+ , proj1End.getTime()
+ , ""
+ , "Indian Point"
+ , "Indian Street"
+ , "Dallas"
+ , "TX"
+ , "US"
+ , "347571");
+
+
+ Calendar proj2Start = Calendar.getInstance();
+ proj2Start.set(2010, 1, 1);
+ Calendar proj2End = Calendar.getInstance();
+ proj2End.set(2020, 1, 1);
+ Projects projectsTwo = new Projects(
+ "project2"
+ , "+1-1122334455"
+ , proj2Start.getTime()
+ , proj2End.getTime()
+ , ""
+ , "Indian Point"
+ , "Indian Street"
+ , "Dallas"
+ , "TX"
+ , "US"
+ , "347571");
+
+ projectsOne = this.projectsRepository.save(projectsOne);
+ projectsTwo = this.projectsRepository.save(projectsTwo);
+
+ Calendar adarshDob = Calendar.getInstance();
+ adarshDob.set(2020, 1, 1);
+ Employee adarsh = new Employee("Adarsh"
+ , "Singh"
+ , Gender.MALE
+ , "adarsh@espark"
+ , adarshDob.getTime());
+ adarsh = employeeRepository.save(adarsh);
+
+
+ Calendar radhaDob = Calendar.getInstance();
+ radhaDob.set(2020, 1, 1);
+ Employee radha = new Employee("Radha"
+ , "Singh"
+ , Gender.MALE
+ , "radha@espark"
+ , radhaDob.getTime());
+ radha = employeeRepository.save(radha);
+
+ projectsOne.setEmployee(adarsh);
+ projectsOne.setEmployee(radha);
+ this.projectsRepository.save(projectsOne);
+
+ projectsTwo.setEmployee(adarsh);
+ projectsTwo.setEmployee(radha);
+ this.projectsRepository.save(projectsTwo);
+
+ adarsh.setProject(projectsOne);
+ adarsh.setProject(projectsTwo);
+ this.employeeRepository.save(adarsh);
+ radha.setProject(projectsOne);
+ radha.setProject(projectsTwo);
+ this.employeeRepository.save(radha);
+
+
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/service/EmployeeInfoService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/service/EmployeeInfoService.java
new file mode 100644
index 00000000..4bc01be8
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/service/EmployeeInfoService.java
@@ -0,0 +1,50 @@
+package com.espark.adarsh.service;
+
+import com.espark.adarsh.bean.EmployeeBean;
+import com.espark.adarsh.bean.ProjectsBean;
+import com.espark.adarsh.respository.ProjectsRepository;
+import com.espark.adarsh.respository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+public class EmployeeInfoService {
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ @Autowired
+ ProjectsRepository projectsRepository;
+
+ public List getEmployee() {
+ List employeeBeans = new LinkedList<>();
+ this.employeeRepository
+ .findAll()
+ .forEach(employee -> employeeBeans.add(new EmployeeBean(employee,
+ employee.getProjects()
+ .stream()
+ .map(employeeExperience ->
+ new ProjectsBean(employeeExperience)
+ ).collect(Collectors.toList()))));
+ return employeeBeans;
+ }
+
+ public List getEmployeeExperience() {
+ List projectsBeans = new LinkedList<>();
+ this.projectsRepository
+ .findAll()
+ .forEach(projects ->
+ projectsBeans.add(new ProjectsBean(projects
+ , projects.getEmployees()
+ .stream()
+ .map(employee -> new EmployeeBean(employee))
+ .collect(Collectors.toList())))
+ );
+ return projectsBeans;
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/web/ApplicationController.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/web/ApplicationController.java
new file mode 100644
index 00000000..b921aa18
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/java/com/espark/adarsh/web/ApplicationController.java
@@ -0,0 +1,29 @@
+package com.espark.adarsh.web;
+
+import com.espark.adarsh.bean.EmployeeBean;
+import com.espark.adarsh.bean.ProjectsBean;
+import com.espark.adarsh.service.EmployeeInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/api")
+public class ApplicationController {
+
+ @Autowired
+ EmployeeInfoService employeeInfoService;
+
+ @GetMapping("/employee")
+ public List getEmployees() {
+ return this.employeeInfoService.getEmployee();
+ }
+
+ @GetMapping("/employee-project")
+ public List getEmployeeProjects() {
+ return this.employeeInfoService.getEmployeeExperience();
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/resources/application.yml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/resources/application.yml
new file mode 100644
index 00000000..34b624d2
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/main/resources/application.yml
@@ -0,0 +1,32 @@
+logging:
+ level:
+ root: DEBUG
+ org:
+ hibernate:
+ SQL: DEBUG
+ type:
+ descriptor:
+ sql:
+ BasicBinder: TRACE
+
+spring:
+ application:
+ name: one-to-one-bidirectional
+ h2:
+ console:
+ enabled: true
+ datasource:
+ url: jdbc:h2:mem:testdb
+ driver-class-name: org.h2.Driver
+ username: root
+ password: root
+ jpa:
+ database-platform: org.hibernate.dialect.H2Dialect
+ hibernate:
+ ddl-auto: update
+ show-sql: true
+ properties:
+ hibernate:
+ format_sql: true
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/test/java/com/espark/adarsh/ApplicationMainTests.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/test/java/com/espark/adarsh/ApplicationMainTests.java
new file mode 100644
index 00000000..83533d04
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-many-to-many-bidirectional/src/test/java/com/espark/adarsh/ApplicationMainTests.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class ApplicationMainTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/.gitignore b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/.gitignore
new file mode 100644
index 00000000..a2a3040a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/document/help.txt b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/document/help.txt
new file mode 100644
index 00000000..0c020cd3
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/document/help.txt
@@ -0,0 +1,12 @@
+
+# to build
+$ mvn clean package
+
+#to run
+$ mvn spring-boot:run
+
+$ curl http://localhost:8080/api/employee
+$ curl http://localhost:8080/api/employee-experience
+
+## h2 db console url
+http://localhost:8080/h2-console
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/pom.xml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/pom.xml
new file mode 100644
index 00000000..83815047
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/pom.xml
@@ -0,0 +1,63 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.6.RELEASE
+
+
+ com.espark.adarsh
+ springboot-jpa-one-to-many-bidirectional
+ 0.0.1-SNAPSHOT
+ springboot-jpa-one-to-many-bidirectional
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.h2database
+ h2
+ runtime
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/ApplicationMain.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/ApplicationMain.java
new file mode 100644
index 00000000..1c7b85d8
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/ApplicationMain.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ApplicationMain {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ApplicationMain.class, args);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/bean/EmployeeBean.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/bean/EmployeeBean.java
new file mode 100644
index 00000000..3af14e2a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/bean/EmployeeBean.java
@@ -0,0 +1,38 @@
+package com.espark.adarsh.bean;
+
+import com.espark.adarsh.entities.Employee;
+import com.espark.adarsh.entities.EmployeeExperience;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class EmployeeBean extends Employee implements Serializable {
+
+ private List employeeExperienceBeans;
+
+ public EmployeeBean() {
+ }
+
+ public EmployeeBean(Employee employee) {
+ this.id = employee.getId();
+ this.firstName = employee.getFirstName();
+ this.lastName = employee.getLastName();
+ this.email = employee.getEmail();
+ this.dob = employee.getDob();
+ this.employeeExperienceBeans = null;
+ }
+
+ public EmployeeBean(Employee employee, List list) {
+ this.id = employee.getId();
+ this.firstName = employee.getFirstName();
+ this.lastName = employee.getLastName();
+ this.email = employee.getEmail();
+ this.dob = employee.getDob();
+ this.employeeExperienceBeans = list;
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/bean/EmployeeExperienceBean.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/bean/EmployeeExperienceBean.java
new file mode 100644
index 00000000..f06c0b51
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/bean/EmployeeExperienceBean.java
@@ -0,0 +1,47 @@
+package com.espark.adarsh.bean;
+
+import com.espark.adarsh.entities.EmployeeExperience;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class EmployeeExperienceBean extends EmployeeExperience
+ implements Serializable {
+
+ EmployeeBean employeeBean;
+
+ public EmployeeExperienceBean() {
+ }
+
+ public EmployeeExperienceBean(EmployeeExperience employeeExperience) {
+ this.id = employeeExperience.getId();
+ this.phoneNumber = employeeExperience.getPhoneNumber();
+ this.start = employeeExperience.getStart();
+ this.end = employeeExperience.getEnd();
+ this.address1 = employeeExperience.getAddress1();
+ this.address2 = employeeExperience.getAddress2();
+ this.street = employeeExperience.getStreet();
+ this.city = employeeExperience.getCity();
+ this.state = employeeExperience.getState();
+ this.country = employeeExperience.getCountry();
+ this.zipCode = employeeExperience.getZipCode();
+ }
+
+ public EmployeeExperienceBean(EmployeeExperience employeeExperience, EmployeeBean employee) {
+ this.id = employeeExperience.getId();
+ this.phoneNumber = employeeExperience.getPhoneNumber();
+ this.start = employeeExperience.getStart();
+ this.end = employeeExperience.getEnd();
+ this.address1 = employeeExperience.getAddress1();
+ this.address2 = employeeExperience.getAddress2();
+ this.street = employeeExperience.getStreet();
+ this.city = employeeExperience.getCity();
+ this.state = employeeExperience.getState();
+ this.country = employeeExperience.getCountry();
+ this.zipCode = employeeExperience.getZipCode();
+ this.employeeBean = employee;
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/Employee.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/Employee.java
new file mode 100644
index 00000000..47487204
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/Employee.java
@@ -0,0 +1,65 @@
+package com.espark.adarsh.entities;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.validation.constraints.Email;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+@Setter
+@Getter
+@Entity
+@Table(name = "employee")
+public class Employee implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ protected Long id;
+
+ @NotNull
+ @Size(max = 65)
+ @Column(name = "first_name")
+ protected String firstName;
+
+ @Size(max = 65)
+ @Column(name = "last_name")
+ protected String lastName;
+
+ @Enumerated(EnumType.STRING)
+ @Column(length = 10)
+ protected Gender gender;
+
+ @NotNull
+ @Email
+ @Size(max = 100)
+ @Column(unique = true)
+ protected String email;
+
+ @Temporal(TemporalType.DATE)
+ @Column(name = "dob")
+ protected Date dob;
+
+ @OneToMany(mappedBy = "employee"
+ , cascade = CascadeType.ALL
+ , orphanRemoval = true)
+ private List employeeExperience;
+
+ public Employee() {
+ }
+
+ public Employee(@NotNull @Size(max = 65) String firstName
+ , @Size(max = 65) String lastName
+ , Gender gender
+ , @NotNull @Email @Size(max = 100) String email
+ , Date dob) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.gender = gender;
+ this.email = email;
+ this.dob = dob;
+ }
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/EmployeeExperience.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/EmployeeExperience.java
new file mode 100644
index 00000000..e7bc75e0
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/EmployeeExperience.java
@@ -0,0 +1,87 @@
+package com.espark.adarsh.entities;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.persistence.*;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+import java.util.Date;
+
+@Setter
+@Getter
+@Entity
+@Table(name = "employee_experience")
+public class EmployeeExperience implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ protected Long id;
+
+ @Size(max = 100)
+ protected String coyName;
+
+ @Column(name = "phone_number")
+ @Size(max = 15)
+ protected String phoneNumber;
+
+ @Temporal(TemporalType.DATE)
+ @Column(name = "start")
+ protected Date start;
+
+ @Temporal(TemporalType.DATE)
+ @Column(name = "end")
+ protected Date end;
+
+ @Size(max = 100)
+ protected String address1;
+
+ @Size(max = 100)
+ protected String address2;
+
+ @Size(max = 100)
+ protected String street;
+
+ @Size(max = 100)
+ protected String city;
+
+ @Size(max = 100)
+ protected String state;
+
+ @Size(max = 100)
+ protected String country;
+
+ @Column(name = "zip_code")
+ @Size(max = 32)
+ protected String zipCode;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ private Employee employee;
+
+ public EmployeeExperience() {
+
+ }
+
+ public EmployeeExperience(@Size(max = 100) String coyName
+ , @Size(max = 15) String phoneNumber
+ , Date start
+ , Date end
+ , @Size(max = 100) String address1
+ , @Size(max = 100) String address2
+ , @Size(max = 100) String street
+ , @Size(max = 100) String city
+ , @Size(max = 100) String state
+ , @Size(max = 100) String country
+ , @Size(max = 32) String zipCode) {
+ this.coyName = coyName;
+ this.phoneNumber = phoneNumber;
+ this.start = start;
+ this.end = end;
+ this.address1 = address1;
+ this.address2 = address2;
+ this.street = street;
+ this.city = city;
+ this.state = state;
+ this.country = country;
+ this.zipCode = zipCode;
+ }
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/Gender.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/Gender.java
new file mode 100644
index 00000000..71f78d64
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/entities/Gender.java
@@ -0,0 +1,6 @@
+package com.espark.adarsh.entities;
+
+public enum Gender {
+ MALE,
+ FEMALE
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/respository/EmployeeExperienceRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/respository/EmployeeExperienceRepository.java
new file mode 100644
index 00000000..b38effe1
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/respository/EmployeeExperienceRepository.java
@@ -0,0 +1,10 @@
+package com.espark.adarsh.respository;
+
+import com.espark.adarsh.entities.EmployeeExperience;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface EmployeeExperienceRepository extends JpaRepository {
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
new file mode 100644
index 00000000..9e2ffbc2
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
@@ -0,0 +1,10 @@
+package com.espark.adarsh.respository;
+
+import com.espark.adarsh.entities.Employee;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface EmployeeRepository extends JpaRepository {
+
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/service/DbInitService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/service/DbInitService.java
new file mode 100644
index 00000000..81ce17cb
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/service/DbInitService.java
@@ -0,0 +1,133 @@
+package com.espark.adarsh.service;
+
+import com.espark.adarsh.entities.Gender;
+import com.espark.adarsh.entities.Employee;
+import com.espark.adarsh.entities.EmployeeExperience;
+import com.espark.adarsh.respository.EmployeeExperienceRepository;
+import com.espark.adarsh.respository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.sql.DataSource;
+import java.util.Arrays;
+import java.util.Calendar;
+
+@Service
+public class DbInitService {
+
+
+ @Autowired
+ DataSource dataSource;
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ @Autowired
+ EmployeeExperienceRepository employeeExperienceRepository;
+
+ @PostConstruct
+ public void init() {
+ Calendar adarshDob = Calendar.getInstance();
+ adarshDob.set(2020, 1, 1);
+ Employee adarsh = new Employee("Adarsh"
+ , "Singh"
+ , Gender.MALE
+ , "adarsh@espark"
+ , adarshDob.getTime());
+
+ Calendar adarshCoy1Start = Calendar.getInstance();
+ adarshCoy1Start.set(2001, 1, 1);
+ Calendar adarshCoy1End = Calendar.getInstance();
+ adarshCoy1End.set(2010, 1, 1);
+ EmployeeExperience adarshCoy1 = new EmployeeExperience(
+ "coy1"
+ ,"+1-1122334455"
+ , adarshCoy1Start.getTime()
+ , adarshCoy1End.getTime()
+ ,""
+ , "Indian Point"
+ , "Indian Street"
+ , "Dallas"
+ , "TX"
+ , "US"
+ , "347571");
+
+
+ Calendar adarshCoy2Start = Calendar.getInstance();
+ adarshCoy2Start.set(2010, 1, 1);
+ Calendar adarshCoy2End = Calendar.getInstance();
+ adarshCoy2End.set(2020, 1, 1);
+ EmployeeExperience adarshCoy2 = new EmployeeExperience(
+ "coy2"
+ ,"+1-1122334455"
+ , adarshCoy2Start.getTime()
+ , adarshCoy2End.getTime()
+ ,""
+ , "Indian Point"
+ , "Indian Street"
+ , "Dallas"
+ , "TX"
+ , "US"
+ , "347571");
+
+ adarsh.setEmployeeExperience(Arrays.asList(adarshCoy1,adarshCoy2));
+ adarshCoy1.setEmployee(adarsh);
+ adarshCoy2.setEmployee(adarsh);
+ employeeRepository.save(adarsh);
+
+
+ Calendar radhaDob = Calendar.getInstance();
+ radhaDob.set(2020, 1, 1);
+ Employee radha = new Employee("Radha"
+ , "Singh"
+ , Gender.MALE
+ , "radha@espark"
+ , radhaDob.getTime());
+
+ Calendar radhaCoy1Start = Calendar.getInstance();
+ radhaCoy1Start.set(2001, 1, 1);
+ Calendar radhaCoy1End = Calendar.getInstance();
+ radhaCoy1End.set(2010, 1, 1);
+ EmployeeExperience radhaCoy1 = new EmployeeExperience(
+ "coy1"
+ ,"+1-55226688"
+ , radhaCoy1Start.getTime()
+ , radhaCoy1End.getTime()
+ ,""
+ , "Indian Point"
+ , "Indian Street"
+ , "Dallas"
+ , "TX"
+ , "US"
+ , "347571");
+
+
+ Calendar radhaCoy2Start = Calendar.getInstance();
+ radhaCoy2Start.set(2010, 1, 1);
+ Calendar radhaCoy2End = Calendar.getInstance();
+ radhaCoy2End.set(2020, 1, 1);
+ EmployeeExperience radhaCoy2 = new EmployeeExperience(
+ "coy2"
+ ,"+1-1122334455"
+ , radhaCoy2Start.getTime()
+ , radhaCoy2End.getTime()
+ ,""
+ , "Indian Point"
+ , "Indian Street"
+ , "Dallas"
+ , "TX"
+ , "US"
+ , "347571");
+
+ radha.setEmployeeExperience(Arrays.asList(radhaCoy1,radhaCoy2));
+ radhaCoy1.setEmployee(radha);
+ radhaCoy2.setEmployee(radha);
+ employeeRepository.save(radha);
+
+ /* Resource initSchema = new ClassPathResource("db.sql_bkp");
+ DatabasePopulator databasePopulator = new ResourceDatabasePopulator(initSchema);
+ DatabasePopulatorUtils.execute(databasePopulator, dataSource);*/
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/service/EmployeeInfoService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/service/EmployeeInfoService.java
new file mode 100644
index 00000000..707708ce
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/service/EmployeeInfoService.java
@@ -0,0 +1,47 @@
+package com.espark.adarsh.service;
+
+import com.espark.adarsh.bean.EmployeeBean;
+import com.espark.adarsh.bean.EmployeeExperienceBean;
+import com.espark.adarsh.respository.EmployeeExperienceRepository;
+import com.espark.adarsh.respository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+public class EmployeeInfoService {
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ @Autowired
+ EmployeeExperienceRepository employeeExperienceRepository;
+
+ public List getEmployee() {
+ List employeeBeans = new LinkedList<>();
+ this.employeeRepository
+ .findAll()
+ .forEach(employee -> employeeBeans.add(new EmployeeBean(employee,
+ employee.getEmployeeExperience()
+ .stream()
+ .map(employeeExperience ->
+ new EmployeeExperienceBean(employeeExperience)
+ ).collect(Collectors.toList()))));
+ return employeeBeans;
+ }
+
+ public List getEmployeeExperience() {
+ List employeeExperienceBeans = new LinkedList<>();
+ this.employeeExperienceRepository
+ .findAll()
+ .forEach(employeeExperience ->
+ employeeExperienceBeans.add(new EmployeeExperienceBean(employeeExperience
+ , new EmployeeBean(employeeExperience.getEmployee())))
+ );
+ return employeeExperienceBeans;
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/web/ApplicationController.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/web/ApplicationController.java
new file mode 100644
index 00000000..16e9382c
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/java/com/espark/adarsh/web/ApplicationController.java
@@ -0,0 +1,29 @@
+package com.espark.adarsh.web;
+
+import com.espark.adarsh.bean.EmployeeBean;
+import com.espark.adarsh.bean.EmployeeExperienceBean;
+import com.espark.adarsh.service.EmployeeInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/api")
+public class ApplicationController {
+
+ @Autowired
+ EmployeeInfoService employeeInfoService;
+
+ @GetMapping("/employee")
+ public List getEmployees() {
+ return this.employeeInfoService.getEmployee();
+ }
+
+ @GetMapping("/employee-experience")
+ public List getEmployeeExperience() {
+ return this.employeeInfoService.getEmployeeExperience();
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/resources/application.yml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/resources/application.yml
new file mode 100644
index 00000000..34b624d2
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/main/resources/application.yml
@@ -0,0 +1,32 @@
+logging:
+ level:
+ root: DEBUG
+ org:
+ hibernate:
+ SQL: DEBUG
+ type:
+ descriptor:
+ sql:
+ BasicBinder: TRACE
+
+spring:
+ application:
+ name: one-to-one-bidirectional
+ h2:
+ console:
+ enabled: true
+ datasource:
+ url: jdbc:h2:mem:testdb
+ driver-class-name: org.h2.Driver
+ username: root
+ password: root
+ jpa:
+ database-platform: org.hibernate.dialect.H2Dialect
+ hibernate:
+ ddl-auto: update
+ show-sql: true
+ properties:
+ hibernate:
+ format_sql: true
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/test/java/com/espark/adarsh/ApplicationMainTests.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/test/java/com/espark/adarsh/ApplicationMainTests.java
new file mode 100644
index 00000000..83533d04
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-many-bidirectional/src/test/java/com/espark/adarsh/ApplicationMainTests.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class ApplicationMainTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/.gitignore b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/.gitignore
new file mode 100644
index 00000000..a2a3040a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/document/db.sql_bkp b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/document/db.sql_bkp
new file mode 100644
index 00000000..f193d13c
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/document/db.sql_bkp
@@ -0,0 +1,69 @@
+
+
+
+
+ drop table user_profiles if exists;
+
+ create table user_profiles (
+ id bigint generated by default as identity,
+ address1 varchar(100),
+ address2 varchar(100),
+ city varchar(100),
+ country varchar(100),
+ dob date,
+ gender varchar(10),
+ phone_number varchar(15),
+ state varchar(100),
+ street varchar(100),
+ zip_code varchar(32),
+ user_id bigint not null,
+ primary key (id)
+);
+
+ drop table users if exists;
+
+ create table users (
+ id bigint generated by default as identity,
+ email varchar(100) not null,
+ first_name varchar(65) not null,
+ last_name varchar(65),
+ password varchar(128) not null,
+ primary key (id)
+ );
+
+ alter table user_profiles add constraint UK_user_id_key unique (user_id);
+
+ alter table users add constraint UK_email_key unique (email);
+
+ alter table user_profiles add constraint FK_user_id_users_key foreign key (user_id) references users;
+
+
+
+ insert
+ into
+ users
+ (id, email, first_name, last_name, password)
+ values
+ (1, 'adarsh@kumar', 'adarsh', 'kumar', '@123@abc')
+
+ insert
+ into
+ user_profiles
+ (id, address1, address2, city, country, dob, gender, phone_number, state, street, user_id, zip_code)
+ values
+ (1, 'indiian place', 'indian point', 'dallas', 'usa', '2020-02-01', 'MALE', '+122334455', 'tx', 'india street', '1', '75034')
+
+
+ insert
+ into
+ users
+ (id, email, first_name, last_name, password)
+ values
+ (2, 'radha@singh', 'radha', 'singh', '@123@abc')
+
+ insert
+ into
+ user_profiles
+ (id, address1, address2, city, country, dob, gender, phone_number, state, street, user_id, zip_code)
+ values
+ (1, 'indiian place', 'indian point', 'dallas', 'usa', '2020-02-01', 'MALE', '+122334455', 'tx', 'india street', '2', '75034')
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/document/help.txt b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/document/help.txt
new file mode 100644
index 00000000..2d7bb50e
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/document/help.txt
@@ -0,0 +1,12 @@
+
+# to build
+$ mvn clean package
+
+#to run
+$ mvn spring-boot:run
+
+$ curl http://localhost:8080/api/users
+$ curl http://localhost:8080/api/userprofiles
+
+## h2 db console url
+http://localhost:8080/h2-console
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/pom.xml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/pom.xml
new file mode 100644
index 00000000..1dbe02a8
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/pom.xml
@@ -0,0 +1,63 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.6.RELEASE
+
+
+ com.espark.adarsh
+ springboot-jpa-one-to-one-bidirectional
+ 0.0.1-SNAPSHOT
+ springboot-jpa-one-to-one-bidirectional
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.h2database
+ h2
+ runtime
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/JpaOneToOneBidirectionalApplicationMain.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/JpaOneToOneBidirectionalApplicationMain.java
new file mode 100644
index 00000000..ed164ec5
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/JpaOneToOneBidirectionalApplicationMain.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class JpaOneToOneBidirectionalApplicationMain {
+
+ public static void main(String[] args) {
+ SpringApplication.run(JpaOneToOneBidirectionalApplicationMain.class, args);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/bean/UserBean.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/bean/UserBean.java
new file mode 100644
index 00000000..993fc711
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/bean/UserBean.java
@@ -0,0 +1,46 @@
+package com.espark.adarsh.bean;
+
+import com.espark.adarsh.entities.User;
+import com.espark.adarsh.entities.UserProfile;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class UserBean implements Serializable {
+
+ private Long id;
+
+ private String firstName;
+
+ private String lastName;
+
+ private String email;
+
+ private String password;
+
+ private UserProfileBean userProfile;
+
+ public UserBean() {
+ }
+
+ public UserBean(User user) {
+ this.id = user.getId();
+ this.firstName = user.getFirstName();
+ this.lastName = user.getLastName();
+ this.email = user.getEmail();
+ this.password = user.getPassword();
+ this.userProfile = null;
+ }
+
+ public UserBean(User user, UserProfile userProfile) {
+ this.id = user.getId();
+ this.firstName = user.getFirstName();
+ this.lastName = user.getLastName();
+ this.email = user.getEmail();
+ this.password = user.getPassword();
+ this.userProfile = new UserProfileBean(userProfile);
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/bean/UserProfileBean.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/bean/UserProfileBean.java
new file mode 100644
index 00000000..2720757d
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/bean/UserProfileBean.java
@@ -0,0 +1,72 @@
+package com.espark.adarsh.bean;
+
+import com.espark.adarsh.entities.Gender;
+import com.espark.adarsh.entities.User;
+import com.espark.adarsh.entities.UserProfile;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class UserProfileBean implements Serializable {
+
+ private Long id;
+
+ private String phoneNumber;
+
+ private Gender gender;
+
+ private Date dateOfBirth;
+
+ private String address1;
+
+ private String address2;
+
+ private String street;
+
+ private String city;
+
+ private String state;
+
+ private String country;
+
+ private String zipCode;
+
+ private UserBean user;
+
+ public UserProfileBean() {
+ }
+
+ public UserProfileBean(UserProfile userProfile) {
+ this.id = userProfile.getId();
+ this.phoneNumber = userProfile.getPhoneNumber();
+ this.gender = userProfile.getGender();
+ this.dateOfBirth = userProfile.getDateOfBirth();
+ this.address1 = userProfile.getAddress1();
+ this.address2 = userProfile.getAddress2();
+ this.street = userProfile.getStreet();
+ this.city = userProfile.getCity();
+ this.state = userProfile.getState();
+ this.country = userProfile.getCountry();
+ this.zipCode = userProfile.getZipCode();
+ this.user = null;
+ }
+
+ public UserProfileBean(UserProfile userProfile, User user) {
+ this.id = userProfile.getId();
+ this.phoneNumber = userProfile.getPhoneNumber();
+ this.gender = userProfile.getGender();
+ this.dateOfBirth = userProfile.getDateOfBirth();
+ this.address1 = userProfile.getAddress1();
+ this.address2 = userProfile.getAddress2();
+ this.street = userProfile.getStreet();
+ this.city = userProfile.getCity();
+ this.state = userProfile.getState();
+ this.country = userProfile.getCountry();
+ this.zipCode = userProfile.getZipCode();
+ this.user = new UserBean(user);
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/entities/Gender.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/entities/Gender.java
new file mode 100644
index 00000000..71f78d64
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/entities/Gender.java
@@ -0,0 +1,6 @@
+package com.espark.adarsh.entities;
+
+public enum Gender {
+ MALE,
+ FEMALE
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/entities/User.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/entities/User.java
new file mode 100644
index 00000000..3737cb4d
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/entities/User.java
@@ -0,0 +1,57 @@
+package com.espark.adarsh.entities;
+
+import com.fasterxml.jackson.annotation.JsonManagedReference;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.validation.constraints.Email;
+import java.io.Serializable;
+
+@Setter
+@Getter
+@Entity
+@Table(name = "users")
+public class User implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Long id;
+
+ @NotNull
+ @Size(max = 65)
+ @Column(name = "first_name")
+ private String firstName;
+
+ @Size(max = 65)
+ @Column(name = "last_name")
+ private String lastName;
+
+ @NotNull
+ @Email
+ @Size(max = 100)
+ @Column(unique = true)
+ private String email;
+
+ @NotNull
+ @Size(max = 128)
+ private String password;
+
+ @JsonManagedReference
+ @OneToOne(fetch = FetchType.LAZY,
+ cascade = CascadeType.ALL,
+ mappedBy = "user")
+ private UserProfile userProfile;
+
+ public User() {
+ }
+
+ public User(String firstName, String lastName, String email, String password) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.email = email;
+ this.password = password;
+ }
+
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/entities/UserProfile.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/entities/UserProfile.java
new file mode 100644
index 00000000..99970e31
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/entities/UserProfile.java
@@ -0,0 +1,79 @@
+package com.espark.adarsh.entities;
+
+import com.fasterxml.jackson.annotation.JsonBackReference;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.persistence.*;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+import java.util.Date;
+
+@Setter
+@Getter
+@Entity
+@Table(name = "user_profiles")
+public class UserProfile implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Long id;
+
+ @Column(name = "phone_number")
+ @Size(max = 15)
+ private String phoneNumber;
+
+ @Enumerated(EnumType.STRING)
+ @Column(length = 10)
+ private Gender gender;
+
+ @Temporal(TemporalType.DATE)
+ @Column(name = "dob")
+ private Date dateOfBirth;
+
+ @Size(max = 100)
+ private String address1;
+
+ @Size(max = 100)
+ private String address2;
+
+ @Size(max = 100)
+ private String street;
+
+ @Size(max = 100)
+ private String city;
+
+ @Size(max = 100)
+ private String state;
+
+ @Size(max = 100)
+ private String country;
+
+ @Column(name = "zip_code")
+ @Size(max = 32)
+ private String zipCode;
+
+ @JsonBackReference
+ @OneToOne(fetch = FetchType.LAZY, optional = false)
+ @JoinColumn(name = "user_id", nullable = false)
+ private User user;
+
+ public UserProfile() {
+
+ }
+
+ public UserProfile(String phoneNumber, Gender gender, Date dateOfBirth,
+ String address1, String address2, String street, String city,
+ String state, String country, String zipCode) {
+ this.phoneNumber = phoneNumber;
+ this.gender = gender;
+ this.dateOfBirth = dateOfBirth;
+ this.address1 = address1;
+ this.address2 = address2;
+ this.street = street;
+ this.city = city;
+ this.state = state;
+ this.country = country;
+ this.zipCode = zipCode;
+ }
+
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/respository/UserProfileRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/respository/UserProfileRepository.java
new file mode 100644
index 00000000..bfe546dd
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/respository/UserProfileRepository.java
@@ -0,0 +1,10 @@
+package com.espark.adarsh.respository;
+
+import com.espark.adarsh.entities.UserProfile;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface UserProfileRepository extends JpaRepository {
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/respository/UserRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/respository/UserRepository.java
new file mode 100644
index 00000000..1e14b012
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/respository/UserRepository.java
@@ -0,0 +1,10 @@
+package com.espark.adarsh.respository;
+
+import com.espark.adarsh.entities.User;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface UserRepository extends JpaRepository {
+
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/service/DbInitService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/service/DbInitService.java
new file mode 100644
index 00000000..76af20e0
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/service/DbInitService.java
@@ -0,0 +1,86 @@
+package com.espark.adarsh.service;
+
+import com.espark.adarsh.entities.Gender;
+import com.espark.adarsh.entities.User;
+import com.espark.adarsh.entities.UserProfile;
+import com.espark.adarsh.respository.UserProfileRepository;
+import com.espark.adarsh.respository.UserRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.jdbc.datasource.init.DatabasePopulator;
+import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils;
+import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.sql.DataSource;
+import java.util.Calendar;
+
+@Service
+public class DbInitService {
+
+
+ @Autowired
+ DataSource dataSource;
+
+ @Autowired
+ UserRepository userRepository;
+
+ @Autowired
+ UserProfileRepository userProfileRepository;
+
+ @PostConstruct
+ public void init() {
+ User adarsh = new User("Adarsh"
+ , "Singh"
+ , "adarsh@espark"
+ , "@123@123");
+
+ Calendar adarshDob = Calendar.getInstance();
+ adarshDob.set(2020, 1, 1);
+ UserProfile adarshProfile = new UserProfile("+1-1122334455"
+ , Gender.MALE
+ , adarshDob.getTime()
+ , "111"
+ , "Indian Street"
+ , "Indian Point"
+ , "Dallas"
+ , "TX"
+ , "US"
+ , "347571");
+
+ adarsh.setUserProfile(adarshProfile);
+ adarshProfile.setUser(adarsh);
+ userRepository.save(adarsh);
+
+
+ User radha = new User("Radha"
+ , "Singh"
+ , "radha@espak"
+ , "@123@123");
+
+ Calendar radhaDob = Calendar.getInstance();
+ radhaDob.set(2020, 1, 1);
+ UserProfile radhaProfile = new UserProfile("+1-55443322"
+ , Gender.MALE
+ , radhaDob.getTime()
+ , "111"
+ , "Indian Street"
+ , "Indian Point"
+ , "Dallas"
+ , "TX"
+ , "US"
+ , "347571");
+
+ radha.setUserProfile(radhaProfile);
+ radhaProfile.setUser(radha);
+ userRepository.save(radha);
+
+
+ /* Resource initSchema = new ClassPathResource("db.sql_bkp");
+ DatabasePopulator databasePopulator = new ResourceDatabasePopulator(initSchema);
+ DatabasePopulatorUtils.execute(databasePopulator, dataSource);*/
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/service/UsersInfoService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/service/UsersInfoService.java
new file mode 100644
index 00000000..2f1d133f
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/service/UsersInfoService.java
@@ -0,0 +1,39 @@
+package com.espark.adarsh.service;
+
+import com.espark.adarsh.bean.UserBean;
+import com.espark.adarsh.bean.UserProfileBean;
+import com.espark.adarsh.entities.User;
+import com.espark.adarsh.entities.UserProfile;
+import com.espark.adarsh.respository.UserProfileRepository;
+import com.espark.adarsh.respository.UserRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import java.util.LinkedList;
+import java.util.List;
+
+@Service
+public class UsersInfoService {
+
+ @Autowired
+ UserRepository userRepository;
+
+ @Autowired
+ UserProfileRepository userProfileRepository;
+
+ public List getUsers() {
+ List users = new LinkedList<>();
+ this.userRepository
+ .findAll()
+ .forEach(user -> users.add(new UserBean(user, user.getUserProfile())));
+ return users;
+ }
+
+ public List getUserProfiles() {
+ List userProfiles = new LinkedList<>();
+ this.userProfileRepository
+ .findAll()
+ .forEach(userProfile -> userProfiles.add(new UserProfileBean(userProfile, userProfile.getUser())));
+ return userProfiles;
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/web/ApplicationController.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/web/ApplicationController.java
new file mode 100644
index 00000000..93a265e6
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/java/com/espark/adarsh/web/ApplicationController.java
@@ -0,0 +1,30 @@
+package com.espark.adarsh.web;
+
+import com.espark.adarsh.bean.UserBean;
+import com.espark.adarsh.bean.UserProfileBean;
+import com.espark.adarsh.entities.UserProfile;
+import com.espark.adarsh.service.UsersInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/api")
+public class ApplicationController {
+
+ @Autowired
+ UsersInfoService usersInfoService;
+
+ @GetMapping("/users")
+ public List getUsers() {
+ return this.usersInfoService.getUsers();
+ }
+
+ @GetMapping("/userprofiles")
+ public List getUserProfiles() {
+ return this.usersInfoService.getUserProfiles();
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/resources/application.yml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/resources/application.yml
new file mode 100644
index 00000000..34b624d2
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/main/resources/application.yml
@@ -0,0 +1,32 @@
+logging:
+ level:
+ root: DEBUG
+ org:
+ hibernate:
+ SQL: DEBUG
+ type:
+ descriptor:
+ sql:
+ BasicBinder: TRACE
+
+spring:
+ application:
+ name: one-to-one-bidirectional
+ h2:
+ console:
+ enabled: true
+ datasource:
+ url: jdbc:h2:mem:testdb
+ driver-class-name: org.h2.Driver
+ username: root
+ password: root
+ jpa:
+ database-platform: org.hibernate.dialect.H2Dialect
+ hibernate:
+ ddl-auto: update
+ show-sql: true
+ properties:
+ hibernate:
+ format_sql: true
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/test/java/com/espark/adarsh/JpaOneToOneBidirectionalApplicationMainTests.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/test/java/com/espark/adarsh/JpaOneToOneBidirectionalApplicationMainTests.java
new file mode 100644
index 00000000..fcaa37dd
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one-bidirectional/src/test/java/com/espark/adarsh/JpaOneToOneBidirectionalApplicationMainTests.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class JpaOneToOneBidirectionalApplicationMainTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/.gitignore b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/.gitignore
new file mode 100644
index 00000000..a2a3040a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/document/help.txt b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/document/help.txt
new file mode 100644
index 00000000..6305453e
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/document/help.txt
@@ -0,0 +1,9 @@
+#to build the application
+$ mvn clean package
+
+$ mvn spring-boot:run
+
+#log into the homepage of db
+http://localhost:8080/h2-console
+
+username, pwd , dburl and db driver class is mentioned in application.properties file
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/pom.xml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/pom.xml
new file mode 100644
index 00000000..46fa3f28
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/pom.xml
@@ -0,0 +1,63 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.6.RELEASE
+
+
+ com.espark.adarsh
+ springboot-jpa-one-to-one
+ 0.0.1-SNAPSHOT
+ springboot-jpa-one-to-one
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.h2database
+ h2
+ runtime
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/ApplicationMain.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/ApplicationMain.java
new file mode 100644
index 00000000..1c7b85d8
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/ApplicationMain.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ApplicationMain {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ApplicationMain.class, args);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/db/DataInitializer.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/db/DataInitializer.java
new file mode 100644
index 00000000..a2883dbe
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/db/DataInitializer.java
@@ -0,0 +1,33 @@
+package com.espark.adarsh.db;
+
+import com.espark.adarsh.entity.Address;
+import com.espark.adarsh.entity.Customer;
+import com.espark.adarsh.repository.AddressRepository;
+import com.espark.adarsh.repository.CustomerRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+
+@Component
+public class DataInitializer {
+
+ @Autowired
+ CustomerRepository repository;
+
+ @Autowired
+ AddressRepository addressRepository;
+
+ @PostConstruct
+ public void init() {
+ addressRepository.save(new Address());
+ repository.save(new Customer("Radha", "Singh"));
+ repository.save(new Customer("Adarsh", "kumar"));
+ repository.save(new Customer("Amit", "kumar"));
+ repository.save(new Customer("Chloe", "O'Brian"));
+ repository.save(new Customer("Kim", "Bauer"));
+ repository.save(new Customer("David", "Palmer"));
+ repository.save(new Customer("Michelle", "Dessler"));
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/entity/Address.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/entity/Address.java
new file mode 100644
index 00000000..db3d8725
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/entity/Address.java
@@ -0,0 +1,51 @@
+package com.espark.adarsh.entity;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "address")
+public class Address {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
+ private Long id;
+
+ String street;
+ String city;
+
+ @OneToOne(mappedBy = "address")
+ private Customer customer;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getStreet() {
+ return street;
+ }
+
+ public void setStreet(String street) {
+ this.street = street;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public Customer getCustomer() {
+ return customer;
+ }
+
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/entity/Customer.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/entity/Customer.java
new file mode 100644
index 00000000..38a37931
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/entity/Customer.java
@@ -0,0 +1,34 @@
+package com.espark.adarsh.entity;
+
+import lombok.*;
+
+import javax.persistence.*;
+
+@Data
+@Setter
+@Getter
+@AllArgsConstructor
+@NoArgsConstructor
+@ToString
+@Entity
+public class Customer {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+
+ private String firstName;
+
+ private String lastName;
+
+
+ @OneToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "address_id", referencedColumnName = "id")
+ private Address address;
+
+ public Customer(String firstName, String lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/repository/AddressRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/repository/AddressRepository.java
new file mode 100644
index 00000000..8d46f07e
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/repository/AddressRepository.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh.repository;
+
+import com.espark.adarsh.entity.Address;
+import org.springframework.data.repository.CrudRepository;
+
+import java.util.List;
+
+public interface AddressRepository extends CrudRepository {
+
+ List findByLastName(String lastName);
+
+ Address findById(long id);
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/repository/CustomerRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/repository/CustomerRepository.java
new file mode 100644
index 00000000..1f8fdb41
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/repository/CustomerRepository.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh.repository;
+
+import java.util.List;
+
+import com.espark.adarsh.entity.Customer;
+import org.springframework.data.repository.CrudRepository;
+
+public interface CustomerRepository extends CrudRepository {
+
+ List findByLastName(String lastName);
+
+ Customer findById(long id);
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/service/CustomerService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/service/CustomerService.java
new file mode 100644
index 00000000..7622e94c
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/service/CustomerService.java
@@ -0,0 +1,43 @@
+package com.espark.adarsh.service;
+
+import com.espark.adarsh.entity.Customer;
+import com.espark.adarsh.repository.CustomerRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.LinkedList;
+import java.util.List;
+
+@Service
+public class CustomerService {
+
+ @Autowired
+ CustomerRepository customerRepository;
+
+ public Customer getCustomer(Long id) {
+ return customerRepository.findById(id).get();
+ }
+
+ public List getAllCustomer() {
+ List customerList = new LinkedList<>();
+ customerRepository
+ .findAll()
+ .forEach(customer -> customerList.add(customer));
+ return customerList;
+ }
+
+ public Customer createCustomer(Customer customer) {
+ return this.customerRepository.save(customer);
+ }
+
+ public Customer updateCustomer(Customer customer) {
+ return this.customerRepository.save(customer);
+ }
+
+ public Customer deleteCustomer(Long id) {
+ Customer customer = customerRepository.findById(id).get();
+ customerRepository.delete(customer);
+ return customer;
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/we/CustomerController.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/we/CustomerController.java
new file mode 100644
index 00000000..63ba9468
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/java/com/espark/adarsh/we/CustomerController.java
@@ -0,0 +1,41 @@
+package com.espark.adarsh.we;
+
+import com.espark.adarsh.entity.Customer;
+import com.espark.adarsh.service.CustomerService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+public class CustomerController {
+
+ @Autowired
+ CustomerService customerService;
+
+ @GetMapping("/customers")
+ public List getAll() {
+ return this.customerService.getAllCustomer();
+ }
+
+ @GetMapping("/customer/{id}")
+ public Customer getCustomer(@PathVariable("id") Long id) {
+ return this.customerService.getCustomer(id);
+ }
+
+ @PutMapping("/customer/{id}")
+ public Customer getCustomer(@PathVariable("id") Long id, @RequestBody Customer customer) {
+ return this.customerService.updateCustomer(customer);
+ }
+
+ @DeleteMapping("/customer/{id}")
+ public Customer deleteCustomer(@PathVariable("id") Long id) {
+ return this.customerService.deleteCustomer(id);
+ }
+
+ @PostMapping("/customer")
+ public Customer getCustomer(@RequestBody Customer customer) {
+ return this.customerService.createCustomer(customer);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/resources/application.properties b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/resources/application.properties
new file mode 100644
index 00000000..0a2b5d21
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/main/resources/application.properties
@@ -0,0 +1,22 @@
+
+spring.datasource.type=com.zaxxer.hikari.HikariDataSource
+spring.datasource.url=jdbc:h2:mem:testdb
+spring.datasource.driverClassName=org.h2.Driver
+spring.datasource.username=root
+spring.datasource.password=root
+spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
+spring.h2.console.enabled=true
+
+spring.jpa.hibernate.connection.provider_class=org.hibernate.hikaricp.internal.HikariCPConnectionProvider
+
+spring.datasource.hikari.minimumIdle=5
+spring.datasource.hikari.maximumPoolSize=20
+spring.datasource.hikari.idleTimeout=30000
+spring.datasource.hikari.poolName=SpringBootJPAHikariCP
+spring.datasource.hikari.maxLifetime=2000000
+spring.datasource.hikari.connectionTimeout=30000
+
+
+logging.level.org.hibernate.SQL=DEBUG
+logging.level.com.zaxxer.hikari.HikariConfig=DEBUG
+logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/test/java/com/espark/adarsh/SpringbootJpaApplicationTests.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/test/java/com/espark/adarsh/SpringbootJpaApplicationTests.java
new file mode 100644
index 00000000..70857b78
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-one-to-one/src/test/java/com/espark/adarsh/SpringbootJpaApplicationTests.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class SpringbootJpaApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/.gitignore b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/.gitignore
new file mode 100644
index 00000000..a2a3040a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/document/help.txt b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/document/help.txt
new file mode 100644
index 00000000..1315fe26
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/document/help.txt
@@ -0,0 +1,29 @@
+#to build
+$ mvn clean package
+
+$ mvn spring-boot:run
+
+# To test
+$ curl localhost:8080/api/employee/adarsh@espark
+$ curl localhost:8080/api/employees
+
+
+
+
+DROP PROCEDURE IF EXISTS `GET_ALL_EMPLOYEES` ;
+DELIMITER //
+CREATE PROCEDURE `GET_ALL_EMPLOYEES`()
+BEGIN
+ SELECT * FROM employee ORDER BY id;
+END //
+
+
+
+DROP procedure IF EXISTS `GET_EMPLOYEE_BY_EMAIL`;
+DELIMITER //
+CREATE PROCEDURE GET_EMPLOYEE_BY_EMAIL(IN employeeEmail VARCHAR(100))
+BEGIN
+ SELECT * FROM employee WHERE email = employeeEmail ORDER BY id;
+END //
+
+CALL GET_EMPLOYEE_BY_EMAIL('adarsh@espark');
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/pom.xml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/pom.xml
new file mode 100644
index 00000000..9205a496
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/pom.xml
@@ -0,0 +1,63 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.6.RELEASE
+
+
+ com.espark.adarsh
+ springboot-jpa-stored-procedure
+ 0.0.1-SNAPSHOT
+ springboot-jpa-stored-procedure
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ mysql
+ mysql-connector-java
+ runtime
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/JpaStoredProcedureApplicationMain.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/JpaStoredProcedureApplicationMain.java
new file mode 100644
index 00000000..fe53d450
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/JpaStoredProcedureApplicationMain.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class JpaStoredProcedureApplicationMain {
+
+ public static void main(String[] args) {
+ SpringApplication.run(JpaStoredProcedureApplicationMain.class, args);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/entity/Employee.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/entity/Employee.java
new file mode 100644
index 00000000..ce8638d3
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/entity/Employee.java
@@ -0,0 +1,54 @@
+package com.espark.adarsh.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.validation.constraints.Email;
+import java.io.Serializable;
+import java.util.Date;
+
+@Setter
+@Getter
+@Entity
+@Table(name = "employee")
+public class Employee implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ protected Long id;
+
+ @NotNull
+ @Size(max = 65)
+ @Column(name = "first_name")
+ protected String firstName;
+
+ @Size(max = 65)
+ @Column(name = "last_name")
+ protected String lastName;
+
+ @NotNull
+ @Email
+ @Size(max = 100)
+ @Column(unique = true)
+ protected String email;
+
+ @Temporal(TemporalType.DATE)
+ @Column(name = "dob")
+ protected Date dob;
+
+ public Employee() {
+ }
+
+ public Employee(@NotNull @Size(max = 65) String firstName
+ , @Size(max = 65) String lastName
+ , @NotNull @Email @Size(max = 100) String email
+ , Date dob) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.email = email;
+ this.dob = dob;
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
new file mode 100644
index 00000000..18a5e559
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
@@ -0,0 +1,22 @@
+package com.espark.adarsh.respository;
+
+import com.espark.adarsh.entity.Employee;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+
+@Repository
+public interface EmployeeRepository extends JpaRepository {
+
+ @Query(nativeQuery = true, value = "call GET_EMPLOYEE_BY_EMAIL(:employeeEmail)")
+ Employee getEmployeeByEmail(@Param("employeeEmail") String employeeEmail);
+
+
+
+ @Query(nativeQuery = true, value = "call GET_ALL_EMPLOYEES")
+ List getAllEmployees();
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/service/DbInitService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/service/DbInitService.java
new file mode 100644
index 00000000..d878c582
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/service/DbInitService.java
@@ -0,0 +1,37 @@
+package com.espark.adarsh.service;
+
+import com.espark.adarsh.entity.Employee;
+import com.espark.adarsh.respository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import java.util.Calendar;
+
+@Service
+public class DbInitService {
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ @PostConstruct
+ public void init(){
+
+ Calendar adarshDob = Calendar.getInstance();
+ adarshDob.set(2020, 1, 1);
+ Employee adarsh = new Employee("Adarsh"
+ , "Singh"
+ , "adarsh@espark"
+ , adarshDob.getTime());
+ adarsh = employeeRepository.save(adarsh);
+
+ Calendar radhaDob = Calendar.getInstance();
+ radhaDob.set(2020, 1, 1);
+ Employee radha = new Employee("Radha"
+ , "Singh"
+ , "radha@espark"
+ , radhaDob.getTime());
+ radha = employeeRepository.save(radha);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/service/EmployeeService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/service/EmployeeService.java
new file mode 100644
index 00000000..4be055b6
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/service/EmployeeService.java
@@ -0,0 +1,24 @@
+package com.espark.adarsh.service;
+
+import com.espark.adarsh.entity.Employee;
+import com.espark.adarsh.respository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class EmployeeService {
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ public List getEmployees() {
+ return employeeRepository.getAllEmployees();
+ }
+
+ public Employee getEmployeeByEmail(String email) {
+ return this.employeeRepository.getEmployeeByEmail(email);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/web/EmployeeController.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/web/EmployeeController.java
new file mode 100644
index 00000000..9796f592
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/java/com/espark/adarsh/web/EmployeeController.java
@@ -0,0 +1,29 @@
+package com.espark.adarsh.web;
+
+import com.espark.adarsh.entity.Employee;
+import com.espark.adarsh.service.EmployeeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/api")
+public class EmployeeController {
+
+ @Autowired
+ EmployeeService employeeService;
+
+ @GetMapping("/employees")
+ public List getEmployees() {
+ return this.employeeService.getEmployees();
+ }
+
+ @GetMapping("/employee/{email}")
+ public Employee getEmployeeByEmail(@PathVariable("email") String email) {
+ return this.employeeService.getEmployeeByEmail(email);
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/resources/application.yml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/resources/application.yml
new file mode 100644
index 00000000..494e77dc
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/resources/application.yml
@@ -0,0 +1,19 @@
+
+server:
+ port: 8080
+
+spring:
+ application:
+ name: sprinboot-jpa
+ datasource:
+ url: jdbc:mysql://localhost:3306/testdb?serverTimezone=UTC
+ username: root
+ password: root1234
+ jpa:
+ hibernate:
+ ddl-auto: 'create-drop'
+ properties:
+ hibernate:
+ format-sql: true
+ generate-ddl: true
+ show-sql: true
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/resources/employee.sql b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/resources/employee.sql
new file mode 100644
index 00000000..0701b764
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/main/resources/employee.sql
@@ -0,0 +1,47 @@
+
+
+--
+-- Table structure for table `employee`
+--
+
+DROP TABLE IF EXISTS `employee`;
+CREATE TABLE `employee` (
+ `id` bigint NOT NULL AUTO_INCREMENT,
+ `dob` date DEFAULT NULL,
+ `email` varchar(100) NOT NULL,
+ `first_name` varchar(65) NOT NULL,
+ `last_name` varchar(65) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `UK_fopic1oh5oln2khj8eat6ino0` (`email`)
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
+
+--
+-- Dumping data for table `employee`
+--
+
+LOCK TABLES `employee` WRITE;
+INSERT INTO `employee`
+ VALUES (1,'2020-02-01','adarsh@espark','Adarsh','Singh')
+ ,(2,'2020-02-01','radha@espark','Radha','Singh');
+UNLOCK TABLES;
+
+--
+-- Dumping routines for database 'testdb'
+--
+
+DROP PROCEDURE IF EXISTS `GET_EMPLOYEE_BY_EMAIL` ;
+DELIMITER ;;
+CREATE PROCEDURE `GET_EMPLOYEE_BY_EMAIL`(IN employeeEmail VARCHAR(100))
+BEGIN
+ SELECT * FROM employee WHERE email = employeeEmail ORDER BY id;
+END ;;
+DELIMITER ;
+
+
+DROP PROCEDURE IF EXISTS `GET_ALL_EMPLOYEES` ;
+DELIMITER ;;
+CREATE PROCEDURE `GET_ALL_EMPLOYEES`()
+BEGIN
+ SELECT * FROM employee ORDER BY id;
+END ;;
+DELIMITER ;
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/test/java/com/espark/adarsh/JpaStoredProcedureApplicationMainTests.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/test/java/com/espark/adarsh/JpaStoredProcedureApplicationMainTests.java
new file mode 100644
index 00000000..a469aaf1
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa-stored-procedure/src/test/java/com/espark/adarsh/JpaStoredProcedureApplicationMainTests.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class JpaStoredProcedureApplicationMainTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/.gitignore b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/.gitignore
new file mode 100644
index 00000000..a2a3040a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/document/help.txt b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/document/help.txt
new file mode 100644
index 00000000..6305453e
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/document/help.txt
@@ -0,0 +1,9 @@
+#to build the application
+$ mvn clean package
+
+$ mvn spring-boot:run
+
+#log into the homepage of db
+http://localhost:8080/h2-console
+
+username, pwd , dburl and db driver class is mentioned in application.properties file
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/pom.xml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/pom.xml
new file mode 100644
index 00000000..8de3c5d9
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/pom.xml
@@ -0,0 +1,63 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.6.RELEASE
+
+
+ com.espark.adarsh
+ springboot-jpa
+ 0.0.1-SNAPSHOT
+ springboot-jpa
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.h2database
+ h2
+ runtime
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/.DS_Store
new file mode 100644
index 00000000..3edf4233
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/.DS_Store
new file mode 100644
index 00000000..404d1a49
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/.DS_Store
new file mode 100644
index 00000000..735d9370
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/.DS_Store
new file mode 100644
index 00000000..a49ab89f
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/.DS_Store
new file mode 100644
index 00000000..fdfd6026
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/ApplicationMain.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/ApplicationMain.java
new file mode 100644
index 00000000..1c7b85d8
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/ApplicationMain.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ApplicationMain {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ApplicationMain.class, args);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/db/DataInitializer.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/db/DataInitializer.java
new file mode 100644
index 00000000..fc6b416c
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/db/DataInitializer.java
@@ -0,0 +1,28 @@
+package com.espark.adarsh.db;
+
+import com.espark.adarsh.entity.Customer;
+import com.espark.adarsh.repository.CustomerRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+
+@Component
+public class DataInitializer {
+
+
+ @Autowired
+ CustomerRepository repository;
+
+ @PostConstruct
+ public void init() {
+ repository.save(new Customer("Radha", "Singh"));
+ repository.save(new Customer("Adarsh", "kumar"));
+ repository.save(new Customer("Amit", "kumar"));
+ repository.save(new Customer("Chloe", "O'Brian"));
+ repository.save(new Customer("Kim", "Bauer"));
+ repository.save(new Customer("David", "Palmer"));
+ repository.save(new Customer("Michelle", "Dessler"));
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/entity/Customer.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/entity/Customer.java
new file mode 100644
index 00000000..cd9a1c2f
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/entity/Customer.java
@@ -0,0 +1,32 @@
+package com.espark.adarsh.entity;
+
+import lombok.*;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Data
+@Setter
+@Getter
+@AllArgsConstructor
+@NoArgsConstructor
+@ToString
+@Entity
+public class Customer {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+
+ private String firstName;
+
+ private String lastName;
+
+ public Customer(String firstName, String lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/repository/CustomerRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/repository/CustomerRepository.java
new file mode 100644
index 00000000..1f8fdb41
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/repository/CustomerRepository.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh.repository;
+
+import java.util.List;
+
+import com.espark.adarsh.entity.Customer;
+import org.springframework.data.repository.CrudRepository;
+
+public interface CustomerRepository extends CrudRepository {
+
+ List findByLastName(String lastName);
+
+ Customer findById(long id);
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/service/CustomerService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/service/CustomerService.java
new file mode 100644
index 00000000..7622e94c
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/service/CustomerService.java
@@ -0,0 +1,43 @@
+package com.espark.adarsh.service;
+
+import com.espark.adarsh.entity.Customer;
+import com.espark.adarsh.repository.CustomerRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.LinkedList;
+import java.util.List;
+
+@Service
+public class CustomerService {
+
+ @Autowired
+ CustomerRepository customerRepository;
+
+ public Customer getCustomer(Long id) {
+ return customerRepository.findById(id).get();
+ }
+
+ public List getAllCustomer() {
+ List customerList = new LinkedList<>();
+ customerRepository
+ .findAll()
+ .forEach(customer -> customerList.add(customer));
+ return customerList;
+ }
+
+ public Customer createCustomer(Customer customer) {
+ return this.customerRepository.save(customer);
+ }
+
+ public Customer updateCustomer(Customer customer) {
+ return this.customerRepository.save(customer);
+ }
+
+ public Customer deleteCustomer(Long id) {
+ Customer customer = customerRepository.findById(id).get();
+ customerRepository.delete(customer);
+ return customer;
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/we/CustomerController.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/we/CustomerController.java
new file mode 100644
index 00000000..63ba9468
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/java/com/espark/adarsh/we/CustomerController.java
@@ -0,0 +1,41 @@
+package com.espark.adarsh.we;
+
+import com.espark.adarsh.entity.Customer;
+import com.espark.adarsh.service.CustomerService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+public class CustomerController {
+
+ @Autowired
+ CustomerService customerService;
+
+ @GetMapping("/customers")
+ public List getAll() {
+ return this.customerService.getAllCustomer();
+ }
+
+ @GetMapping("/customer/{id}")
+ public Customer getCustomer(@PathVariable("id") Long id) {
+ return this.customerService.getCustomer(id);
+ }
+
+ @PutMapping("/customer/{id}")
+ public Customer getCustomer(@PathVariable("id") Long id, @RequestBody Customer customer) {
+ return this.customerService.updateCustomer(customer);
+ }
+
+ @DeleteMapping("/customer/{id}")
+ public Customer deleteCustomer(@PathVariable("id") Long id) {
+ return this.customerService.deleteCustomer(id);
+ }
+
+ @PostMapping("/customer")
+ public Customer getCustomer(@RequestBody Customer customer) {
+ return this.customerService.createCustomer(customer);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/resources/application.properties b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/resources/application.properties
new file mode 100644
index 00000000..0a2b5d21
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/main/resources/application.properties
@@ -0,0 +1,22 @@
+
+spring.datasource.type=com.zaxxer.hikari.HikariDataSource
+spring.datasource.url=jdbc:h2:mem:testdb
+spring.datasource.driverClassName=org.h2.Driver
+spring.datasource.username=root
+spring.datasource.password=root
+spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
+spring.h2.console.enabled=true
+
+spring.jpa.hibernate.connection.provider_class=org.hibernate.hikaricp.internal.HikariCPConnectionProvider
+
+spring.datasource.hikari.minimumIdle=5
+spring.datasource.hikari.maximumPoolSize=20
+spring.datasource.hikari.idleTimeout=30000
+spring.datasource.hikari.poolName=SpringBootJPAHikariCP
+spring.datasource.hikari.maxLifetime=2000000
+spring.datasource.hikari.connectionTimeout=30000
+
+
+logging.level.org.hibernate.SQL=DEBUG
+logging.level.com.zaxxer.hikari.HikariConfig=DEBUG
+logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/test/java/com/espark/adarsh/SpringbootJpaApplicationTests.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/test/java/com/espark/adarsh/SpringbootJpaApplicationTests.java
new file mode 100644
index 00000000..70857b78
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-jpa/src/test/java/com/espark/adarsh/SpringbootJpaApplicationTests.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class SpringbootJpaApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/.gitignore b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/.gitignore
new file mode 100644
index 00000000..a2a3040a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/document/help.txt b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/document/help.txt
new file mode 100644
index 00000000..fb551872
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/document/help.txt
@@ -0,0 +1,13 @@
+#to build the application
+$ mvn clean package
+
+$ mvn spring-boot:run
+
+#log into the homepage of db
+http://localhost:8080/h2-console
+username, pwd , dburl and db driver class is mentioned in application.yml file
+
+# To Fetch Data
+$ curl -v localhost:8080/employees
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/pom.xml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/pom.xml
new file mode 100644
index 00000000..d2f4685a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/pom.xml
@@ -0,0 +1,65 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.6.RELEASE
+
+
+ com.espark.adarsh
+ springboot-many-to-many-unidirectional
+ 0.0.1-SNAPSHOT
+ springboot-many-to-many-unidirectional
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.h2database
+ h2
+ runtime
+ 1.4.199
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+ junit
+ junit
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/.DS_Store
new file mode 100644
index 00000000..41d8ef29
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/.DS_Store
new file mode 100644
index 00000000..31ed979c
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/.DS_Store
new file mode 100644
index 00000000..23164e0b
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/.DS_Store
new file mode 100644
index 00000000..3a722e50
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/ApplicationMain.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/ApplicationMain.java
new file mode 100644
index 00000000..1c7b85d8
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/ApplicationMain.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ApplicationMain {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ApplicationMain.class, args);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/entity/Contact.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/entity/Contact.java
new file mode 100644
index 00000000..622286be
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/entity/Contact.java
@@ -0,0 +1,58 @@
+package com.espark.adarsh.entity;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "contact")
+public class Contact {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "contact_id")
+ private Long id;
+ private String street;
+ private String state;
+ private String country;
+
+ public Contact() {
+ }
+
+ public Contact(String street, String state, String country) {
+ this.street = street;
+ this.state = state;
+ this.country = country;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getStreet() {
+ return street;
+ }
+
+ public void setStreet(String street) {
+ this.street = street;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+}
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/entity/Employee.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/entity/Employee.java
new file mode 100644
index 00000000..021024ac
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/entity/Employee.java
@@ -0,0 +1,89 @@
+package com.espark.adarsh.entity;
+
+import javax.persistence.*;
+import java.util.List;
+
+@Entity
+@Table(name = "employee")
+public class Employee {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "employee_id")
+ private Long id;
+ private String firstName;
+ private String lastName;
+ private String career;
+
+
+ @ManyToMany(cascade = CascadeType.ALL)
+ @JoinTable(name = "employee_contact",
+ joinColumns = { @JoinColumn(name = "employee_id") },
+ inverseJoinColumns = { @JoinColumn(name = "contact_id") })
+ private List contact;
+
+ public Employee() {
+ }
+
+ public Employee(String firstName, String lastName, String career) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.career = career;
+ }
+
+ public Employee(Long id, String firstName, String lastName, String career) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.career = career;
+ }
+
+
+ public Employee(String firstName, String lastName, String career, List contact) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.career = career;
+ this.contact = contact;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getCareer() {
+ return career;
+ }
+
+ public void setCareer(String career) {
+ this.career = career;
+ }
+
+ public List getContact() {
+ return contact;
+ }
+
+ public void setContact(List contact) {
+ this.contact = contact;
+ }
+}
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
new file mode 100644
index 00000000..e37cce1a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
@@ -0,0 +1,9 @@
+package com.espark.adarsh.respository;
+
+import com.espark.adarsh.entity.Employee;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface EmployeeRepository extends CrudRepository {
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/service/DataInitService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/service/DataInitService.java
new file mode 100644
index 00000000..81f9430d
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/service/DataInitService.java
@@ -0,0 +1,45 @@
+package com.espark.adarsh.service;
+
+import com.espark.adarsh.entity.Contact;
+import com.espark.adarsh.entity.Employee;
+import com.espark.adarsh.respository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.jdbc.datasource.init.DatabasePopulator;
+import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils;
+import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.sql.DataSource;
+import java.util.Arrays;
+
+@Service
+public class DataInitService {
+
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ @Autowired
+ DataSource dataSource;
+
+ @PostConstruct
+ public void init() {
+ /*
+ Resource initSchema = new ClassPathResource("data.sql");
+ DatabasePopulator databasePopulator = new ResourceDatabasePopulator(initSchema);
+ DatabasePopulatorUtils.execute(databasePopulator, dataSource);
+ */
+
+ /* employeeRepository.save(new Employee("adarsh", "kumar", "It",
+ Arrays.asList(new Contact("bang street", "mp", "in"))));
+ employeeRepository.save(new Employee("radha", "singh", "It",
+ Arrays.asList(new Contact("hyd street", "ap", "in"))));
+ employeeRepository.save(new Employee("sonu", "singh", "IT",
+ Arrays.asList(new Contact("ald street", "up", "in"))));
+ employeeRepository.save(new Employee("amit", "kumar", "Finance",
+ Arrays.asList(new Contact("delhi street", "delhi", "in"))));*/
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/web/EmployeeController.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/web/EmployeeController.java
new file mode 100644
index 00000000..dc490612
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/java/com/espark/adarsh/web/EmployeeController.java
@@ -0,0 +1,46 @@
+package com.espark.adarsh.web;
+
+import com.espark.adarsh.entity.Employee;
+import com.espark.adarsh.respository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.LinkedList;
+import java.util.List;
+
+@RestController
+public class EmployeeController {
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ @GetMapping("/employees")
+ public List getAllEmployee() {
+ List employeeList = new LinkedList<>();
+ this.employeeRepository.findAll().forEach(employee -> employeeList.add(employee));
+ return employeeList;
+ }
+
+ @GetMapping("/employees/{id}")
+ public Employee getEmployee(@PathVariable("id") Long id) {
+ return this.employeeRepository.findById(id).get();
+ }
+
+ @DeleteMapping("/employees/{id}")
+ public Employee removeEmployee(@PathVariable("id") Long id) {
+ Employee employee = this.employeeRepository.findById(id).get();
+ this.employeeRepository.deleteById(id);
+ return employee;
+ }
+
+ @PostMapping("/employee")
+ public Employee saveEmployee(@RequestBody Employee employee) {
+ return this.employeeRepository.save(employee);
+ }
+
+ @PostMapping("/employee/{id}")
+ public Employee updateEmployee(@PathVariable("id") Long id, @RequestBody Employee employee) {
+ return this.employeeRepository.save(employee);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/resources/application.properties b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/resources/application.properties
new file mode 100644
index 00000000..702da713
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/resources/application.properties
@@ -0,0 +1,9 @@
+logging.level.root=DEBUG
+logging.level.org.hibernate.SQL=DEBUG
+logging.level.org.hibernate.type=TRACE
+
+
+
+spring.h2.console.path=/h2-console
+spring.h2.console.settings.trace=false
+spring.h2.console.settings.web-allow-others=false
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/resources/application.yml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/resources/application.yml
new file mode 100644
index 00000000..54da917c
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/resources/application.yml
@@ -0,0 +1,24 @@
+
+server:
+ port: 8080
+
+spring:
+ application:
+ name: springboot-one-one-mapping
+ datasource:
+ url: jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
+ driver-class-name: org.h2.Driver
+ username: root
+ password: root
+ jpa:
+ database-platform: org.hibernate.dialect.H2Dialect
+ hibernate:
+ ddl-auto: update
+ show-sql: true
+ format-sql: true
+ h2:
+ console:
+ enabled: true
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/resources/data.sql b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/resources/data.sql
new file mode 100644
index 00000000..279d91f8
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/main/resources/data.sql
@@ -0,0 +1,46 @@
+
+drop table IF EXISTS contact;
+
+create table contact (
+contact_id bigint generated by default as identity
+, country varchar(255)
+, state varchar(255)
+, street varchar(255)
+, primary key (contact_id));
+
+drop table IF EXISTS employee;
+
+create table employee (
+employee_id bigint generated by default as identity
+, career varchar(255)
+, first_name varchar(255)
+, last_name varchar(255)
+, primary key (employee_id));
+
+drop table IF EXISTS employee_contact;
+
+create table employee_contact (
+employee_id bigint not null
+, contact_id bigint not null);
+
+alter table employee_contact add constraint FK_contact_id_contact foreign key (contact_id) references contact;
+alter table employee_contact add constraint FK_employee_id_employee foreign key (employee_id) references employee;
+
+
+insert into contact (contact_id,street, state, country) values
+ (10,'bang street', 'mp', 'in'),
+ (20,'hyd street', 'ap', 'in'),
+ (30,'ald street', 'up', 'in'),
+ (40,'delhi street', 'delhi', 'in');
+
+insert into employee (employee_id,first_name, last_name, career) values
+ (10,'adarsh', 'kumar', 'It'),
+ (20,'radha', 'singh', 'IT'),
+ (30,'sonu', 'singh', 'IT'),
+ (40,'amit', 'kumar', 'Finance');
+
+insert into employee_contact(employee_id,contact_id) values
+(10,10),
+(20,20),
+(30,30),
+(40,40);
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/test/java/com/espark/adarsh/SpringbootH2DbApplicationTests.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/test/java/com/espark/adarsh/SpringbootH2DbApplicationTests.java
new file mode 100644
index 00000000..a946a93b
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-many-to-many-unidirectional/src/test/java/com/espark/adarsh/SpringbootH2DbApplicationTests.java
@@ -0,0 +1,16 @@
+package com.espark.adarsh;
+
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ApplicationMain.class)
+class SpringbootH2DbApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/.gitignore b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/.gitignore
new file mode 100644
index 00000000..a29b8e6d
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/.gitignore
@@ -0,0 +1,31 @@
+
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/HELP.md b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/HELP.md
new file mode 100644
index 00000000..47cda201
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/HELP.md
@@ -0,0 +1,18 @@
+# Getting Started
+
+### Reference Documentation
+For further reference, please consider the following sections:
+
+* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
+* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.2.6.RELEASE/maven-plugin/)
+* [Spring Web](https://docs.spring.io/spring-boot/docs/2.2.6.RELEASE/reference/htmlsingle/#boot-features-developing-web-applications)
+* [Spring Data JPA](https://docs.spring.io/spring-boot/docs/2.2.6.RELEASE/reference/htmlsingle/#boot-features-jpa-and-spring-data)
+
+### Guides
+The following guides illustrate how to use some features concretely:
+
+* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
+* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
+* [Building REST services with Spring](https://spring.io/guides/tutorials/bookmarks/)
+* [Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/)
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/document/help.txt b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/document/help.txt
new file mode 100644
index 00000000..fb551872
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/document/help.txt
@@ -0,0 +1,13 @@
+#to build the application
+$ mvn clean package
+
+$ mvn spring-boot:run
+
+#log into the homepage of db
+http://localhost:8080/h2-console
+username, pwd , dburl and db driver class is mentioned in application.yml file
+
+# To Fetch Data
+$ curl -v localhost:8080/employees
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/pom.xml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/pom.xml
new file mode 100644
index 00000000..01b3efbf
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/pom.xml
@@ -0,0 +1,65 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.6.RELEASE
+
+
+ com.espark.adarsh
+ springboot-one-to-many-unidirectional
+ 0.0.1-SNAPSHOT
+ springboot-one-to-many-unidirectional
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.h2database
+ h2
+ runtime
+ 1.4.199
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+ junit
+ junit
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/.DS_Store
new file mode 100644
index 00000000..41d8ef29
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/.DS_Store
new file mode 100644
index 00000000..31ed979c
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/.DS_Store
new file mode 100644
index 00000000..23164e0b
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/.DS_Store
new file mode 100644
index 00000000..3a722e50
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/ApplicationMain.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/ApplicationMain.java
new file mode 100644
index 00000000..1c7b85d8
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/ApplicationMain.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ApplicationMain {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ApplicationMain.class, args);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/entity/Department.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/entity/Department.java
new file mode 100644
index 00000000..2bd20a76
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/entity/Department.java
@@ -0,0 +1,68 @@
+package com.espark.adarsh.entity;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "department")
+public class Department {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private Long id;
+ private String name;
+ private String street;
+ private String state;
+ private String country;
+
+ public Department() {
+ }
+
+ public Department(String name, String street, String state, String country) {
+ this.name = name;
+ this.street = street;
+ this.state = state;
+ this.country = country;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getStreet() {
+ return street;
+ }
+
+ public void setStreet(String street) {
+ this.street = street;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+}
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/entity/Employee.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/entity/Employee.java
new file mode 100644
index 00000000..1b4721f1
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/entity/Employee.java
@@ -0,0 +1,85 @@
+package com.espark.adarsh.entity;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "employee")
+public class Employee {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private Long id;
+ private String firstName;
+ private String lastName;
+ private String career;
+
+
+ @ManyToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "department_id")
+ private Department department;
+
+ public Employee() {
+ }
+
+ public Employee(String firstName, String lastName, String career) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.career = career;
+ }
+
+ public Employee(Long id, String firstName, String lastName, String career) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.career = career;
+ }
+
+ public Employee(String firstName, String lastName, String career, Department address) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.career = career;
+ this.department = address;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getCareer() {
+ return career;
+ }
+
+ public void setCareer(String career) {
+ this.career = career;
+ }
+
+ public Department getDepartment() {
+ return department;
+ }
+
+ public void setDepartment(Department department) {
+ this.department = department;
+ }
+}
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
new file mode 100644
index 00000000..e37cce1a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
@@ -0,0 +1,9 @@
+package com.espark.adarsh.respository;
+
+import com.espark.adarsh.entity.Employee;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface EmployeeRepository extends CrudRepository {
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/service/DataInitService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/service/DataInitService.java
new file mode 100644
index 00000000..7b67c370
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/service/DataInitService.java
@@ -0,0 +1,31 @@
+package com.espark.adarsh.service;
+
+import com.espark.adarsh.respository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.jdbc.datasource.init.DatabasePopulator;
+import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils;
+import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.sql.DataSource;
+
+@Service
+public class DataInitService {
+
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ @Autowired
+ DataSource dataSource;
+
+ @PostConstruct
+ public void init() {
+ Resource initSchema = new ClassPathResource("data.sql");
+ DatabasePopulator databasePopulator = new ResourceDatabasePopulator(initSchema);
+ DatabasePopulatorUtils.execute(databasePopulator, dataSource);
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/web/EmployeeController.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/web/EmployeeController.java
new file mode 100644
index 00000000..dc490612
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/java/com/espark/adarsh/web/EmployeeController.java
@@ -0,0 +1,46 @@
+package com.espark.adarsh.web;
+
+import com.espark.adarsh.entity.Employee;
+import com.espark.adarsh.respository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.LinkedList;
+import java.util.List;
+
+@RestController
+public class EmployeeController {
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ @GetMapping("/employees")
+ public List getAllEmployee() {
+ List employeeList = new LinkedList<>();
+ this.employeeRepository.findAll().forEach(employee -> employeeList.add(employee));
+ return employeeList;
+ }
+
+ @GetMapping("/employees/{id}")
+ public Employee getEmployee(@PathVariable("id") Long id) {
+ return this.employeeRepository.findById(id).get();
+ }
+
+ @DeleteMapping("/employees/{id}")
+ public Employee removeEmployee(@PathVariable("id") Long id) {
+ Employee employee = this.employeeRepository.findById(id).get();
+ this.employeeRepository.deleteById(id);
+ return employee;
+ }
+
+ @PostMapping("/employee")
+ public Employee saveEmployee(@RequestBody Employee employee) {
+ return this.employeeRepository.save(employee);
+ }
+
+ @PostMapping("/employee/{id}")
+ public Employee updateEmployee(@PathVariable("id") Long id, @RequestBody Employee employee) {
+ return this.employeeRepository.save(employee);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/resources/application.properties b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/resources/application.properties
new file mode 100644
index 00000000..702da713
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/resources/application.properties
@@ -0,0 +1,9 @@
+logging.level.root=DEBUG
+logging.level.org.hibernate.SQL=DEBUG
+logging.level.org.hibernate.type=TRACE
+
+
+
+spring.h2.console.path=/h2-console
+spring.h2.console.settings.trace=false
+spring.h2.console.settings.web-allow-others=false
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/resources/application.yml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/resources/application.yml
new file mode 100644
index 00000000..54da917c
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/resources/application.yml
@@ -0,0 +1,24 @@
+
+server:
+ port: 8080
+
+spring:
+ application:
+ name: springboot-one-one-mapping
+ datasource:
+ url: jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
+ driver-class-name: org.h2.Driver
+ username: root
+ password: root
+ jpa:
+ database-platform: org.hibernate.dialect.H2Dialect
+ hibernate:
+ ddl-auto: update
+ show-sql: true
+ format-sql: true
+ h2:
+ console:
+ enabled: true
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/resources/data.sql b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/resources/data.sql
new file mode 100644
index 00000000..4caa172f
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/main/resources/data.sql
@@ -0,0 +1,34 @@
+
+drop table IF EXISTS department;
+
+create table department (
+id bigint generated by default as identity
+, name VARCHAR(255)
+, country VARCHAR(255)
+, state VARCHAR(255)
+, street VARCHAR(255)
+, primary key (id));
+
+drop table IF EXISTS employee;
+
+create table employee (
+id bigint generated by default as identity
+, career VARCHAR(255)
+, first_name VARCHAR(255)
+, last_name VARCHAR(255)
+, department_id bigint
+, primary key (id));
+
+alter table employee add constraint FK_department_id foreign key (department_id) references department;
+
+insert into department (id,name,street, state, country) values
+ (10,'it','bang street', 'mp', 'in'),
+ (20,'it','hyd street', 'ap', 'in'),
+ (30,'it','ald street', 'up', 'in'),
+ (40,'fa','delhi street', 'delhi', 'in');
+
+insert into employee (id,first_name, last_name, career,department_id) values
+ (10,'adarsh', 'kumar', 'It',10),
+ (20,'radha', 'singh', 'IT',20),
+ (30,'sonu', 'singh', 'IT',30),
+ (40,'amit', 'kumar', 'Finance',40);
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/test/java/com/espark/adarsh/SpringbootH2DbApplicationTests.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/test/java/com/espark/adarsh/SpringbootH2DbApplicationTests.java
new file mode 100644
index 00000000..a946a93b
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-many-unidirectional/src/test/java/com/espark/adarsh/SpringbootH2DbApplicationTests.java
@@ -0,0 +1,16 @@
+package com.espark.adarsh;
+
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ApplicationMain.class)
+class SpringbootH2DbApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/.gitignore b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/.gitignore
new file mode 100644
index 00000000..a2a3040a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/document/help.txt b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/document/help.txt
new file mode 100644
index 00000000..fb551872
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/document/help.txt
@@ -0,0 +1,13 @@
+#to build the application
+$ mvn clean package
+
+$ mvn spring-boot:run
+
+#log into the homepage of db
+http://localhost:8080/h2-console
+username, pwd , dburl and db driver class is mentioned in application.yml file
+
+# To Fetch Data
+$ curl -v localhost:8080/employees
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/pom.xml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/pom.xml
new file mode 100644
index 00000000..55cbe8c1
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/pom.xml
@@ -0,0 +1,65 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.6.RELEASE
+
+
+ com.espark.adarsh
+ springboot-one-to-one-unidirectional
+ 0.0.1-SNAPSHOT
+ springboot-one-to-one-unidirectional
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.h2database
+ h2
+ runtime
+ 1.4.199
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+ junit
+ junit
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/.DS_Store
new file mode 100644
index 00000000..41d8ef29
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/.DS_Store
new file mode 100644
index 00000000..31ed979c
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/.DS_Store
new file mode 100644
index 00000000..23164e0b
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/.DS_Store
new file mode 100644
index 00000000..3a722e50
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/ApplicationMain.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/ApplicationMain.java
new file mode 100644
index 00000000..1c7b85d8
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/ApplicationMain.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ApplicationMain {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ApplicationMain.class, args);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/entity/Address.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/entity/Address.java
new file mode 100644
index 00000000..6bd88c42
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/entity/Address.java
@@ -0,0 +1,58 @@
+package com.espark.adarsh.entity;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "address")
+public class Address {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private Long id;
+ private String street;
+ private String state;
+ private String country;
+
+ public Address() {
+ }
+
+ public Address( String street, String state, String country) {
+ this.street = street;
+ this.state = state;
+ this.country = country;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getStreet() {
+ return street;
+ }
+
+ public void setStreet(String street) {
+ this.street = street;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+}
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/entity/Employee.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/entity/Employee.java
new file mode 100644
index 00000000..6af38952
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/entity/Employee.java
@@ -0,0 +1,85 @@
+package com.espark.adarsh.entity;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "employee")
+public class Employee {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private Long id;
+ private String firstName;
+ private String lastName;
+ private String career;
+
+
+ @OneToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "address_id")
+ private Address address;
+
+ public Employee() {
+ }
+
+ public Employee(String firstName, String lastName, String career) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.career = career;
+ }
+
+ public Employee(Long id, String firstName, String lastName, String career) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.career = career;
+ }
+
+ public Employee(String firstName, String lastName, String career, Address address) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.career = career;
+ this.address = address;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getCareer() {
+ return career;
+ }
+
+ public void setCareer(String career) {
+ this.career = career;
+ }
+
+ public Address getAddress() {
+ return address;
+ }
+
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+}
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
new file mode 100644
index 00000000..e37cce1a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
@@ -0,0 +1,9 @@
+package com.espark.adarsh.respository;
+
+import com.espark.adarsh.entity.Employee;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface EmployeeRepository extends CrudRepository {
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/service/DataInitService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/service/DataInitService.java
new file mode 100644
index 00000000..2893f202
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/service/DataInitService.java
@@ -0,0 +1,42 @@
+package com.espark.adarsh.service;
+
+import com.espark.adarsh.entity.Address;
+import com.espark.adarsh.entity.Employee;
+import com.espark.adarsh.respository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.jdbc.datasource.init.DatabasePopulator;
+import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils;
+import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.sql.DataSource;
+
+@Service
+public class DataInitService {
+
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ @Autowired
+ DataSource dataSource;
+
+ @PostConstruct
+ public void init() {
+ Resource initSchema = new ClassPathResource("data.sql");
+ DatabasePopulator databasePopulator = new ResourceDatabasePopulator(initSchema);
+ DatabasePopulatorUtils.execute(databasePopulator, dataSource);
+
+ /* employeeRepository.save(new Employee("adarsh", "kumar", "It",
+ new Address("bang street", "mp", "in")));
+ employeeRepository.save(new Employee("radha", "singh", "It",
+ new Address("hyd street", "ap", "in")));
+ employeeRepository.save(new Employee("sonu", "singh", "IT",
+ new Address("ald street", "up", "in")));
+ employeeRepository.save(new Employee("amit", "kumar", "Finance",
+ new Address("delhi street", "delhi", "in")));*/
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/web/EmployeeController.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/web/EmployeeController.java
new file mode 100644
index 00000000..dc490612
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/java/com/espark/adarsh/web/EmployeeController.java
@@ -0,0 +1,46 @@
+package com.espark.adarsh.web;
+
+import com.espark.adarsh.entity.Employee;
+import com.espark.adarsh.respository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.LinkedList;
+import java.util.List;
+
+@RestController
+public class EmployeeController {
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ @GetMapping("/employees")
+ public List getAllEmployee() {
+ List employeeList = new LinkedList<>();
+ this.employeeRepository.findAll().forEach(employee -> employeeList.add(employee));
+ return employeeList;
+ }
+
+ @GetMapping("/employees/{id}")
+ public Employee getEmployee(@PathVariable("id") Long id) {
+ return this.employeeRepository.findById(id).get();
+ }
+
+ @DeleteMapping("/employees/{id}")
+ public Employee removeEmployee(@PathVariable("id") Long id) {
+ Employee employee = this.employeeRepository.findById(id).get();
+ this.employeeRepository.deleteById(id);
+ return employee;
+ }
+
+ @PostMapping("/employee")
+ public Employee saveEmployee(@RequestBody Employee employee) {
+ return this.employeeRepository.save(employee);
+ }
+
+ @PostMapping("/employee/{id}")
+ public Employee updateEmployee(@PathVariable("id") Long id, @RequestBody Employee employee) {
+ return this.employeeRepository.save(employee);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/resources/application.properties b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/resources/application.properties
new file mode 100644
index 00000000..702da713
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/resources/application.properties
@@ -0,0 +1,9 @@
+logging.level.root=DEBUG
+logging.level.org.hibernate.SQL=DEBUG
+logging.level.org.hibernate.type=TRACE
+
+
+
+spring.h2.console.path=/h2-console
+spring.h2.console.settings.trace=false
+spring.h2.console.settings.web-allow-others=false
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/resources/application.yml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/resources/application.yml
new file mode 100644
index 00000000..54da917c
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/resources/application.yml
@@ -0,0 +1,24 @@
+
+server:
+ port: 8080
+
+spring:
+ application:
+ name: springboot-one-one-mapping
+ datasource:
+ url: jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
+ driver-class-name: org.h2.Driver
+ username: root
+ password: root
+ jpa:
+ database-platform: org.hibernate.dialect.H2Dialect
+ hibernate:
+ ddl-auto: update
+ show-sql: true
+ format-sql: true
+ h2:
+ console:
+ enabled: true
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/resources/data.sql b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/resources/data.sql
new file mode 100644
index 00000000..5a1ebdd5
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/main/resources/data.sql
@@ -0,0 +1,33 @@
+
+drop table IF EXISTS address;
+
+create table address (
+id bigint generated by default as identity
+, country VARCHAR(255)
+, state VARCHAR(255)
+, street VARCHAR(255)
+, primary key (id));
+
+drop table IF EXISTS employee;
+
+create table employee (
+id bigint generated by default as identity
+, career VARCHAR(255)
+, first_name VARCHAR(255)
+, last_name VARCHAR(255)
+, address_id bigint
+, primary key (id));
+
+alter table employee add constraint FK_address_id foreign key (address_id) references address;
+
+insert into address (id,street, state, country) values
+ (10,'bang street', 'mp', 'in'),
+ (20,'hyd street', 'ap', 'in'),
+ (30,'ald street', 'up', 'in'),
+ (40,'delhi street', 'delhi', 'in');
+
+insert into employee (id,first_name, last_name, career,address_id) values
+ (10,'adarsh', 'kumar', 'It',10),
+ (20,'radha', 'singh', 'IT',20),
+ (30,'sonu', 'singh', 'IT',30),
+ (40,'amit', 'kumar', 'Finance',40);
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/test/java/com/espark/adarsh/SpringbootH2DbApplicationTests.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/test/java/com/espark/adarsh/SpringbootH2DbApplicationTests.java
new file mode 100644
index 00000000..a946a93b
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-one-to-one-unidirectional/src/test/java/com/espark/adarsh/SpringbootH2DbApplicationTests.java
@@ -0,0 +1,16 @@
+package com.espark.adarsh;
+
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ApplicationMain.class)
+class SpringbootH2DbApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/.gitignore b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/.gitignore
new file mode 100644
index 00000000..a2a3040a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/README.md b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/README.md
new file mode 100644
index 00000000..bd49b427
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/README.md
@@ -0,0 +1,10 @@
+# SPRINGBOOT JPA ORACLE DB
+
+---
+
+### To Build Code
+* mvn clean package
+
+
+### [step by step guide for oracle xe db docker image cration ](oracle-db-xe-docker-image-building-process.md)
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/oracle-db-xe-docker-image-building-process.md b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/oracle-db-xe-docker-image-building-process.md
new file mode 100644
index 00000000..44b20d4b
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/oracle-db-xe-docker-image-building-process.md
@@ -0,0 +1,111 @@
+
+
+# https://www.codesanook.com/setup-oracle-xe-database-on-docker-container-and-connect-with-dbeaver
+
+## Clone the github from oralce
+* git clone git@github.com:oracle/docker-images.git
+
+## move to the docker file directory
+* $ cd docker-images/OracleDatabase/SingleInstance/dockerfiles
+
+# list the supported version
+* $ ls
+```
+11.2.0.2 12.2.0.1 18.4.0 21.3.0
+12.1.0.2 18.3.0 19.3.0 buildContainerImage.sh
+```
+
+## url to download the verion of oracle zip
+* https://www.oracle.com/database/technologies/xe18c-downloads.html
+* copy into the same directtoy of the version in ls cmd
+
+## Build the docker iamge
+* $ sh buildContainerImage.sh -v 18.4.0 -x
+
+```
+Oracle Database container image for 'xe' version 18.4.0 is ready to be extended:
+
+ --> oracle/database:18.4.0-xe
+
+ Build completed in 510 seconds.
+```
+
+## db client opernsource
+* https://dbeaver.io/download/
+
+## lauch the db
+* $ docker run --name OracleXE \
+--shm-size=1g \
+-p 1521:1521 \
+-p 8081:8080 \
+-e ORACLE_PWD=12345 \
+-v oracle-data:/u01/app/oracle/oradata \
+oracle/database:18.4.0-xe
+
+```
+ORACLE PASSWORD FOR SYS AND SYSTEM: 12345
+Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:
+Confirm the password:
+Configuring Oracle Listener.
+Listener configuration succeeded.
+Configuring Oracle Database XE.
+Enter SYS user password:
+******
+Enter SYSTEM user password:
+*****
+Enter PDBADMIN User Password:
+*****
+Prepare for db operation
+7% complete
+Copying database files
+29% complete
+Creating and starting Oracle instance
+Completing Database Creation
+47% complete
+50% complete
+Creating Pluggable Databases
+54% complete
+71% complete
+Executing Post Configuration Actions
+93% complete
+Running Custom Scripts
+100% complete
+Database creation complete. For details check the logfiles at:
+ /opt/oracle/cfgtoollogs/dbca/XE.
+Database Information:
+Global Database Name:XE
+System Identifier(SID):XE
+Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE.log" for further details.
+
+Connect to Oracle Database using one of the connect strings:
+ Pluggable database: 2f7354fc4ee1/XEPDB1
+ Multitenant container database: 2f7354fc4ee1
+Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE
+The Oracle base remains unchanged with value /opt/oracle
+#########################
+DATABASE IS READY TO USE!
+#########################
+The following output is now a tail of the alert.log:
+2021-10-05T23:03:43.054971+00:00
+XEPDB1(3):Resize operation completed for file# 10, old size 358400K, new size 368640K
+2021-10-05T23:03:56.975470+00:00
+XEPDB1(3):CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/opt/oracle/oradata/XE/XEPDB1/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
+XEPDB1(3):Completed: CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/opt/oracle/oradata/XE/XEPDB1/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
+XEPDB1(3):ALTER DATABASE DEFAULT TABLESPACE "USERS"
+XEPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
+2021-10-05T23:04:03.318085+00:00
+ALTER PLUGGABLE DATABASE XEPDB1 SAVE STATE
+Completed: ALTER PLUGGABLE DATABASE XEPDB1 SAVE STATE
+
+```
+
+## Connect to db
+```
+Host: localhost
+Port: 1521
+Database: XE
+Use SID
+User name: SYS
+Role: SYSDBA
+Password: 12345
+```
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/pom.xml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/pom.xml
new file mode 100644
index 00000000..fdd9bed8
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/pom.xml
@@ -0,0 +1,72 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.6.RELEASE
+
+
+ com.espark.adarsh
+ springboot-oracle-db
+ 0.0.1-SNAPSHOT
+ springboot-oracle-db
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.oracle.database.jdbc
+ ojdbc10
+ 19.3.0.0
+
+
+
+ com.zaxxer
+ HikariCP
+ 2.6.0
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+ junit
+ junit
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/.DS_Store
new file mode 100644
index 00000000..8813de11
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/.DS_Store
new file mode 100644
index 00000000..e8e05c2d
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/.DS_Store
new file mode 100644
index 00000000..3705dc35
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/.DS_Store
new file mode 100644
index 00000000..08d27d3d
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/.DS_Store b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/.DS_Store
new file mode 100644
index 00000000..35af2b5e
Binary files /dev/null and b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/.DS_Store differ
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/ApplicationMain.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/ApplicationMain.java
new file mode 100644
index 00000000..1c7b85d8
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/ApplicationMain.java
@@ -0,0 +1,13 @@
+package com.espark.adarsh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ApplicationMain {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ApplicationMain.class, args);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/entity/Employee.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/entity/Employee.java
new file mode 100644
index 00000000..bea6c6b4
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/entity/Employee.java
@@ -0,0 +1,64 @@
+package com.espark.adarsh.entity;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "employee")
+public class Employee {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long empId;
+ private String firstName;
+ private String lastName;
+ private String career;
+
+ public Employee() {
+ }
+
+ public Employee(String firstName, String lastName, String career) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.career = career;
+ }
+
+ public Employee(Long empId, String firstName, String lastName, String career) {
+ this.empId = empId;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.career = career;
+ }
+
+ public Long getEmpId() {
+ return empId;
+ }
+
+ public void setEmpId(Long empId) {
+ this.empId = empId;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getCareer() {
+ return career;
+ }
+
+ public void setCareer(String career) {
+ this.career = career;
+ }
+}
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
new file mode 100644
index 00000000..e37cce1a
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/respository/EmployeeRepository.java
@@ -0,0 +1,9 @@
+package com.espark.adarsh.respository;
+
+import com.espark.adarsh.entity.Employee;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface EmployeeRepository extends CrudRepository {
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/service/DataInitService.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/service/DataInitService.java
new file mode 100644
index 00000000..db7ba9c3
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/service/DataInitService.java
@@ -0,0 +1,27 @@
+package com.espark.adarsh.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.jdbc.datasource.init.DatabasePopulator;
+import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils;
+import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.sql.DataSource;
+
+@Service
+public class DataInitService {
+
+
+ @Autowired
+ DataSource dataSource;
+
+ @PostConstruct
+ public void init() {
+ Resource initSchema = new ClassPathResource("data.sql");
+ DatabasePopulator databasePopulator = new ResourceDatabasePopulator(initSchema);
+ DatabasePopulatorUtils.execute(databasePopulator, dataSource);
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/web/EmployeeController.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/web/EmployeeController.java
new file mode 100644
index 00000000..dc490612
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/java/com/espark/adarsh/web/EmployeeController.java
@@ -0,0 +1,46 @@
+package com.espark.adarsh.web;
+
+import com.espark.adarsh.entity.Employee;
+import com.espark.adarsh.respository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.LinkedList;
+import java.util.List;
+
+@RestController
+public class EmployeeController {
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ @GetMapping("/employees")
+ public List getAllEmployee() {
+ List employeeList = new LinkedList<>();
+ this.employeeRepository.findAll().forEach(employee -> employeeList.add(employee));
+ return employeeList;
+ }
+
+ @GetMapping("/employees/{id}")
+ public Employee getEmployee(@PathVariable("id") Long id) {
+ return this.employeeRepository.findById(id).get();
+ }
+
+ @DeleteMapping("/employees/{id}")
+ public Employee removeEmployee(@PathVariable("id") Long id) {
+ Employee employee = this.employeeRepository.findById(id).get();
+ this.employeeRepository.deleteById(id);
+ return employee;
+ }
+
+ @PostMapping("/employee")
+ public Employee saveEmployee(@RequestBody Employee employee) {
+ return this.employeeRepository.save(employee);
+ }
+
+ @PostMapping("/employee/{id}")
+ public Employee updateEmployee(@PathVariable("id") Long id, @RequestBody Employee employee) {
+ return this.employeeRepository.save(employee);
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/resources/application.properties b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/resources/application.properties
new file mode 100644
index 00000000..0affdca6
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/resources/application.properties
@@ -0,0 +1,23 @@
+
+
+
+
+spring.datasource.url=jdbc:oracle:thin:@//localhost:1521/XE
+spring.datasource.username=SYSTEM
+spring.datasource.password=12345
+spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
+
+# HikariCP settings
+spring.datasource.hikari.minimumIdle=5
+spring.datasource.hikari.maximumPoolSize=20
+spring.datasource.hikari.idleTimeout=30000
+spring.datasource.hikari.maxLifetime=2000000
+spring.datasource.hikari.connectionTimeout=30000
+spring.datasource.hikari.poolName=HikariPoolBooks
+
+# JPA settings
+spring.jpa.database-platform=org.hibernate.dialect.Oracle12cDialect
+spring.jpa.hibernate.use-new-id-generator-mappings=false
+spring.jpa.hibernate.ddl-auto=create-drop
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/resources/data.sql b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/resources/data.sql
new file mode 100644
index 00000000..f4af5504
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/main/resources/data.sql
@@ -0,0 +1,5 @@
+
+INSERT INTO employee (emp_id, first_name, last_name, career) VALUES (100,'adarsh', 'kumar', 'It');
+INSERT INTO employee (emp_id, first_name, last_name, career) VALUES (200,'radha', 'singh', 'IT');
+INSERT INTO employee (emp_id, first_name, last_name, career) VALUES(300,'sonu', 'singh', 'IT');
+INSERT INTO employee (emp_id, first_name, last_name, career) VALUES(400,'amit', 'kumar', 'Finance');
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/test/java/com/espark/adarsh/SpringbootH2DbApplicationTests.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/test/java/com/espark/adarsh/SpringbootH2DbApplicationTests.java
new file mode 100644
index 00000000..a946a93b
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot-oracle-db/src/test/java/com/espark/adarsh/SpringbootH2DbApplicationTests.java
@@ -0,0 +1,16 @@
+package com.espark.adarsh;
+
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ApplicationMain.class)
+class SpringbootH2DbApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/.gitignore b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/.gitignore
new file mode 100644
index 00000000..82eca336
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/.gitignore
@@ -0,0 +1,25 @@
+/target/
+!.mvn/wrapper/maven-wrapper.jar
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/build/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/document/help.txt b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/document/help.txt
new file mode 100644
index 00000000..388ee345
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/document/help.txt
@@ -0,0 +1,63 @@
+$ mvn clean package
+$ mvn spring-boot:run
+
+##########################################
+Post
+http://localhost:9090/api/employee
+==========================================
+{
+ "name":"adarsh"
+ ,"email":"adarsh@kumar"
+}
+==========================================
+{
+ "name":"radha"
+ ,"email":"radha@singh"
+}
+==========================================
+
+##########################################
+Get
+http://localhost:9090/api/employee
+
+[
+ {
+ "id": 1,
+ "name": "adarsh",
+ "email": "adarsh@kumar",
+ "createdDate": "2018-04-07T03:03:16.000+0000",
+ "updatedDate": "2018-04-07T03:03:16.000+0000"
+ },
+ {
+ "id": 2,
+ "name": "radha",
+ "email": "radha@singh",
+ "createdDate": "2018-04-07T03:03:31.000+0000",
+ "updatedDate": "2018-04-07T03:03:31.000+0000"
+ }
+]
+
+##########################################
+PUT
+http://localhost:9090/api/employee/1
+{
+ "id": 1,
+ "name": "adarsh",
+ "email": "adarsh@kumar.singh"
+}
+
+##########################################
+DElETE
+http://localhost:9090/api/employee/3
+
+##########################################
+GET
+SEARCH API
+http://localhost:9090/api/search
+http://localhost:9090/api/search?searchOr=name::radha,id::2
+http://localhost:9090/api/search?searchAnd=name::radha,id>1&searchOr=name::adarsh
+http://localhost:9090/api/search?searchAnd=name::radha,id<1&searchOr=name::adarsh
+Number search between
+http://localhost:9090/api/search?searchBt=id:bt:0::1::false::true
+Date search between
+http://localhost:9090/api/search?searchBt=createdDate:bt:2016-04-14 00:00:00::2019-04-14 00:00:00::true::false
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/pom.xml b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/pom.xml
new file mode 100644
index 00000000..66d8b7ce
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/pom.xml
@@ -0,0 +1,77 @@
+
+
+ 4.0.0
+
+ springboot2-jpa
+ springboot2-jpa
+ 0.0.1-SNAPSHOT
+ jar
+
+ springboot2-jpa
+ Demo project for Spring Boot
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.0.1.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+
+
+ mysql
+ mysql-connector-java
+ runtime
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ commons-lang
+ commons-lang
+ 2.6
+
+
+
+ org.projectlombok
+ lombok
+ 1.16.0
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/ApplicationMain.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/ApplicationMain.java
new file mode 100644
index 00000000..e435adb0
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/ApplicationMain.java
@@ -0,0 +1,14 @@
+package com.espark.adarsh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
+
+@EnableJpaAuditing
+@SpringBootApplication
+public class ApplicationMain {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ApplicationMain.class, args);
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/bean/InBean.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/bean/InBean.java
new file mode 100644
index 00000000..ab853885
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/bean/InBean.java
@@ -0,0 +1,26 @@
+package com.espark.adarsh.bean;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class InBean {
+
+ private List data=new LinkedList<>();
+ private String fieldName;
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ public void setFieldName(String fieldName) {
+ this.fieldName = fieldName;
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/bean/RangeCriteria.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/bean/RangeCriteria.java
new file mode 100644
index 00000000..6656e95e
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/bean/RangeCriteria.java
@@ -0,0 +1,62 @@
+package com.espark.adarsh.bean;
+
+public class RangeCriteria{
+
+ private String fieldName;
+ private Object lowerRange;
+ private Object upperRange;
+ private boolean date;
+ private boolean number;
+
+
+ public RangeCriteria() {
+ }
+
+ public RangeCriteria(String fieldName, Object lowerRange, Object upperRange, boolean date, boolean number) {
+ this.fieldName = fieldName;
+ this.lowerRange = lowerRange;
+ this.upperRange = upperRange;
+ this.date = date;
+ this.number = number;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ public void setFieldName(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
+ public Object getLowerRange() {
+ return lowerRange;
+ }
+
+ public void setLowerRange(Object lowerRange) {
+ this.lowerRange = lowerRange;
+ }
+
+ public Object getUpperRange() {
+ return upperRange;
+ }
+
+ public void setUpperRange(Object upperRange) {
+ this.upperRange = upperRange;
+ }
+
+ public boolean isDate() {
+ return date;
+ }
+
+ public void setDate(boolean date) {
+ this.date = date;
+ }
+
+ public boolean isNumber() {
+ return number;
+ }
+
+ public void setNumber(boolean number) {
+ this.number = number;
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/bean/SearchBean.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/bean/SearchBean.java
new file mode 100644
index 00000000..25069114
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/bean/SearchBean.java
@@ -0,0 +1,80 @@
+package com.espark.adarsh.bean;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class SearchBean {
+
+ private Class classType;
+
+ private List andSearchCriteria = new LinkedList<>();
+
+ private List orSearchCriteria = new LinkedList<>();
+
+ private List rangeCriteria = new LinkedList<>();
+
+ private List inList=new LinkedList<>();
+
+ private Integer pageNumber;
+
+ private Integer pageSize;
+
+ public SearchBean() {
+ }
+
+ public Class getClassType() {
+ return classType;
+ }
+
+ public void setClassType(Class classType) {
+ this.classType = classType;
+ }
+
+ public List getAndSearchCriteria() {
+ return andSearchCriteria;
+ }
+
+ public void setAndSearchCriteria(List andSearchCriteria) {
+ this.andSearchCriteria = andSearchCriteria;
+ }
+
+ public List getOrSearchCriteria() {
+ return orSearchCriteria;
+ }
+
+ public void setOrSearchCriteria(List orSearchCriteria) {
+ this.orSearchCriteria = orSearchCriteria;
+ }
+
+ public List getRangeCriteria() {
+ return rangeCriteria;
+ }
+
+ public void setRangeCriteria(List rangeCriteria) {
+ this.rangeCriteria = rangeCriteria;
+ }
+
+ public Integer getPageNumber() {
+ return pageNumber;
+ }
+
+ public void setPageNumber(Integer pageNumber) {
+ this.pageNumber = pageNumber;
+ }
+
+ public Integer getPageSize() {
+ return pageSize;
+ }
+
+ public void setPageSize(Integer pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ public List getInList() {
+ return inList;
+ }
+
+ public void setInList(List inList) {
+ this.inList = inList;
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/bean/SearchCriteria.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/bean/SearchCriteria.java
new file mode 100644
index 00000000..7f4ecbfb
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/bean/SearchCriteria.java
@@ -0,0 +1,41 @@
+package com.espark.adarsh.bean;
+
+public class SearchCriteria {
+
+ private String key;
+ private String operation;
+ private Object value;
+
+ public SearchCriteria() {
+ }
+
+ public SearchCriteria(String key, String operation, Object value) {
+ this.key = key;
+ this.operation = operation;
+ this.value = value;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getOperation() {
+ return operation;
+ }
+
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/controller/EmployeeController.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/controller/EmployeeController.java
new file mode 100644
index 00000000..c0728ad5
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/controller/EmployeeController.java
@@ -0,0 +1,52 @@
+package com.espark.adarsh.controller;
+
+import com.espark.adarsh.entity.Employee;
+import com.espark.adarsh.service.EmployeeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
+
+@RestController
+@RequestMapping("/api")
+public class EmployeeController {
+
+ @Autowired
+ EmployeeService employeeService;
+
+ // Get a all Employee
+ @GetMapping("/employee")
+ public List getAllEmployee() {
+ return employeeService.getAllEmployee();
+ }
+
+ // Create a new Employee
+ @PostMapping("/employee")
+ public Employee createEmployee(@Valid @RequestBody Employee employee) {
+ return employeeService.createEmployee(employee);
+ }
+
+
+ // Get a Single Employee
+ @GetMapping("/employee/{id}")
+ public Employee getEmployeeById(@PathVariable(value = "id") Long empId) {
+ return this.employeeService.getEmployeeById(empId);
+ }
+
+ // Update a Employee
+ @PutMapping("/employee/{id}")
+ public Employee updateEmployee(@PathVariable(value = "id") Long empId,
+ @Valid @RequestBody Employee employeeDetails) {
+ return this.employeeService.updateEmployee(empId, employeeDetails);
+ }
+
+ // Delete a Employee
+ @DeleteMapping("/employee/{id}")
+ public ResponseEntity deleteEmployee(@PathVariable(value = "id") Long empId) {
+ Employee employee = this.employeeService.deleteEmployee(empId);
+ return ResponseEntity.ok().body(employee);
+ }
+
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/controller/SearchController.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/controller/SearchController.java
new file mode 100644
index 00000000..2e11d4be
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/controller/SearchController.java
@@ -0,0 +1,67 @@
+package com.espark.adarsh.controller;
+
+import com.espark.adarsh.bean.RangeCriteria;
+import com.espark.adarsh.bean.SearchBean;
+import com.espark.adarsh.bean.SearchCriteria;
+import com.espark.adarsh.entity.DbEntity;
+import com.espark.adarsh.entity.Employee;
+import com.espark.adarsh.repository.GenericRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+@RestController
+@RequestMapping("/api")
+public class SearchController {
+
+ @Autowired
+ private GenericRepository genericRepository;
+
+ @RequestMapping(method = RequestMethod.POST, value = "/search")
+ @ResponseBody
+ public List search(@RequestBody SearchBean search) throws Exception {
+ return genericRepository.search(search);
+ }
+
+ @RequestMapping(method = RequestMethod.GET, value = "/search")
+ @ResponseBody
+ public List search(@RequestParam(value = "searchAnd", required = false) String searchAnd
+ ,@RequestParam(value = "searchOr", required = false) String searchOr
+ ,@RequestParam(value = "searchBt", required = false) String searchBt) throws Exception {
+ Pattern pattern = Pattern.compile("(\\w+?)(::|<|>|>=|=<|:eq:|:neq:|:lk:|:bt:)(\\w+?),");
+ List searchAndCriteria = new ArrayList();
+ if (searchAnd != null) {
+ Matcher matcher = pattern.matcher(searchAnd + ",");
+ while (matcher.find()) {
+ searchAndCriteria.add(new SearchCriteria(matcher.group(1), matcher.group(2), matcher.group(3)));
+ }
+ }
+ List searchOrCriteria = new ArrayList();
+ if (searchOr != null) {
+ Matcher matcher = pattern.matcher(searchOr + ",");
+ while (matcher.find()) {
+ searchOrCriteria.add(new SearchCriteria(matcher.group(1), matcher.group(2), matcher.group(3)));
+ }
+ }
+
+ List rangeCriteria=new ArrayList<>();
+ if(searchBt!=null){
+ Pattern patternBetween = Pattern.compile("(\\w+?)(:bt:)(\\d{4}-[01]\\d-[0-3]\\d\\s\\d{2}:\\d{2}:\\d{2})(::)(\\d{4}-[01]\\d-[0-3]\\d\\s\\d{2}:\\d{2}:\\d{2})(::)(\\w+?)(::)(\\w+?),");
+ Matcher matcher = patternBetween.matcher(searchBt + ",");
+ while (matcher.find()) {
+ rangeCriteria.add(new RangeCriteria(matcher.group(1), matcher.group(3), matcher.group(5)
+ ,Boolean.valueOf(matcher.group(7)),Boolean.valueOf(matcher.group(9))));
+ }
+ }
+ SearchBean searchBean =new SearchBean();
+ searchBean.setClassType(Employee.class);
+ searchBean.setAndSearchCriteria(searchAndCriteria);
+ searchBean.setOrSearchCriteria(searchOrCriteria);
+ searchBean.setRangeCriteria(rangeCriteria);
+ return genericRepository.search(searchBean);
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/entity/DbEntity.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/entity/DbEntity.java
new file mode 100644
index 00000000..4d9dccb7
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/entity/DbEntity.java
@@ -0,0 +1,6 @@
+package com.espark.adarsh.entity;
+
+import java.io.Serializable;
+
+public interface DbEntity extends Serializable{
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/entity/Employee.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/entity/Employee.java
new file mode 100644
index 00000000..2dd5a2a9
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/entity/Employee.java
@@ -0,0 +1,87 @@
+package com.espark.adarsh.entity;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+import javax.persistence.*;
+import javax.validation.constraints.NotBlank;
+import java.util.Date;
+
+@Entity
+@Table(name = "employee")
+@EntityListeners(AuditingEntityListener.class)
+@JsonIgnoreProperties(value = {"createdDate", "updatedDate"},
+ allowGetters = true)
+public class Employee implements DbEntity {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Long id;
+
+ @NotBlank
+ private String name;
+
+ @NotBlank
+ private String email;
+
+ @Column(nullable = false, updatable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ @CreatedDate
+ private Date createdDate;
+
+ @Column(nullable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ @LastModifiedDate
+ private Date updatedDate;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public Date getCreatedDate() {
+ return createdDate;
+ }
+
+ public void setCreatedDate(Date createdDate) {
+ this.createdDate = createdDate;
+ }
+
+ public Date getUpdatedDate() {
+ return updatedDate;
+ }
+
+ public void setUpdatedDate(Date updatedDate) {
+ this.updatedDate = updatedDate;
+ }
+
+ @Override
+ public String toString() {
+ return "Employee{" +
+ "id=" + id +
+ ", name='" + name + '\'' +
+ ", email='" + email + '\'' +
+ ", createdDate=" + createdDate +
+ ", updatedDate=" + updatedDate +
+ '}';
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/exception/ResourceNotFoundException.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/exception/ResourceNotFoundException.java
new file mode 100644
index 00000000..41539399
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/exception/ResourceNotFoundException.java
@@ -0,0 +1,30 @@
+package com.espark.adarsh.exception;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+@ResponseStatus(value = HttpStatus.NOT_FOUND)
+public class ResourceNotFoundException extends RuntimeException {
+ private String resourceName;
+ private String fieldName;
+ private Object fieldValue;
+
+ public ResourceNotFoundException( String resourceName, String fieldName, Object fieldValue) {
+ super(String.format("%s not found with %s : '%s'", resourceName, fieldName, fieldValue));
+ this.resourceName = resourceName;
+ this.fieldName = fieldName;
+ this.fieldValue = fieldValue;
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ public Object getFieldValue() {
+ return fieldValue;
+ }
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/repository/EmployeeRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/repository/EmployeeRepository.java
new file mode 100644
index 00000000..3c17d285
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/repository/EmployeeRepository.java
@@ -0,0 +1,10 @@
+package com.espark.adarsh.repository;
+
+import com.espark.adarsh.entity.Employee;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface EmployeeRepository extends JpaRepository {
+
+}
\ No newline at end of file
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/repository/GenericRepository.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/repository/GenericRepository.java
new file mode 100644
index 00000000..550e677d
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/repository/GenericRepository.java
@@ -0,0 +1,11 @@
+package com.espark.adarsh.repository;
+
+import com.espark.adarsh.bean.SearchBean;
+import com.espark.adarsh.entity.DbEntity;
+
+import java.text.ParseException;
+import java.util.List;
+
+public interface GenericRepository {
+ List search(SearchBean searchBean) throws Exception;
+}
diff --git a/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/repository/GenericRepositoryImpl.java b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/repository/GenericRepositoryImpl.java
new file mode 100644
index 00000000..cdae3966
--- /dev/null
+++ b/APPLICATIONS/SPRINGBOOT-JPA-SAMPLES/springboot2-jpa/src/main/java/com/espark/adarsh/repository/GenericRepositoryImpl.java
@@ -0,0 +1,169 @@
+package com.espark.adarsh.repository;
+
+
+import com.espark.adarsh.bean.InBean;
+import com.espark.adarsh.bean.RangeCriteria;
+import com.espark.adarsh.bean.SearchBean;
+import com.espark.adarsh.bean.SearchCriteria;
+import com.espark.adarsh.entity.DbEntity;
+import com.espark.adarsh.entity.Employee;
+import org.apache.commons.lang.time.DateUtils;
+import org.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.criterion.Restrictions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.*;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.List;
+
+@Repository
+public class GenericRepositoryImpl implements GenericRepository{
+
+ @Autowired
+ private EntityManager entityManager;
+
+
+ @Override
+ public List search(SearchBean searchBean) throws Exception {
+ List andSearchCriteria=searchBean.getAndSearchCriteria();
+ CriteriaBuilder builder = entityManager.getCriteriaBuilder();
+ CriteriaQuery builderQuery = builder.createQuery(searchBean.getClassType());
+ Root root = builderQuery.from(searchBean.getClassType());
+ Predicate predicate = builder.conjunction();
+ for (SearchCriteria param : andSearchCriteria) {
+ if (param.getOperation().equalsIgnoreCase(">")) {
+ predicate = builder.and(predicate,
+ builder.greaterThan(root.get(param.getKey()),
+ param.getValue().toString()));
+ }else if (param.getOperation().equalsIgnoreCase(">=")) {
+ predicate = builder.and(predicate,
+ builder.greaterThanOrEqualTo(root.get(param.getKey()),
+ param.getValue().toString()));
+ }else if (param.getOperation().equalsIgnoreCase("<")) {
+ predicate = builder.and(predicate,
+ builder.lessThan(root.get(param.getKey()),
+ param.getValue().toString()));
+ }else if (param.getOperation().equalsIgnoreCase("=<")) {
+ predicate = builder.and(predicate,
+ builder.lessThanOrEqualTo(root.get(param.getKey()),
+ param.getValue().toString()));
+ }else if (param.getOperation().equalsIgnoreCase(":lk:")||
+ param.getOperation().equalsIgnoreCase("::")) {
+ if (root.get(param.getKey()).getJavaType() == String.class) {
+ predicate = builder.and(predicate,
+ builder.like(root.get(param.getKey()),
+ "%" + param.getValue() + "%"));
+ } else {
+ predicate = builder.and(predicate,
+ builder.equal(root.get(param.getKey()), param.getValue()));
+ }
+ } else if(param.getOperation().equalsIgnoreCase(":neq:")){
+ predicate = builder.and(predicate,
+ builder.notEqual(root.get(param.getKey()),
+ param.getValue().toString()));
+ }else if(param.getOperation().equalsIgnoreCase(":eq:")){
+ predicate = builder.and(predicate,
+ builder.equal(root.get(param.getKey()),
+ param.getValue().toString()));
+ }
+ }
+ List orSearchCriteria=searchBean.getOrSearchCriteria();
+ for (SearchCriteria param : orSearchCriteria) {
+ if (param.getOperation().equalsIgnoreCase(">")) {
+ predicate = builder.or(predicate,
+ builder.greaterThanOrEqualTo(root.get(param.getKey()),
+ param.getValue().toString()));
+ } else if (param.getOperation().equalsIgnoreCase("<")) {
+ predicate = builder.or(predicate,
+ builder.lessThanOrEqualTo(root.get(param.getKey()),
+ param.getValue().toString()));
+ } else if (param.getOperation().equalsIgnoreCase("lk")||
+ param.getOperation().equalsIgnoreCase("::")) {
+ if (root.get(param.getKey()).getJavaType() == String.class) {
+ predicate = builder.or(predicate,
+ builder.like(root.get(param.getKey()),
+ "%" + param.getValue() + "%"));
+ } else {
+ predicate = builder.or(predicate,
+ builder.equal(root.get(param.getKey()), param.getValue()));
+ }
+ }else if(param.getOperation().equalsIgnoreCase("neq")){
+ predicate = builder.and(predicate,
+ builder.notEqual(root.get(param.getKey()),
+ param.getValue().toString()));
+ }else if(param.getOperation().equalsIgnoreCase("eq")){
+ predicate = builder.and(predicate,
+ builder.equal(root.get(param.getKey()),
+ param.getValue().toString()));
+ }
+ }
+
+ List rangeCriteria = searchBean.getRangeCriteria();
+ for (RangeCriteria criteria : rangeCriteria) {
+ if (criteria.isDate()) {
+ predicate = builder.between(root.get(criteria.getFieldName())
+ , this.getDate(criteria.getLowerRange())
+ , this.getDate(criteria.getUpperRange()));
+ }
+ if (criteria.isNumber()) {
+ predicate = builder.between(root.get(criteria.getFieldName())
+ , Long.valueOf(criteria.getLowerRange().toString())
+ , Long.valueOf(criteria.getUpperRange().toString()));
+ }
+ }
+
+
+ List inList=searchBean.getInList();
+ for(InBean inBean:inList) {
+ final String fieldName=inBean.getFieldName();
+ CriteriaBuilder.In