go4it

just do it

2009年1月23日

读书的技巧

摘要: 1.宏观把握总体,分清轻重,简单和高级内容 看书时可以先跳过高级内容和对基本掌握不大相关的内容 2.把书读厚-----不断提问和释疑(对比) 3.把书读薄-----总结和融会贯通 阅读全文

posted @ 2009-01-23 17:20 cxccbv 阅读(293) 评论(0) 推荐(0)

关联查询

摘要: 1.查询关联实体: (1)在一对一关连查询中,可以直接通过引用其关联属性来查询: select c.address from Customer c JPA实现者会根据实体映射的关系自动关联所对应的实体。 (2)在一对多中,可以通过IN select c.name,o from Customer c, in (c.orders) o 其中o为集合的别名。 ... 阅读全文

posted @ 2009-01-23 17:17 cxccbv 阅读(498) 评论(0) 推荐(0)

EJB的查询

摘要: 参考网址:http://blog.csdn.net/senton/archive/2007/03/08/1524432.aspx 1.创建Query查询对象的三种方式 (1)JPQL查询 (2)命名查询(Named) (3)本地查询(Native) 2.三种返回形式 (1)getResultList():一般返回实体集合类型:List result=query.getResul... 阅读全文

posted @ 2009-01-23 16:28 cxccbv 阅读(587) 评论(0) 推荐(0)

实体的高级操作

摘要: 1.通过getReference()捕获异常 Customer customer=null; try{ customer=em.getReference(Customer.class,new Integer(1)); }catch(EntityNotFoundException e){ //自定义捕获异常 } 2.同步数据库 当调用persist,merge,remove... 阅读全文

posted @ 2009-01-23 15:13 cxccbv 阅读(248) 评论(0) 推荐(0)

实体的生命周期

摘要: 一个实体从创建到销毁经历的几个状态: 瞬时状态(transient)----持久化状态(Persisted)-----托管状态(Managed/Attached)-----游离状态(Detached)-----销毁状态(Removed) 1.瞬时状态(transient): 只是new,但是还没persist到数据库,只是在内存当中。 2.持久化状态(Persisted): ... 阅读全文

posted @ 2009-01-23 14:32 cxccbv 阅读(462) 评论(0) 推荐(0)

持久化带关系的实体

摘要: customer与address单向一对一关系 1.增加级联 在customer中@OneToOne@JoinColumn(name="address_id") public Address getAddress(){ return this.address; } address中无特别的注解 同时增加一个customer和address:@PersistenceContext pro... 阅读全文

posted @ 2009-01-23 13:59 cxccbv 阅读(402) 评论(0) 推荐(0)

导航