Struts 2, Hibernate 4 and MySQL Integration with Maven (Part 3)

Posted on 1 CommentPosted in Hibernate, Java, Struts2

Now we need to configure Hibernate and MySQL. For this, lets add the dependencies for Hibernate jars and MySQL driver in the project’s pom.xml file. <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.34</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>4.3.10.Final</version> </dependency> Modify the versions according to the version you are using for MySQL and Hibernate. After adding these dependencies, run following […]

Struts 2, Hibernate 4 and MySQL Integration with Maven (Part 2)

Posted on 1 CommentPosted in Hibernate, Java, Struts2

Let’s modify the application code now to create a New Employee page and add corresponding Action class and mappings. Step 1: Create a new jsp file NewEmployee.jsp under WEB-INF/example folder. <%@ page contentType=“text/html; charset=UTF-8”%> <%@ taglib prefix=“s”uri=“/struts-tags”%> <html> <head> <title><s:text name=“HelloWorld.message”/></title> </head> <body> <s:actionerror/> <s:form action=“register”> <s:textfield name=“name”label=“Name”></s:textfield> <s:textfield name=“age”label=“Age”></s:textfield> <s:submit/> </s:form> </body> </html> Also, […]

Struts 2, Hibernate 4 and MySQL Integration with Maven (Part1)

Posted on Posted in Hibernate, Java, Struts2

In this tutorial we will create a web application using Struts2, Hibernate 4 and Maven. We will create a page where we can add an Employee to a MySQL database. The application will be deployed on Tomcat server. First of all, lets create a Struts2 project using following Struts2 Blank archetype from Maven. If you […]

Hibernate 4 Hello world

Posted on Posted in Hibernate, Java

In this program we will create a basic hibernate 4 project using Maven. This program will connect to MySQL database, create an Employee table and add a record using Hibernate. If you need an introduction to Maven, please refer Maven Introduction on Maven basics. We will use basic Maven archetype to build a simple project […]

Hibernate interview questions

Posted on 1 CommentPosted in Hibernate, Interview questions

What is Hibernate ? Hibernate is an ORM tool that maps POJOs to tables in relational database. The mapping is done through a xml configuration file or through annotations.   What is ORM ? Object Relational Mapping frameworks like Hibernate, IBatis etc provideĀ mapping between code and tables. This helps productivity as the developers can focus […]