Skip to content

Commit

Permalink
Merge pull request #17 from pavankjadda/development
Browse files Browse the repository at this point in the history
Upgrades Spring Boot version to 2.6.4 and Liquibase version to 4.9.0
  • Loading branch information
pavankjadda authored Mar 21, 2022
2 parents 52b9f8d + 04408e9 commit 2627432
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 62 deletions.
23 changes: 9 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<version>2.6.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.pj</groupId>
<artifactId>liquibasedemo</artifactId>
<version>2.2.0</version>
<version>2.3.0</version>
<name>liquibasedemo</name>
<description>Liquibase Demo project with Spring Boot and Spring Data</description>

<properties>
<spring-boot.version>2.4.0</spring-boot.version>
<hibernate.version>5.4.24.Final</hibernate.version>
<liquibase-core.version>4.8.0</liquibase-core.version>
<liquibase-maven-plugin.version>4.2.0</liquibase-maven-plugin.version>
<liquibase-hibernate5.version>4.1.1</liquibase-hibernate5.version>
<validation-api.version>2.0.1.Final</validation-api.version>
<spring-boot.version>2.6.4</spring-boot.version>
<hibernate.version>5.6.7.Final</hibernate.version>
<liquibase-core.version>4.9.0</liquibase-core.version>
<liquibase-maven-plugin.version>4.9.0</liquibase-maven-plugin.version>
<liquibase-hibernate5.version>4.9.0</liquibase-hibernate5.version>
<javassist.version>3.27.0-GA</javassist.version>
<jaxb-api.version>2.4.0-b180830.0359</jaxb-api.version>
<jaxb-api.version>2.3.1</jaxb-api.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -164,11 +163,7 @@
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${validation-api.version}</version>
</dependency>

<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/pj/liquibasedemo/domain/Country.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
import javax.persistence.ManyToOne;
import javax.persistence.Table;


/**
* Entity class that maps to country table in the database.
*
* @author Pavan Kumar Jadda
* @since 1.0.0
*/
@Entity
@Table(name = "country")
@Data
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/pj/liquibasedemo/domain/Employee.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
import javax.persistence.Id;
import javax.persistence.Table;


/**
* Entity class that maps to employee table in the database.
*
* @author Pavan Kumar Jadda
* @since 1.0.0
*/
@Entity
@Table(name = "employee")
@Data
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/pj/liquibasedemo/domain/EmploymentType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.pj.liquibasedemo.domain;

