当前位置: 首页 > news >正文

Introduction to the Java Persistence API

JPA是Java Persistence API的简称,中文名Java持久层API,是JDK 5.0注解或XML描述对象-关系表的映射关系,并将运行期的实体对象持久化到数据库中。 [1]
Sun引入新的JPA ORM规范出于两个原因:其一,简化现有Java EE和Java SE应用开发工作;其二,Sun希望整合ORM技术,实现天下归一。

Entities
An entity is a lightweight persistence domain object. Typically an entity represents a table in a relational database, and each entity instance corresponds to a row in that table.

The persistent state of an entity is represented either through persistent fields or persistent properties. These fields or properties use object/relational mapping annotations to map the entities and entity relationships to the relational data in the underlying data store.

Requirements for Entity Classes
An entity class must follow these requirements:

The class must be annotated with the javax.persistence.Entity annotation.

The class must have a public or protected, no-argument constructor. The class may have other constructors.

The class must not be declared final. No methods or persistent instance variables must be declared final.

If an entity instance be passed by value as a detached object, such as through a session bean’s remote business interface, the class must implement the Serializable interface.

Entities may extend both entity and non-entity classes, and non-entity classes may extend entity classes.

Persistent instance variables must be declared private, protected, or package-private, and can only be accessed directly by the entity class’s methods. Clients must access the entity’s state through accessor or business methods.

Persistent Fields and Properties in Entity Classes
成员变量和属性
The persistent state of an entity can be accessed either through the entity’s instance variables or through JavaBeans-style properties. The fields or properties must be of the following Java language types:

  1. Java primitive types原始类型
    在Java中,变量有两种类型,一种是原始类型,一种是引用类型。
    原始类型一共有8种,它们分别是char,boolean,byte,short,int,long,float,double。在Java API中,有它们对应的包装类,分别是(首字母大写)Character,Boolean,Byte,Short,Integer,Long,Float,Double(char,int的变化稍微大点)。
  2. java.lang.String
  3. Other serializable types including:
  4. Wrappers of Java primitive types
  5. java.math.BigInteger
  6. java.math.BigDecimal
  7. java.util.Date
  8. java.util.Calendar
  9. java.sql.Date
  10. java.sql.Time
  11. java.sql.TimeStamp
  12. User-defined serializable types
    byte[],Byte[],char[],Character[]
  13. Enumerated types
  14. Other entities and/or collections of entities
  15. Embeddable classes v.美[ɪm’bed]英[ɪm’bed]可嵌入

相关文章:

  • 电脑开机后总是提示对话框:服务器正在运行中
  • hibernate第一天:环境搭建
  • 创建自己的yum源
  • hibernate第二天:hibernate原理
  • LINUX系统监控
  • hibernate第三天:O/R MAPPING常见框架
  • hadoop on nitrous.io
  • java常见日志理解
  • cobbler使用入门(未完整,待修改)
  • Externalizable和Serializable序列化与关键字transient
  • nmon系统监控工具
  • oracle官方文档使用
  • FlashBuilder(FB/eclipse) 打开多个无效
  • python 读写文件时,r、rt、rb、r+的区别
  • 类什么时候被加载
  • $translatePartialLoader加载失败及解决方式
  • 【译】理解JavaScript:new 关键字
  • CentOS6 编译安装 redis-3.2.3
  • classpath对获取配置文件的影响
  • cookie和session
  • Python 使用 Tornado 框架实现 WebHook 自动部署 Git 项目
  • react 代码优化(一) ——事件处理
  • SOFAMosn配置模型
  • 深度解析利用ES6进行Promise封装总结
  • 微信小程序填坑清单
  • 一些css基础学习笔记
  • 原创:新手布局福音!微信小程序使用flex的一些基础样式属性(一)
  • shell使用lftp连接ftp和sftp,并可以指定私钥
  • ​Z时代时尚SUV新宠:起亚赛图斯值不值得年轻人买?
  • # Panda3d 碰撞检测系统介绍
  • #我与虚拟机的故事#连载20:周志明虚拟机第 3 版:到底值不值得买?
  • (26)4.7 字符函数和字符串函数
  • (Redis使用系列) SpirngBoot中关于Redis的值的各种方式的存储与取出 三
  • (zt)最盛行的警世狂言(爆笑)
  • (附源码)ssm高校社团管理系统 毕业设计 234162
  • (论文阅读11/100)Fast R-CNN
  • (转)linux下的时间函数使用
  • .naturalWidth 和naturalHeight属性,
  • .net core 微服务_.NET Core 3.0中用 Code-First 方式创建 gRPC 服务与客户端
  • .NET NPOI导出Excel详解
  • .net 调用php,php 调用.net com组件 --
  • .net 写了一个支持重试、熔断和超时策略的 HttpClient 实例池
  • .NET 中的轻量级线程安全
  • .NET/C# 将一个命令行参数字符串转换为命令行参数数组 args
  • .net企业级架构实战之7——Spring.net整合Asp.net mvc
  • .NET下ASPX编程的几个小问题
  • .NET应用架构设计:原则、模式与实践 目录预览
  • .Net中ListT 泛型转成DataTable、DataSet
  • @transactional 方法执行完再commit_当@Transactional遇到@CacheEvict,你的代码是不是有bug!...
  • [\u4e00-\u9fa5] //匹配中文字符
  • [1159]adb判断手机屏幕状态并点亮屏幕
  • [20170728]oracle保留字.txt
  • [AutoSAR系列] 1.3 AutoSar 架构
  • [C#]OpenCvSharp结合yolov8-face实现L2CS-Net眼睛注视方向估计或者人脸朝向估计
  • [C#]扩展方法