- 浏览: 394741 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (325)
- 数据中台 (15)
- 设计模式 (7)
- 数据结构 (4)
- JavaScript (51)
- 网页设计与制作 (7)
- Flex (4)
- Fckeditor (7)
- Struts (12)
- Spring (19)
- Hibernate (14)
- EJB3.0 (19)
- Java EE 6 (2)
- JSP (22)
- 辅助框架 (9)
- WebService (1)
- XML (8)
- 正则表达式 (5)
- 并发(多线程) (2)
- Java网络 (10)
- 开发工具 (25)
- Oracle (15)
- MySQL (8)
- Git (4)
- SQL Server (2)
- C# (9)
- php (14)
- asp (2)
- ColdFusion (5)
- Tex (1)
- 云游戏 (1)
最新评论
-
CSDNBenbenChong:
...
SQL里desc和asc是什么意思 -
雪狐一号:
非常好 顶一个
SQL里desc和asc是什么意思 -
boyleichinasoft:
thinking...
该如何去使用设计模式呢? -
nforce_com:
写的很好,学习了!不过Student 一般情况下不会删除所有 ...
JPA多对多 -
TaoistWar:
那是FCKEditor的,详细信息只能查看官方文档,或者直接看 ...
1.fckeditor-java-2.5给上传图片添加水印
1.添加jar包
hibernate & jpa jar(15): hibernate-distribution-3.3.1.GA/hibernate3.jar hibernate-distribution-3.3.1.GA/lib/required/antlr-2.7.6.jar hibernate-distribution-3.3.1.GA/lib/required/dom4j-1.6.1.jar hibernate-distribution-3.3.1.GA/lib/required/commons-collections-3.1.jar hibernate-distribution-3.3.1.GA/lib/required/jta-1.1.jar hibernate-distribution-3.3.1.GA/lib/required/javassist-3.4.GA.jar hibernate-distribution-3.3.1.GA/lib/required/slf4j-api-1.5.2.jar hibernate-distribution-3.3.1.GA/lib/bytecode/cglib/hibernate-cglib-repack-2.1_3.jar hibernate-distribution-3.3.1.GA/lib/optional/ehcache-1.2.jar hibernate-annotations-3.4.0.GA/hibernate-annotations.jar hibernate-annotations-3.4.0.GA/lib/hibernate-commons-annotations.jar hibernate-annotations-3.4.0.GA/lib/test/slf4j-log4j12.jar hibernate-annotations-3.4.0.GA/lib/test/log4j.jar hibernate-annotations-3.4.0.GA/lib/ejb3-persistence.jar hibernate-entitymanager-3.4.0.GA/lib/hibernate-entitymanager.jar
2.在src创建META-INF文件夹,在其下面创建persistence.xml文件,其内容如下:
<?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="ssj_unit" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <properties> <!-- <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" /> <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" /> <property name="hibernate.connection.username" value="yxuser" /> <property name="hibernate.connection.password" value="yxuser" /> <property name="hibernate.connection.url" value="jdbc:oracle:thin:@192.168.1.96:1521:yxdb" /> --> <!-- 连接参数 --> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" /> <property name="hibernate.connection.driver_class" value="org.gjt.mm.mysql.Driver" /> <property name="hibernate.connection.username" value="root" /> <property name="hibernate.connection.password" value="root" /> <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/ssj?useUnicode=true&characterEncoding=UTF-8" /> <!-- 数据源设置 --> <property name="hibernate.max_fetch_depth" value="3" /> <property name="hibernate.hbm2ddl.auto" value="update" /> <property name="hibernate.jdbc.fetch_size" value="50" /> <property name="hibernate.jdbc.batch_size" value="10" /> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.format_sql" value="true" /> </properties> </persistence-unit> </persistence>
3.创建实体类,其内容如下:
package com.taoistwar.ssj.producty.entity; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @Entity public class ProductType { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Integer id; private String name; public ProductType() { super(); } 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; } }
4.创建测试类
package test.producty.entity; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; import org.junit.Test; import com.taoistwar.ssj.producty.entity.ProductType; public class ProductTypeTest { @Test public void testRun() { try { EntityManagerFactory emf = Persistence .createEntityManagerFactory("ssj_unit"); EntityManager em = emf.createEntityManager(); em.getTransaction().begin(); ProductType pt = new ProductType(); pt.setName("中文"); em.persist(pt); em.getTransaction().commit(); em.close(); } catch (Exception e) { e.printStackTrace(); } } }
发表评论
-
8.EJB3的拦截器(外部类)
2010-05-11 11:00 1049EJB3的拦截器的开步骤: 1.开发拦截器 使用@A ... -
Caused by: org.hibernate.HibernateException: unknown Oracle major version [0]
2010-02-24 09:34 1758昨天试了一下把mysql的数据源配置mysql-ds.xml放 ... -
detached entity passed to persist
2010-02-02 08:01 1694detached entity passed to persi ... -
实体的状态
2009-06-17 23:04 579新建状态:新建的实体对象,尚未拥有持久化主键,没有和一个持久化 ... -
EJB3的一些常见注解
2009-06-17 22:58 8990.实体管理器 @Persisten ... -
JPA双向一对多和多对一
2009-06-16 01:03 4666JPA中一对多和多对一双向关系中,多的一方为关系维护端 ... -
JPA一对多和多对一关系
2009-05-16 11:18 59991-m:多的一方为关系维护端,关系维护端负责外键纪录 ... -
JPA多对多
2009-05-16 10:38 8453维护端注解 @ManyToMany (cascade ... -
6.2 配置JBoss数据源(Oracle10G)
2009-03-17 10:38 15821.配置数据源 <?xml version=" ... -
6.1 配置JBoss数据源(MS SQL Server2005)
2009-03-17 09:35 17181.SQL Server 2005 配置内容: <?xm ... -
8.开发消息驱动Bean
2009-03-13 22:59 10141.配置消息服务 <?xml version=&qu ... -
7.单表实体Bean
2009-03-09 23:47 997(1):建表SQL语句(MySQL) ... -
6.配置JBoss数据源
2009-03-09 18:57 2357以MySQL为例: (1):添 ... -
5.开发有状态Bean
2009-03-05 23:37 8061.无状态Bean使用实例池技术管理Bean.性能 ... -
4.开发本地接口的无状态会话Bean
2009-03-05 23:03 779远程接口需要 ... -
3.通过ANT来提高应用的开发效率
2009-03-05 22:21 596<?xml version="1.0" ... -
2.开发EJB的客户端
2009-03-05 20:49 879EJB是业务层,通常被客户端调用,客户端可以是J ... -
1.EJB的HelloWorld!
2009-03-05 20:32 1700用Eclipse开发EJB需要用到EJB的类库 ...
相关推荐
SpringMVC+Hibernate+Jpa Maven环境搭建 可直接下载下来使用
03_JPA详解_搭建JPA开发环境和全局事务介绍.zip
这是jpa环境的大家,里面引入jpa所需要的类库,以及访问mysql的驱动。最基本的骨架。适合初学者!
采用hibernate搭建JPA环境所需的jar包,有需要的可以下载
NULL 博文链接:https://jerval.iteye.com/blog/875801
03_传智播客JPA详解_搭建JPA开发环境和全局事务介绍
jpa 简单环境搭建,涵盖了JPa的所有jar包
JPA环境搭建所许的jar包,根据视频收集的,比较全的。
JPA连接MySql搭建HelloWorld示例代码,J
用xfire+spring+jpa搭建项目
JPA工程,以hibernate-4.2.4为基础.,包含详细注解和所有的Jar包
免费的Spring++JPA+Hibernate搭建,手把手教你如何搭建SpringMVC+Hibernate框架
SpringMVC+JPA使用注入的方式环境搭建
SpringMVC3.2+JPA使用注解的方式环境搭建
采取SpringBoot+JPA+Mysql的架构模式搭建BBS论坛,实现了登录、注册、修改个人信息(包括普通游客、会员和管理员)、发帖、回帖、修改帖子、查找帖子等
NULL 博文链接:https://1028826685.iteye.com/blog/1523349
spring+springMVC+maven+jpa框架搭建
5分钟利用Myeclipse快速搭建ssh(JPA)环境,自动生成dao,model 5分钟利用Myeclipse快速搭建ssh(JPA)环境,自动生成dao,model
搭建一个JPA+hibernate实例
JSF+Spring+JPA(Hibernate实现)的环境搭建.doc JSF+Spring+JPA(Hibernate实现)的环境搭建.doc