JPA的一个重要特性:它是基于POJO的。
通过JDK5.0注解或XML描述对象—关系表的映射关系,并将运行期的实体对象持久化到数据库中
JPA包括以下3方面的技术
1.ORM映射元数据
2.JPA的API,操作实体对象,执行CRUD操作。
3.查询语句
JPA的查询语句
select distinct t from Topic t where t.topicTitle = ?1
select distinct t from Topic t where t.topicTitle = :title
等价写法
select distinct p from PollTopic p join p.options o
where o.optionItem like ?1
select distinct p from PollTopic p
where p.options.optionItem like ??1
从one到many
关联查询 : select distinct p from PollTopic p in(p.options) o where o.optionItem like ?1
对应的SQL语句:
select distinct t.topic_id,t.topic_type,t.topic_title,t.topic_time,t.topic_views,t.multiple,t.max_choices from t_topic t,t_poll_option t1 where (((t1.option_item like ?) and (t.topic_type=?)) and (t1.topic_id = t.topic_id))
从many到one
select p from PollOption p join p.PollTopic t where t.topicId = :topicId
sql语句: select t.option_id,t.option_item... from T_poll_option t, Topic t1
where ((t1.topic_id = ?) and ((t1.topic_id=t.topic_id) and (( t1_topic_type =?)))
分享到:
相关推荐
JPA(Java Persistence API)作为Java EE 5.0平台标准的ORM规范,将得到所有Java EE服务器的支持
Apress Pro JPA2 Mastering the Java Persistence API
Java Persistence API 2.0-final-spec 免费下载
Java Persistence API PDF
比较全面的教程 一共29页PPT 包含示例代码和标签描述 适合快速学习的需要
APress Pro EJB 3 Java Persistence API
This document is the specification of the Java API for the management of persistence and object/relational mapping with Java EE and Java SE. The technical objective of this work is to provide an ...
Pro JPA 2 Mastering the Java Persistence API
Pro EJB 3 Java Persistence API.pdf。。。。。。。。。。。。。。。。。。。。
Pro JPA 2 Mastering the Java Persistence API 2009.pdf
Apress-Pro EJB 3 Java Persistence API.pdf
Java Persistence API(EJB3.0中的 JPA 规范说明) 。
[课堂课件讲解]Java微服务实践-Spring Boot Java Persistence API.pptx
text content 博文链接:https://clarancepeng.iteye.com/blog/67672
This document is the specification of the Java API for the management of persistence and object/relational mapping with Java EE and Java SE. The technical objective of this work is to provide an ...
要是你对 Hibernate 或 TopLink 的 Criteria API 不熟悉的话,可以将它想像成一个以 Java 为中心的面向对象,线程安全并可以与 JPQL 划上等号的一组 API .这组 API 适合于编写复杂的动态查询语句,还可避免解析 JPQL...