SOURCE CODE (GitHub Link)
https://github.com/VikramThakur8/Enqu...
PURPOSE:
This video covers Institute Registration and Listing. The institute registration for data is divided into 3 tables(normalization style) - Institute, Contact and Address. Also Spring @Transaction is used to maintain the data integrity.
For Institute Listing I have added customized method with JPQL @Query annotation in Repository interface. The JPQL must use alias for each field and All fetching fields are mapped to Project Interface. Projection Interface is a simplest way to map fields in DTO.
The video also covers optimization guideline to use Spring Data JPA API.
SOURCE CODE REFERENCE:
1. SAVE INSTITUTE FORM :
@Transactional
public void saveInstitute(Institute inst) {
//address
addressRepository.save(inst.getContact().getPermanentAddress());
//contact
contactRepository.save(inst.getContact());
//institute
instituteRepository.save(inst);
}
2. LIST INSTITUTE USING JPQL CUSTOMIZE QUERY AND INTERFACE PROJECTION:
@Query("SELECT i.instituteId AS instituteId, i.name AS name, i.contact.phone AS phone, i.contact.email AS email, i.contact.permanentAddress.city AS city FROM Institute AS i ")
public List of InstituteDto getInstList();
TECHNOLOGY USED:
Java 8, Spring Boot, Spring Data JPA, MySQL Database, NetBeans IDE, Hibernate JPA Implementation, Maven, MySQL Workbench, JSON, MicroServices.
PREVIOUS JPA ENTITY CUSTOMIZATION VIDEO IN CASE YOU MISSED :
• 5 - Spring Data JPA | Spring Boot | Projec...