EclipseLink/Features/JPA
2015-06-15 09:41
661 查看
Page
Discussion
View
source
History
< EclipseLink | Features
This page ...
[hide]
1 Mapping
1.1 Basic:
DirectToFieldMapping
1.2 Relationship
Mappings
1.3 Relational
Descriptor
1.3.1 Sequencing
Policies
1.3.2 Optimistic
Locking
2 Query
Framework
2.1 Expression
Framework
2.1.1 Transactions
3 EntityManager
3.1 EntityManagerFactory
Properties
3.2 EntityManager
Properties
4 DatabasePlatform
4.1 Oracle
4.2 IBM
Platforms
4.3 Sybase
4.4 Microsoft
Platforms
4.5 Informix
4.6 Other
Database Platforms
5 ServerPlatforms
6 Performance
and Scalability Features
Mapping entity classes to relational tables involves configuration of a mapping per persistent field.
For all mapping types there are a common
set of options available:
Read-Only: Specifies that the mapping should populate the value on read and copy. Required when multiple mappings share the same database column.
See Configuring Read-Only
Mappings in the EclipseLink User's Guide for
details.
Converters allow custom data types and data conversions to be used with most mapping types
Annotations: @Converter, @TypeConverter, @ObjectTypeConverter, @StructConverter, @Convert
XML: <converter>, <type-converter>, <object-type-converter>, <struct-converter>, <convert>
See Converters
and Transformers in the EclipseLink User's
Guide for details.
Mappings where a single attribute of the entity class is mapped to a column. EclipseLink's DirectToFieldMapping is
used to represent basic mappings in the metadata model.
Direct Mapping properties
Default Value for Null
See Configuring
a Default Null Value at the Mapping Level in the EclipseLink
User's Guide for details.
Lazy
Loading (Fetch Groups)
Relationship Mapping Features
Private-Owned: Indicates that the mapping forms a tight containment relationship. Used for cascade delete and merging operations
See Configuring
Private or Independent Relationships in the EclipseLink
User's Guide for details.
Collection Types: List, Set, Map, custom container
Transparent Indirection (Lazy Loading)
OneToOne Mapping (includes ManyToOne)
Target Foreign Key
OneToMany
ManyToMany
AggregateObject: Multiple classes within the same row
Nested aggregate object mapping
AggregateCollection
Direct Collection
Direct Map
Common Mapping Features
Converter
Custom
Object-Type
Type Conversion
A relational descriptor allows the mapping from an entity class to one or more tables. It shares all of the capabilities of the Class
Descriptor
Single Table Mapping
Multi-table Policy:
Using primary key fields of the same name (default)
Join using a specified foreign key
Inheritance
EclipseLink allows multiple sequences to be defined which are used to generate sequence values for new objects.
Native Sequencing
Sequence Table
Row per Sequence
Table per Sequence
Custom Sequencing Policy
Pre-allocation offers performance improvements minimizing the number of calls to the database
A descriptor's optimistic locking policy controls how EclipseLink will use values read from the database during the writes to the row to ensure the row has not been modified by another concurrent writer.
Version
Numeric
Timestamp
Fields
All
Selected
Changed
'Note: Pessimistic locking can be configured on a query or by default on the descriptor'
Query Types
Object Read Queries
ReadAllQuery
ReadObjectQuery
ReportQuery: Data project query including aggregate functions and group-by support
DataReadQuery
ValueReadQuery
Object Write Queries
InsertObjectQuery
UpdateObjectQuery
WriteObjectQuery
DeleteObjectQuery
Bulk Write Queries
UpdateAllQuery
DeleteAllQuery
EclipseLink's expression framework allows developers to define search criteria, ordering, batch/join reading, selective read fields, etc. using expressions based on the object model instead of coding the relational
schema into the application. This not only provides independence between the two models but also simplifies the Java developers work.
See Introduction
to EclipseLink Expressions (ELUG) in the EclipseLink User's
Guide for more information.
The query framework in conjunction with the expressions can define almost any query and can work cooperatively with EJB-QL, SQL, & Stored Procedure queries. Some of the key features include:
All comparison operators
Transparent join definition (inner & outer joins)
Pre-defined and custom inline functions (i.e. UPPER)
Sub-selects
Complex Ordering
Aggregate functions (SUM, MIN, MAX, … - ReportQuery)
GROUP BY (ReportQuery)
Re-usable expression fragments to control joining behavior
Definable batch and join reading to any level (reduces N+1 reading)
Native Queries
SQL
Stored Procedure
Query By Example
Cursored streams and Scrollable cursor
The UnitOfWork feature is an object-level transaction to simplify development of INSERT, UPDATE, and DELETE logic.
Session Query API
Register API to include objects in TX
Thread isolated changes to object graph
Deferred writing of changes (minimal TX window possible)
Minimal change-set calculation
SQL Call Ordering determined by referential integrity rules and minimize deadlock through consistent table access.
Commit, Commit and Resume
Revert instances and all registered objects
Cache merge only on successful TX commit
PK Assignment for new objects on demand or at commit
Merge API for applying client serialized objects
Un-register instances to remove from TX
Nested & Parallel UnitOfWork support
UnitOfWork begin Early Transaction support
In addition to being a compliant JPA implementation EclipseLink provides advanced features through the usage of JPA's properties for customizing EntityManagerFactory and EntityManager instances.
EclipseLink offers a number of properties for configuring an EntityManagerFactory that can be specified in either the persistence.xml or in the map passed to Persistence.createEntityManagerFactory. The configuration
of these advanced features is covered in the EclipseLink
User Guide.
JDBC
Configuration Options
JDBC Usage (Applicable to Data Source and EclipseLink's internal JDBC connection pooling)
eclipselink.jdbc.bind-parameters
eclipselink.jdbc.native-sql
eclipselink.jdbc.batch-writing
JDBC
Connection Pooling
eclipselink.jdbc.driver
eclipselink.jdbc.url
eclipselink.jdbc.user
eclipselink.jdbc.password
eclipselink.jdbc.read-connections.max
eclipselink.jdbc.read-connections.min
eclipselink.jdbc.read-connections.shared
eclipselink.jdbc.write-connections.max
eclipselink.jdbc.write-connections.min
eclipselink.jdbc.cache-statements
eclipselink.jdbc.cache-statements.size
Logging
eclipselink.logging.logger
eclipselink.logging.level
eclipselink.logging.timestamp
eclipselink.logging.thread
eclipselink.logging.session
eclipselink.logging.exceptions
eclipselink.logging.file
Caching
eclipselink.cache.type.default
eclipselink.cache.size.default
eclipselink.cache.shared.default
eclipselink.cache.type.<ENTITY>
eclipselink.cache.size.<ENTITY>
eclipselink.cache.shared.<ENTITY>
eclipselink.flush-clear.cache
Environment
Configuration and Customization
eclipselink.target-database - see Database
Platforms
eclipselink.target-server - see ServerPlatforms
Classic Metadata Usage
eclipselink.session-name
eclipselink.sessions-xml
eclipselink.session-event-listener
eclipselink.session.include.descriptor.queries
Schema
Generation
eclipselink.ddl-generation
eclipselink.application-location
eclipselink.create-ddl-jdbc-file-name
eclipselink.drop-ddl-jdbc-file-name
eclipselink.ddl-generation.output-mode
Entity
Change Tracking
eclipselink.weaving.changetracking
Weaving
Configuration
eclipselink.weaving
eclipselink.weaving.lazy
eclipselink.weaving.changetracking
eclipselink.weaving.fetchgroups
eclipselink.weaving.internal
eclipselink.weaving.eager
Reference Mode (eclipselink.persistence.context.reference-mode) with values HARD (default), WEAK, FORCE_WEAK. Defines the reference type used to hold managed objects within a persistence context.
User defined properties: Any property passed in will be accessible from with SessionEventListener callbacks
EclipseLink's DatabasePlatform encapsulates database specific behavior. While EclipseLink ships with out of the box and extended support for all of the leading database it is also possible to author a custom platform
or extend an existing platform to add custom behavior. The following are the capabilities defined by a database platform:
Field Types: Specifies the mapping from the common Java types to database type names. This is used for schema generation.
Native SQL (boolean, default = false): allows the user to select the usage of the default SQL92 dialect or the usage of the platform specific SQL generation.
ConversionManager
shoudTrimStrings (boolean): Indicates if strings returned form the JDBC result set should be trimed during processing
Server time query
Batch Writing configuration
Mode: Concatenation, JDBC, Native-JDBC
Batching size
Statement caching size (default = 50): controls the number of statements that will be cached per connection. this configuration is only applicable when using internal connection pooling.
Cursor handling
Transaction isolation
shouldOptimizeDataConversion (boolean, default = false): Allow for driver level data conversion optimization to be disabled, required because some drivers can loose precision.
Struct Converters: Allows converters to be set directly on the database platform. This is necessary when the Struct being converted requires the JDBC connection to complete its conversion into a Java type.
See Database
Platforms in the EclipseLink User's Guide for more information.
OraclePlatform
Object-relational type mappings
Native Sequencing (SELECT NEXTVAL FROM DUAL)
Stored Procedure
Hints
Oracle8Platform
Hierarchical Queries
Custom LOB Support for Oracle JDBC
Oracle9Platform
Oracle Spatial
Oracle10Platform
Oracle11Platform
TimesTenPlatform
DB2
Native SQL Support (BLOB, Date, Timestamp, Time)
Custom Operators (UCASE, LCASE, CONCAT)
Server Time
Ignore no data found/modified exceptions
Mainframe DB2
Native Sequencing (@@IDENTITY)
Native SQL (BLOB, Date, Timestamp, Time)
Stored Procedures
Server Time
SQL Server
Native Sequencing (@@IDENTITY)
Native SQL (BLOB, Date, Timestamp, Time)
Stored Procedures
Server Time
MS Access
Native Sequencing ("SELECT DISTINCT(DBINFO('sqlca.sqlerrd1')) FROM systables")
Native SQL (Date, Timestamp, Time)
Outer Joins
MySQL
Derby
Cloudscape
HSQL
JavaDB
PointBase
PostgreSQL
SQLAnyWhere
Oracle
OC4J
WebLogic Server (9, 10, 10.3)
JBoss
Tomcat 6 (EJB3 standalone)
SunAS9
IBM WebSphere (generic & 6.1)
SAP NetWeaver
EclipseLink offers numerous performance tuning capabilities that allow a developer to get the optimal performance and scalability characteristics for a specific application.
EclipseLink/Features/Core#Caching
Entity Caching: Allows EclipseLink to minimize database calls and avoids unnecessary object creation
Mapping
Indirection:
Allows relationships to be lazily loaded form the database
Fetch
Groups: Allows developer to control when the attributes of a class are loaded
Query
Batch
Reading (optimized SQL generation for data retrieval)
Join
Reading (optimized SQL generation for data retrieval)
Report & Partial Attribute Queries
Stored
Procedure support
In-Memory
Querying
Transactions
(UnitOfWork)
Minimal change-sets: Only modify what has changed
Batch Writing
SQL Concatenation
JDBC batch writing
Native JDBC batching
Bulk Operations
Bulk Update: Issue a single query to update the database and invalidate cached objects effected
Bulk Delete
JDBC
Prepared
Statement Caching (when using EclipseLink's connection pooling)
Parameter
Binding (Strings, LOBs, or ALL)
Sequence
pre-allocation: Reduce quantity of database calls by retrieving PK chunks
This page was last modified 07:05, 27 May 2011 by Jon
Lee. Based on work by Sabine
Heider, Michael OBrien and Doug
Clarke and others.
This page has been accessed 49,492 times.
Discussion
View
source
History
EclipseLink/Features/JPA
< EclipseLink | FeaturesThis page ...
Contents
[hide] 1 Mapping
1.1 Basic:
DirectToFieldMapping
1.2 Relationship
Mappings
1.3 Relational
Descriptor
1.3.1 Sequencing
Policies
1.3.2 Optimistic
Locking
2 Query
Framework
2.1 Expression
Framework
2.1.1 Transactions
3 EntityManager
3.1 EntityManagerFactory
Properties
3.2 EntityManager
Properties
4 DatabasePlatform
4.1 Oracle
4.2 IBM
Platforms
4.3 Sybase
4.4 Microsoft
Platforms
4.5 Informix
4.6 Other
Database Platforms
5 ServerPlatforms
6 Performance
and Scalability Features
Mapping
Mapping entity classes to relational tables involves configuration of a mapping per persistent field.For all mapping types there are a common
set of options available:
Read-Only: Specifies that the mapping should populate the value on read and copy. Required when multiple mappings share the same database column.
See Configuring Read-Only
Mappings in the EclipseLink User's Guide for
details.
Converters allow custom data types and data conversions to be used with most mapping types
Annotations: @Converter, @TypeConverter, @ObjectTypeConverter, @StructConverter, @Convert
XML: <converter>, <type-converter>, <object-type-converter>, <struct-converter>, <convert>
See Converters
and Transformers in the EclipseLink User's
Guide for details.
Basic: DirectToFieldMapping
Mappings where a single attribute of the entity class is mapped to a column. EclipseLink's DirectToFieldMapping isused to represent basic mappings in the metadata model.
Direct Mapping properties
Default Value for Null
See Configuring
a Default Null Value at the Mapping Level in the EclipseLink
User's Guide for details.
Lazy
Loading (Fetch Groups)
Relationship Mappings
Relationship Mapping FeaturesPrivate-Owned: Indicates that the mapping forms a tight containment relationship. Used for cascade delete and merging operations
See Configuring
Private or Independent Relationships in the EclipseLink
User's Guide for details.
Collection Types: List, Set, Map, custom container
Transparent Indirection (Lazy Loading)
OneToOne Mapping (includes ManyToOne)
Target Foreign Key
OneToMany
ManyToMany
AggregateObject: Multiple classes within the same row
Nested aggregate object mapping
AggregateCollection
Direct Collection
Direct Map
Common Mapping Features
Converter
Custom
Object-Type
Type Conversion
Relational Descriptor
A relational descriptor allows the mapping from an entity class to one or more tables. It shares all of the capabilities of the ClassDescriptor
Single Table Mapping
Multi-table Policy:
Using primary key fields of the same name (default)
Join using a specified foreign key
Inheritance
Sequencing Policies
EclipseLink allows multiple sequences to be defined which are used to generate sequence values for new objects.Native Sequencing
Sequence Table
Row per Sequence
Table per Sequence
Custom Sequencing Policy
Pre-allocation offers performance improvements minimizing the number of calls to the database
Optimistic Locking
A descriptor's optimistic locking policy controls how EclipseLink will use values read from the database during the writes to the row to ensure the row has not been modified by another concurrent writer.Version
Numeric
Timestamp
Fields
All
Selected
Changed
'Note: Pessimistic locking can be configured on a query or by default on the descriptor'
Query Framework
Query TypesObject Read Queries
ReadAllQuery
ReadObjectQuery
ReportQuery: Data project query including aggregate functions and group-by support
DataReadQuery
ValueReadQuery
Object Write Queries
InsertObjectQuery
UpdateObjectQuery
WriteObjectQuery
DeleteObjectQuery
Bulk Write Queries
UpdateAllQuery
DeleteAllQuery
Expression Framework
EclipseLink's expression framework allows developers to define search criteria, ordering, batch/join reading, selective read fields, etc. using expressions based on the object model instead of coding the relationalschema into the application. This not only provides independence between the two models but also simplifies the Java developers work.
See Introduction
to EclipseLink Expressions (ELUG) in the EclipseLink User's
Guide for more information.
The query framework in conjunction with the expressions can define almost any query and can work cooperatively with EJB-QL, SQL, & Stored Procedure queries. Some of the key features include:
All comparison operators
Transparent join definition (inner & outer joins)
Pre-defined and custom inline functions (i.e. UPPER)
Sub-selects
Complex Ordering
Aggregate functions (SUM, MIN, MAX, … - ReportQuery)
GROUP BY (ReportQuery)
Re-usable expression fragments to control joining behavior
Definable batch and join reading to any level (reduces N+1 reading)
Native Queries
SQL
Stored Procedure
Query By Example
Cursored streams and Scrollable cursor
Transactions
The UnitOfWork feature is an object-level transaction to simplify development of INSERT, UPDATE, and DELETE logic.Session Query API
Register API to include objects in TX
Thread isolated changes to object graph
Deferred writing of changes (minimal TX window possible)
Minimal change-set calculation
SQL Call Ordering determined by referential integrity rules and minimize deadlock through consistent table access.
Commit, Commit and Resume
Revert instances and all registered objects
Cache merge only on successful TX commit
PK Assignment for new objects on demand or at commit
Merge API for applying client serialized objects
Un-register instances to remove from TX
Nested & Parallel UnitOfWork support
UnitOfWork begin Early Transaction support
EntityManager
In addition to being a compliant JPA implementation EclipseLink provides advanced features through the usage of JPA's properties for customizing EntityManagerFactory and EntityManager instances.
EntityManagerFactory Properties
EclipseLink offers a number of properties for configuring an EntityManagerFactory that can be specified in either the persistence.xml or in the map passed to Persistence.createEntityManagerFactory. The configurationof these advanced features is covered in the EclipseLink
User Guide.
JDBC
Configuration Options
JDBC Usage (Applicable to Data Source and EclipseLink's internal JDBC connection pooling)
eclipselink.jdbc.bind-parameters
eclipselink.jdbc.native-sql
eclipselink.jdbc.batch-writing
JDBC
Connection Pooling
eclipselink.jdbc.driver
eclipselink.jdbc.url
eclipselink.jdbc.user
eclipselink.jdbc.password
eclipselink.jdbc.read-connections.max
eclipselink.jdbc.read-connections.min
eclipselink.jdbc.read-connections.shared
eclipselink.jdbc.write-connections.max
eclipselink.jdbc.write-connections.min
eclipselink.jdbc.cache-statements
eclipselink.jdbc.cache-statements.size
Logging
eclipselink.logging.logger
eclipselink.logging.level
eclipselink.logging.timestamp
eclipselink.logging.thread
eclipselink.logging.session
eclipselink.logging.exceptions
eclipselink.logging.file
Caching
eclipselink.cache.type.default
eclipselink.cache.size.default
eclipselink.cache.shared.default
eclipselink.cache.type.<ENTITY>
eclipselink.cache.size.<ENTITY>
eclipselink.cache.shared.<ENTITY>
eclipselink.flush-clear.cache
Environment
Configuration and Customization
eclipselink.target-database - see Database
Platforms
eclipselink.target-server - see ServerPlatforms
Classic Metadata Usage
eclipselink.session-name
eclipselink.sessions-xml
eclipselink.session-event-listener
eclipselink.session.include.descriptor.queries
Schema
Generation
eclipselink.ddl-generation
eclipselink.application-location
eclipselink.create-ddl-jdbc-file-name
eclipselink.drop-ddl-jdbc-file-name
eclipselink.ddl-generation.output-mode
Entity
Change Tracking
eclipselink.weaving.changetracking
Weaving
Configuration
eclipselink.weaving
eclipselink.weaving.lazy
eclipselink.weaving.changetracking
eclipselink.weaving.fetchgroups
eclipselink.weaving.internal
eclipselink.weaving.eager
EntityManager Properties
Reference Mode (eclipselink.persistence.context.reference-mode) with values HARD (default), WEAK, FORCE_WEAK. Defines the reference type used to hold managed objects within a persistence context.User defined properties: Any property passed in will be accessible from with SessionEventListener callbacks
DatabasePlatform
EclipseLink's DatabasePlatform encapsulates database specific behavior. While EclipseLink ships with out of the box and extended support for all of the leading database it is also possible to author a custom platformor extend an existing platform to add custom behavior. The following are the capabilities defined by a database platform:
Field Types: Specifies the mapping from the common Java types to database type names. This is used for schema generation.
Native SQL (boolean, default = false): allows the user to select the usage of the default SQL92 dialect or the usage of the platform specific SQL generation.
ConversionManager
shoudTrimStrings (boolean): Indicates if strings returned form the JDBC result set should be trimed during processing
Server time query
Batch Writing configuration
Mode: Concatenation, JDBC, Native-JDBC
Batching size
Statement caching size (default = 50): controls the number of statements that will be cached per connection. this configuration is only applicable when using internal connection pooling.
Cursor handling
Transaction isolation
shouldOptimizeDataConversion (boolean, default = false): Allow for driver level data conversion optimization to be disabled, required because some drivers can loose precision.
Struct Converters: Allows converters to be set directly on the database platform. This is necessary when the Struct being converted requires the JDBC connection to complete its conversion into a Java type.
See Database
Platforms in the EclipseLink User's Guide for more information.
Oracle
OraclePlatformObject-relational type mappings
Native Sequencing (SELECT NEXTVAL FROM DUAL)
Stored Procedure
Hints
Oracle8Platform
Hierarchical Queries
Custom LOB Support for Oracle JDBC
Oracle9Platform
Oracle Spatial
Oracle10Platform
Oracle11Platform
TimesTenPlatform
IBM Platforms
DB2Native SQL Support (BLOB, Date, Timestamp, Time)
Custom Operators (UCASE, LCASE, CONCAT)
Server Time
Ignore no data found/modified exceptions
Mainframe DB2
Sybase
Native Sequencing (@@IDENTITY)Native SQL (BLOB, Date, Timestamp, Time)
Stored Procedures
Server Time
Microsoft Platforms
SQL ServerNative Sequencing (@@IDENTITY)
Native SQL (BLOB, Date, Timestamp, Time)
Stored Procedures
Server Time
MS Access
Informix
Native Sequencing ("SELECT DISTINCT(DBINFO('sqlca.sqlerrd1')) FROM systables")Native SQL (Date, Timestamp, Time)
Outer Joins
Other Database Platforms
MySQLDerby
Cloudscape
HSQL
JavaDB
PointBase
PostgreSQL
SQLAnyWhere
ServerPlatforms
OracleOC4J
WebLogic Server (9, 10, 10.3)
JBoss
Tomcat 6 (EJB3 standalone)
SunAS9
IBM WebSphere (generic & 6.1)
SAP NetWeaver
Performance and Scalability Features
EclipseLink offers numerous performance tuning capabilities that allow a developer to get the optimal performance and scalability characteristics for a specific application.EclipseLink/Features/Core#Caching
Entity Caching: Allows EclipseLink to minimize database calls and avoids unnecessary object creation
Mapping
Indirection:
Allows relationships to be lazily loaded form the database
Fetch
Groups: Allows developer to control when the attributes of a class are loaded
Query
Batch
Reading (optimized SQL generation for data retrieval)
Join
Reading (optimized SQL generation for data retrieval)
Report & Partial Attribute Queries
Stored
Procedure support
In-Memory
Querying
Transactions
(UnitOfWork)
Minimal change-sets: Only modify what has changed
Batch Writing
SQL Concatenation
JDBC batch writing
Native JDBC batching
Bulk Operations
Bulk Update: Issue a single query to update the database and invalidate cached objects effected
Bulk Delete
JDBC
Prepared
Statement Caching (when using EclipseLink's connection pooling)
Parameter
Binding (Strings, LOBs, or ALL)
Sequence
pre-allocation: Reduce quantity of database calls by retrieving PK chunks
This page was last modified 07:05, 27 May 2011 by Jon
Lee. Based on work by Sabine
Heider, Michael OBrien and Doug
Clarke and others.
This page has been accessed 49,492 times.
相关文章推荐
- Java 多线程编程
- eclipse操作快捷键
- Java核心API -- 5(包装类、BigDecimal、BigInteger)
- 通过一个简单类就可以知道java类和对象的初始化顺序
- Dubbo+Spring+MyBaits客户端得到对象的属性为空
- Java的日期格式化常用方法
- Gradle安装及Eclipse插件配置
- java.lang.NoClassDefFoundError: Could not initialize class ces.com.log.Logge
- Eclipse Xml编译错误Referenced file contains errors - spring-beans-4.0.xsd
- Java中的Object类详细介绍
- java quarz,job控制,时间表示方法
- java中char与汉字占用字节个数问题
- Java中一个for语句导致无穷大死循环的例子
- JAVA经典实例
- struts2实现文件上传进度条(前端JS+Java)(自我整理)
- mac和windows下的eclipse不同编码
- Java内存理解 && 反射访问私有属性或方法
- Java中遍历数组使用foreach循环还是for循环?
- maven3.3不支持JDK1.6
- Java中使用异或语句实现两个变量的互换