- First step setup for the pom.xml with hibernate dependency ,
hibernate dependency need to before the struts2,because the javassist dependency
<dependency><groupId>com.google.guavagroupId><artifactId>guavaartifactId><version>RELEASEversion>dependency><dependency><groupId>javax.servletgroupId><artifactId>javax.servlet-apiartifactId><version>${servlet.version}version><scope>providedscope>dependency><dependency><groupId>javax.servlet.jspgroupId><artifactId>jsp-apiartifactId><version>${servlet.jsp.version}version><type>jartype><scope>testscope>dependency><dependency><groupId>log4jgroupId><artifactId>log4jartifactId><version>${log4j.version}version>dependency><dependency><groupId>junitgroupId><artifactId>junitartifactId><version>${junit.version}version><scope>testscope>dependency><dependency><groupId>org.hibernategroupId><artifactId>hibernate-coreartifactId><version>${hibernate.version}version>dependency><dependency><groupId>org.jboss.spec.javax.transactiongroupId><artifactId>jboss-transaction-api_1.2_specartifactId><version>${jboss.api.version}version>dependency><dependency><groupId>org.springframeworkgroupId><artifactId>spring-coreartifactId><version>${spring.version}version>dependency><dependency><groupId>org.springframeworkgroupId><artifactId>spring-contextartifactId><version>${spring.version}version>dependency><dependency><groupId>org.springframeworkgroupId><artifactId>spring-jdbcartifactId><version>${spring.version}version>dependency><dependency><groupId>org.springframeworkgroupId><artifactId>spring-txartifactId><version>${spring.version}version>dependency><dependency><groupId>org.springframeworkgroupId><artifactId>spring-beansartifactId><version>${spring.version}version>dependency><dependency><groupId>org.springframeworkgroupId><artifactId>spring-webartifactId><version>${spring.version}version>dependency><dependency><groupId>org.springframeworkgroupId><artifactId>spring-expressionartifactId><version>${spring.version}version>dependency><dependency><groupId>org.springframeworkgroupId><artifactId>spring-ormartifactId><version>${spring.version}version>dependency><dependency><groupId>commons-dbcpgroupId><artifactId>commons-dbcpartifactId><version>${spring.dbcp.version}version>dependency><dependency><groupId>xml-apisgroupId><artifactId>xml-apisartifactId><version>${spring.xmapis.version}version>dependency><dependency><groupId>org.apache.strutsgroupId><artifactId>struts2-coreartifactId><version>${struts2.version}version>dependency><dependency><groupId>org.apache.strutsgroupId><artifactId>struts2-convention-pluginartifactId><version>${struts2.version}version>dependency><dependency><groupId>org.apache.strutsgroupId><artifactId>struts2-json-pluginartifactId><version>${struts2.version}version>dependency><dependency><groupId>org.apache.strutsgroupId><artifactId>struts2-config-browser-pluginartifactId><version>${struts2.version}version>dependency><dependency><groupId>org.apache.strutsgroupId><artifactId>struts2-junit-pluginartifactId><version>${struts2.version}version><scope>testscope>dependency><dependency><groupId>org.apache.strutsgroupId><artifactId>struts2-spring-pluginartifactId><version>${struts2.version}version>dependency>
2. ApplicationContext.xml for hibernate :
<bean id="sessionFactory"class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"><property name="dataSource" ref="dataSource" /><property name="packagesToScan" value="${entities.path}" /><property name="hibernateProperties"><props><prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}prop><prop key="hibernate.dialect">${hibernate.dialect}prop><prop key="hibernate.show_sql">${hibernate.show_sql}prop><prop key="hibernate.format_sql">${hibernate.format_sql}prop>props>property>bean>
3. Install the hibernate tool to generate the entity class automatically:
choose the “hibernate tool” and “hibernate maven integration” and follow the step to install it .
4.using the hibernate reverse engineering(reveng.xml) to generate the reveng.xml file
5.using the hibernate code generate tool to generate the hibernate entities
6.create a new hibernate.cfg.xml file and then create the hibernate console
7.then you can use the HQL editor and hibernate criteria editor .