Building a Hypermedia-Driven RESTful Web Service with Spring HATEOAS

1. Introduction. This note follows up the rest-hateoas tutorial from Spring which describes the general concept about HATEOAS. According to the Richardson Maturity Model, HATEOAS is considered the final level of REST, which explains that the REST resources contain not only data, but links to related resources. 2. Solution with Spring HATEOAS. From the last… Read More »

Hibernate cache in theory

The note will follow: 1. Introduction. Hibernate has a two-level cache architecture: first-level cache and second-level cache. Figure 1: Hibernate’s two levels cache (source: Manning) The first-level cache is the persistence context cache (scope of Session). The cache ensures that when the application requests the same persistent object twice in a particular session, it gets back… Read More »

Paging and sorting with Spring Data JPA and Querydsl

1. Introduction. Retrieved data with paging and storing is a basic feature of any application. This can be handled by database side (page and sort in a stored procedure, or native SQL query), and Spring Data JPA via use QueryDSL or Specifications. The note will present how to implement QueryDSL with Optional in Java 8.… Read More »

Scaling up and scaling out in Enterprise Systems

The two most important things of an enterprise application are performance and scaling because it needs to store and retrieve as much data and as fast as possible. This note will consider scaling up and out metrics in details. Scaling up (Vertical Scaling): Add more resources to a single machine such as CPU, Memory, Disk… Read More »

Advantages and Disadvantages of Microservices

To begin with an interesting question, is a microservice architecture a good choice for the system you’re working on? Basically, micro-service often deals with large team, multi-tenancy, supporting many user interaction models, allowing different business functions to evolve independently, and scaling. However, the best answer is it depends on complexity and productivity. If a system… Read More »

Multi-tier application architecture with Microservices

Microservice Architecture notes follow: 1. A stock market example In the stock market, settlement is all processes the buyer received his shares and the seller received his money after they bought or sold shares through his broker. The period within which buyers receive their shares and sellers receive their money is called a settlement cycle.… Read More »

Liquibase notes

1. Generate Change Logs from an existing database Generate change logs from an existing database. For instance, copy postgresSQL driver to %LINQUIBASE_HOME%/postgresql-8.3-603.jdbc3.jar. Run a following line command in console (single line). If successful, liquibase will show a message “Liquibase ‘generateChangeLog’ Successful” 2. Check a table already presents Using preCondition tag which follows some form of… Read More »

Model Mapper for data response

1. Fund Adaptor Suppose that Fund Adaptor executes a service to search the response data- a monthly or daily (depending on the schedule). This example is to show how the customer details response data is mapped. There are two data transfer objects (DTO) namely CustomerDTO (maybe to present in UI) and CustomerSvcDTO (from executing store procedures… Read More »

Summary of OO hierarchy inheritance mapping strategies

1. Pre-requisites Should read first there types of mapping below: Single-table strategy Joined-tables strategy Table-per-class strategy 2. Summary mapping strategies Table 1: Summary of OO hierarchy inheritance mapping strategies (source: EJB3 in Action) References: D. Pan, R. Rahman, R. Cuprak, M. Remijan, “Mapping inheritance”, In EJB3 in Action,pp.292-293, Manning, Second Edition, 2014

Table-per-class strategy for mapping inheritance with JPA

1. Table-per-class strategy Table-per-class strategy is similar to  joined-tables strategy because each entity in domain model gets its own table. One significant difference is no relationship between the tables, which doesn’t take advantage of power of relational database at all. Following the stock market example in join-table-strategy and single-table-strategy , we are there different tables namely product, bonds, shares but product_code, description, version… Read More »