resourcePaths = uriInfo.getUriResourceParts();
- UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0); // in our example, the first segment is the EntitySet
- EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
-
- // 2nd: fetch the data from backend for this requested EntitySetName
- Long count = getCount(edmEntitySet, uriInfo);
-
- // Finally: configure the response object: set the body, headers and status code
- response.setContent(new ByteArrayInputStream(count.toString().getBytes()));
- response.setStatusCode(HttpStatusCode.OK.getStatusCode());
- response.setHeader(HttpHeader.CONTENT_TYPE, "text/plain");
-
- }
-
- /**
- * Helper method to retrieve all entities of an entity set from an the backend database
- * @param edmEntitySet
- * @param uriInfo
- * @return
- */
- protected EntityCollection getData(EdmEntitySet edmEntitySet, UriInfo uriInfo) {
-
- EdmEntityType type = edmEntitySet.getEntityType();
- JpaRepository, ?> repo = (JpaRepository, ?>)repositoryRegistry.getRepositoryForEntity(type);
- EntityCollection result = new EntityCollection();
-
- repo.findAll()
- .stream()
- .forEach((it) -> result.getEntities()
- .add(entityMapper.map2entity(edmEntitySet, it)));
-
- return result;
- }
-
-
- /**
- * Helper method to get the total size of an entity set
- * @param edmEntitySet
- * @param uriInfo
- * @return
- */
- protected Long getCount(EdmEntitySet edmEntitySet, UriInfo uriInfo) {
-
- EdmEntityType type = edmEntitySet.getEntityType();
- JpaRepository, ?> repo = (JpaRepository, ?>)repositoryRegistry.getRepositoryForEntity(type);
- EntityCollection result = new EntityCollection();
-
- return repo.count();
- }
-
-
-
-
-}
diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/processor/JpaEntityMapper.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/processor/JpaEntityMapper.java
deleted file mode 100644
index 1978aa4fd6..0000000000
--- a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/processor/JpaEntityMapper.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- *
- */
-package org.baeldung.examples.olingo4.processor;
-
-import java.lang.reflect.InvocationTargetException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.metamodel.EntityType;
-
-import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ValueType;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.commons.api.ex.ODataRuntimeException;
-import org.springframework.stereotype.Component;
-
-/**
- * Helper class that converts a JPA entity into an OData entity using
- * available metadata from the JPA's EntityManagerFactory.
- *
- * @author Philippe
- *
- */
-@Component
-public class JpaEntityMapper {
-
- private EntityManagerFactory emf;
-
- public JpaEntityMapper(EntityManagerFactory emf) {
- this.emf = emf;
- }
-
-
- public Entity map2entity(EdmEntitySet edmEntitySet, Object entry) {
-
- EntityType> et = emf.getMetamodel()
- .entity(entry.getClass());
-
-
- Entity e = new Entity();
- try {
- et.getDeclaredSingularAttributes().stream()
- .forEach( (attr) -> {
- if ( !attr.isAssociation()) {
- Object v = getPropertyValue(entry,attr.getName());
- Property p = new Property(null, attr.getName(),ValueType.PRIMITIVE,v);
- e.addProperty(p);
-
- if ( attr.isId()) {
- e.setId(createId(edmEntitySet.getName(),v));
- }
- }
- });
- } catch (Exception ex) {
- throw new ODataRuntimeException("[E141] Unable to create OData entity", ex);
- }
-
- return e;
- }
-
-
- public Object getPropertyValue(Object entry, String name) {
- try {
- return PropertyUtils.getProperty(entry,name);
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- throw new ODataRuntimeException("[E141] Unable to read property from entity, property=" + name, e);
- }
- }
-
- public void setPropertyValue(Object entry, String name,Object value) {
- try {
- PropertyUtils.setProperty(entry,name,value);
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- throw new ODataRuntimeException("[E141] Unable to read property from entity, property=" + name, e);
- }
- }
-
-
- private URI createId(String entitySetName, Object id) {
- try {
- return new URI(entitySetName + "(" + String.valueOf(id) + ")");
- } catch (URISyntaxException e) {
- throw new ODataRuntimeException("[E177] Unable to create URI", e);
- }
- }
-
-
-
-}
diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/processor/JpaEntityProcessor.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/processor/JpaEntityProcessor.java
deleted file mode 100644
index 719e5de160..0000000000
--- a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/processor/JpaEntityProcessor.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/**
- *
- */
-package org.baeldung.examples.olingo4.processor;
-
-import java.io.InputStream;
-import java.util.List;
-import java.util.Locale;
-import java.util.Optional;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.metamodel.SingularAttribute;
-
-import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
-import org.apache.olingo.commons.api.ex.ODataRuntimeException;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.http.HttpHeader;
-import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.ODataApplicationException;
-import org.apache.olingo.server.api.ODataLibraryException;
-import org.apache.olingo.server.api.ODataRequest;
-import org.apache.olingo.server.api.ODataResponse;
-import org.apache.olingo.server.api.ServiceMetadata;
-import org.apache.olingo.server.api.processor.EntityProcessor;
-import org.apache.olingo.server.api.serializer.EntitySerializerOptions;
-import org.apache.olingo.server.api.serializer.ODataSerializer;
-import org.apache.olingo.server.api.serializer.SerializerResult;
-import org.apache.olingo.server.api.uri.UriInfo;
-import org.apache.olingo.server.api.uri.UriParameter;
-import org.apache.olingo.server.api.uri.UriResource;
-import org.apache.olingo.server.api.uri.UriResourceEntitySet;
-import org.apache.olingo.server.api.uri.UriResourceNavigation;
-import org.baeldung.examples.olingo4.repository.EdmEntityRepository;
-import org.baeldung.examples.olingo4.repository.RepositoryRegistry;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Component;
-
-/**
- * JpaEntityProcessor adapter.
- * This implementation is heavily based on the Tutorial available
- * at Olingo's site. It is meant to be an starting point for an actual implementation.
- * Please note that many features from a full-fledged are missing
- * @author Philippe
- *
- */
-@Component
-public class JpaEntityProcessor implements EntityProcessor {
-
- private EntityManagerFactory emf;
- private OData odata;
- private ServiceMetadata serviceMetadata;
- private RepositoryRegistry registry;
- private JpaEntityMapper entityMapper;
-
- public JpaEntityProcessor(EntityManagerFactory emf, RepositoryRegistry registry, JpaEntityMapper entityMapper) {
- this.emf = emf;
- this.registry = registry;
- this.entityMapper = entityMapper;
- }
-
- /* (non-Javadoc)
- * @see org.apache.olingo.server.api.processor.Processor#init(org.apache.olingo.server.api.OData, org.apache.olingo.server.api.ServiceMetadata)
- */
- @Override
- public void init(OData odata, ServiceMetadata serviceMetadata) {
- this.odata = odata;
- this.serviceMetadata = serviceMetadata;
-
- }
-
- /* (non-Javadoc)
- * @see org.apache.olingo.server.api.processor.EntityProcessor#readEntity(org.apache.olingo.server.api.ODataRequest, org.apache.olingo.server.api.ODataResponse, org.apache.olingo.server.api.uri.UriInfo, org.apache.olingo.commons.api.format.ContentType)
- */
- @Override
- public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
-
- // First, we have to figure out which entity is requested
- List resourceParts = uriInfo.getUriResourceParts();
- InputStream entityStream;
-
- UriResourceEntitySet rootResourceEntitySet = (UriResourceEntitySet) resourceParts.get(0);
- EdmEntitySet rootEntitySet = rootResourceEntitySet.getEntitySet();
- List rootPredicates = rootResourceEntitySet.getKeyPredicates();
-
- if ( resourceParts.size() == 1 ) {
- entityStream = readRootEntity(rootEntitySet,rootPredicates,responseFormat);
- }
- else if ( resourceParts.size() == 2 ) {
- UriResource part = resourceParts.get(1);
- if ( !(part instanceof UriResourceNavigation)) {
- throw new ODataRuntimeException("[E103] part type not supported: class=" + part.getClass().getName());
- }
-
- UriResourceNavigation navSegment = (UriResourceNavigation)part;
- entityStream = readRelatedEntity(request, rootEntitySet,rootPredicates,navSegment.getProperty(),navSegment.getKeyPredicates(),responseFormat);
- }
- else {
- // For now, we'll only allow navigation just to directly linked navs
- throw new ODataApplicationException("[E109] Multi-level navigation not supported", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
- }
-
- //4. configure the response object
- response.setContent(entityStream);
- response.setStatusCode(HttpStatusCode.OK.getStatusCode());
- response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
-
- }
-
-
- // Lookup the EntitySet associated with an EntityType
- // In our example, we assume we have only one entityset for each entity type
- private EdmEntitySet entitySetFromType(EdmEntityType type) {
- return serviceMetadata
- .getEdm()
- .getEntityContainer()
- .getEntitySets()
- .stream()
- .filter((s) -> s.getEntityType().getName().equals(type.getName()))
- .findFirst()
- .orElseThrow(() -> new ODataRuntimeException("[E144] No entity set found for type " + type.getFullQualifiedName()));
- }
-
- //
- // private boolean isOne2ManyProperty(EdmEntityType entityType, EdmNavigationProperty property) {
- // return entityType.getProperty(property.getName()) != null && property.isCollection();
- //}
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- private InputStream readRootEntity(EdmEntitySet entitySet, List keyPredicates,ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
- EdmEntityType type = entitySet.getEntityType();
- JpaRepository repo = registry.getRepositoryForEntity(type);
-
- // Get key value
- Long keyValue = getEntityKey(keyPredicates);
- Optional entry = repo.findById(keyValue);
- if ( !entry.isPresent()) {
- throw new ODataApplicationException(
- "[E116] NO entity found for the given key",
- HttpStatusCode.NOT_FOUND.getStatusCode(),
- Locale.ENGLISH);
- }
-
- Entity e = entityMapper.map2entity(entitySet, entry.get());
- return serializeEntity(entitySet,e,responseFormat);
- }
-
- private InputStream serializeEntity(EdmEntitySet entitySet, Entity entity,ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
- ContextURL contextUrl = ContextURL.with().entitySet(entitySet).build();
- // expand and select currently not supported
- EntitySerializerOptions options = EntitySerializerOptions
- .with()
- .contextURL(contextUrl)
- .build();
-
- ODataSerializer serializer = odata.createSerializer(responseFormat);
-
- SerializerResult serializerResult = serializer.entity(serviceMetadata, entitySet.getEntityType(), entity, options);
- return serializerResult.getContent();
-
- }
-
-// @SuppressWarnings("unchecked")
-// protected InputStream readRelatedEntities(EdmEntitySet rootEntitySet, List rootPredicates, EdmNavigationProperty property, ContentType responseFormat) throws ODataApplicationException {
-//
-// Object jpaEntity = readJPAEntity(rootEntitySet, rootPredicates);
-// try {
-// Collection set = (Collection)PropertyUtils.getProperty(jpaEntity, property.getName());
-// EdmEntitySet entitySet = entitySetFromType(property.getType());
-// ContextURL contextUrl = ContextURL
-// .with()
-// .entitySet(entitySet)
-// .build();
-//
-// EntityCollectionSerializerOptions options = EntityCollectionSerializerOptions
-// .with()
-// .contextURL(contextUrl)
-// .build();
-//
-// EntityCollection result = new EntityCollection();
-//
-// set.stream()
-// .map((o) -> this.entityMapper.map2entity(entitySet, o))
-// .forEach((e) -> result.getEntities().add(e));
-//
-// ODataSerializer serializer = odata.createSerializer(responseFormat);
-// SerializerResult serializerResult = serializer.entityCollection(serviceMetadata, property.getType(), result, options);
-// return serializerResult.getContent();
-// }
-// catch(Exception ex) {
-// throw new ODataRuntimeException("[E181] Error accessing database", ex);
-// }
-// }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- private InputStream readRelatedEntity(ODataRequest request, EdmEntitySet entitySet, List rootPredicates, EdmNavigationProperty property, List parentPredicates, ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
-
-
- JpaRepository repo = (JpaRepository)registry.getRepositoryForEntity(entitySet.getEntityType());
- EdmEntityRepository relatedRepo = (EdmEntityRepository)registry.getRepositoryForEntity(property.getType());
-
- // We assume here that we have a bi-directional 1:N relationship, so we'll
- // always have a property in the child entity that points to the parent
- Class> rootClass = ((EdmEntityRepository)repo).getEntityClass();
- Class> relatedClass = ((EdmEntityRepository)relatedRepo).getEntityClass();
-
- SingularAttribute fk = emf.getMetamodel()
- .entity(rootClass)
- .getSingularAttributes()
- .stream()
- .filter((attr) -> {
- boolean b = attr.isAssociation() && attr.getJavaType().isAssignableFrom(relatedClass);
- return b;
- })
- .findFirst()
- .orElse(null);
-
- if ( fk == null ) {
- throw new ODataRuntimeException("[E230] No singular attribute of child class '" + relatedClass.getName() + "' found" );
- }
-
- Long pkValue = getEntityKey(rootPredicates);
- EntityManager em = this.emf.createEntityManager();
- try {
- // Read data from DB
- Object root = em.find(rootClass, pkValue);
- Object related = this.entityMapper.getPropertyValue(root, fk.getName());
-
- EdmEntitySet relatedEntitySet = entitySetFromType(property.getType());
- Entity e = entityMapper.map2entity(relatedEntitySet, related);
- return serializeEntity(relatedEntitySet,e,responseFormat);
- }
- finally {
- em.close();
- }
- }
-
-// @SuppressWarnings("unchecked")
-// private Object readJPAEntity(EdmEntitySet edmEntitySet, List keyPredicates) throws ODataApplicationException {
-// EdmEntityType type = edmEntitySet.getEntityType();
-// JpaRepository repo = (JpaRepository)registry.getRepositoryForEntity(type);
-//
-// // Get key value
-// Object keyValue = getEntityKey(type,keyPredicates);
-// Object entry = repo
-// .findById(keyValue)
-// .orElseThrow(
-// () -> new ODataApplicationException("[E116] NO entity found for the given key",
-// HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH));
-//
-// return entry;
-// }
-
- private Long getEntityKey(List keyPredicates) {
-
- if ( keyPredicates.size() > 1 ) {
- throw new ODataRuntimeException("[E131] Composite keys are not supported");
- }
-
- // For now, we'll assume we only have numeric keys.
- UriParameter keyParam = keyPredicates.get(0);
- try {
- return Long.parseLong(keyParam.getText());
- }
- catch(NumberFormatException nfe) {
- throw new ODataRuntimeException("[E140] Invalid key value. Only numeric keys are supported by this service");
- }
-
-
- }
-
- /* (non-Javadoc)
- * @see org.apache.olingo.server.api.processor.EntityProcessor#createEntity(org.apache.olingo.server.api.ODataRequest, org.apache.olingo.server.api.ODataResponse, org.apache.olingo.server.api.uri.UriInfo, org.apache.olingo.commons.api.format.ContentType, org.apache.olingo.commons.api.format.ContentType)
- */
- @Override
- public void createEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.apache.olingo.server.api.processor.EntityProcessor#updateEntity(org.apache.olingo.server.api.ODataRequest, org.apache.olingo.server.api.ODataResponse, org.apache.olingo.server.api.uri.UriInfo, org.apache.olingo.commons.api.format.ContentType, org.apache.olingo.commons.api.format.ContentType)
- */
- @Override
- public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.apache.olingo.server.api.processor.EntityProcessor#deleteEntity(org.apache.olingo.server.api.ODataRequest, org.apache.olingo.server.api.ODataResponse, org.apache.olingo.server.api.uri.UriInfo)
- */
- @Override
- public void deleteEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws ODataApplicationException, ODataLibraryException {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/CarMakerRepository.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/CarMakerRepository.java
deleted file mode 100644
index 1bde9f148c..0000000000
--- a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/CarMakerRepository.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.baeldung.examples.olingo4.repository;
-
-import org.baeldung.examples.olingo4.domain.CarMaker;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public interface CarMakerRepository extends EdmEntityRepository, JpaRepository, JpaSpecificationExecutor {
-
- public default String getEdmEntityName() { return CarMaker.class.getSimpleName();}
- @Override
- default Class getEntityClass() {
- return CarMaker.class;
- }
-}
diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/CarModelRepository.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/CarModelRepository.java
deleted file mode 100644
index 247bf6e77b..0000000000
--- a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/CarModelRepository.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.baeldung.examples.olingo4.repository;
-
-import java.util.List;
-
-import org.baeldung.examples.olingo4.domain.CarModel;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public interface CarModelRepository extends EdmEntityRepository, JpaRepository, JpaSpecificationExecutor {
-
- public List findByMakerId(Long makerId);
-
- public default String getEdmEntityName() { return CarModel.class.getSimpleName();}
-
- @Override
- default Class getEntityClass() {
- return CarModel.class;
- }
-
-}
diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/EdmEntityRepository.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/EdmEntityRepository.java
deleted file mode 100644
index dbfd0e6f93..0000000000
--- a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/EdmEntityRepository.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- *
- */
-package org.baeldung.examples.olingo4.repository;
-
-
-/**
- * @author Philippe
- *
- */
-public interface EdmEntityRepository {
-
- public String getEdmEntityName();
- public Class getEntityClass();
-
-
-}
diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/RepositoryRegistry.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/RepositoryRegistry.java
deleted file mode 100644
index e3bb172e3a..0000000000
--- a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/RepositoryRegistry.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.baeldung.examples.olingo4.repository;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Component;
-
-@Component
-public class RepositoryRegistry {
-
- private Map> repositoriesByClassName = new HashMap<>();
-
- public RepositoryRegistry(List> allRepositories) {
-
- allRepositories.stream()
- .forEach((r) ->
- repositoriesByClassName.put(r.getEdmEntityName(),(JpaRepository,?>)r));
-
- }
-
-
- public JpaRepository,?> getRepositoryForEntity(EdmEntityType entityType) {
- JpaRepository,?> repo = repositoriesByClassName.get(entityType.getName());
- return repo;
- }
-}
diff --git a/apache-olingo/olingo4/src/main/resources/application.properties b/apache-olingo/olingo4/src/main/resources/application.properties
deleted file mode 100644
index 02c7fe5c4d..0000000000
--- a/apache-olingo/olingo4/src/main/resources/application.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-server:
- port: 8080
-
-spring:
- jpa:
- show-sql: true
- open-in-view: true
- hibernate:
- ddl-auto: update
diff --git a/apache-olingo/olingo4/src/main/resources/data.sql b/apache-olingo/olingo4/src/main/resources/data.sql
deleted file mode 100644
index 327f2688c5..0000000000
--- a/apache-olingo/olingo4/src/main/resources/data.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-insert into car_maker(id,name) values (1,'Special Motors');
-insert into car_maker(id,name) values (2,'BWM');
-insert into car_maker(id,name) values (3,'Dolores');
-
-insert into car_model(id,maker_fk,name,sku,year) values(1,1,'Muze','SM001',2018);
-insert into car_model(id,maker_fk,name,sku,year) values(2,1,'Empada','SM002',2008);
-
-insert into car_model(id,maker_fk,name,sku,year) values(4,2,'BWM-100','BWM100',2008);
-insert into car_model(id,maker_fk,name,sku,year) values(5,2,'BWM-200','BWM200',2009);
-insert into car_model(id,maker_fk,name,sku,year) values(6,2,'BWM-300','BWM300',2008);
-
-alter sequence hibernate_sequence restart with 100;
\ No newline at end of file
diff --git a/apache-olingo/olingo4/src/test/java/org/baeldung/examples/olingo4/Olingo4SampleApplicationTests.java b/apache-olingo/olingo4/src/test/java/org/baeldung/examples/olingo4/Olingo4SampleApplicationTests.java
deleted file mode 100644
index 5d23a4148e..0000000000
--- a/apache-olingo/olingo4/src/test/java/org/baeldung/examples/olingo4/Olingo4SampleApplicationTests.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.baeldung.examples.olingo4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class Olingo4SampleApplicationTests {
-
- @Test
- public void contextLoads() {
- }
-
-}
diff --git a/clojure/ring/.gitignore b/clojure/ring/.gitignore
new file mode 100644
index 0000000000..d18f225992
--- /dev/null
+++ b/clojure/ring/.gitignore
@@ -0,0 +1,12 @@
+/target
+/classes
+/checkouts
+profiles.clj
+pom.xml
+pom.xml.asc
+*.jar
+*.class
+/.lein-*
+/.nrepl-port
+.hgignore
+.hg/
diff --git a/clojure/ring/README.md b/clojure/ring/README.md
new file mode 100644
index 0000000000..20263c6b95
--- /dev/null
+++ b/clojure/ring/README.md
@@ -0,0 +1,19 @@
+# Clojure Ring Examples
+
+This project acts as a set of examples for the Clojure Ring library.
+
+## Runing the examples
+
+The examples can all be run from the Leiningen REPL.
+
+Firstly, start the REPL with `lein repl`. Then the examples can be executed with:
+
+* `(run simple-handler)` - A simple handler that just echos a constant string to the client
+* `(run check-ip-handler)` - A handler that echos the clients IP Address back to them
+* `(run echo-handler)` - A handler that echos the value of the "input" parameter back
+* `(run request-count-handler)` - A handler with a session that tracks how many times this session has requested this handler
+
+In all cases, the handlers can be accessed on http://localhost:3000.
+
+## Relevant Articles
+- [Writing Clojure Webapps with Ring](https://www.baeldung.com/clojure-ring)
diff --git a/clojure/ring/project.clj b/clojure/ring/project.clj
new file mode 100644
index 0000000000..7f2fcc4263
--- /dev/null
+++ b/clojure/ring/project.clj
@@ -0,0 +1,8 @@
+(defproject baeldung-ring "0.1.0-SNAPSHOT"
+ :dependencies [[org.clojure/clojure "1.10.0"]
+ [ring/ring-core "1.7.1"]
+ [ring/ring-jetty-adapter "1.7.1"]
+ [ring/ring-devel "1.7.1"]]
+ :plugins [[lein-ring "0.12.5"]]
+ :ring {:handler ring.core/simple-handler}
+ :repl-options {:init-ns ring.core})
diff --git a/clojure/ring/src/ring/core.clj b/clojure/ring/src/ring/core.clj
new file mode 100644
index 0000000000..a56e2f2bde
--- /dev/null
+++ b/clojure/ring/src/ring/core.clj
@@ -0,0 +1,48 @@
+(ns ring.core
+ (:use ring.adapter.jetty
+ [ring.middleware.content-type]
+ [ring.middleware.cookies]
+ [ring.middleware.params]
+ [ring.middleware.session]
+ [ring.middleware.session.cookie]
+ [ring.util.response]))
+
+;; Handler that just echos back the string "Hello World"
+(defn simple-handler [request]
+ {:status 200
+ :headers {"Content-Type" "text/plain"}
+ :body "Hello World"})
+
+;; Handler that echos back the clients IP Address
+;; This demonstrates building responses properly, and extracting values from the request
+(defn check-ip-handler [request]
+ (content-type
+ (response (:remote-addr request))
+ "text/plain"))
+
+;; Handler that echos back the incoming parameter "input"
+;; This demonstrates middleware chaining and accessing parameters
+(def echo-handler
+ (-> (fn [{params :params}]
+ (content-type
+ (response (get params "input"))
+ "text/plain"))
+ (wrap-params {:encoding "UTF-8"})
+ ))
+
+;; Handler that keeps track of how many times each session has accessed the service
+;; This demonstrates cookies and sessions
+(def request-count-handler
+ (-> (fn [{session :session}]
+ (let [count (:count session 0)
+ session (assoc session :count (inc count))]
+ (-> (response (str "You accessed this page " count " times."))
+ (assoc :session session))))
+ wrap-cookies
+ (wrap-session {:cookie-attrs {:max-age 3600}})
+ ))
+
+;; Run the provided handler on port 3000
+(defn run
+ [h]
+ (run-jetty h {:port 3000}))
diff --git a/core-java-lang/src/main/java/com/baeldung/error/ErrorGenerator.java b/core-java-lang/src/main/java/com/baeldung/error/ErrorGenerator.java
new file mode 100644
index 0000000000..58cbe22df5
--- /dev/null
+++ b/core-java-lang/src/main/java/com/baeldung/error/ErrorGenerator.java
@@ -0,0 +1,15 @@
+package com.baeldung.error;
+
+public class ErrorGenerator {
+ public void throwException() throws Exception {
+ throw new Exception("checked");
+ }
+
+ public void throwRuntimeException() {
+ throw new RuntimeException("unchecked");
+ }
+
+ public void throwError() {
+ throw new Error("unchecked");
+ }
+}
diff --git a/core-java-lang/src/test/java/com/baeldung/error/ErrorGeneratorUnitTest.java b/core-java-lang/src/test/java/com/baeldung/error/ErrorGeneratorUnitTest.java
new file mode 100644
index 0000000000..2a7c24f5fa
--- /dev/null
+++ b/core-java-lang/src/test/java/com/baeldung/error/ErrorGeneratorUnitTest.java
@@ -0,0 +1,51 @@
+package com.baeldung.error;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ErrorGeneratorUnitTest {
+
+ private ErrorGenerator errorGenerator;
+
+ @Before
+ public void setUp() {
+ errorGenerator = new ErrorGenerator();
+ }
+
+ @Test
+ public void whenCheckedException_thenIsCaughtByCatchException() {
+ try {
+ errorGenerator.throwException();
+ } catch (Exception e) {
+ // caught! -> test pass
+ }
+ }
+
+ @Test
+ public void whenUncheckedException_thenIsCaughtByCatchException() {
+ try {
+ errorGenerator.throwRuntimeException();
+ } catch (Exception e) {
+ // caught! -> test pass
+ }
+ }
+
+ @Test(expected = Error.class)
+ public void whenError_thenIsNotCaughtByCatchException() {
+ try {
+ errorGenerator.throwError();
+ } catch (Exception e) {
+ Assert.fail(); // errors are not caught by catch exception
+ }
+ }
+
+ @Test
+ public void whenError_thenIsCaughtByCatchError() {
+ try {
+ errorGenerator.throwError();
+ } catch (Error e) {
+ // caught! -> test pass
+ }
+ }
+}
\ No newline at end of file
diff --git a/core-java-modules/core-java-9/src/modules/com.baeldung.logging.slf4j/com/baeldung/logging/slf4j/Slf4jLogger.java b/core-java-modules/core-java-9/src/modules/com.baeldung.logging.slf4j/com/baeldung/logging/slf4j/Slf4jLogger.java
index a5d6abeac7..db19613c94 100644
--- a/core-java-modules/core-java-9/src/modules/com.baeldung.logging.slf4j/com/baeldung/logging/slf4j/Slf4jLogger.java
+++ b/core-java-modules/core-java-9/src/modules/com.baeldung.logging.slf4j/com/baeldung/logging/slf4j/Slf4jLogger.java
@@ -75,7 +75,7 @@ public class Slf4jLogger implements System.Logger {
if (!isLoggable(level)) {
return;
}
- String message = MessageFormat.format (format, params);
+ String message = MessageFormat.format(format, params);
switch (level) {
case TRACE:
diff --git a/core-java-modules/core-java-lambdas/README.MD b/core-java-modules/core-java-lambdas/README.MD
new file mode 100644
index 0000000000..31790ffbb1
--- /dev/null
+++ b/core-java-modules/core-java-lambdas/README.MD
@@ -0,0 +1,3 @@
+### Relevant Articles
+
+- [Why Do Local Variables Used in Lambdas Have to Be Final or Effectively Final?](https://www.baeldung.com/java-lambda-effectively-final-local-variables)
diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/jvmannotations/Document.kt b/core-kotlin-2/src/main/kotlin/com/baeldung/jvmannotations/Document.kt
index 3f9922b88b..f66f8fbae0 100644
--- a/core-kotlin-2/src/main/kotlin/com/baeldung/jvmannotations/Document.kt
+++ b/core-kotlin-2/src/main/kotlin/com/baeldung/jvmannotations/Document.kt
@@ -5,6 +5,8 @@ import java.util.*
interface Document {
@JvmDefault
+ fun getTypeDefault() = "document"
+
fun getType() = "document"
}
@@ -23,9 +25,3 @@ class TextDocument : Document {
}
class XmlDocument(d : Document) : Document by d
-
-fun main() {
- val myDocument = TextDocument()
- val myTextDocument = XmlDocument(myDocument)
- println("${myDocument.getType()} ${myTextDocument.getType()}")
-}
diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/DocumentTest.kt b/core-kotlin-2/src/test/kotlin/com/baeldung/range/DocumentTest.kt
new file mode 100644
index 0000000000..449e009104
--- /dev/null
+++ b/core-kotlin-2/src/test/kotlin/com/baeldung/range/DocumentTest.kt
@@ -0,0 +1,18 @@
+package com.baeldung.range
+
+import org.junit.Test
+import kotlin.test.assertEquals
+
+class DocumentTest {
+
+ @Test
+ fun testDefaultMethod() {
+
+ val myDocument = TextDocument()
+ val myTextDocument = XmlDocument(myDocument)
+
+ assertEquals("text", myDocument.getType())
+ assertEquals("text", myTextDocument.getType())
+ assertEquals("document", myTextDocument.getTypeDefault())
+ }
+}
\ No newline at end of file
diff --git a/java-strings-2/src/test/java/com/baeldung/string/search/SubstringSearch.java b/java-strings-2/src/test/java/com/baeldung/string/search/SubstringSearchUnitTest.java
similarity index 98%
rename from java-strings-2/src/test/java/com/baeldung/string/search/SubstringSearch.java
rename to java-strings-2/src/test/java/com/baeldung/string/search/SubstringSearchUnitTest.java
index 4a5adb45ef..293e6d2125 100644
--- a/java-strings-2/src/test/java/com/baeldung/string/search/SubstringSearch.java
+++ b/java-strings-2/src/test/java/com/baeldung/string/search/SubstringSearchUnitTest.java
@@ -10,7 +10,7 @@ import org.junit.Test;
/**
* BAEL-2832: Different ways to check if a Substring could be found in a String.
*/
-public class SubstringSearch {
+public class SubstringSearchUnitTest {
@Test
public void searchSubstringWithIndexOf() {
diff --git a/jhipster/jhipster-microservice/car-app/pom.xml b/jhipster/jhipster-microservice/car-app/pom.xml
index 529877d448..86d94d0a44 100644
--- a/jhipster/jhipster-microservice/car-app/pom.xml
+++ b/jhipster/jhipster-microservice/car-app/pom.xml
@@ -1,21 +1,100 @@
4.0.0
- com.car.app
- car-app
- car-app
- war
jhipster-microservice
com.baeldung.jhipster
1.0.0-SNAPSHOT
+ com.car.app
+ car-app
+ war
+ car-app
${maven.version}
+
+ -Djava.security.egd=file:/dev/./urandom -Xmx256m
+ 3.6.2
+ 2.0.0
+ 2.5
+ 3.5
+ 0.4.13
+ 1.2
+ 5.2.8.Final
+ 2.6.0
+ 0.7.9
+ 1.8
+ 3.21.0-GA
+ 1.0.0
+ 1.1.0
+ 0.7.0
+ 3.6
+ 2.0.0
+ 3.6.2
+ 4.8
+ jdt_apt
+ 1.1.0.Final
+ 2.10
+ 1.4.1
+ 3.0.1
+ yyyyMMddHHmmss
+ 3.0.0
+ 3.1.3
+ v6.10.0
+
+
+
+
+ ${project.build.directory}/test-results
+ 0.0.20
+ false
+ 3.2.2
+ 2.12.1
+ 3.2
+
+ src/main/webapp/content/**/*.*, src/main/webapp/bower_components/**/*.*, src/main/webapp/i18n/*.js, target/www/**/*.*
+
+ S3437,UndocumentedApi,BoldAndItalicTagsCheck
+
+
+ src/main/webapp/app/**/*.*
+ Web:BoldAndItalicTagsCheck
+
+ src/main/java/**/*
+ squid:S3437
+
+ src/main/java/**/*
+ squid:UndocumentedApi
+
+ ${project.testresult.directory}/coverage/jacoco/jacoco-it.exec
+ ${project.testresult.directory}/coverage/jacoco/jacoco.exec
+ jacoco
+
+ ${project.testresult.directory}/karma
+
+ ${project.testresult.directory}/coverage/report-lcov/lcov.info
+
+ ${project.testresult.directory}/coverage/report-lcov/lcov.info
+
+ ${project.basedir}/src/main/
+ ${project.testresult.directory}/surefire-reports
+ ${project.basedir}/src/test/
+
+ 2.5.0
+
+ Camden.SR5
+ 2.6.1
+ 1.4.10.Final
+ 1.1.0.Final
+ v0.21.3
+
+
@@ -819,83 +898,4 @@
-
- -Djava.security.egd=file:/dev/./urandom -Xmx256m
- 3.6.2
- 2.0.0
- 2.5
- 3.5
- 0.4.13
- 1.2
- 5.2.8.Final
- 2.6.0
- 0.7.9
- 1.8
- 3.21.0-GA
- 1.0.0
- 1.1.0
- 0.7.0
- 3.6
- 2.0.0
- 3.6.2
- 4.8
- jdt_apt
- 1.1.0.Final
- 2.10
- 1.4.1
- 3.0.1
- yyyyMMddHHmmss
- 3.0.0
- 3.1.3
- v6.10.0
-
-
-
-
- ${project.build.directory}/test-results
- 0.0.20
- false
- 3.2.2
- 2.12.1
- 3.2
-
- src/main/webapp/content/**/*.*, src/main/webapp/bower_components/**/*.*, src/main/webapp/i18n/*.js, target/www/**/*.*
-
- S3437,UndocumentedApi,BoldAndItalicTagsCheck
-
-
- src/main/webapp/app/**/*.*
- Web:BoldAndItalicTagsCheck
-
- src/main/java/**/*
- squid:S3437
-
- src/main/java/**/*
- squid:UndocumentedApi
-
- ${project.testresult.directory}/coverage/jacoco/jacoco-it.exec
- ${project.testresult.directory}/coverage/jacoco/jacoco.exec
- jacoco
-
- ${project.testresult.directory}/karma
-
- ${project.testresult.directory}/coverage/report-lcov/lcov.info
-
- ${project.testresult.directory}/coverage/report-lcov/lcov.info
-
- ${project.basedir}/src/main/
- ${project.testresult.directory}/surefire-reports
- ${project.basedir}/src/test/
-
- 2.5.0
-
- Camden.SR5
- 2.6.1
- 1.4.10.Final
- 1.1.0.Final
- v0.21.3
-
-
diff --git a/jhipster/jhipster-microservice/dealer-app/pom.xml b/jhipster/jhipster-microservice/dealer-app/pom.xml
index 1eac8a930e..3051399ae6 100644
--- a/jhipster/jhipster-microservice/dealer-app/pom.xml
+++ b/jhipster/jhipster-microservice/dealer-app/pom.xml
@@ -1,21 +1,99 @@
4.0.0
- com.dealer.app
- dealer-app
- dealer-app
- war
jhipster-microservice
com.baeldung.jhipster
1.0.0-SNAPSHOT
+ com.dealer.app
+ dealer-app
+ war
+ dealer-app
${maven.version}
+
+ -Djava.security.egd=file:/dev/./urandom -Xmx256m
+ 3.6.2
+ 2.0.0
+ 2.5
+ 3.5
+ 0.4.13
+ 1.2
+ 5.2.8.Final
+ 2.6.0
+ 0.7.9
+ 3.21.0-GA
+ 1.0.0
+ 1.1.0
+ 0.7.0
+ 3.6
+ 2.0.0
+ 3.6.2
+ 4.8
+ jdt_apt
+ 1.1.0.Final
+ 2.10
+ 1.4.1
+ 3.0.1
+ yyyyMMddHHmmss
+ 3.0.0
+ 3.1.3
+ v6.10.0
+
+
+
+
+ ${project.build.directory}/test-results
+ 0.0.20
+ false
+ 3.2.2
+ 2.12.1
+ 3.2
+
+ src/main/webapp/content/**/*.*, src/main/webapp/bower_components/**/*.*, src/main/webapp/i18n/*.js, target/www/**/*.*
+
+ S3437,UndocumentedApi,BoldAndItalicTagsCheck
+
+
+ src/main/webapp/app/**/*.*
+ Web:BoldAndItalicTagsCheck
+
+ src/main/java/**/*
+ squid:S3437
+
+ src/main/java/**/*
+ squid:UndocumentedApi
+
+ ${project.testresult.directory}/coverage/jacoco/jacoco-it.exec
+ ${project.testresult.directory}/coverage/jacoco/jacoco.exec
+ jacoco
+
+ ${project.testresult.directory}/karma
+
+ ${project.testresult.directory}/coverage/report-lcov/lcov.info
+
+ ${project.testresult.directory}/coverage/report-lcov/lcov.info
+
+ ${project.basedir}/src/main/
+ ${project.testresult.directory}/surefire-reports
+ ${project.basedir}/src/test/
+
+ 2.5.0
+
+ Camden.SR5
+ 2.6.1
+ 1.4.10.Final
+ 1.1.0.Final
+ v0.21.3
+
+
@@ -813,83 +891,5 @@
-
-
- -Djava.security.egd=file:/dev/./urandom -Xmx256m
- 3.6.2
- 2.0.0
- 2.5
- 3.5
- 0.4.13
- 1.2
- 5.2.8.Final
- 2.6.0
- 0.7.9
- 3.21.0-GA
- 1.0.0
- 1.1.0
- 0.7.0
- 3.6
- 2.0.0
- 3.6.2
- 4.8
- jdt_apt
- 1.1.0.Final
- 2.10
- 1.4.1
- 3.0.1
- yyyyMMddHHmmss
- 3.0.0
- 3.1.3
- v6.10.0
-
-
-
-
- ${project.build.directory}/test-results
- 0.0.20
- false
- 3.2.2
- 2.12.1
- 3.2
- src/main/webapp/content/**/*.*, src/main/webapp/bower_components/**/*.*, src/main/webapp/i18n/*.js, target/www/**/*.*
-
- S3437,UndocumentedApi,BoldAndItalicTagsCheck
-
-
- src/main/webapp/app/**/*.*
- Web:BoldAndItalicTagsCheck
-
- src/main/java/**/*
- squid:S3437
-
- src/main/java/**/*
- squid:UndocumentedApi
-
- ${project.testresult.directory}/coverage/jacoco/jacoco-it.exec
- ${project.testresult.directory}/coverage/jacoco/jacoco.exec
- jacoco
-
- ${project.testresult.directory}/karma
-
- ${project.testresult.directory}/coverage/report-lcov/lcov.info
-
- ${project.testresult.directory}/coverage/report-lcov/lcov.info
-
- ${project.basedir}/src/main/
- ${project.testresult.directory}/surefire-reports
- ${project.basedir}/src/test/
-
- 2.5.0
-
- Camden.SR5
- 2.6.1
- 1.4.10.Final
- 1.1.0.Final
- v0.21.3
-
-
diff --git a/jhipster/jhipster-microservice/gateway-app/pom.xml b/jhipster/jhipster-microservice/gateway-app/pom.xml
index babc9e4f24..4e2c19ed2d 100644
--- a/jhipster/jhipster-microservice/gateway-app/pom.xml
+++ b/jhipster/jhipster-microservice/gateway-app/pom.xml
@@ -1,21 +1,103 @@
4.0.0
- com.gateway
- gateway-app
- gateway-app
- war
jhipster-microservice
com.baeldung.jhipster
1.0.0-SNAPSHOT
+ com.gateway
+ gateway-app
+ war
+ gateway-app
${maven.version}
+
+ -Djava.security.egd=file:/dev/./urandom -Xmx256m
+ 3.6.2
+ 2.0.0
+ 3.6.0
+ 1.10
+ 2.5
+ 3.5
+ 0.4.13
+ 1.3
+ 1.2
+ 5.2.8.Final
+ 2.6.0
+ 0.7.9
+ 3.21.0-GA
+ 1.0.0
+ 1.1.0
+ 0.7.0
+ 3.6
+ 2.0.0
+ 3.6.2
+ 4.8
+ 1.3.0
+ jdt_apt
+ 1.1.0.Final
+ 2.10
+ 1.4.1
+ 3.0.1
+ yyyyMMddHHmmss
+ 3.0.0
+ 3.1.3
+ v6.10.0
+
+
+
+
+ ${project.build.directory}/test-results
+ 0.0.20
+ false
+ 3.2.2
+ 2.12.1
+ 3.2
+
+ src/main/webapp/content/**/*.*, src/main/webapp/bower_components/**/*.*, src/main/webapp/i18n/*.js, target/www/**/*.*
+
+ S3437,UndocumentedApi,BoldAndItalicTagsCheck
+
+
+ src/main/webapp/app/**/*.*
+ Web:BoldAndItalicTagsCheck
+
+ src/main/java/**/*
+ squid:S3437
+
+ src/main/java/**/*
+ squid:UndocumentedApi
+
+ ${project.testresult.directory}/coverage/jacoco/jacoco-it.exec
+ ${project.testresult.directory}/coverage/jacoco/jacoco.exec
+ jacoco
+
+ ${project.testresult.directory}/karma
+
+ ${project.testresult.directory}/coverage/report-lcov/lcov.info
+
+ ${project.testresult.directory}/coverage/report-lcov/lcov.info
+
+ ${project.basedir}/src/main/
+ ${project.testresult.directory}/surefire-reports
+ ${project.basedir}/src/test/
+
+ 2.5.0
+
+ Camden.SR5
+ 2.6.1
+ 1.4.10.Final
+ 1.1.0.Final
+ v0.21.3
+
+
@@ -925,87 +1007,5 @@
-
-
- -Djava.security.egd=file:/dev/./urandom -Xmx256m
- 3.6.2
- 2.0.0
- 3.6.0
- 1.10
- 2.5
- 3.5
- 0.4.13
- 1.3
- 1.2
- 5.2.8.Final
- 2.6.0
- 0.7.9
- 3.21.0-GA
- 1.0.0
- 1.1.0
- 0.7.0
- 3.6
- 2.0.0
- 3.6.2
- 4.8
- 1.3.0
- jdt_apt
- 1.1.0.Final
- 2.10
- 1.4.1
- 3.0.1
- yyyyMMddHHmmss
- 3.0.0
- 3.1.3
- v6.10.0
-
-
-
-
- ${project.build.directory}/test-results
- 0.0.20
- false
- 3.2.2
- 2.12.1
- 3.2
-
- src/main/webapp/content/**/*.*, src/main/webapp/bower_components/**/*.*, src/main/webapp/i18n/*.js, target/www/**/*.*
-
- S3437,UndocumentedApi,BoldAndItalicTagsCheck
-
-
- src/main/webapp/app/**/*.*
- Web:BoldAndItalicTagsCheck
-
- src/main/java/**/*
- squid:S3437
-
- src/main/java/**/*
- squid:UndocumentedApi
-
- ${project.testresult.directory}/coverage/jacoco/jacoco-it.exec
- ${project.testresult.directory}/coverage/jacoco/jacoco.exec
- jacoco
-
- ${project.testresult.directory}/karma
-
- ${project.testresult.directory}/coverage/report-lcov/lcov.info
-
- ${project.testresult.directory}/coverage/report-lcov/lcov.info
-
- ${project.basedir}/src/main/
- ${project.testresult.directory}/surefire-reports
- ${project.basedir}/src/test/
-
- 2.5.0
-
- Camden.SR5
- 2.6.1
- 1.4.10.Final
- 1.1.0.Final
- v0.21.3
-
diff --git a/patterns/README.md b/patterns/README.md
deleted file mode 100644
index f627251aa4..0000000000
--- a/patterns/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-### Relevant Articles:
-- [A Guide to the Front Controller Pattern in Java](http://www.baeldung.com/java-front-controller-pattern)
-- [Introduction to Intercepting Filter Pattern in Java](http://www.baeldung.com/intercepting-filter-pattern-in-java)
-- [Introduction to the Null Object Pattern](https://www.baeldung.com/java-null-object-pattern)
-- [The Dependency Inversion Principle in Java](https://www.baeldung.com/java-dependency-inversion-principle)
-- [Avoid Check for Null Statement in Java](https://www.baeldung.com/java-avoid-null-check)
diff --git a/patterns/design-patterns-2/README.md b/patterns/design-patterns-2/README.md
index c2a75d4680..8e4ef657e1 100644
--- a/patterns/design-patterns-2/README.md
+++ b/patterns/design-patterns-2/README.md
@@ -1,3 +1,5 @@
### Relevant Articles
- [The Mediator Pattern in Java](https://www.baeldung.com/java-mediator-pattern)
+- [Introduction to the Null Object Pattern](https://www.baeldung.com/java-null-object-pattern)
+- [Avoid Check for Null Statement in Java](https://www.baeldung.com/java-avoid-null-check)
diff --git a/patterns/dip/README.md b/patterns/dip/README.md
new file mode 100644
index 0000000000..8876bbe766
--- /dev/null
+++ b/patterns/dip/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles:
+
+- [The Dependency Inversion Principle in Java](https://www.baeldung.com/java-dependency-inversion-principle)
diff --git a/patterns/front-controller/README.md b/patterns/front-controller/README.md
new file mode 100644
index 0000000000..5f8cb5d568
--- /dev/null
+++ b/patterns/front-controller/README.md
@@ -0,0 +1,2 @@
+### Relevant Articles:
+- [A Guide to the Front Controller Pattern in Java](http://www.baeldung.com/java-front-controller-pattern)
diff --git a/patterns/intercepting-filter/README.md b/patterns/intercepting-filter/README.md
new file mode 100644
index 0000000000..88b7f58469
--- /dev/null
+++ b/patterns/intercepting-filter/README.md
@@ -0,0 +1,2 @@
+### Relevant Articles:
+- [Introduction to Intercepting Filter Pattern in Java](http://www.baeldung.com/intercepting-filter-pattern-in-java)
diff --git a/patterns/principles/solid/README.md b/patterns/solid/README.md
similarity index 100%
rename from patterns/principles/solid/README.md
rename to patterns/solid/README.md
diff --git a/persistence-modules/README.md b/persistence-modules/README.md
deleted file mode 100644
index e9a7d625cc..0000000000
--- a/persistence-modules/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-
-## Persistence Modules
-
-
-### Relevant Articles:
-
-- [Introduction to Hibernate Search](http://www.baeldung.com/hibernate-search)
-- [Introduction to Lettuce – the Java Redis Client](http://www.baeldung.com/java-redis-lettuce)
-- [A Guide to Jdbi](http://www.baeldung.com/jdbi)
-- [Pessimistic Locking in JPA](http://www.baeldung.com/jpa-pessimistic-locking)
-- [Get All Data from a Table with Hibernate](https://www.baeldung.com/hibernate-select-all)
-- [Spring Data with Reactive Cassandra](https://www.baeldung.com/spring-data-cassandra-reactive)
-- [Spring Data JPA – Derived Delete Methods](https://www.baeldung.com/spring-data-jpa-deleteby)
-- [Difference Between save() and saveAndFlush() in Spring Data JPA](https://www.baeldung.com/spring-data-jpa-save-saveandflush)
-- [Spring Boot with Hibernate](https://www.baeldung.com/spring-boot-hibernate)
-- [Persisting Maps with Hibernate](https://www.baeldung.com/hibernate-persisting-maps)
-- [Difference Between @Size, @Length, and @Column(length=value)](https://www.baeldung.com/jpa-size-length-column-differences)
diff --git a/persistence-modules/hibernate-mapping/README.md b/persistence-modules/hibernate-mapping/README.md
index 223d93e1ed..203cb2f8e4 100644
--- a/persistence-modules/hibernate-mapping/README.md
+++ b/persistence-modules/hibernate-mapping/README.md
@@ -2,3 +2,4 @@
### Relevant Articles:
- [Persisting Maps with Hibernate](https://www.baeldung.com/hibernate-persisting-maps)
+- [Difference Between @Size, @Length, and @Column(length=value)](https://www.baeldung.com/jpa-size-length-column-differences)
diff --git a/persistence-modules/java-jdbi/README.md b/persistence-modules/java-jdbi/README.md
index 7d843af9ea..4c1ff931ce 100644
--- a/persistence-modules/java-jdbi/README.md
+++ b/persistence-modules/java-jdbi/README.md
@@ -1 +1,3 @@
### Relevant Articles:
+
+- [A Guide to Jdbi](http://www.baeldung.com/jdbi)
diff --git a/persistence-modules/spring-data-jpa-2/README.md b/persistence-modules/spring-data-jpa-2/README.md
index 78a228986a..1db0d23396 100644
--- a/persistence-modules/spring-data-jpa-2/README.md
+++ b/persistence-modules/spring-data-jpa-2/README.md
@@ -15,3 +15,4 @@
- [Spring Data JPA and Named Entity Graphs](https://www.baeldung.com/spring-data-jpa-named-entity-graphs)
- [Tagging and Filtering JUnit Tests](https://www.baeldung.com/junits-filtering-tests)
- [Batch Insert/Update with Hibernate/JPA](https://www.baeldung.com/jpa-hibernate-batch-insert-update)
+- [Difference Between save() and saveAndFlush() in Spring Data JPA](https://www.baeldung.com/spring-data-jpa-save-saveandflush)
diff --git a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteFromRepositoryUnitTest.java b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteFromRepositoryUnitTest.java
index 9e7e516735..5f4a36bc0e 100644
--- a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteFromRepositoryUnitTest.java
+++ b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteFromRepositoryUnitTest.java
@@ -43,22 +43,22 @@ public class DeleteFromRepositoryUnitTest {
public void whenDeleteByIdFromRepository_thenDeletingShouldBeSuccessful() {
repository.deleteById(book1.getId());
- assertThat(repository.count() == 1).isTrue();
+ assertThat(repository.count()).isEqualTo(1);
}
@Test
public void whenDeleteAllFromRepository_thenRepositoryShouldBeEmpty() {
repository.deleteAll();
- assertThat(repository.count() == 0).isTrue();
+ assertThat(repository.count()).isEqualTo(0);
}
@Test
@Transactional
public void whenDeleteFromDerivedQuery_thenDeletingShouldBeSuccessful() {
- repository.deleteByTitle("The Hobbit");
+ long deletedRecords = repository.deleteByTitle("The Hobbit");
- assertThat(repository.count() == 1).isTrue();
+ assertThat(deletedRecords).isEqualTo(1);
}
@Test
@@ -66,7 +66,7 @@ public class DeleteFromRepositoryUnitTest {
public void whenDeleteFromCustomQuery_thenDeletingShouldBeSuccessful() {
repository.deleteBooks("The Hobbit");
- assertThat(repository.count() == 1).isTrue();
+ assertThat(repository.count()).isEqualTo(1);
}
}
\ No newline at end of file
diff --git a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteInRelationshipsUnitTest.java b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteInRelationshipsUnitTest.java
index 56de8749b2..6275ace6e0 100644
--- a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteInRelationshipsUnitTest.java
+++ b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteInRelationshipsUnitTest.java
@@ -46,15 +46,15 @@ public class DeleteInRelationshipsUnitTest {
public void whenDeletingCategories_thenBooksShouldAlsoBeDeleted() {
categoryRepository.deleteAll();
- assertThat(bookRepository.count() == 0).isTrue();
- assertThat(categoryRepository.count() == 0).isTrue();
+ assertThat(bookRepository.count()).isEqualTo(0);
+ assertThat(categoryRepository.count()).isEqualTo(0);
}
@Test
public void whenDeletingBooks_thenCategoriesShouldAlsoBeDeleted() {
bookRepository.deleteAll();
- assertThat(bookRepository.count() == 0).isTrue();
- assertThat(categoryRepository.count() == 2).isTrue();
+ assertThat(bookRepository.count()).isEqualTo(0);
+ assertThat(categoryRepository.count()).isEqualTo(2);
}
}
\ No newline at end of file
diff --git a/persistence-modules/spring-hibernate-5/README.md b/persistence-modules/spring-hibernate-5/README.md
index c48e58fcca..dfcc4e7eb8 100644
--- a/persistence-modules/spring-hibernate-5/README.md
+++ b/persistence-modules/spring-hibernate-5/README.md
@@ -3,3 +3,4 @@
- [Hibernate Many to Many Annotation Tutorial](http://www.baeldung.com/hibernate-many-to-many)
- [Programmatic Transactions in the Spring TestContext Framework](http://www.baeldung.com/spring-test-programmatic-transactions)
- [JPA Criteria Queries](http://www.baeldung.com/hibernate-criteria-queries)
+- [Introduction to Hibernate Search](http://www.baeldung.com/hibernate-search)
diff --git a/pom.xml b/pom.xml
index bdd7562486..39803fd9b0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1527,7 +1527,8 @@
1.1.7
- 2.22.0
+
+ 2.21.0
3.7.0
1.6.0
1.8
@@ -1538,7 +1539,7 @@
1.19
1.3
1.6.0
- 2.19.1
+ 2.21.0
2.5
1.4
3.0.0
diff --git a/spring-batch/src/main/java/org/baeldung/batch/App.java b/spring-batch/src/main/java/org/baeldung/batch/App.java
index cea4e8d486..8bf58e65d2 100644
--- a/spring-batch/src/main/java/org/baeldung/batch/App.java
+++ b/spring-batch/src/main/java/org/baeldung/batch/App.java
@@ -3,6 +3,7 @@ package org.baeldung.batch;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParameters;
+import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -21,7 +22,11 @@ public class App {
final Job job = (Job) context.getBean("firstBatchJob");
System.out.println("Starting the batch job");
try {
- final JobExecution execution = jobLauncher.run(job, new JobParameters());
+ // To enable multiple execution of a job with the same parameters
+ JobParameters jobParameters = new JobParametersBuilder()
+ .addString("jobID", String.valueOf(System.currentTimeMillis()))
+ .toJobParameters();
+ final JobExecution execution = jobLauncher.run(job, jobParameters);
System.out.println("Job Status : " + execution.getStatus());
System.out.println("Job succeeded");
} catch (final Exception e) {
diff --git a/spring-cloud/README.md b/spring-cloud/README.md
deleted file mode 100644
index 5139cdca20..0000000000
--- a/spring-cloud/README.md
+++ /dev/null
@@ -1,21 +0,0 @@
-## The Module Holds Sources for the Following Articles
-
-- [Quick Intro to Spring Cloud Configuration](http://www.baeldung.com/spring-cloud-configuration)
-
- Spring Cloud Config is Spring’s client/server approach for storing and serving distributed configurations across multiple applications and environments.
-
- In this write-up, we’ll focus on an example of how to setup a Git-backed config server, use it in a simple REST application server and setup a secure environment including encrypted property values.
-
-- [Introduction to Spring Cloud Netflix – Eureka](http://www.baeldung.com/spring-cloud-netflix-eureka)
-
- In this article, we’ll introduce client-side service discovery via “Spring Cloud Netflix Eureka“.
-
- Client-side service discovery allows services to find and communicate with each other without hardcoding hostname and port. The only ‘fixed point’ in such an architecture consists of a service registry with which each service has to register.
-
-### Relevant Articles:
-- [Intro to Spring Cloud Netflix - Hystrix](http://www.baeldung.com/spring-cloud-netflix-hystrix)
-- [Dockerizing a Spring Boot Application](http://www.baeldung.com/dockerizing-spring-boot-application)
-- [Instance Profile Credentials using Spring Cloud](http://www.baeldung.com/spring-cloud-instance-profiles)
-- [Running Spring Boot Applications With Minikube](http://www.baeldung.com/spring-boot-minikube)
-- [Introduction to Spring Cloud OpenFeign](https://www.baeldung.com/spring-cloud-openfeign)
-
diff --git a/spring-cloud/spring-cloud-aws/README.md b/spring-cloud/spring-cloud-aws/README.md
index 3b7b4dbcd7..bf33728c74 100644
--- a/spring-cloud/spring-cloud-aws/README.md
+++ b/spring-cloud/spring-cloud-aws/README.md
@@ -5,6 +5,7 @@
- [Spring Cloud AWS – EC2](https://www.baeldung.com/spring-cloud-aws-ec2)
- [Spring Cloud AWS – RDS](https://www.baeldung.com/spring-cloud-aws-rds)
- [Spring Cloud AWS – Messaging Support](https://www.baeldung.com/spring-cloud-aws-messaging)
+- [Instance Profile Credentials using Spring Cloud](http://www.baeldung.com/spring-cloud-instance-profiles)
#### Running the Integration Tests
diff --git a/spring-cloud/spring-cloud-config/README.md b/spring-cloud/spring-cloud-config/README.md
index b28c750ee6..b7c8c36e65 100644
--- a/spring-cloud/spring-cloud-config/README.md
+++ b/spring-cloud/spring-cloud-config/README.md
@@ -1,2 +1,3 @@
### Relevant Articles:
+- [Quick Intro to Spring Cloud Configuration](http://www.baeldung.com/spring-cloud-configuration)
- [Dockerizing a Spring Boot Application](http://www.baeldung.com/dockerizing-spring-boot-application)
diff --git a/spring-cloud/spring-cloud-openfeign/README.md b/spring-cloud/spring-cloud-openfeign/README.md
new file mode 100644
index 0000000000..e5777732e4
--- /dev/null
+++ b/spring-cloud/spring-cloud-openfeign/README.md
@@ -0,0 +1,4 @@
+### Relevant Articles:
+
+- [Introduction to Spring Cloud OpenFeign](https://www.baeldung.com/spring-cloud-openfeign)
+
diff --git a/spring-rest-full/src/main/java/org/baeldung/web/util/RestPreconditions.java b/spring-rest-full/src/main/java/org/baeldung/web/util/RestPreconditions.java
index 4e211ccb10..4f2dedcfa0 100644
--- a/spring-rest-full/src/main/java/org/baeldung/web/util/RestPreconditions.java
+++ b/spring-rest-full/src/main/java/org/baeldung/web/util/RestPreconditions.java
@@ -31,11 +31,11 @@ public final class RestPreconditions {
/**
* Check if some value was found, otherwise throw exception.
- *
- * @param expression
- * has value true if found, otherwise false
+ *
+ * @param resource
+ * has value not null to be returned, otherwise throw exception
* @throws MyResourceNotFoundException
- * if expression is false, means value not found.
+ * if resource is null, means value not found.
*/
public static T checkFound(final T resource) {
if (resource == null) {
diff --git a/spring-rest/README.md b/spring-rest/README.md
index 6d3aac3eb8..5d7894cdf8 100644
--- a/spring-rest/README.md
+++ b/spring-rest/README.md
@@ -21,3 +21,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [Get and Post Lists of Objects with RestTemplate](http://www.baeldung.com/spring-rest-template-list)
- [How to Set a Header on a Response with Spring 5](http://www.baeldung.com/spring-response-header)
- [Uploading MultipartFile with Spring RestTemplate](http://www.baeldung.com/spring-rest-template-multipart-upload)
+- [Download an Image or a File with Spring MVC](http://www.baeldung.com/spring-controller-return-image-file)
diff --git a/spring-rest/src/main/java/com/baeldung/produceimage/README.md b/spring-rest/src/main/java/com/baeldung/produceimage/README.md
deleted file mode 100644
index 4aeadea546..0000000000
--- a/spring-rest/src/main/java/com/baeldung/produceimage/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-### Relevant articles
-
-- [Download an Image or a File with Spring MVC](http://www.baeldung.com/spring-controller-return-image-file)
diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml
index 38cbfddab8..2180b917e5 100644
--- a/spring-security-rest-custom/pom.xml
+++ b/spring-security-rest-custom/pom.xml
@@ -26,6 +26,14 @@
org.springframework.security
spring-security-config