Hibernate 之 Mapping】的更多相关文章

转自:  http://blog.csdn.net/jnqqls/article/details/8372732 从前面的介绍的Hibernate文章中我们已经对Hibernate有了一个初步的认识,接下来我们所说的Mapping将会是学习Hibernate中比较重要的内容. Hibernate的映射是ORM(Object Relational Mapping)即对象关系映射框架的一个具体实现,能够实现ORM功能的框架有很多例如OpenORM,Hibernate等等,只不过Hibernate是这…
A Component is a containted object that is be persisted value type and not an entity.But you can embed the component to entity. Now We need one-to-one association for husband an wife. We just let the in one table. Then we create one entity, on compon…
相对微软的linq-to-sql或EF框架而言,"Hibernate对于eclipse的集成开发“ 新手并不容易掌握,下面是新手上路的步骤: 一.准备工作: 1.先下载eclipse (官网 http://eclipse.org/) 注:如本机已经安装了eclipse,可跳过 2.下载Hibernate 最新版本(目前已经到了4.X版本) (官网 http://hibernate.org/ ) 3.根据你的db使用情况,下载对应的jdbc驱动包(本文使用的是oracle,本机安装完oracle…
最近一个项目要用Java做,一点都不熟啊.没办法,只好硬着头皮啃了,花了大半天的时间,终于在Eclipse上完成了第一个Hibernate例子.下面记录关键的步骤,权作笔记,以备日后查看. (1)下载Hibernate,并向项目中导入Hibernate.     Project->Properies->Java Build Path->Libraries->Add External JARs...,选择Hibernate根目录下的hibernate3.jar,添加到项目中.    …
hibernate环境配置:导包.... 单向n-1:单向 n-1 关联只需从 n 的一端可以访问 1 的一端 <many-to-one> 元素来映射组成关系: name: 设定待映射的持久化类的属性的名字 column: 设定和持久化类的属性对应的表的外键 class:设定待映射的持久化类的属性的类型 建立1所对应的封装类,这儿只写属性,setter和getter就不写了: private Integer customerId; private String customerName; 建立…
环境搭建,在eclipse中导入spring和hibernate框架的插件,和导入所有使用到的架包 首先,hibernate的创建: 建立两个封装类,其中封装了数据库中表的属性,这儿只写属性,getter和setter方法就不写了 类:Account中的属性 private Integer id; private String username; private int balance; 类:Book中的属性 private Integer id; private String bookName…
在lib文件夹里面导入Hibernate开发的架包和连接mysql,连接数据源c3p0的架包... 在src目录下建立Hibernate Configuration  File(cfg.xml)的配置文件:hibernate.cfg.xml; 其中有配置连接数据库的架包,配置Hibernate的基本信息:最后,指定关系的 .hbm.xml文件 ,包名和在该包下的hbm.xml文件名,是一个目录结构 <?xml version="1.0" encoding="UTF-8&…
Hibernate understands both the Java and JDBC representations of application data. The ability to read and write object data to a database is called marshalling, and is the function of a Hibernate type. A type is an implementation of the org.hibernate…
Java bean: package com.my.bean; import java.util.Date; public class WorkPack { private String uWorkPackID; private String BaselineID; private String SourceID; private String uProjectID; private String sPackName; private String sDescription; private D…
Hibernate的所有session都是由sessionFactory来生成的,那么,sessionFactory是怎么得来的呢?它与我们配置的xxx.cfg.xml文件以及xxx.hbm.xml文件之间又有着怎么样的联系呢? 先看一小段生成sessionFactory的代码: code_1: public class HibernateTest { @Test public void test() { System.out.println("test..."); //1. 创建一个…