共 24 篇文章 |
|
注:低版权的 Mysql 不支持 EXISTS // 如果存在订单号为 1 的订单,就获取所有 OrderItem select oi from OrderItem as oi where exists (select o from Order o where o.orderid=1) // 如果不存在订单号为 10 的订单,就获取 id 为 1 的 OrderItem select oi from OrderItem as oi where oi.id=1 and not exists (select o from Order o where... 阅43406 转87 评0 公众公开 14-07-07 10:30 |
这一代码是有问题的,当你告诉实体管理器删除该实体的时候,实体管理器并不会自动地从指向该实体的所有关联中删除它,就像JPA不会自动地管理双向关联一样,就例子中的情况而言,关联指的应该是OrderLine.order属性指向的Order对象中的orderLines集合。OrderLine确实已是从Order.orderlines集中删除,并且不仅仅只是在该事务中,如果我们在新的... 阅1358 转9 评0 公众公开 10-12-17 17:01 |
Hibernate中get和load方法的区别。本文向您介绍Hibernate中的get方法和Load方法,并简单说明 Hibernate get方法和Hibernate load方法的两个重要区别。这次我们来谈一下Hibernate3.2 Session加载数据时get和load方法的区别(Hibernate 3以后的版本就用get()方法取代find()这个方法了),其实这个在网上有很多的论述,可大多语焉不详或经不起实践... 阅2134 转19 评0 公众公开 10-03-24 16:16 |
<class name="Person"><id name="id" column="personId"><generator class="native"/></id><set name="addresses"><key column="address_person_id"not-null="true"/><one-to-many class="Address"/></set>... 阅132 转1 评0 公众公开 09-02-24 15:58 |
equals和hashcode根本不是hibernate提出的新概念和新要求。看看Hibernate in action,有三种方法: 1. 就是的这种用无意义主键id做hashCode/equals 2. 就是用的所有值做hashCode/equals 3. 用一个(或者几个)相对稳定的业务字段做hashCode/equals (比如user, 就用userName). hibernate 推荐的是第3种, 按照这种推荐的做法, 就不会出现以上说的所... 阅617 转2 评0 公众公开 09-02-16 23:39 |
You can even includean SQL function call in the order-by attribute:<map name="images" table="ITEM_IMAGE" order-by="lower(FILENAME) asc"> <key column="ITEM_ID"/> <map-key column="IMAGENAME" type="string"/> <element type=&quo... 阅101 转1 评0 公众公开 09-02-12 00:29 |
6.1.6 Sorted collections(SortedMap,SortedSet)6.1.6 Sorted collectionsIn a startling abuse of the English language, the words sorted and ordered mean differentthings when it comes to Hibernate persistent collections. 阅180 转1 评0 公众公开 09-02-12 00:11 |
阅148 转1 评0 公众公开 09-02-11 22:15 |
hibernate中的 bag--解释的太好了hibernate中的 bag--解释的太好了.}最简单的Bag映射是使用<bag>标签,在这之前,假设您如下建立表格:CREATE TABLE user ( id INT(11) NOT NULL auto_increment PRIMARY KEY, name VARCHAR(100) NOT NULL default '''');CREATE TABLE item ( id INT(11) NOT NULL, name VARCHAR(... 阅3603 转9 评0 公众公开 09-02-10 22:32 |
产生persisitent对象有两种方法:1,对一个transient对象(即由应用程序创建的对象)调用持续管理器(Persistence Manager)的API的Session的save()方法2,由一个已经存在的persistent对象创建的对象实例就是persisitent对象persisitent对象总是跟Seesion相关联的,并且是事务性的,它参与到事务中去,在事务结束时,它们的状态和数据库相同步。... 阅621 转1 评0 公众公开 09-01-30 15:00 |