//Predicate for Employee Projects data
Predicate predicateForData = criteriaBuilder.or(
criteriaBuilder.like(root.get("firstName"), "%" + employeeRequestDTO.getFilterText() + "%"),
criteriaBuilder.like(root.get("lastName"), "%" + employeeRequestDTO.getFilterText() + "%"),
criteriaBuilder.like(root.get("projectId").as(String.class), "%" + employeeRequestDTO.getFilterText() + "%"),
criteriaBuilder.like(root.get("projectName"), "%" + employeeRequestDTO.getFilterText() + "%"),
criteriaBuilder.like(root.get("projectBudget").as(String.class), "%" + employeeRequestDTO.getFilterText() + "%"),
criteriaBuilder.like(root.get("projectLocation"), "%" + employeeRequestDTO.getFilterText() + "%"));
/**
* Builds and return specification object that filters data based on search string
*
* @param employeeRequestDTO Employee Projects Request DTO object
*
* @return Specification with Employee Id and Filter Text
*/
private Specification<EmployeeProjectView> getSpecification(EmployeeRequestDTO employeeRequestDTO)
{
@Override
public Page<EmployeeProjectView> findEmployeeProjectsExampleMatcher(EmployeeRequestDTO employeeRequestDTO)
{
/* Build Search object */
EmployeeProjectView employeeProjectView=new EmployeeProjectView();
employeeProjectView.setEmployeeId(employeeRequestDTO.getEmployeeId());
employeeProjectView.setLastName(employeeRequestDTO.getFilterText());
employeeProjectView.setFirstName(employeeRequestDTO.getFilterText());
try
package com.pj.multicolumnsearch.domain;
import lombok.Data;
import org.springframework.data.annotation.Immutable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
- Add 5 years to user date of birth timestamp
update user set date_of_birth=dateadd(year, 5, date_of_birth) where datepart(year, date_of_birth)>1965;
- Remove 100 years from user date of birth timestamp
update user set date_of_birth=dateadd(year , -100, date_of_birth) where datepart(year, date_of_birth)>2015;
- Create schema.sql file
src/main/resources
directory. This file contains all DDL statements - Create data.sql file in
src/main/resources
directory. This file contains all DML statements(insert,update statements) - Create the application.yml file with following config
spring:
datasource:
url: jdbc:h2:mem:db
username: admin
password: admin
initialization-mode: always
async createEmployee(url:string,employee: Employee)
{
return await this.httpClient.post(url, employee).toPromise();
}
getEmployees(url:string)
{
return this.httpClient.get<Employee[]>(url);
}
async createEmployee()
{
let url = API_URL + 'employees';
let employee = new Employee();
employee.id = Math.floor(Math.random() * 10000);
employee.firstName = "John";
employee.lastName = "McCain" + employee.id;
//Wait for POST operation to complete then return response
package com.pj.jwt.security;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.BeanIds;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
private String createToken(Map<String, Object> claims, String subject)
{
return Jwts.builder().setClaims(claims).setSubject(subject).setIssuedAt(new Date(System.currentTimeMillis()))
.setExpiration(new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 24))
.signWith(Keys.hmacShaKeyFor(coreProperties.getJwtSecret().getBytes()), SignatureAlgorithm.HS512).compact();
}
public boolean validateToken(String token, UserDetails userDetails)
{