Could Not register the user in database using JPA - spring

I am trying to insert an User by http://localhost:8080/register to register a new User.But when i am clicking the register button it shows me the hibernate error such as "There was an unexpected error (type=Internal Server Error, status=500).could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement".
welcome.jsp
<!DOCTYPE html >
<%#taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div role="navigation">
<div class="navbar navbar-inverse">
Tecno-Tab
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>Login</li>
<li>New Registration</li>
<li>All Users</li>
</ul>
</div>
</div>
</div>
<c:choose>
<c:when test="${mode=='MODE_HOME'}">
<div class="container" id="homediv">
<div class="jumbotron text-center">
<h1>Welcome to Tecno-tab</h1>
<h3>Subscribe my channel to support me</h3>
</div>
</div>
</c:when>
<c:when test="${mode=='MODE_REGISTER'}">
<div class="container text-center">
<h3>New Registration</h3>
<hr>
<form class="form-horizontal" method="POST" action="save-user">
<input type="hidden" name="id" value="${user.id }" />
<div class="form-group">
<label class="control-label col-md-3">Username</label>
<div class="col-md-7">
<input type="text" class="form-control" name="username"
value="${user.userName}" />
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3">First Name</label>
<div class="col-md-7">
<input type="text" class="form-control" name="firstname"
value="${user.firstName}" />
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3">Last Name</label>
<div class="col-md-7">
<input type="text" class="form-control" name="lastname"
value="${user.lastName}" />
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3">Age </label>
<div class="col-md-3">
<input type="text" class="form-control" name="age"
value="${user.age}" />
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3">Password</label>
<div class="col-md-7">
<input type="password" class="form-control" name="password"
value="${user.passWord}" />
</div>
</div>
<div class="form-group ">
<input type="submit" class="btn btn-primary" value="Register" />
</div>
</form>
</div>
</c:when>
</c:choose>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="static/js/jquery.min.js"></script>
<script src="static/js/bootstrap.min.js"></script>
</body>
</html>
ApplicationController.java
package com.ashwin.myapplication.controller;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ashwin.myapplication.model.User;
import com.ashwin.myapplication.service.UserService;
#Controller
public class ApplicationController {
#Autowired
private UserService userService;
#RequestMapping("/home")
public String Welcome(HttpServletRequest request) {
request.setAttribute("mode","MODE_HOME");
return "welcome";
}
#RequestMapping("/register")
public String registeration(HttpServletRequest request) {
request.setAttribute("mode","MODE_REGISTER");
return "welcome";
}
#PostMapping("/save-user")
public String saveUser(#ModelAttribute User user,
BindingResult bindingResult,HttpServletRequest request) {
userService.saveMyUser(user);
request.setAttribute("mode","MODE_HOME");
return "welcome";
}
}
User.java
package com.ashwin.myapplication.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
#Entity
#Table(name="mytable1")
public class User {
#Id
#GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
#Column(name="user_name")
private String userName;
#Column(name="first_name")
private String firstName;
#Column(name="last_name")
private String lastName;
#Column(name="age")
private int age;
#Column(name="password")
private String passWord;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassWord() {
return passWord;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
public User(String firstName, String lastName, int age, String password) {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
this.passWord = password;
}
public User() {
}
#Override
public String toString() {
return "User [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", age=" + age + ", password="
+ passWord + "]";
}
}

Related

Neither BindingResult nor plain target object for bean name 'user' available as request attribute during form implemetntaion

I am getting this error when I run my Project and I tried all the fixes online but it did not work.
Neither BindingResult nor plain target object for bean name 'user' available as request attribute during form implementation
I am pasting the code below
Do I have to create a table in my database or how do I fix this?
I am trying to read the values entered from the form to another jsp page using spring mvc but without using annotations. And while doing so I am getting this error: Neither BindingResult nor plain target object for bean name 'user' available as request attribute My Controller Class code is as follows:
User.java
package User;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table
public class User {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String name;
private Integer age;
private String gender;
private String email;
private String city;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
}
UserController.java
package Controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import User.User;
#Controller
public class UserController {
#Autowired
private UserRepository userRepository;
#GetMapping("/greeting")
public String greetingForm(Model model) {
model.addAttribute("user", new User());
return "greeting";
}
#PostMapping("/greeting")
public String greetingSubmit(#ModelAttribute User user , Model model) {
User newUser = new User();
newUser.setName(user.getName());
newUser.setAge(user.getAge());
newUser.setGender(user.getGender());
newUser.setEmail(user.getEmail());
newUser.setCity(user.getCity());
userRepository.save(user);
return "result";
}
#GetMapping("/all")
public String getMeassage(Model model ) {
Iterable<User> users = userRepository.findAll();
model.addAttribute("users", users);
return "all";
}
}
greeting.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1">
<title>Form Submission</title>
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<br><br>
<h2 style="color:green">Form</h2>
<br><br>
<form class="form-horizontal" role="form" action="#" th:action="#{/greeting}" th:object="${user}" modelAttribute="user" method="post">
<div class="form-group" style="width:300px">
<label for="name" class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<input type="text" th:field="*{name}" class="form-control" id="name" placeholder="Enter name">
</div>
</div>
<div class="form-group" style="width:300px">
<label for="age" class="col-sm-2 control-label">Age</label>
<div class="col-sm-10">
<input type="text" th:field="*{age}" class="form-control" id="age" placeholder="Enter age">
</div>
</div>
<div class="form-group" style="width:300px">
<label for="gender" class="col-sm-2 control-label">Gender</label>
<div class="col-sm-10">
<input type="text" th:field="*{gender}" class="form-control" id="gender" placeholder="Enter gender(M or F)">
</div>
</div>
<div class="form-group" style="width:300px">
<label for="email" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="text" th:field="*{email}" class="form-control" id="email" placeholder="Enter email">
</div>
</div>
<div class="form-group" style="width:300px">
<label for="city" class="col-sm-2 control-label">City</label>
<div class="col-sm-10">
<input type="text" th:field="*{city}" class="form-control" id="city" placeholder="Enter city">
</div>
</div>
<div class="form-group">
<div>
<button type="submit" class="btn btn-primary" id="btn">Submit</button>
<input type="reset" class="btn btn-warning" value="Reset" />
</div>
</div>
</form>
</body>
</html>
Thanks in advance for the help

In browser i couldn't get Boot Strap tables instead i get white label error

In Spring Boot, earlier, I've created Employee Management System Table with 4 Columns -> firtsname, lastname, email and Actions column where it has Update&Delete Buttons. now, I've added extra 3 Columns -> gender, birthday, skill. Everything works fine, there is no compilation Errors and console errors but when i hit the browser i get whitelabel error. can anyone please give me a solution for this problem.
1.Employee Entity.Class
package com.employee.entity;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name = "employees")
public class Employee
{
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String firstname;
private String lastname;
private String email;
private String gender;
private Date birthday;
private String skill;
public Employee() {
}
public Employee(long id, String firstname, String lastname, String email, String gender, Date birthday,
String skill) {
super();
this.id = id;
this.firstname = firstname;
this.lastname = lastname;
this.email = email;
this.gender = gender;
this.birthday = birthday;
this.skill = skill;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getSkill() {
return skill;
}
public void setSkill(String skill) {
this.skill = skill;
}
}
2.EmployeeController.class
package com.employee.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import com.employee.entity.Employee;
import com.employee.service.EmployeeService;
#Controller // Controller Layer holds all Spring MVC Controllers
public class EmployeeController
{
private EmployeeService employeeService;
public EmployeeController(EmployeeService employeeService) {
super();
this.employeeService = employeeService;
}
#GetMapping("/employees")
public String listEmployess(Model model)
{
model.addAttribute("employees", employeeService.getAllEmployees());
return "employees";
}
#GetMapping("/employees/new")
public String createEmployeeForm(Model model)
{
//Create empty employee object to hold employee form data
Employee employee = new Employee();
model.addAttribute("employee", employee);
return "create_employee";
}
#PostMapping("/employees")
public String saveEmployee(#ModelAttribute("employee") Employee employee)
{
employeeService.saveEmployee(employee);
return "redirect:/employees";
}
#GetMapping("/employees/edit/{id}")
public String editEmployeeForm(#PathVariable Long id, Model model)
{
model.addAttribute("employee", employeeService.getEmployeeById(id));
return "edit_employee";
}
#PostMapping("/employees/{id}")
public String updateEmployee(#PathVariable Long id, #ModelAttribute("employee") Employee employee, Model model)
{
// get employee from database by id
Employee existingEmployee = employeeService.getEmployeeById(id);
//existingEmployee.setId(id);
existingEmployee.setFirstname(employee.getFirstname());
existingEmployee.setLastname(employee.getLastname());
existingEmployee.setEmail(employee.getEmail());
existingEmployee.setGender(employee.getGender());
existingEmployee.setBirthday(employee.getBirthday());
existingEmployee.setSkill(employee.getSkill());
// save updated employee object
employeeService.updateEmployee(existingEmployee);
return "redirect:/employees";
}
#GetMapping("/employees/{id}")
public String deleteEmployee(#PathVariable Long id)
{
employeeService.deleteEmployeeById(id);
return "redirect:/employees";
}
}
3.EmployeeRepository.interface
package com.employee.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.employee.entity.Employee;
#Repository
public interface EmployeeRepository extends JpaRepository<Employee, Long>
{
}
4.EmployeeService.interface
package com.employee.service;
import java.util.List;
import com.employee.entity.Employee;
public interface EmployeeService
{
public List<Employee> getAllEmployees();
Employee saveEmployee(Employee employee);
Employee getEmployeeById(Long id);
Employee updateEmployee(Employee employee);
void deleteEmployeeById(Long id);
}
5.EmployeeServiceImpl.class
package com.employee.service.impl;
import java.util.List;
import org.springframework.stereotype.Service;
import com.employee.entity.Employee;
import com.employee.repository.EmployeeRepository;
import com.employee.service.EmployeeService;
#Service
public class EmployeeServiceImpl implements EmployeeService
{
private EmployeeRepository employeeRepository;
public EmployeeServiceImpl(EmployeeRepository employeeRepository) {
super();
this.employeeRepository = employeeRepository;
}
#Override
public List<Employee> getAllEmployees()
{
return employeeRepository.findAll();
}
#Override
public Employee saveEmployee(Employee employee)
{
return employeeRepository.save(employee);
}
#Override
public Employee getEmployeeById(Long id) {
return employeeRepository.findById(id).get();
}
#Override
public Employee updateEmployee(Employee employee) {
return employeeRepository.save(employee);
}
#Override
public void deleteEmployeeById(Long id)
{
employeeRepository.deleteById(id);
}
}
6.application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/ems?useSSL=false&serverTime=UTC&useLegacyDatetimeCode=false
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=1441
server.port=8097
#spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect
#spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
spring.thymeleaf.check-template=true
spring.thymeleaf.check-template-location=true
spring.thymeleaf.enabled=true
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
debug=true
logging.level.org.hibernate.SQL=DEBUG
#logging.level.<package_name>=<LOGGING_LEVEL>
#logging.level.org.springframework.context=DEBUG
spring.profiles.active=#spring.profiles.active#
spring.jpa.open-in-view=false
logging.level.org.springframework.boot.autoconfigure=ERROR
7.employees.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<!-- Brand -->
<a class="navbar-brand" href="#">Employee Management System</a>
<!-- Toggler/collapsibe Button -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Navbar links -->
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" th:href="#{/employees}">Employee Management</a>
</li>
</ul>
</div>
</nav>
<div class ="container">
<div class = "row">
<h1> List Employees </h1>
</div>
<div class = "row" >
<div class = "col-lg-3">
<a th:href = "#{/employees/new}" class = "btn btn-primary btn-sm mb-3"> Add Employee</a>
</div>
</div>
<table class = "table table-striped table-bordered" >
<thead class = "table-dark">
<tr>
<th> Employee First Name </th>
<th> Employee Last Name </th>
<th> Employee Email </th>
<th> Employee Gender </th>
<th> Employee Birthday </th>
<th> Employee Skill </th>
<th> Actions </th>
</tr>
</thead>
<tbody>
<tr th:each = "employee : ${employees}">
<td th:text = "${employee.firstname}"></td>
<td th:text = "${employee.lastname}"></td>
<td th:text = "${employee.email}"></td>
<td th:text = "${employee.gender}"></td>
<td th:text = "${employee.birthday}"></td>
<td th:text = "${employee.skill}"></td>
<td>
<a th:href = "#{/employees/edit/{id}(id=${employee.id})}"
class = "btn btn-primary">Update</a>
<a th:href = "#{/employees/{id}(id=${employee.id})}"
class = "btn btn-danger">Delete</a>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
8.create_employee.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1">
<title>Employee Management System</title>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<!-- Brand -->
<a class="navbar-brand" href="#">Employee Management System</a>
<!-- Toggler/collapsibe Button -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Navbar links -->
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" th:href="#{/employees}">Employee Management</a>
</li>
</ul>
</div>
</nav>
<br>
<br>
<div class = "container">
<div class = "row">
<div class = "col-lg-6 col-md-6 col-sm-6 container justify-content-center-center card">
<h1 class = "text-center"> Create New Employee </h1>
<div class = "card-body" >
<form th:action="#{/employees}" th:object = "${employee}" method="POST">
<div class = "form-group">
<label> Employee First Name </label>
<input
type = "text"
name = "firstname"
th:field = "*{firstname}"
class = "form-control"
placeholder = "Enter Employee First Name"
/>
</div>
<div class = "form-group">
<label> Employee Last Name </label>
<input
type = "text"
name = "lastname"
th:field = "*{lastname}"
class = "form-control"
placeholder = "Enter Employee Last Name"
/>
</div>
<div class = "form-group">
<label> Employee Email </label>
<input
type = "text"
name = "email"
th:field = "*{email}"
class = "form-control"
placeholder = "Enter Employee Email"
/>
</div>
<div class = "form-group">
<label> Employee Gender </label>
<input type="radio" th:field="*{gender}" value="Male" />Male
<input type="radio" th:field="*{gender}" value="Female" />Female
<input
type = "radio"
name = "gender"
th:field = "*{gender}"
class = "form-control"
/>
</div>
<div class = "form-group">
<label> Employee Birthday </label>
<input type="date" th:field="*{birthday}" />
<input
type = "date"
name = "birthday"
th:field = "*{birthday}"
class = "form-control"
/>
</div>
<div class = "form-group">
<label> Employee Skill </label>
<input
type = "text"
name = "skill"
th:field = "*{skill}"
class = "form-control"
placeholder = "Enter Employee Skill"
/>
</div>
<div class = "box-footer">
<button type="submit" class = "btn btn-primary">
Submit
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
9.edit_employee.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1">
<title>Employee Management System</title>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<!-- Brand -->
<a class="navbar-brand" href="#">Employee Management System</a>
<!-- Toggler/collapsibe Button -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Navbar links -->
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" th:href="#{/employees}">Employee Management</a>
</li>
</ul>
</div>
</nav>
<br>
<br>
<div class = "container">
<div class = "row">
<div class = "col-lg-6 col-md-6 col-sm-6 container justify-content-center-center card">
<h1 class = "text-center"> Create New Employee </h1>
<div class = "card-body" >
<form th:action="#{/employees/{id} (id=${employee.id})}" th:object = "${employee}" method="POST">
<div class = "form-group">
<label> Employee First Name </label>
<input
type = "text"
name = "firstname"
th:field = "*{firstname}"
class = "form-control"
placeholder = "Enter Employee First Name"
/>
</div>
<div class = "form-group">
<label> Employee Last Name </label>
<input
type = "text"
name = "lastname"
th:field = "*{lastname}"
class = "form-control"
placeholder = "Enter Employee Last Name"
/>
</div>
<div class = "form-group">
<label> Employee Email </label>
<input
type = "text"
name = "email"
th:field = "*{email}"
class = "form-control"
placeholder = "Enter Employee Email"
/>
</div>
<div class = "form-group">
<label> Employee Gender </label>
<input type="radio" th:field="*{gender}" value="Male" />Male
<input type="radio" th:field="*{gender}" value="Female" />Female
<input
type = "radio"
name = "gender"
th:field = "*{gender}"
class = "form-control"
/>
</div>
<div class = "form-group">
<label> Employee Birthday </label>
<input type="date" th:field="*{birthday}" />
<input
type = "date"
name = "birthday"
th:field = "*{birthday}"
class = "form-control"
/>
</div>
<div class = "form-group">
<label> Employee Skill </label>
<input
type = "text"
name = "skill"
th:field = "*{skill}"
class = "form-control"
placeholder = "Enter Employee Skill"
/>
</div>
<div class = "box-footer">
<button type="submit" class = "btn btn-primary">
Submit
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
You just need to add mapping for /, which will redirect to the landing page (in your case employees page).
So, just add the following GET mapping in your EmployeeController
#GetMapping('/')
public String index() {
return "redirect:/employees";
}

How to use LocalDateTime

what is the right way to solve LocalDateTime error?
I am new to spring therefore I have tried to look for the way to solve this online but I cannot get around it.
This is my entity
package com.reserve.entities;
import java.time.LocalDateTime;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
#Entity
public class Flight extends AbstractEntity {
private String flightNumber;
private String operatingAirlines;
private String departureCity;
private String arrivalCity;
#DateTimeFormat(iso=ISO.DATE)
private Date dateOfDeparture;
#Column(name="estimatedDepartureTime",columnDefinition="TIMESTAMP")
private LocalDateTime estimatedDepartureTime;
public String getFlightNumber() {
return flightNumber;
}
public void setFlightNumber(String flightNumber) {
this.flightNumber = flightNumber;
}
public String getOperatingAirlines() {
return operatingAirlines;
}
public void setOperatingAirlines(String operatingAirlines) {
this.operatingAirlines = operatingAirlines;
}
public String getDepartureCity() {
return departureCity;
}
public void setDepartureCity(String departureCity) {
this.departureCity = departureCity;
}
public String getArrivalCity() {
return arrivalCity;
}
public void setArrivalCity(String arrivalCity) {
this.arrivalCity = arrivalCity;
}
public Date getDateOfDeparture() {
return dateOfDeparture;
}
public void setDateOfDeparture(Date dateOfDeparture) {
this.dateOfDeparture = dateOfDeparture;
}
public LocalDateTime getEstimatedDepartureTime() {
return estimatedDepartureTime;
}
public void setEstimatedDepartureTime(LocalDateTime estimatedDepartureTime) {
this.estimatedDepartureTime = estimatedDepartureTime;
}
#Override
public String toString() {
return "Flight [flightNumber=" + flightNumber + ", operatingAirlines=" + operatingAirlines + ", departureCity="
+ departureCity + ", arrivalCity=" + arrivalCity + ", dateOfDeparture=" + dateOfDeparture
+ ", estimatedDepartureTime=" + estimatedDepartureTime + "]";
}
}
This is my controller.
I am not sure which information is required.
Please let me know if there are more information that could help.
package com.reserve.controllers;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.reserve.entities.Flight;
import com.reserve.repository.FlightRepository;
#Controller
public class FlightController {
#Autowired
private FlightRepository flightRepository;
#RequestMapping("findFlights")
public String findFlights(
#RequestParam("from")String from,
#RequestParam("to")String to,
#RequestParam("departureDate")
#DateTimeFormat(pattern = "MM-dd-yyyy")
Date departureDate,
Model model)
{
List<Flight> flights = flightRepository.findFlights(from,to,departureDate);
model.addAttribute("flights", flights);
return "displayFlights";
}
#RequestMapping("/ourFlights")
public String ourFlights() {
return "ourFlights";
}
#RequestMapping(value="/add", method=RequestMethod.POST)
public String addFlights(#ModelAttribute("flight")Flight flight,Model model) {
Flight save = flightRepository.save(flight);
String msg = save.getFlightNumber() + " from " + save.getDepartureCity() + " to "
+ save.getArrivalCity() + " has been added.";
model.addAttribute("msg", msg);
return "ourFlights";
}
}
This is my JSP file
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%#taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%#page isELIgnored="false"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Money Wise</title>
<link rel="stylesheet" href="/reserve/css/bootstrap.min.css"/>
<link rel="stylesheet" href="/reserve/css/custom.css"/>
</head>
<body>
<div class="container">
<div id="body">
<nav class="navbar navbar-expand-lg navbar-light bg-lights">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="home">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Ideology</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Faq</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">News</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0 pull-right">
<input class="form-control mr-sm-2" type="search" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<!-- Site Body -->
<div id="content" class="container">
<div class="row">
<div id="leftMain" class="col-sm-3">
<img src="/reserve/images/jim.png"width=100%/>
</div>
<div id="mainBody" class="col-sm-9 ">
<h2>Add Flights</h2>
<form action="add" method="post">
<div class="form-group">
<label for="flightNumber">Flight number</label>
<input type="text" class="form-control" name="flightNumber" placeholder="Flight number"/>
</div>
<div class="form-group">
<label for="operatingAirlines">Operating airlines</label>
<input type="text" class="form-control" name="operatingAirlines" placeholder="Operating airlines"/>
</div>
<div class="form-group">
<label for="departureCity">Departure city</label>
<input type="text" class="form-control" name="departureCity" placeholder="Departure city"/>
</div>
<div class="form-group">
<label for="arrivalCity">Arrival city</label>
<input type="text" class="form-control" name="arrivalCity" placeholder="Arrival city"/>
</div>
<div class="form-group">
<label for="dateOfDeparture">Date of departure</label>
<input type="Date" class="form-control" name="dateOfDeparture" placeholder="Date of departure"/>
</div>
<div class="form-group">
<label for="estimatedDepartureTime">Estimated departure time</label>
<input type="datetime-local" class="form-control" name="estimatedDepartureTime" placeholder="Estimated departure time"/>
</div>
<button type="submit" class="btn btn-primary">Save</button>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- JS, Popper.js, and jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"></script>
<script src="/reserve/js/bootstrap.min.js"></script>
</body>
</html>
This is the error I get
Field error in object 'flight' on field 'estimatedDepartureTime': rejected value [2020-06-20T17:35]; codes
[typeMismatch.flight.estimatedDepartureTime,typeMismatch.estimatedDepartureTime,typeMismatch.java.time.LocalDateTime,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable:
codes [flight.estimatedDepartureTime,estimatedDepartureTime]; arguments []; default message [estimatedDepartureTime]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.time.LocalDateTime' for property 'estimatedDepartureTime';
nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type
[java.lang.String] to type [#javax.persistence.Column java.time.LocalDateTime] for value '2020-06-20T17:35'; nested exception is java.lang.IllegalArgumentException: Parse attempt failed for value [2020-06-20T17:35]]]
``````
You can try to use Spring The Formatter SPI to convert Date expressed as String to LocalDateTime and vice versa.
public class DateTimeFormatters {
public static class LocalDateTimeFormatter implements Formatter<LocalDateTime> {
#Override
public LocalDateTime parse(String pattern, Locale locale) throws ParseException {
return LocalDateTime.parse(pattern, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
}
#Override
public String print(LocalDateTime object, Locale locale) {
return object.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
}
}
}
And register your Formatter e.g
public class ApplicationConfig implements WebMvcConfigurer {
...
#Override
public void addFormatters(FormatterRegistry registry) {
registry.addFormatter(new DateTimeFormatters.LocalDateTimeFormatter());
}
...
}

How to Bind the list data thymeleaf html from to spring controller?

This is my Controller class
package com.myblog.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import com.myblog.model.User;
#Controller
public class UserController {
private static final Logger log = LoggerFactory.getLogger(UserController.class);
#GetMapping(value="/user")
public String getUser(Model model){
model.addAttribute("user", new User());
return "user";
}
#PostMapping(value="/user")
public String postUser(#ModelAttribute("user") User user){
log.info("user :"+user);
return "user";
}
}
This is My Model class
user.java
package com.myblog.model;
import java.util.ArrayList;
import java.util.List;
public class User {
private int id;
private String name;
private List<Address> address=new ArrayList<Address>();
#Override
public String toString() {
return "User [name=" + name + ", address=" + address + "]";
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Address> getAddress() {
return address;
}
public void setAddress(List<Address> address) {
this.address = address;
}
}
address.java
package com.myblog.model;
public class Address {
private int id;
private String street;
private String city;
public int getAddid() {
return addid;
}
public void setAddid(int addid) {
this.addid = addid;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
}
This is my thymeleaf HTML page
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Page Title</title>
<link href="/static/css/bootstrap.min.css" rel="stylesheet" media="screen" th:href="#{css/bootstrap.min.css}"/>
<script src="/static/js/bootstrap.min.js" th:src="#{js/bootstrap.min.js}"></script>
</head>
<body>
<div class="container">
<h1> User Account</h1>
<form class="form-horizontal" th:action="#{/user}" method="POST" th:object="${user}">
<div class="form-group">
<label for="inputDescription" class="col-sm-2 control-label">Full Name</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="name" placeholder="Full name"/>
</div>
</div>
<div class="form-group">
<label for="inputDescription" class="col-sm-2 control-label">Address</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="address.city" placeholder="City"/>
</div>
</div>
<div class="form-group">
<label for="inputDescription" class="col-sm-2 control-label">Street</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="address.street" placeholder="street" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<input type="submit" class="btn btn-primary" value="Add"/>
</div>
</div>
</form>
</div>
</body>
</html>
in controller user object does not bind the data into address model object.
output is user :user[name="name",address[]]
Your form seems to only manage one adress, but your domain model specifies a list of adresses. In this case you would need to name your input fields like address[0].street for the first address and so on.
So I'd consider to use a thymleaf iterator (th:each) to make all addresses manageable in your form. Then use th:field instead of defining name attributes. This should solve your problem.
<form class="form-horizontal" th:action="#{/user}" method="POST" th:object="${user}">
<div class="form-group">
<label for="inputDescription" class="col-sm-2 control-label">Full Name</label>
<div class="col-sm-5">
<input type="text" class="form-control" th:field="*{name}" placeholder="Full name"/>
</div>
</div>
<div class="form-group">
<label for="inputDescription" class="col-sm-2 control-label">Address</label>
<div class="col-sm-5">
<input type="text" class="form-control" th:field="*{address[0].city}" placeholder="City"/>
</div>
</div>
<div class="form-group">
<label for="inputDescription" class="col-sm-2 control-label">Street</label>
<div class="col-sm-5">
<input type="text" class="form-control" th:field="*{address[0].street}" placeholder="street" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<input type="submit" class="btn btn-primary" value="Add"/>
</div>
</div>
</form>

I am unable to post my form to the post method of my controller

I am trying to submit the form and send the data to the post method of my controller, but all i get is status 400 error I am not able to understand why this error is poping when i am able to submit for the post method for the different JSP pages.
Have I gone wrong somewhere, please help me I am not able to find my mistake
this is my controller
#RequestMapping(value = "personal" , method=RequestMethod.GET)
public String test(HttpServletRequest request, Model model, HttpServletResponse response, #ModelAttribute("personalDetails") PersonalDetails personalDetails) {
if(personalDetails==null){
personalDetails = new PersonalDetails();
}
Map referenceData = new HashMap();
Map<Long, String> salutation = new LinkedHashMap<Long, String>();
salutation.put(1L, "Mr");
salutation.put(2L, "Miss");
salutation.put(3L, "Mrs");
Map<Long,String> bloodGrp = new LinkedHashMap<Long, String>();
bloodGrp.put(1L, "A+");
bloodGrp.put(2L, "B+");
Map<Long, String> gender = new LinkedHashMap<Long, String>();
gender.put(1L, "MALE");
gender.put(2L, "Female");
Map<Long, String> marriageStatus = new LinkedHashMap<Long, String>();
marriageStatus.put(1L, "Single");
marriageStatus.put(2L, "divorsy");
log.info("Before setting model attributes");
model.addAttribute("salutationList", salutation);
model.addAttribute("bloodGrp", bloodGrp);
model.addAttribute("genderList", gender);
model.addAttribute("marriageStatus", marriageStatus);
model.addAttribute("persoanalDetails", personalDetails);
log.info("after setting model attributes");
return "personal";
}
#RequestMapping(value="personaldetails" , method=RequestMethod.POST)
public String personalDetails(#ModelAttribute("personalDetails") PersonalDetails personalDetails, HttpServletRequest request, HttpServletResponse response){
this.personalDetails = personalDetails;
return "success";
}
My jsp
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%# taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Generic Tool For Employee</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<link rel="stylesheet" href="layout/css/bootstrap.min.css">
<link rel="stylesheet" href="layout/css/validator/screen.css">
<link rel="stylesheet"
href="layout/datepicker/css/bootstrap-datepicker3.min.css">
<link rel="stylesheet" href="layout/css/index.css">
<div class="container-fluid">
<h2>Personal Details</h2>
<form:form commandName="personalDetails" class="form-horizontal" id="personalDetailsForm" role="form"
method="POST" action="${pageContext.request.contextPath}/personaldetails">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Personal Information</h4>
</div>
<div class="panel-body">
<div class="form-group">
<label class="col-sm-2 control-label" for="salutation">Salutation</label>
<div class="col-sm-2">
<form:select path="salutation" id="salutation"
name="salutation" class="form-control">
<!-- <option value="Mr">Mr</option>
<option value="Miss">Miss</option>
<option value="Mrs">Mrs</option>
<option value="Mx">Mx</option> -->
<form:options items="${salutationList}" />
</form:select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">First Name</label>
<div class="col-sm-4">
<form:input path="firstName" id="firstName" type="text"
class="form-control charcterClss" name="firstName"
placeholder="FIRST NAME" maxlength="250" />
</div>
<label class="col-sm-2 control-label">Middle Name</label>
<div class="col-sm-4">
<form:input path="middleName" id="middleName" type="text"
class="form-control charcterClss" name="middleName"
placeholder="MIDDLE NAME" maxlength="250" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Last Name</label>
<div class="col-sm-4">
<form:input path="lastName" id="lastName" type="text"
class="form-control charcterClss" name="lastName"
placeholder="LAST NAME" maxlength="250" />
</div>
<label class="col-sm-2 control-label">Blood group</label>
<div class="col-sm-4">
<form:select path="bloodGrp" id="bloodGroup"
name="bloodGroup" class="form-control">
<!-- <option></option>
<option>O +ve</option>
<option>O -ve</option>
<option>B +ve</option>
<option>B -ve</option>
<option>A +ve</option>
<option>A -ve</option>
<option>AB +ve</option>
<option>AB -ve</option> -->
<form:options items="${bloodGrp}" />
</form:select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Gender</label>
<div class="col-sm-4">
<form:select path="gender" id="gender" name="gender"
class="form-control">
<!-- <option value="Male">Male</option>
<option value="FeMale">Fe-Male</option>
<option value="Neutral">Transgender</option> -->
<form:options items="${genderList}" />
</form:select>
</div>
<label class="col-sm-2 control-label">Email Id</label>
<div class="col-sm-4">
<form:input path="emailId" class="form-control" type="text"
name="personalEmail" id="personalEmail"
placeholder="Personal Email" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Contact Number</label>
<div class="col-sm-4">
<form:input path="contactNo" class="form-control" type="text"
id="personalPhoneNno" name="personalPhoneNno"
placeholder="Personal Contact" />
</div>
<label class="col-sm-2 control-label">Alternative Contact
Number</label>
<div class="col-sm-4">
<form:input path="alterContactNo" class="form-control" type="text"
id="alternativePhoneNo" name="alternativePhoneNo"
placeholder="Alternative Contact" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Date of Birth</label>
<div class="col-sm-4">
<form:input path="dob" type="text" class="form-control datepicker"
placeholder="DOB" id="dOb" name="dOb" />
</div>
<label class="col-sm-2 control-label">Birth Place</label>
<div class="col-sm-4">
<form:input path="birthPlace" type="text"
class="form-control charcterClss" placeholder="PLACE YOU BORN"
id="birthPlace" name="birthPlace" maxlength="250" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Nationality</label>
<div class="col-sm-4">
<form:input path="nationality" type="text"
class="form-control charcterClss" placeholder="NATIONALITY"
id="nationality" name="nationality" />
</div>
<label class="col-sm-2 control-label">Religion</label>
<div class="col-sm-4">
<form:input path="religion" type="text"
class="form-control charcterClss" placeholder="RELIGION"
id="religion" name="religion" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Marital Status</label>
<div class="col-sm-4">
<form:select path="marriageDetails" id="maritalStatus" name="maritalStatus"
class="form-control">
<!-- <option value="single">Single</option>
<option value="married">Married</option>
<option value="divorcee">Divorcee</option> -->
<form:options items="${marriageStatus}"/>
</form:select>
</div>
<label class="col-sm-2 control-label">Date of Wedding</label>
<div class="col-sm-4">
<form:input path="dow" type="text" class="form-control datepicker"
placeholder="WEDDING DATE" id="weedingDate" name="weedingDate"/>
</div>
</div>
</div>
<div class="panel-footer">
<input class="submit btn btn-default" type="submit" value="Submit">
</div>
</div>
</form:form>
</div>
<!-- SCRIPTS -->
<script src="js/vendors/jquery-1.9.1.min.js"></script>
<script src="js/vendors/jquery.validate.min.js"></script>
<script src="js/vendors/bootstrap-3.3.5.js"></script>
<script src="datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="js/index.js"></script>
<script src="js/personal.js"></script>
and this is my model
#Entity
#Table(name="TB_PERSONAL_DETAILS")
public class PersonalDetails implements Serializable {
#Id
#GeneratedValue
#Column(name="PERSON_ID")
private Long personId;
#ManyToOne(fetch=FetchType.EAGER, cascade=CascadeType.DETACH)
#JoinColumn(name="SALUTATION_ID")
private SalutationMaster salutation;
#Column(name="FIRST_NAME")
private String firstName;
#Column(name="MIDDLE_NAME")
private String middleName;
#Column(name="LAST_NAME")
private String lastName;
#OneToOne(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
#JoinColumn(name="BLOOD_GRP_ID")
private BloodGrpMaster bloodGrp;
#OneToOne(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
#JoinColumn(name="GENDER_ID")
private GenderMaster gender;
#Column(name="EMAIL_ID")
private String emailId;
#Column(name="CONTACT_NO")
private String contactNo;
#Column(name="ALTERNATE_CONTACT_NO")
private String alterContactNo;
#Column(name="DATE_OF_BIRTH")
private Date dob;
#Column(name="BIRTH_PLACE")
private String birthPlace;
#Column(name="RELIGION")
private String religion;
#Column(name="NATIONALITY")
private String nationality;
#ManyToOne(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
#JoinColumn(name="MARRIAGE_DETAILS_ID")
private MarriageMaster marriageDetails;
#Column(name="DOW")
private Date dow;
#OneToOne(fetch=FetchType.EAGER,cascade=CascadeType.ALL,mappedBy="personalDetails")
private EmployeeDetails employeeDetails;
public PersonalDetails() {
// TODO Auto-generated constructor stub
}
public Long getPersonId() {
return personId;
}
public void setPersonId(Long personId) {
this.personId = personId;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getMiddleName() {
return middleName;
}
public void setMiddleName(String middleName) {
this.middleName = middleName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public BloodGrpMaster getBloodGrp() {
return bloodGrp;
}
public void setBloodGrp(BloodGrpMaster bloodGrp) {
this.bloodGrp = bloodGrp;
}
public GenderMaster getGender() {
return gender;
}
public void setGender(GenderMaster gender) {
this.gender = gender;
}
public Date getDob() {
return dob;
}
public void setDob(Date dob) {
this.dob = dob;
}
public String getBirthPlace() {
return birthPlace;
}
public void setBirthPlace(String birthPlace) {
this.birthPlace = birthPlace;
}
public String getReligion() {
return religion;
}
public void setReligion(String religion) {
this.religion = religion;
}
public String getNationality() {
return nationality;
}
public void setNationality(String nationality) {
this.nationality = nationality;
}
public SalutationMaster getSalutation() {
return salutation;
}
public void setSalutation(SalutationMaster salutation) {
this.salutation = salutation;
}
public EmployeeDetails getEmployeeDetails() {
return employeeDetails;
}
public void setEmployeeDetails(EmployeeDetails employeeDetails) {
this.employeeDetails = employeeDetails;
}
/**
* give the marital details of the employee
* #return
*/
public MarriageMaster getMarriageDetails() {
return marriageDetails;
}
/**
* set the marital details of the employee
* #param marriageDetails
*/
public void setMarriageDetails(MarriageMaster marriageDetails) {
this.marriageDetails = marriageDetails;
}
public Date getDow() {
return dow;
}
public void setDow(Date dow) {
this.dow = dow;
}
public String getEmailId() {
return emailId;
}
public void setEmailId(String emailId) {
this.emailId = emailId;
}
public String getContactNo() {
return contactNo;
}
public void setContactNo(String contactNo) {
this.contactNo = contactNo;
}
public String getAlterContactNo() {
return alterContactNo;
}
public void setAlterContactNo(String alterContactNo) {
this.alterContactNo = alterContactNo;
}
}
Thank you in advance for going through my issue and giving your best on that.

Resources