primefaces教程_Primefaces,带有JPA的Spring 4(Hibernate 4 / EclipseLink)示例教程

primefaces教程

Java Persistence API is a standard specification. It provides a persistence model that’s implemented by different implementer frameworks.

Java Persistence API是一个标准规范。 它提供了由不同的实现者框架实现的持久性模型。

Primefaces Spring Hibernate EclipseLink (Primefaces Spring Hibernate EclipseLink)

Hibernate & EclipseLink are two most popular implementations used for persisting given business model against some sort of persistence store like relational database. As such, this tutorial will provide you a full-fledged example containing all required configuration steps to developer a layered application that uses:

HibernateEclipseLink是两个最流行的实现,用于将给定的业务模型持久化到某种持久性存储(如关系数据库)中。 这样,本教程将为您提供一个完整的示例,其中包含开发使用以下内容的分层应用程序所需的所有配置步骤:

  1. Primefaces components to develop a compelling User Interface that aimed to handle user’s interactions and verify user’s inputs.

    Primefaces组件可开发引人注目的用户界面,旨在处理用户的交互并验证用户的输入。
  2. Hibernate/EclipseLink implementations to develop an Object/Relational Mapping beneath JPA umbrella.

    Hibernate / EclipseLink实现可在JPA框架下开发对象/关系映射。
  3. Spring framework as a kind of glue that get everything attached each together.

    Spring框架是一种胶粘剂,可以将所有东西都粘在一起。

We’ve discussed before using Hibernate ORM for persisting given domain classes. But today we will use only JPA based configurations.

在使用Hibernate ORM持久存储给定的域类之前,我们已经进行了讨论。 但是今天,我们将仅使用基于JPA的配置。

JPA specification does its bootstrap in a different way. In hibernate we’ve bootstrapped our application using hibernate.cfg.xml file, but JPA doesn’t specify that file.

JPA规范以不同的方式进行引导。 在hibernate中,我们使用hibernate.cfg.xml文件引导了我们的应用程序,但是JPA没有指定该文件。

JPA provides another way of configuration, it’s using persistence.xml file that is located within your classpath and under META-INF folder.

JPA提供了另一种配置方式,它使用位于classpathMETA-INF文件夹下的persistence.xml文件。

Let’s see how can we use both of Hibernate and EclipseLink for implementing a single registration form.

让我们看看如何使用HibernateEclipseLink来实现单个注册表单。

Primefaces Spring JPA Hibernate EclipseLink示例所需的工具 (Primefaces Spring JPA Hibernate EclipseLink Example Required Tools)

Before proceeding far away, you must prepare your environments that should contain for:

在继续进行之前,您必须准备以下环境:

  • JDK 1.6+.

    JDK 1.6以上版本。
  • Eclipse Kepler 4.3.

    Eclipse开普勒4.3。
  • Hibernate 4.3.6.Final.

    Hibernate4.3.6。最终版。
  • Spring 4.0.3.RELEASE.

    Spring 4.0.3发布。
  • EclipseLink 2.5.0-RC1

    EclipseLink 2.5.0-RC1
  • Maven Build Tool

    Maven构建工具
  • MySQL 5.x.

    MySQL5.x。

Primefaces Spring JPA Hibernate EclipseLink示例项目结构 (Primefaces Spring JPA Hibernate EclipseLink Example Project Structure)

Primefaces Spring JPA Hibernate EclipseLink示例数据库表 (Primefaces Spring JPA Hibernate EclipseLink Example Database Tables)

We have Employee table in our MySQL database, you can use below script to create it.

我们MySQL数据库中有Employee表,您可以使用以下脚本来创建它。

CREATE TABLE `employee` (
  `EMP_ID` int(11) NOT NULL AUTO_INCREMENT,
  `EMP_NAME` varchar(45) DEFAULT NULL,
  `EMP_HIRE_DATE` datetime DEFAULT NULL,
  `EMP_SALARY` decimal(11,4) DEFAULT NULL,
  PRIMARY KEY (`EMP_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
  • Employee Table contains one Primary Key with Auto Increment value.

    雇员表包含一个具有自动增量值的主键。

Primefaces Spring JPA Hibernate EclipseLink示例域类 (Primefaces Spring JPA Hibernate EclipseLink Example Domain Classes)

We have also one domain class that would be persisting into our database Employee table.

我们还有一个域类,该域类将持久存储到我们的数据库Employee表中。

Employee.java

Employee.java

package com.journaldev.hibernate.jpa.data;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Temporal;
import jav
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值