Category Archives: Spring

Spring Framework, Spring Security, Spring Web Service, Spring HATEOSA, Spring ActiveMQ

What is the behavior of the annotation @Autowired with regards to field injection, constructor injection, and method injection?

The following are the types of dependency injections (DI) that could be injected into your application: Constructor-based dependency injection Setter-based dependency injection Field-based dependency injection The constructor injection pattern It is more suitable for mandatory dependencies, and it makes a strong dependency contract It provides a more compact code structure than others It supports testing… Read More »

Creating a URL Shortener with Spring RESTful Web Service, Liquibase, and Postgresql

In this note I will create a URL shortening service using Spring Restful, Spring Boot, Liquibase, and PostgreSQL database.  In a similar way of some shortening services, such as goo.gl, tinyurl.com, and bit.ly, purpose of the shortened URL may be more convenience for website and provide detailed information on clicks a link receives. 1. URL Shortener Service. The service will… 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 »

Joined-tables strategy for mapping inheritance with JPA

1. Joined-tables strategy Follow up the Single-table strategy for mapping inheritance with JPA, this strategy stores all financial products in a single table. In contrast, the joined table strategy creates separate tables for each entity in the domain model. This means that the financial product is the parent table and it holds common data for… Read More »