/**
* Enum that represents the employment type.
*
* @author Pavan Kumar Jadda
* @since 1.0.0
*/
public enum EmploymentType
{
CONTRACTOR("contractor"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
import javax.persistence.Converter;
import java.util.stream.Stream;

/**
* Employee Type Converter that converts the Enum type to a String and vice versa.
*
* @author Pavan Kumar Jadda
* @since 1.0.0
*/
@Converter(autoApply = true)
public class EmploymentTypeConverter implements AttributeConverter<EmploymentType, String>
{
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/pj/liquibasedemo/domain/Region.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
import javax.persistence.Id;
import javax.persistence.Table;

/**
* Entity class that maps to region table in the database.
*
* @author Pavan Kumar Jadda
* @since 1.0.0
*/
@Entity
@Table(name = "region")
@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import com.pj.liquibasedemo.domain.Country;
import org.springframework.data.jpa.repository.JpaRepository;

/**
* Country Repository interface that gets, saves, updates and deletes Country objects.
*
* @author Pavan Kumar Jadda
* @since 1.0.0
*/
public interface CountryRepository extends JpaRepository<Country, Long>
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import com.pj.liquibasedemo.domain.Employee;
import org.springframework.data.jpa.repository.JpaRepository;

/**
* Employee Repository interface that gets, saves, updates and deletes Employee objects.
*
* @author Pavan Kumar Jadda
* @since 1.0.0
*/
public interface EmployeeRepository extends JpaRepository<Employee, Long>
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@

import java.util.Optional;

/**
* Region Repository interface that gets, saves, updates and deletes Region objects.
*
* @author Pavan Kumar Jadda
* @since 1.0.0
*/
public interface RegionRepository extends JpaRepository<Region, Long>
{
Optional<Region> findByName(String name);
Optional<Region> findByName(String name);
}
70 changes: 46 additions & 24 deletions src/main/java/com/pj/liquibasedemo/web/CountryController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,54 @@

import java.util.List;

/**
* Provides API endpoints for Country and related operations
*
* @author Pavan Kumar Jadda
* @since 1.0.0
*/
@RestController
@RequestMapping("/api/v1/country")
public class CountryController
{
private final CountryRepository countryRepository;

public CountryController(CountryRepository countryRepository)
{
this.countryRepository = countryRepository;
}

@GetMapping(path = "/list")
public List<Country> findAllCountries()
{
return countryRepository.findAll();
}

@GetMapping(path = "/create")
public Country createCountry()
{
Country country=new Country();
country.setCode("USD");
country.setIsoCode("USD");
country.setName("United States Dollar");


return countryRepository.saveAndFlush(country);
}
private final CountryRepository countryRepository;

public CountryController(CountryRepository countryRepository)
{
this.countryRepository = countryRepository;
}

/**
* Finds all countries in the database
*
* @return List of countries
*
* @author Pavan Kumar Jadda
* @since 1.0.0
*/
@GetMapping(path = "/list")
public List<Country> findAllCountries()
{
return countryRepository.findAll();
}

/**
* Create a new country in the database and returns the newly created country
*
* @return Newly created country
*
* @author Pavan Kumar Jadda
* @since 1.0.0
*/
@GetMapping(path = "/create")
public Country createCountry()
{
Country country = new Country();
country.setCode("USD");
country.setIsoCode("USD");
country.setName("United States Dollar");


return countryRepository.saveAndFlush(country);
}
}
64 changes: 43 additions & 21 deletions src/main/java/com/pj/liquibasedemo/web/EmployeeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,55 @@

import java.util.List;

/**
* Provides API endpoints for Employee and related operations
*
* @author Pavan Kumar Jadda
* @since 1.0.0
*/
@RestController
@RequestMapping("/api/v1/employee")
public class EmployeeController
{
private final EmployeeRepository employeeRepository;
private final EmployeeRepository employeeRepository;

public EmployeeController(EmployeeRepository employeeRepository)
{
this.employeeRepository = employeeRepository;
}
public EmployeeController(EmployeeRepository employeeRepository)
{
this.employeeRepository = employeeRepository;
}


@GetMapping(path = "/list")
public List<Employee> findAll()
{
return employeeRepository.findAll();
}
/**
* Finds all employees in the database
*
* @return List of employees
*
* @author Pavan Kumar Jadda
* @since 1.0.0
*/
@GetMapping(path = "/list")
public List<Employee> findAll()
{
return employeeRepository.findAll();
}

@GetMapping(path = "/create")
public Employee createEmployee()
{
Employee employee = new Employee();
employee.setFirstName("John");
employee.setLastName("Reese");
employee.setEmail("[email protected]");
employee.setPhone("903-888-9999");
employee.setEmploymentType(EmploymentType.CONTRACTOR);
return employeeRepository.saveAndFlush(employee);
}
/**
* Creates a new employee in the database
*
* @return Newly created employee
*
* @author Pavan Kumar Jadda
* @since 1.0.0
*/
@GetMapping(path = "/create")
public Employee createEmployee()
{
Employee employee = new Employee();
employee.setFirstName("John");
employee.setLastName("Reese");
employee.setEmail("[email protected]");
employee.setPhone("903-888-9999");
employee.setEmploymentType(EmploymentType.CONTRACTOR);
return employeeRepository.saveAndFlush(employee);
}
}

0 comments on commit 2627432

Please sign in to comment.