随笔分类 -  Hibernate

摘要:一。 inverse = ? inverse=false(default) 用于单向one-to-many关联 parent.getChildren().add(child) // insert child parent.getChildren().delete(child) // delete child inverse=true 用于双向one-to-many关联 child.setParent(parent); session.save(child) // insert child sessio... 阅读全文
posted @ 2012-12-14 13:59 zdp072 阅读(218) 评论(0) 推荐(0)
摘要:1、自动增长identity适用于MySQL、DB2、MS SQL Server,采用数据库生成的主键,用于为long、short、int类型生成唯一标识 使用SQL Server 和 MySQL 的自增字段,这个方法不能放到 Oracle 中,Oracle 不支持自增字段,要设定sequence(MySQL 和 SQL Server 中很常用) 数据库中的语法如下: MySQL:create table t_user(id int auto_increment primary key, name varchar(20)); SQL Server:create table t_user(id 阅读全文
posted @ 2012-12-14 13:52 zdp072 阅读(172) 评论(0) 推荐(0)
摘要:在Spring的applicationContext.xml中配置映射文件,通常是在<sessionFactory>这个Bean实例中进行的,若配置的映射文件较少时,可以用sessionFactory的所属类LocalSessionFactoryBean的“mappingResources”属性,定义方法如下:<property name="mappingResources"> <list> <value>com/w3cs/vlar/hibernate/Person.hbm.xml</value> <valu 阅读全文
posted @ 2012-10-18 17:15 zdp072 阅读(167) 评论(0) 推荐(0)