- 浏览: 411383 次
- 性别:
- 来自: 北京
-
文章分类
- 全部博客 (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 1100EJB3的拦截器的开步骤: 1.开发拦截器 使用@A ... -
Caused by: org.hibernate.HibernateException: unknown Oracle major version [0]
2010-02-24 09:34 1797昨天试了一下把mysql的数据源配置mysql-ds.xml放 ... -
detached entity passed to persist
2010-02-02 08:01 1737detached entity passed to persi ... -
实体的状态
2009-06-17 23:04 615新建状态:新建的实体对象,尚未拥有持久化主键,没有和一个持久化 ... -
EJB3的一些常见注解
2009-06-17 22:58 9530.实体管理器 @Persisten ... -
JPA双向一对多和多对一
2009-06-16 01:03 4711JPA中一对多和多对一双向关系中,多的一方为关系维护端 ... -
JPA一对多和多对一关系
2009-05-16 11:18 60511-m:多的一方为关系维护端,关系维护端负责外键纪录 ... -
JPA多对多
2009-05-16 10:38 8523维护端注解 @ManyToMany (cascade ... -
6.2 配置JBoss数据源(Oracle10G)
2009-03-17 10:38 16461.配置数据源 <?xml version=" ... -
6.1 配置JBoss数据源(MS SQL Server2005)
2009-03-17 09:35 17671.SQL Server 2005 配置内容: <?xm ... -
8.开发消息驱动Bean
2009-03-13 22:59 10741.配置消息服务 <?xml version=&qu ... -
7.单表实体Bean
2009-03-09 23:47 1041(1):建表SQL语句(MySQL) ... -
6.配置JBoss数据源
2009-03-09 18:57 2415以MySQL为例: (1):添 ... -
5.开发有状态Bean
2009-03-05 23:37 8431.无状态Bean使用实例池技术管理Bean.性能 ... -
4.开发本地接口的无状态会话Bean
2009-03-05 23:03 835远程接口需要 ... -
3.通过ANT来提高应用的开发效率
2009-03-05 22:21 642<?xml version="1.0" ... -
2.开发EJB的客户端
2009-03-05 20:49 928EJB是业务层,通常被客户端调用,客户端可以是J ... -
1.EJB的HelloWorld!
2009-03-05 20:32 1745用Eclipse开发EJB需要用到EJB的类库 ...
相关推荐
Hibernate 4则增强了性能和并发处理能力,同时提供了更丰富的API和JPA 2.1的支持。Struts2则在安全性、性能和可扩展性上进行了改进。 Maven是这个项目中的构建工具,它管理项目的依赖关系,提供了一种标准的方式来...
总的来说,“Hiberante lib”压缩包提供了搭建和学习Hibernate环境的基础组件,对于想要进入Java ORM领域的开发者来说,这是一个很好的起点。通过这个压缩包,你可以开始探索和体验Hibernate的强大功能,以及它如何...
5. **事务管理**:Hibernate整合了JTA(Java Transaction API)和JPA(Java Persistence API)的事务处理,确保数据操作的原子性和一致性。 这些知识点结合在一起,可以帮助开发者构建高效、灵活且易于维护的Web...
前者包含了JPA和Hiberante,后者则提供了Spring Web MVC框架。 ```xml <groupId>org.springframework.boot <artifactId>spring-boot-starter-data-jpa <groupId>org.springframework.boot <artifactId>...
通过Hibernate Tools,开发者可以自动生成包含getter和setter方法、构造函数以及JPA注解的实体类。这极大地减少了手动编写代码的工作量,提高了开发效率。 四、映射文件编辑 该插件提供了一个可视化的映射文件编辑...
通过这些配置和代码,开发者可以快速搭建一个功能完备的Java Web应用,并且能够根据需求进行扩展和定制。这个整合方案虽然现在已被更新的技术栈取代,但对于理解Web开发的基本架构和原理仍然具有重要的学习价值。
4. **数据库连接**:Spring Data JPA和Hiberante是常见的ORM框架,它们可以帮助开发者与数据库交互。Spring Boot自动配置了DataSource和JPA,只需添加对应的依赖,即可实现数据库操作。 5. **日志**:Spring Boot...
2. **数据持久化**:通过集成JPA(Java Persistence API)和Hiberante,SpringBoot能够方便地操作数据库,如MySQL、MongoDB等。可以使用@Entity定义模型类,@Repository注解仓库接口,实现数据的CRUD操作。 3. **...