Create a project with dependency web along with"security" in it In the main application enable the security dependency using annotation @EnableWebSecurity Now create a package with a name "springconfig" and inside that create a class "SpringConfiguration". Annotate it as a @Configuration Extent the WebSecuriyConfigurationAdaptor and override two methods with the same name (configure) but with … Continue reading springboot-basic-security
SpringBoot RestCrud App
Visit http://start.spring.io and initialize project with below dependencies: Spring Web Spring Data Jpa: manage sql queries Mysql Driver: connect to db Projectlombok : auto configuring getter setter and constructor in Entity Devtools: auto restart the application on changes Thymeleaf: engine for creating frontend (avoid if frontend is not required and app can be tested by … Continue reading SpringBoot RestCrud App
Custom Validation
Activity: Custom validation Perform custom validation based on your business rulesOur example: Course Code must start with "KVT"Spring MVC calls our custom validationCustom validation returns Boolean value for pass/fail (true/false) Development Process Create custom validation rule Add validation rule to Customer classDisplay error message on HTML formUpdate confirmation page Breaking from up top // "CourseCodeConstrainValidator.class" … Continue reading Custom Validation
entity-lifecycle-model
Entity Lifecycle Model in JPA & Hibernate The entity lifecycle model is one of the core concepts of JPA and all its implementations. Even though it’s not directly visible when working with JPA’s EntityManager, it affects all operations you perform. The different states of the model define how your persistence provider, e.g. Hibernate, handles your … Continue reading entity-lifecycle-model
Advance Hibernate Mapping Overview
Basic Mapping: Advance Mappings In the database you most likely will haveMultiple tablesRelationships between TablesNeed to model this with Hibernate Advanced Mappings Type One-to-OneOne-to-Many, Many-to-OneMany-to-Many Important Database Concepts Primary key and foreign keyCascade Primary Key and Foreign Key Primary Key: identify a unique row in a tableForeign Key:Link tables togetherA field in one table that … Continue reading Advance Hibernate Mapping Overview
FAQ: How To View Hibernate SQL Parameter Values
Question: I see hibernate printing out the query parameters as ? in the console.Is it possible to printout the value that was actually queried on thedatabase. Asking as this would help in the debugging purpose. Answer: When using Hibernate, if you log the Hibernate SQL statements, you will see this: Hibernate: insert into student (email, first_name, last_name, … Continue reading FAQ: How To View Hibernate SQL Parameter Values
Resetting Auto Increment
This method let you purge a table completely and also let the primary key start with one or from whatever digit you want. We all have gone through the pain of not getting the primary key back to one once the data (rows) from the table is deleted. Deleting all the rows from atable wont … Continue reading Resetting Auto Increment
Hibernate Development Process :CRUD
To Do List Add Hibernate Configuration fileAnnotate Java ClassDevelop Java Code to perform database operations Hibernate uses JDBC in the background for communicating with the database So the bulk of the information we will have in our config file is actually JDBC configuration (url, userid, password and so on … ), just to tell hibernate … Continue reading Hibernate Development Process :CRUD
Setting up Hibernate Development Environment
Setup your development Required Softwares To Build Hibernate Applications, you need the following: Java Integrated Development Environment (IDE)Database Server (MySQL server)Hibernate JAR files and JDBC Driver Create a new Java project Create a new folder "lib" for Hibernate jar files Download Hibernate ORM zip form hibernate.org Now download JDBC drivers (Connector/J) zip from link below: … Continue reading Setting up Hibernate Development Environment
Hibernate Introduction
Hibernate Overview Topics What is Hibernate?Benefits of HibernateCode Snippets What is Hibernate? A framework for persisting/ saving java objects into a databasewww.hibernate.org At high level you will have Java Application, it will make use of Hibernate framework for saving and retrieving data from the database. Benefits of Hibernate Hibernate handles all the low-level SQLMinimize the … Continue reading Hibernate Introduction