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
Category: Java
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 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