lonord
7 years ago
3460 changed files with 501403 additions and 0 deletions
@ -0,0 +1,3 @@ |
|||||||
|
# dependence-adapter |
||||||
|
|
||||||
|
该模块为一个辅助的中间模块,为改过包名的第三方包之间的相互引用作适配 |
@ -0,0 +1,13 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<module type="JAVA_MODULE" version="4"> |
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true"> |
||||||
|
<exclude-output /> |
||||||
|
<content url="file://$MODULE_DIR$"> |
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> |
||||||
|
</content> |
||||||
|
<orderEntry type="inheritedJdk" /> |
||||||
|
<orderEntry type="sourceFolder" forTests="false" /> |
||||||
|
<orderEntry type="module" module-name="fine-druid" /> |
||||||
|
<orderEntry type="module" module-name="fine-hibernate" /> |
||||||
|
</component> |
||||||
|
</module> |
@ -0,0 +1,65 @@ |
|||||||
|
package com.fr.third.adapter.druid; |
||||||
|
|
||||||
|
import java.sql.Connection; |
||||||
|
import java.sql.SQLException; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; |
||||||
|
import com.fr.third.org.hibernate.service.spi.Configurable; |
||||||
|
import com.fr.third.org.hibernate.service.spi.Stoppable; |
||||||
|
|
||||||
|
import com.fr.third.alibaba.druid.pool.DruidDataSource; |
||||||
|
import com.fr.third.alibaba.druid.pool.DruidDataSourceFactory; |
||||||
|
|
||||||
|
public class DruidConnectionProvider implements ConnectionProvider, Configurable, Stoppable { |
||||||
|
|
||||||
|
private static final long serialVersionUID = 1026193803901107651L; |
||||||
|
|
||||||
|
private DruidDataSource dataSource; |
||||||
|
|
||||||
|
public DruidConnectionProvider(){ |
||||||
|
dataSource = new DruidDataSource(); |
||||||
|
} |
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes") |
||||||
|
@Override |
||||||
|
public boolean isUnwrappableAs(Class unwrapType) { |
||||||
|
return dataSource.isWrapperFor(unwrapType); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public <T> T unwrap(Class<T> unwrapType) { |
||||||
|
return dataSource.unwrap(unwrapType); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Connection getConnection() throws SQLException { |
||||||
|
return dataSource.getConnection(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void closeConnection(Connection conn) throws SQLException { |
||||||
|
conn.close(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean supportsAggressiveRelease() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes") |
||||||
|
@Override |
||||||
|
public void configure(Map configurationValues) { |
||||||
|
try { |
||||||
|
DruidDataSourceFactory.config(dataSource, configurationValues); |
||||||
|
} catch (SQLException e) { |
||||||
|
throw new IllegalArgumentException("config error", e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void stop() { |
||||||
|
dataSource.close(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,9 @@ |
|||||||
|
# fine-hibernate |
||||||
|
|
||||||
|
改包名的hibernate(5.1.0.Final),包括: |
||||||
|
|
||||||
|
- hibernate-commons-annotations |
||||||
|
- hibernate-core |
||||||
|
- hibernate-entitymanager |
||||||
|
- hibernate-java8 |
||||||
|
- hibernate-jpamodelgen |
@ -0,0 +1,14 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<module type="JAVA_MODULE" version="4"> |
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true"> |
||||||
|
<exclude-output /> |
||||||
|
<content url="file://$MODULE_DIR$"> |
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> |
||||||
|
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" /> |
||||||
|
</content> |
||||||
|
<orderEntry type="inheritedJdk" /> |
||||||
|
<orderEntry type="sourceFolder" forTests="false" /> |
||||||
|
<orderEntry type="library" name="hibernate-build" level="project" /> |
||||||
|
<orderEntry type="module" module-name="fine-jboss-logging" /> |
||||||
|
</component> |
||||||
|
</module> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,13 @@ |
|||||||
|
# |
||||||
|
# Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
# |
||||||
|
# License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
||||||
|
# |
||||||
|
# |
||||||
|
# Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
# |
||||||
|
# License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
||||||
|
# |
||||||
|
com.fr.third.org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor |
@ -0,0 +1,13 @@ |
|||||||
|
# |
||||||
|
# Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
# |
||||||
|
# License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
||||||
|
# |
||||||
|
# |
||||||
|
# Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
# |
||||||
|
# License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
||||||
|
# |
||||||
|
com.fr.third.org.hibernate.jpa.HibernatePersistenceProvider |
@ -0,0 +1,59 @@ |
|||||||
|
<!-- |
||||||
|
~ Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
~ |
||||||
|
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- Hibernate file-based configuration document. |
||||||
|
|
||||||
|
<!DOCTYPE hibernate-configuration PUBLIC |
||||||
|
"-//Hibernate/Hibernate Configuration DTD 3.0//EN" |
||||||
|
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> |
||||||
|
|
||||||
|
An instance of this document contains property settings and references |
||||||
|
to mapping files for a number of SessionFactory instances to be listed |
||||||
|
in JNDI. |
||||||
|
|
||||||
|
--> |
||||||
|
|
||||||
|
<!ELEMENT hibernate-configuration (session-factory,security?)> |
||||||
|
|
||||||
|
<!ELEMENT property (#PCDATA)> |
||||||
|
<!ATTLIST property name CDATA #REQUIRED> |
||||||
|
|
||||||
|
<!ELEMENT mapping EMPTY> <!-- reference to a mapping file --> |
||||||
|
<!ATTLIST mapping resource CDATA #IMPLIED> |
||||||
|
<!ATTLIST mapping file CDATA #IMPLIED> |
||||||
|
<!ATTLIST mapping jar CDATA #IMPLIED> |
||||||
|
<!ATTLIST mapping package CDATA #IMPLIED> |
||||||
|
<!ATTLIST mapping class CDATA #IMPLIED> |
||||||
|
|
||||||
|
<!ELEMENT class-cache EMPTY> |
||||||
|
<!ATTLIST class-cache class CDATA #REQUIRED> |
||||||
|
<!ATTLIST class-cache region CDATA #IMPLIED> |
||||||
|
<!ATTLIST class-cache usage (read-only|read-write|nonstrict-read-write|transactional) #REQUIRED> |
||||||
|
<!ATTLIST class-cache include (all|non-lazy) "all"> |
||||||
|
|
||||||
|
<!ELEMENT collection-cache EMPTY> |
||||||
|
<!ATTLIST collection-cache collection CDATA #REQUIRED> |
||||||
|
<!ATTLIST collection-cache region CDATA #IMPLIED> |
||||||
|
<!ATTLIST collection-cache usage (read-only|read-write|nonstrict-read-write|transactional) #REQUIRED> |
||||||
|
|
||||||
|
<!ELEMENT event (listener*)> |
||||||
|
<!ATTLIST event type (auto-flush|merge|create|create-onflush|delete|dirty-check|evict|flush|flush-entity|load|load-collection|lock|refresh|replicate|save-update|save|update|pre-load|pre-update|pre-insert|pre-delete|pre-collection-recreate|pre-collection-remove|pre-collection-update|post-load|post-update|post-insert|post-delete|post-collection-recreate|post-collection-remove|post-collection-update|post-commit-update|post-commit-insert|post-commit-delete) #REQUIRED> |
||||||
|
|
||||||
|
<!ELEMENT listener EMPTY> |
||||||
|
<!ATTLIST listener type (auto-flush|merge|create|create-onflush|delete|dirty-check|evict|flush|flush-entity|load|load-collection|lock|refresh|replicate|save-update|save|update|pre-load|pre-update|pre-insert|pre-delete|pre-collection-recreate|pre-collection-remove|pre-collection-update|post-load|post-update|post-insert|post-delete|post-collection-recreate|post-collection-remove|post-collection-update|post-commit-update|post-commit-insert|post-commit-delete) #IMPLIED> |
||||||
|
<!ATTLIST listener class CDATA #REQUIRED> |
||||||
|
|
||||||
|
<!ELEMENT session-factory (property*, mapping*, (class-cache|collection-cache)*, event*, listener*)> |
||||||
|
<!ATTLIST session-factory name CDATA #IMPLIED> <!-- the JNDI name --> |
||||||
|
|
||||||
|
<!ELEMENT security (grant*)> |
||||||
|
<!ATTLIST security context CDATA #REQUIRED> <!--the JACC contextID--> |
||||||
|
|
||||||
|
<!ELEMENT grant EMPTY> |
||||||
|
<!ATTLIST grant role CDATA #REQUIRED> |
||||||
|
<!ATTLIST grant entity-name CDATA #REQUIRED> |
||||||
|
<!ATTLIST grant actions CDATA #REQUIRED> |
@ -0,0 +1,148 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!-- |
||||||
|
~ Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
~ |
||||||
|
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
||||||
|
--> |
||||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" |
||||||
|
xmlns="http://www.hibernate.org/xsd/orm/cfg" |
||||||
|
targetNamespace="http://www.hibernate.org/xsd/orm/cfg" |
||||||
|
elementFormDefault="qualified" |
||||||
|
version="4.0"> |
||||||
|
|
||||||
|
<xs:element name="hibernate-configuration"> |
||||||
|
<xs:complexType> |
||||||
|
<xs:sequence> |
||||||
|
<xs:element name="session-factory"> |
||||||
|
<xs:complexType> |
||||||
|
<xs:sequence> |
||||||
|
<xs:element name="property" minOccurs="0" maxOccurs="unbounded" type="ConfigPropertyType"/> |
||||||
|
<xs:element name="mapping" minOccurs="0" maxOccurs="unbounded" type="MappingReferenceType"/> |
||||||
|
<xs:choice minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xs:element name="class-cache" type="EntityCacheType"/> |
||||||
|
<xs:element name="collection-cache" type="CollectionCacheType"/> |
||||||
|
</xs:choice> |
||||||
|
<xs:element name="event" minOccurs="0" maxOccurs="unbounded" type="EventListenerGroupType" /> |
||||||
|
<xs:element name="listener" minOccurs="0" maxOccurs="unbounded" type="EventListenerType"/> |
||||||
|
</xs:sequence> |
||||||
|
<xs:attribute name="name" type="xs:string"/> |
||||||
|
<!-- the JNDI name --> |
||||||
|
</xs:complexType> |
||||||
|
</xs:element> |
||||||
|
<xs:element name="security" minOccurs="0"> |
||||||
|
<xs:complexType> |
||||||
|
<xs:sequence> |
||||||
|
<xs:element name="grant" minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xs:complexType> |
||||||
|
<xs:attribute name="actions" use="required" type="xs:string"/> |
||||||
|
<xs:attribute name="entity-name" use="required" type="xs:string"/> |
||||||
|
<xs:attribute name="role" use="required" type="xs:string"/> |
||||||
|
</xs:complexType> |
||||||
|
</xs:element> |
||||||
|
</xs:sequence> |
||||||
|
<xs:attribute name="context" use="required" type="xs:string"/> |
||||||
|
<!--the JACC contextID--> |
||||||
|
</xs:complexType> |
||||||
|
</xs:element> |
||||||
|
</xs:sequence> |
||||||
|
</xs:complexType> |
||||||
|
</xs:element> |
||||||
|
|
||||||
|
<xs:complexType name="ConfigPropertyType" mixed="true"> |
||||||
|
<xs:simpleContent> |
||||||
|
<xs:extension base="xs:string"> |
||||||
|
<xs:attribute name="name" use="required" type="xs:string"/> |
||||||
|
</xs:extension> |
||||||
|
</xs:simpleContent> |
||||||
|
</xs:complexType> |
||||||
|
|
||||||
|
<xs:complexType name="MappingReferenceType"> |
||||||
|
<xs:attribute name="class" type="xs:string"/> |
||||||
|
<xs:attribute name="file" type="xs:string"/> |
||||||
|
<xs:attribute name="jar" type="xs:string"/> |
||||||
|
<xs:attribute name="package" type="xs:string"/> |
||||||
|
<xs:attribute name="resource" type="xs:string"/> |
||||||
|
</xs:complexType> |
||||||
|
|
||||||
|
<xs:complexType name="EntityCacheType"> |
||||||
|
<xs:attribute name="class" use="required" type="xs:string"/> |
||||||
|
<xs:attribute name="include" default="all"> |
||||||
|
<xs:simpleType> |
||||||
|
<xs:restriction base="xs:token"> |
||||||
|
<xs:enumeration value="all"/> |
||||||
|
<xs:enumeration value="non-lazy"/> |
||||||
|
</xs:restriction> |
||||||
|
</xs:simpleType> |
||||||
|
</xs:attribute> |
||||||
|
<xs:attribute name="region" type="xs:string"/> |
||||||
|
<xs:attribute name="usage" use="required" type="CacheUsageEnum"/> |
||||||
|
</xs:complexType> |
||||||
|
|
||||||
|
<xs:complexType name="CollectionCacheType"> |
||||||
|
<xs:attribute name="collection" use="required" type="xs:string"/> |
||||||
|
<xs:attribute name="region" type="xs:string"/> |
||||||
|
<xs:attribute name="usage" use="required" type="CacheUsageEnum"/> |
||||||
|
</xs:complexType> |
||||||
|
|
||||||
|
<xs:complexType name="EventListenerGroupType"> |
||||||
|
<xs:sequence> |
||||||
|
<xs:element name="listener" minOccurs="0" maxOccurs="unbounded" type="EventListenerType"/> |
||||||
|
</xs:sequence> |
||||||
|
<xs:attribute name="type" use="required" type="EventTypeEnum"/> |
||||||
|
</xs:complexType> |
||||||
|
|
||||||
|
<xs:complexType name="EventListenerType"> |
||||||
|
<xs:attribute name="class" use="required" type="xs:string"/> |
||||||
|
<xs:attribute name="type" type="EventTypeEnum"/> |
||||||
|
</xs:complexType> |
||||||
|
|
||||||
|
<xs:simpleType name="EventTypeEnum"> |
||||||
|
<xs:restriction base="xs:token"> |
||||||
|
<xs:enumeration value="auto-flush"/> |
||||||
|
<xs:enumeration value="create"/> |
||||||
|
<xs:enumeration value="create-onflush"/> |
||||||
|
<xs:enumeration value="delete"/> |
||||||
|
<xs:enumeration value="dirty-check"/> |
||||||
|
<xs:enumeration value="evict"/> |
||||||
|
<xs:enumeration value="flush"/> |
||||||
|
<xs:enumeration value="flush-entity"/> |
||||||
|
<xs:enumeration value="load"/> |
||||||
|
<xs:enumeration value="load-collection"/> |
||||||
|
<xs:enumeration value="lock"/> |
||||||
|
<xs:enumeration value="merge"/> |
||||||
|
<xs:enumeration value="post-collection-recreate"/> |
||||||
|
<xs:enumeration value="post-collection-remove"/> |
||||||
|
<xs:enumeration value="post-collection-update"/> |
||||||
|
<xs:enumeration value="post-commit-delete"/> |
||||||
|
<xs:enumeration value="post-commit-insert"/> |
||||||
|
<xs:enumeration value="post-commit-update"/> |
||||||
|
<xs:enumeration value="post-delete"/> |
||||||
|
<xs:enumeration value="post-insert"/> |
||||||
|
<xs:enumeration value="post-load"/> |
||||||
|
<xs:enumeration value="post-update"/> |
||||||
|
<xs:enumeration value="pre-collection-recreate"/> |
||||||
|
<xs:enumeration value="pre-collection-remove"/> |
||||||
|
<xs:enumeration value="pre-collection-update"/> |
||||||
|
<xs:enumeration value="pre-delete"/> |
||||||
|
<xs:enumeration value="pre-insert"/> |
||||||
|
<xs:enumeration value="pre-load"/> |
||||||
|
<xs:enumeration value="pre-update"/> |
||||||
|
<xs:enumeration value="refresh"/> |
||||||
|
<xs:enumeration value="replicate"/> |
||||||
|
<xs:enumeration value="save"/> |
||||||
|
<xs:enumeration value="save-update"/> |
||||||
|
<xs:enumeration value="update"/> |
||||||
|
</xs:restriction> |
||||||
|
</xs:simpleType> |
||||||
|
|
||||||
|
<xs:simpleType name="CacheUsageEnum"> |
||||||
|
<xs:restriction base="xs:token"> |
||||||
|
<xs:enumeration value="nonstrict-read-write"/> |
||||||
|
<xs:enumeration value="read-only"/> |
||||||
|
<xs:enumeration value="read-write"/> |
||||||
|
<xs:enumeration value="transactional"/> |
||||||
|
</xs:restriction> |
||||||
|
</xs:simpleType> |
||||||
|
|
||||||
|
</xs:schema> |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,267 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!-- |
||||||
|
~ Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
~ |
||||||
|
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- persistence.xml schema --> |
||||||
|
<xsd:schema targetNamespace="http://java.sun.com/xml/ns/persistence" |
||||||
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
||||||
|
xmlns:persistence="http://java.sun.com/xml/ns/persistence" |
||||||
|
elementFormDefault="qualified" |
||||||
|
attributeFormDefault="unqualified" |
||||||
|
version="1.0"> |
||||||
|
|
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
@(#)persistence_1_0.xsd 1.0 Feb 9 2006 |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation><![CDATA[ |
||||||
|
|
||||||
|
This is the XML Schema for the persistence configuration file. |
||||||
|
The file must be named "META-INF/persistence.xml" in the |
||||||
|
persistence archive. |
||||||
|
Persistence configuration files must indicate |
||||||
|
the persistence schema by using the persistence namespace: |
||||||
|
|
||||||
|
http://java.sun.com/xml/ns/persistence |
||||||
|
|
||||||
|
and indicate the version of the schema by |
||||||
|
using the version element as shown below: |
||||||
|
|
||||||
|
<persistence xmlns="http://java.sun.com/xml/ns/persistence" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence |
||||||
|
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" |
||||||
|
version="1.0"> |
||||||
|
... |
||||||
|
</persistence> |
||||||
|
|
||||||
|
]]></xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
|
||||||
|
<xsd:simpleType name="versionType"> |
||||||
|
<xsd:restriction base="xsd:token"> |
||||||
|
<xsd:pattern value="[0-9]+(\.[0-9]+)*"/> |
||||||
|
</xsd:restriction> |
||||||
|
</xsd:simpleType> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="persistence"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:sequence> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="persistence-unit" |
||||||
|
minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
Configuration of a persistence unit. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:sequence> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="description" type="xsd:string" |
||||||
|
minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
Textual description of this persistence unit. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="provider" type="xsd:string" |
||||||
|
minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
Provider class that supplies EntityManagers for this |
||||||
|
persistence unit. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="jta-data-source" type="xsd:string" |
||||||
|
minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
The container-specific name of the JTA datasource to use. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="non-jta-data-source" type="xsd:string" |
||||||
|
minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
The container-specific name of a non-JTA datasource to use. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="mapping-file" type="xsd:string" |
||||||
|
minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
File containing mapping information. Loaded as a resource |
||||||
|
by the persistence provider. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="jar-file" type="xsd:string" |
||||||
|
minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
Jar file that should be scanned for entities. |
||||||
|
Not applicable to Java SE persistence units. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="class" type="xsd:string" |
||||||
|
minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
Class to scan for annotations. It should be annotated |
||||||
|
with either @Entity, @Embeddable or @MappedSuperclass. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="exclude-unlisted-classes" type="xsd:boolean" |
||||||
|
default="false" minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
When set to true then only listed classes and jars will |
||||||
|
be scanned for persistent classes, otherwise the enclosing |
||||||
|
jar or directory will also be scanned. Not applicable to |
||||||
|
Java SE persistence units. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="properties" minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
A list of vendor-specific properties. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:sequence> |
||||||
|
<xsd:element name="property" |
||||||
|
minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
A name-value pair. |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:attribute name="name" type="xsd:string" |
||||||
|
use="required"/> |
||||||
|
<xsd:attribute name="value" type="xsd:string" |
||||||
|
use="required"/> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
</xsd:sequence> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
</xsd:sequence> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
Name used in code to reference this persistence unit. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:attribute> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:attribute name="transaction-type" |
||||||
|
type="persistence:persistence-unit-transaction-type"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
Type of transactions used by EntityManagers from this |
||||||
|
persistence unit. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:attribute> |
||||||
|
|
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
</xsd:sequence> |
||||||
|
<xsd:attribute name="version" type="persistence:versionType" |
||||||
|
fixed="1.0" use="required"/> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:simpleType name="persistence-unit-transaction-type"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
public enum TransactionType { JTA, RESOURCE_LOCAL }; |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:restriction base="xsd:token"> |
||||||
|
<xsd:enumeration value="JTA"/> |
||||||
|
<xsd:enumeration value="RESOURCE_LOCAL"/> |
||||||
|
</xsd:restriction> |
||||||
|
</xsd:simpleType> |
||||||
|
|
||||||
|
</xsd:schema> |
||||||
|
|
@ -0,0 +1,232 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> <!-- |
||||||
|
~ Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
~ |
||||||
|
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
||||||
|
--> <!-- persistence.xml schema --> |
||||||
|
<xsd:schema targetNamespace="http://java.sun.com/xml/ns/persistence" |
||||||
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
||||||
|
xmlns:persistence="http://java.sun.com/xml/ns/persistence" |
||||||
|
elementFormDefault="qualified" |
||||||
|
attributeFormDefault="unqualified" |
||||||
|
version="2.0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
@(#)persistence_2_0.xsd 1.0 October 1 2009 |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation><![CDATA[ |
||||||
|
This is the XML Schema for the persistence configuration file. The file must be named "META-INF/persistence.xml" in the persistence archive. |
||||||
|
Persistence configuration files must indicate the persistence schema by using the persistence namespace: |
||||||
|
http://java.sun.com/xml/ns/persistence |
||||||
|
and indicate the version of the schema by using the version element as shown below: |
||||||
|
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence |
||||||
|
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0"> |
||||||
|
... </persistence> |
||||||
|
]]></xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:simpleType name="versionType"> |
||||||
|
<xsd:restriction base="xsd:token"> |
||||||
|
<xsd:pattern value="[0-9]+(\.[0-9]+)*"/> |
||||||
|
</xsd:restriction> |
||||||
|
</xsd:simpleType> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:element name="persistence"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:sequence> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:element name="persistence-unit" minOccurs="1" maxOccurs="unbounded"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
Configuration of a persistence unit. |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:sequence> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:element name="description" type="xsd:string" minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
Description of this persistence unit. |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:element name="provider" type="xsd:string" minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
Provider class that supplies EntityManagers for this persistence unit. |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:element name="jta-data-source" type="xsd:string" minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
The container-specific name of the JTA datasource to use. |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:element name="non-jta-data-source" type="xsd:string" minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
The container-specific name of a non-JTA datasource to use. |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:element name="mapping-file" type="xsd:string" minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
File containing mapping information. Loaded as a resource by the persistence |
||||||
|
provider. |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:element name="jar-file" type="xsd:string" minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
Jar file that is to be scanned for managed classes. |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:element name="class" type="xsd:string" minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
Managed class to be included in the persistence unit and to scan for |
||||||
|
annotations. It should be annotated with either @Entity, @Embeddable or |
||||||
|
@MappedSuperclass. |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:element name="exclude-unlisted-classes" |
||||||
|
type="xsd:boolean" |
||||||
|
default="true" |
||||||
|
minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
When set to true then only listed classes and jars will be scanned for |
||||||
|
persistent classes, otherwise the enclosing jar or directory will also be |
||||||
|
scanned. Not applicable to Java SE persistence units. |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:element name="shared-cache-mode" type="persistence:persistence-unit-caching-type" |
||||||
|
minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
Defines whether caching is enabled for the persistence unit if caching is |
||||||
|
supported by the persistence provider. When set to ALL, all entities will be |
||||||
|
cached. When set to NONE, no entities will be cached. When set to |
||||||
|
ENABLE_SELECTIVE, only entities specified as cacheable will be cached. When set |
||||||
|
to |
||||||
|
JSR-317 Final Release |
||||||
|
323 11/10/09 |
||||||
|
Sun Microsystems, Inc. |
||||||
|
Entity Packaging |
||||||
|
Java Persistence 2.0, Final Release persistence.xml Schema |
||||||
|
DISABLE_SELECTIVE, entities specified as not cacheable will not be cached. When |
||||||
|
not specified or when set to UNSPECIFIED, provider defaults may apply. |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:element name="validation-mode" type="persistence:persistence-unit-validation-mode-type" |
||||||
|
minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation>The validation mode to be used for the persistence unit. |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:element name="properties" minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
A list of standard and vendor-specific properties and hints. |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:sequence> |
||||||
|
<xsd:element name="property" |
||||||
|
minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation>A name-value pair.</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required"/> |
||||||
|
<xsd:attribute name="value" type="xsd:string" use="required"/> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
</xsd:sequence> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
</xsd:sequence> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation>Name used in code to reference this persistence unit. |
||||||
|
</xsd:documentation> |
||||||
|
|
||||||
|
</xsd:annotation> |
||||||
|
</xsd:attribute> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:attribute name="transaction-type" type="persistence:persistence-unit-transaction-type"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
Type of transactions used by EntityManagers from this persistence unit. |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:attribute> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
</xsd:sequence> |
||||||
|
<xsd:attribute name="version" type="persistence:versionType" |
||||||
|
fixed="2.0" use="required"/> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:simpleType name="persistence-unit-transaction-type"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation>public enum PersistenceUnitTransactionType {JTA, RESOURCE_LOCAL}; |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:restriction base="xsd:token"> |
||||||
|
<xsd:enumeration value="JTA"/> |
||||||
|
<xsd:enumeration value="RESOURCE_LOCAL"/> |
||||||
|
</xsd:restriction> |
||||||
|
</xsd:simpleType> |
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:simpleType name="persistence-unit-caching-type"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
public enum SharedCacheMode { ALL, NONE, ENABLE_SELECTIVE, DISABLE_SELECTIVE, UNSPECIFIED}; |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:restriction base="xsd:token"> |
||||||
|
<xsd:enumeration value="ALL"/> |
||||||
|
<xsd:enumeration value="NONE"/> |
||||||
|
<xsd:enumeration value="ENABLE_SELECTIVE"/> |
||||||
|
<xsd:enumeration value="DISABLE_SELECTIVE"/> |
||||||
|
<xsd:enumeration value="UNSPECIFIED"/> |
||||||
|
</xsd:restriction> |
||||||
|
</xsd:simpleType> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
<xsd:simpleType name="persistence-unit-validation-mode-type"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation>public enum ValidationMode { AUTO, CALLBACK, NONE}; |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:restriction base="xsd:token"> |
||||||
|
<xsd:enumeration value="AUTO"/> |
||||||
|
<xsd:enumeration value="CALLBACK"/> |
||||||
|
<xsd:enumeration value="NONE"/> |
||||||
|
</xsd:restriction> |
||||||
|
</xsd:simpleType> |
||||||
|
</xsd:schema> |
@ -0,0 +1,341 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
|
||||||
|
<!-- |
||||||
|
~ Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
~ |
||||||
|
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
||||||
|
--> |
||||||
|
<xsd:schema targetNamespace="http://xmlns.jcp.org/xml/ns/persistence" |
||||||
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
||||||
|
xmlns:persistence="http://xmlns.jcp.org/xml/ns/persistence" |
||||||
|
elementFormDefault="qualified" |
||||||
|
attributeFormDefault="unqualified" |
||||||
|
version="2.1"> |
||||||
|
|
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
@(#)persistence_2_1.xsd 2.1 February 8, 2013 |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
|
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation><![CDATA[ |
||||||
|
|
||||||
|
This is the XML Schema for the persistence configuration file. |
||||||
|
The file must be named "META-INF/persistence.xml" in the |
||||||
|
persistence archive. |
||||||
|
|
||||||
|
Persistence configuration files must indicate |
||||||
|
the persistence schema by using the persistence namespace: |
||||||
|
|
||||||
|
http://xmlns.jcp.org/xml/ns/persistence |
||||||
|
|
||||||
|
and indicate the version of the schema by |
||||||
|
using the version element as shown below: |
||||||
|
|
||||||
|
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence |
||||||
|
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" |
||||||
|
version="2.1"> |
||||||
|
... |
||||||
|
</persistence> |
||||||
|
|
||||||
|
]]></xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
|
||||||
|
<xsd:simpleType name="versionType"> |
||||||
|
<xsd:restriction base="xsd:token"> |
||||||
|
<xsd:pattern value="[0-9]+(\.[0-9]+)*"/> |
||||||
|
</xsd:restriction> |
||||||
|
</xsd:simpleType> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="persistence"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:sequence> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="persistence-unit" |
||||||
|
minOccurs="1" maxOccurs="unbounded"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
Configuration of a persistence unit. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:sequence> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="description" type="xsd:string" |
||||||
|
minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
Description of this persistence unit. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="provider" type="xsd:string" |
||||||
|
minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
Provider class that supplies EntityManagers for this |
||||||
|
persistence unit. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="jta-data-source" type="xsd:string" |
||||||
|
minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
The container-specific name of the JTA datasource to use. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="non-jta-data-source" type="xsd:string" |
||||||
|
minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
The container-specific name of a non-JTA datasource to use. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="mapping-file" type="xsd:string" |
||||||
|
minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
File containing mapping information. Loaded as a resource |
||||||
|
by the persistence provider. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="jar-file" type="xsd:string" |
||||||
|
minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
Jar file that is to be scanned for managed classes. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="class" type="xsd:string" |
||||||
|
minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
Managed class to be included in the persistence unit and |
||||||
|
to scan for annotations. It should be annotated |
||||||
|
with either @Entity, @Embeddable or @MappedSuperclass. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="exclude-unlisted-classes" type="xsd:boolean" |
||||||
|
default="true" minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
When set to true then only listed classes and jars will |
||||||
|
be scanned for persistent classes, otherwise the |
||||||
|
enclosing jar or directory will also be scanned. |
||||||
|
Not applicable to Java SE persistence units. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="shared-cache-mode" |
||||||
|
type="persistence:persistence-unit-caching-type" |
||||||
|
minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
Defines whether caching is enabled for the |
||||||
|
persistence unit if caching is supported by the |
||||||
|
persistence provider. When set to ALL, all entities |
||||||
|
will be cached. When set to NONE, no entities will |
||||||
|
be cached. When set to ENABLE_SELECTIVE, only entities |
||||||
|
specified as cacheable will be cached. When set to |
||||||
|
DISABLE_SELECTIVE, entities specified as not cacheable |
||||||
|
will not be cached. When not specified or when set to |
||||||
|
UNSPECIFIED, provider defaults may apply. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="validation-mode" |
||||||
|
type="persistence:persistence-unit-validation-mode-type" |
||||||
|
minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
The validation mode to be used for the persistence unit. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:element name="properties" minOccurs="0"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
A list of standard and vendor-specific properties |
||||||
|
and hints. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:sequence> |
||||||
|
<xsd:element name="property" |
||||||
|
minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
A name-value pair. |
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:attribute name="name" type="xsd:string" |
||||||
|
use="required"/> |
||||||
|
<xsd:attribute name="value" type="xsd:string" |
||||||
|
use="required"/> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
</xsd:sequence> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
</xsd:sequence> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
Name used in code to reference this persistence unit. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:attribute> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:attribute name="transaction-type" |
||||||
|
type="persistence:persistence-unit-transaction-type"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
Type of transactions used by EntityManagers from this |
||||||
|
persistence unit. |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
</xsd:attribute> |
||||||
|
|
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
</xsd:sequence> |
||||||
|
<xsd:attribute name="version" type="persistence:versionType" |
||||||
|
fixed="2.1" use="required"/> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:simpleType name="persistence-unit-transaction-type"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
public enum PersistenceUnitTransactionType {JTA, RESOURCE_LOCAL}; |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:restriction base="xsd:token"> |
||||||
|
<xsd:enumeration value="JTA"/> |
||||||
|
<xsd:enumeration value="RESOURCE_LOCAL"/> |
||||||
|
</xsd:restriction> |
||||||
|
</xsd:simpleType> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:simpleType name="persistence-unit-caching-type"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
public enum SharedCacheMode { ALL, NONE, ENABLE_SELECTIVE, DISABLE_SELECTIVE, UNSPECIFIED}; |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:restriction base="xsd:token"> |
||||||
|
<xsd:enumeration value="ALL"/> |
||||||
|
<xsd:enumeration value="NONE"/> |
||||||
|
<xsd:enumeration value="ENABLE_SELECTIVE"/> |
||||||
|
<xsd:enumeration value="DISABLE_SELECTIVE"/> |
||||||
|
<xsd:enumeration value="UNSPECIFIED"/> |
||||||
|
</xsd:restriction> |
||||||
|
</xsd:simpleType> |
||||||
|
|
||||||
|
<!-- **************************************************** --> |
||||||
|
|
||||||
|
<xsd:simpleType name="persistence-unit-validation-mode-type"> |
||||||
|
<xsd:annotation> |
||||||
|
<xsd:documentation> |
||||||
|
|
||||||
|
public enum ValidationMode { AUTO, CALLBACK, NONE}; |
||||||
|
|
||||||
|
</xsd:documentation> |
||||||
|
</xsd:annotation> |
||||||
|
<xsd:restriction base="xsd:token"> |
||||||
|
<xsd:enumeration value="AUTO"/> |
||||||
|
<xsd:enumeration value="CALLBACK"/> |
||||||
|
<xsd:enumeration value="NONE"/> |
||||||
|
</xsd:restriction> |
||||||
|
</xsd:simpleType> |
||||||
|
|
||||||
|
</xsd:schema> |
@ -0,0 +1,149 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
|
||||||
|
<!-- |
||||||
|
~ Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
~ |
||||||
|
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
||||||
|
--> |
||||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" |
||||||
|
xmlns="http://www.hibernate.org/xsd/orm/cfg" |
||||||
|
targetNamespace="http://www.hibernate.org/xsd/orm/cfg" |
||||||
|
elementFormDefault="qualified" |
||||||
|
version="4.0"> |
||||||
|
|
||||||
|
<xs:element name="hibernate-configuration"> |
||||||
|
<xs:complexType> |
||||||
|
<xs:sequence> |
||||||
|
<xs:element name="session-factory"> |
||||||
|
<xs:complexType> |
||||||
|
<xs:sequence> |
||||||
|
<xs:element name="property" minOccurs="0" maxOccurs="unbounded" type="ConfigPropertyType"/> |
||||||
|
<xs:element name="mapping" minOccurs="0" maxOccurs="unbounded" type="MappingReferenceType"/> |
||||||
|
<xs:choice minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xs:element name="class-cache" type="EntityCacheType"/> |
||||||
|
<xs:element name="collection-cache" type="CollectionCacheType"/> |
||||||
|
</xs:choice> |
||||||
|
<xs:element name="event" minOccurs="0" maxOccurs="unbounded" type="EventListenerGroupType" /> |
||||||
|
<xs:element name="listener" minOccurs="0" maxOccurs="unbounded" type="EventListenerType"/> |
||||||
|
</xs:sequence> |
||||||
|
<xs:attribute name="name" type="xs:string"/> |
||||||
|
<!-- the JNDI name --> |
||||||
|
</xs:complexType> |
||||||
|
</xs:element> |
||||||
|
<xs:element name="security" minOccurs="0"> |
||||||
|
<xs:complexType> |
||||||
|
<xs:sequence> |
||||||
|
<xs:element name="grant" minOccurs="0" maxOccurs="unbounded"> |
||||||
|
<xs:complexType> |
||||||
|
<xs:attribute name="actions" use="required" type="xs:string"/> |
||||||
|
<xs:attribute name="entity-name" use="required" type="xs:string"/> |
||||||
|
<xs:attribute name="role" use="required" type="xs:string"/> |
||||||
|
</xs:complexType> |
||||||
|
</xs:element> |
||||||
|
</xs:sequence> |
||||||
|
<xs:attribute name="context" use="required" type="xs:string"/> |
||||||
|
<!--the JACC contextID--> |
||||||
|
</xs:complexType> |
||||||
|
</xs:element> |
||||||
|
</xs:sequence> |
||||||
|
</xs:complexType> |
||||||
|
</xs:element> |
||||||
|
|
||||||
|
<xs:complexType name="ConfigPropertyType" mixed="true"> |
||||||
|
<xs:simpleContent> |
||||||
|
<xs:extension base="xs:string"> |
||||||
|
<xs:attribute name="name" use="required" type="xs:string"/> |
||||||
|
</xs:extension> |
||||||
|
</xs:simpleContent> |
||||||
|
</xs:complexType> |
||||||
|
|
||||||
|
<xs:complexType name="MappingReferenceType"> |
||||||
|
<xs:attribute name="class" type="xs:string"/> |
||||||
|
<xs:attribute name="file" type="xs:string"/> |
||||||
|
<xs:attribute name="jar" type="xs:string"/> |
||||||
|
<xs:attribute name="package" type="xs:string"/> |
||||||
|
<xs:attribute name="resource" type="xs:string"/> |
||||||
|
</xs:complexType> |
||||||
|
|
||||||
|
<xs:complexType name="EntityCacheType"> |
||||||
|
<xs:attribute name="class" use="required" type="xs:string"/> |
||||||
|
<xs:attribute name="include" default="all"> |
||||||
|
<xs:simpleType> |
||||||
|
<xs:restriction base="xs:token"> |
||||||
|
<xs:enumeration value="all"/> |
||||||
|
<xs:enumeration value="non-lazy"/> |
||||||
|
</xs:restriction> |
||||||
|
</xs:simpleType> |
||||||
|
</xs:attribute> |
||||||
|
<xs:attribute name="region" type="xs:string"/> |
||||||
|
<xs:attribute name="usage" use="required" type="CacheUsageEnum"/> |
||||||
|
</xs:complexType> |
||||||
|
|
||||||
|
<xs:complexType name="CollectionCacheType"> |
||||||
|
<xs:attribute name="collection" use="required" type="xs:string"/> |
||||||
|
<xs:attribute name="region" type="xs:string"/> |
||||||
|
<xs:attribute name="usage" use="required" type="CacheUsageEnum"/> |
||||||
|
</xs:complexType> |
||||||
|
|
||||||
|
<xs:complexType name="EventListenerGroupType"> |
||||||
|
<xs:sequence> |
||||||
|
<xs:element name="listener" minOccurs="0" maxOccurs="unbounded" type="EventListenerType"/> |
||||||
|
</xs:sequence> |
||||||
|
<xs:attribute name="type" use="required" type="EventTypeEnum"/> |
||||||
|
</xs:complexType> |
||||||
|
|
||||||
|
<xs:complexType name="EventListenerType"> |
||||||
|
<xs:attribute name="class" use="required" type="xs:string"/> |
||||||
|
<xs:attribute name="type" type="EventTypeEnum"/> |
||||||
|
</xs:complexType> |
||||||
|
|
||||||
|
<xs:simpleType name="EventTypeEnum"> |
||||||
|
<xs:restriction base="xs:token"> |
||||||
|
<xs:enumeration value="auto-flush"/> |
||||||
|
<xs:enumeration value="create"/> |
||||||
|
<xs:enumeration value="create-onflush"/> |
||||||
|
<xs:enumeration value="delete"/> |
||||||
|
<xs:enumeration value="dirty-check"/> |
||||||
|
<xs:enumeration value="evict"/> |
||||||
|
<xs:enumeration value="flush"/> |
||||||
|
<xs:enumeration value="flush-entity"/> |
||||||
|
<xs:enumeration value="load"/> |
||||||
|
<xs:enumeration value="load-collection"/> |
||||||
|
<xs:enumeration value="lock"/> |
||||||
|
<xs:enumeration value="merge"/> |
||||||
|
<xs:enumeration value="post-collection-recreate"/> |
||||||
|
<xs:enumeration value="post-collection-remove"/> |
||||||
|
<xs:enumeration value="post-collection-update"/> |
||||||
|
<xs:enumeration value="post-commit-delete"/> |
||||||
|
<xs:enumeration value="post-commit-insert"/> |
||||||
|
<xs:enumeration value="post-commit-update"/> |
||||||
|
<xs:enumeration value="post-delete"/> |
||||||
|
<xs:enumeration value="post-insert"/> |
||||||
|
<xs:enumeration value="post-load"/> |
||||||
|
<xs:enumeration value="post-update"/> |
||||||
|
<xs:enumeration value="pre-collection-recreate"/> |
||||||
|
<xs:enumeration value="pre-collection-remove"/> |
||||||
|
<xs:enumeration value="pre-collection-update"/> |
||||||
|
<xs:enumeration value="pre-delete"/> |
||||||
|
<xs:enumeration value="pre-insert"/> |
||||||
|
<xs:enumeration value="pre-load"/> |
||||||
|
<xs:enumeration value="pre-update"/> |
||||||
|
<xs:enumeration value="refresh"/> |
||||||
|
<xs:enumeration value="replicate"/> |
||||||
|
<xs:enumeration value="save"/> |
||||||
|
<xs:enumeration value="save-update"/> |
||||||
|
<xs:enumeration value="update"/> |
||||||
|
</xs:restriction> |
||||||
|
</xs:simpleType> |
||||||
|
|
||||||
|
<xs:simpleType name="CacheUsageEnum"> |
||||||
|
<xs:restriction base="xs:token"> |
||||||
|
<xs:enumeration value="nonstrict-read-write"/> |
||||||
|
<xs:enumeration value="read-only"/> |
||||||
|
<xs:enumeration value="read-write"/> |
||||||
|
<xs:enumeration value="transactional"/> |
||||||
|
</xs:restriction> |
||||||
|
</xs:simpleType> |
||||||
|
|
||||||
|
</xs:schema> |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,35 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Annotation related exception. |
||||||
|
* |
||||||
|
* The EJB3 EG will probably set a generic exception. I'll then use this one. |
||||||
|
* |
||||||
|
* @author Emmanuel Bernard |
||||||
|
*/ |
||||||
|
public class AnnotationException extends MappingException { |
||||||
|
/** |
||||||
|
* Constructs an AnnotationException using the given message and cause. |
||||||
|
* |
||||||
|
* @param msg The message explaining the reason for the exception. |
||||||
|
* @param cause The underlying cause. |
||||||
|
*/ |
||||||
|
public AnnotationException(String msg, Throwable cause) { |
||||||
|
super( msg, cause ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs an AnnotationException using the given message. |
||||||
|
* |
||||||
|
* @param msg The message explaining the reason for the exception. |
||||||
|
*/ |
||||||
|
public AnnotationException(String msg) { |
||||||
|
super( msg ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.internal.CoreMessageLogger; |
||||||
|
|
||||||
|
import com.fr.third.org.jboss.logging.Logger; |
||||||
|
|
||||||
|
/** |
||||||
|
* Indicates failure of an assertion: a possible bug in Hibernate. |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class AssertionFailure extends RuntimeException { |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
private static final CoreMessageLogger LOG = Logger.getMessageLogger( |
||||||
|
CoreMessageLogger.class, |
||||||
|
AssertionFailure.class.getName() |
||||||
|
); |
||||||
|
|
||||||
|
/** |
||||||
|
* Creates an instance of AssertionFailure using the given message. |
||||||
|
* |
||||||
|
* @param message The message explaining the reason for the exception |
||||||
|
*/ |
||||||
|
public AssertionFailure(String message) { |
||||||
|
super( message ); |
||||||
|
LOG.failed( this ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Creates an instance of AssertionFailure using the given message and underlying cause. |
||||||
|
* |
||||||
|
* @param message The message explaining the reason for the exception |
||||||
|
* @param cause The underlying cause. |
||||||
|
*/ |
||||||
|
public AssertionFailure(String message, Throwable cause) { |
||||||
|
super( message, cause ); |
||||||
|
LOG.failed( cause ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,104 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* A no-op implementation of SessionEventListener. Intended as a convenient base class for developing |
||||||
|
* SessionEventListener implementations. |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
@SuppressWarnings("UnusedDeclaration") |
||||||
|
public class BaseSessionEventListener implements SessionEventListener { |
||||||
|
@Override |
||||||
|
public void transactionCompletion(boolean successful) { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void jdbcConnectionAcquisitionStart() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void jdbcConnectionAcquisitionEnd() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void jdbcConnectionReleaseStart() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void jdbcConnectionReleaseEnd() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void jdbcPrepareStatementStart() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void jdbcPrepareStatementEnd() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void jdbcExecuteStatementStart() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void jdbcExecuteStatementEnd() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void jdbcExecuteBatchStart() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void jdbcExecuteBatchEnd() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void cachePutStart() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void cachePutEnd() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void cacheGetStart() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void cacheGetEnd(boolean hit) { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void flushStart() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void flushEnd(int numberOfEntities, int numberOfCollections) { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void partialFlushStart() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void partialFlushEnd(int numberOfEntities, int numberOfCollections) { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void dirtyCalculationStart() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void dirtyCalculationEnd(boolean dirty) { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void end() { |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,212 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.type.Type; |
||||||
|
|
||||||
|
/** |
||||||
|
* Defines the aspects of query definition that apply to all forms of querying. |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public interface BasicQueryContract { |
||||||
|
/** |
||||||
|
* Obtain the FlushMode in effect for this query. By default, the query inherits the FlushMode of the Session |
||||||
|
* from which is originates. |
||||||
|
* |
||||||
|
* @return The query FlushMode. |
||||||
|
* |
||||||
|
* @see Session#getFlushMode() |
||||||
|
* @see FlushMode |
||||||
|
*/ |
||||||
|
public FlushMode getFlushMode(); |
||||||
|
|
||||||
|
/** |
||||||
|
* (Re)set the current FlushMode in effect for this query. |
||||||
|
* |
||||||
|
* @param flushMode The new FlushMode to use. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
* |
||||||
|
* @see #getFlushMode() |
||||||
|
*/ |
||||||
|
public BasicQueryContract setFlushMode(FlushMode flushMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtain the CacheMode in effect for this query. By default, the query inherits the CacheMode of the Session |
||||||
|
* from which is originates. |
||||||
|
* |
||||||
|
* NOTE: The CacheMode here only effects reading/writing of the query cache, not the |
||||||
|
* entity/collection caches. |
||||||
|
* |
||||||
|
* @return The query CacheMode. |
||||||
|
* |
||||||
|
* @see Session#getCacheMode() |
||||||
|
* @see CacheMode |
||||||
|
*/ |
||||||
|
public CacheMode getCacheMode(); |
||||||
|
|
||||||
|
/** |
||||||
|
* (Re)set the current CacheMode in effect for this query. |
||||||
|
* |
||||||
|
* @param cacheMode The new CacheMode to use. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
* |
||||||
|
* @see #getCacheMode() |
||||||
|
*/ |
||||||
|
public BasicQueryContract setCacheMode(CacheMode cacheMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Are the results of this query eligible for second level query caching? This is different that second level |
||||||
|
* caching of any returned entities and collections. |
||||||
|
* |
||||||
|
* NOTE: the query being "eligible" for caching does not necessarily mean its results will be cached. Second level |
||||||
|
* query caching still has to be enabled on the {@link SessionFactory} for this to happen. Usually that is |
||||||
|
* controlled by the {@code hibernate.cache.use_query_cache} configuration setting. |
||||||
|
* |
||||||
|
* @return {@code true} if the query results are eligible for caching, {@code false} otherwise. |
||||||
|
* |
||||||
|
* @see com.fr.third.org.hibernate.cfg.AvailableSettings#USE_QUERY_CACHE |
||||||
|
*/ |
||||||
|
public boolean isCacheable(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Enable/disable second level query (result) caching for this query. |
||||||
|
* |
||||||
|
* @param cacheable Should the query results be cacheable? |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
* |
||||||
|
* @see #isCacheable |
||||||
|
*/ |
||||||
|
public BasicQueryContract setCacheable(boolean cacheable); |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtain the name of the second level query cache region in which query results will be stored (if they are |
||||||
|
* cached, see the discussion on {@link #isCacheable()} for more information). {@code null} indicates that the |
||||||
|
* default region should be used. |
||||||
|
* |
||||||
|
* @return The specified cache region name into which query results should be placed; {@code null} indicates |
||||||
|
* the default region. |
||||||
|
*/ |
||||||
|
public String getCacheRegion(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the name of the cache region where query results should be cached (if cached at all). |
||||||
|
* |
||||||
|
* @param cacheRegion the name of a query cache region, or {@code null} to indicate that the default region |
||||||
|
* should be used. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
* |
||||||
|
* @see #getCacheRegion() |
||||||
|
*/ |
||||||
|
public BasicQueryContract setCacheRegion(String cacheRegion); |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtain the query timeout <b>in seconds</b>. This value is eventually passed along to the JDBC query via |
||||||
|
* {@link java.sql.Statement#setQueryTimeout(int)}. Zero indicates no timeout. |
||||||
|
* |
||||||
|
* @return The timeout <b>in seconds</b> |
||||||
|
* |
||||||
|
* @see java.sql.Statement#getQueryTimeout() |
||||||
|
* @see java.sql.Statement#setQueryTimeout(int) |
||||||
|
*/ |
||||||
|
public Integer getTimeout(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the query timeout <b>in seconds</b>. |
||||||
|
* |
||||||
|
* NOTE it is important to understand that any value set here is eventually passed directly through to the JDBC |
||||||
|
* Statement which expressly disallows negative values. So negative values should be avoided as a general rule. |
||||||
|
* |
||||||
|
* @param timeout the timeout <b>in seconds</b> |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
* |
||||||
|
* @see #getTimeout() |
||||||
|
*/ |
||||||
|
public BasicQueryContract setTimeout(int timeout); |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtain the JDBC fetch size hint in effect for this query. This value is eventually passed along to the JDBC |
||||||
|
* query via {@link java.sql.Statement#setFetchSize(int)}. As defined b y JDBC, this value is a hint to the |
||||||
|
* driver to indicate how many rows to fetch from the database when more rows are needed. |
||||||
|
* |
||||||
|
* NOTE : JDBC expressly defines this value as a hint. It may or may not have any effect on the actual |
||||||
|
* query execution and ResultSet processing depending on the driver. |
||||||
|
* |
||||||
|
* @return The timeout <b>in seconds</b> |
||||||
|
* |
||||||
|
* @see java.sql.Statement#getFetchSize() |
||||||
|
* @see java.sql.Statement#setFetchSize(int) |
||||||
|
*/ |
||||||
|
public Integer getFetchSize(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a JDBC fetch size hint for the query. |
||||||
|
* |
||||||
|
* @param fetchSize the fetch size hint |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
* |
||||||
|
* @see #getFetchSize() |
||||||
|
*/ |
||||||
|
public BasicQueryContract setFetchSize(int fetchSize); |
||||||
|
|
||||||
|
/** |
||||||
|
* Should entities and proxies loaded by this Query be put in read-only mode? If the |
||||||
|
* read-only/modifiable setting was not initialized, then the default |
||||||
|
* read-only/modifiable setting for the persistence context is returned instead. |
||||||
|
* @see Query#setReadOnly(boolean) |
||||||
|
* @see com.fr.third.org.hibernate.engine.spi.PersistenceContext#isDefaultReadOnly() |
||||||
|
* |
||||||
|
* The read-only/modifiable setting has no impact on entities/proxies returned by the |
||||||
|
* query that existed in the session before the query was executed. |
||||||
|
* |
||||||
|
* @return true, entities and proxies loaded by the query will be put in read-only mode |
||||||
|
* false, entities and proxies loaded by the query will be put in modifiable mode |
||||||
|
*/ |
||||||
|
public boolean isReadOnly(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the read-only/modifiable mode for entities and proxies |
||||||
|
* loaded by this Query. This setting overrides the default setting |
||||||
|
* for the persistence context. |
||||||
|
* @see com.fr.third.org.hibernate.engine.spi.PersistenceContext#isDefaultReadOnly() |
||||||
|
* |
||||||
|
* To set the default read-only/modifiable setting used for |
||||||
|
* entities and proxies that are loaded into the session: |
||||||
|
* @see com.fr.third.org.hibernate.engine.spi.PersistenceContext#setDefaultReadOnly(boolean) |
||||||
|
* @see com.fr.third.org.hibernate.Session#setDefaultReadOnly(boolean) |
||||||
|
* |
||||||
|
* Read-only entities are not dirty-checked and snapshots of persistent |
||||||
|
* state are not maintained. Read-only entities can be modified, but |
||||||
|
* changes are not persisted. |
||||||
|
* |
||||||
|
* When a proxy is initialized, the loaded entity will have the same |
||||||
|
* read-only/modifiable setting as the uninitialized |
||||||
|
* proxy has, regardless of the session's current setting. |
||||||
|
* |
||||||
|
* The read-only/modifiable setting has no impact on entities/proxies |
||||||
|
* returned by the query that existed in the session before the query was executed. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
* |
||||||
|
* @param readOnly true, entities and proxies loaded by the query will be put in read-only mode |
||||||
|
* false, entities and proxies loaded by the query will be put in modifiable mode |
||||||
|
*/ |
||||||
|
public BasicQueryContract setReadOnly(boolean readOnly); |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the Hibernate types of the query results. |
||||||
|
* |
||||||
|
* @return an array of types |
||||||
|
*/ |
||||||
|
public Type[] getReturnTypes(); |
||||||
|
} |
@ -0,0 +1,178 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* Provides an API for querying/managing the second level cache regions. |
||||||
|
* <p/> |
||||||
|
* CAUTION: None of these methods respect any isolation or transactional |
||||||
|
* semantics associated with the underlying caches. Specifically, evictions |
||||||
|
* perform an immediate "hard" removal outside any transactions and/or locking |
||||||
|
* scheme(s). |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public interface Cache { |
||||||
|
/** |
||||||
|
* Determine whether the cache contains data for the given entity "instance". |
||||||
|
* <p/> |
||||||
|
* The semantic here is whether the cache contains data visible for the |
||||||
|
* current call context. |
||||||
|
* |
||||||
|
* @param entityClass The entity class. |
||||||
|
* @param identifier The entity identifier |
||||||
|
* |
||||||
|
* @return True if the underlying cache contains corresponding data; false |
||||||
|
* otherwise. |
||||||
|
*/ |
||||||
|
public boolean containsEntity(Class entityClass, Serializable identifier); |
||||||
|
|
||||||
|
/** |
||||||
|
* Determine whether the cache contains data for the given entity "instance". |
||||||
|
* <p/> |
||||||
|
* The semantic here is whether the cache contains data visible for the |
||||||
|
* current call context. |
||||||
|
* |
||||||
|
* @param entityName The entity name. |
||||||
|
* @param identifier The entity identifier |
||||||
|
* |
||||||
|
* @return True if the underlying cache contains corresponding data; false otherwise. |
||||||
|
*/ |
||||||
|
public boolean containsEntity(String entityName, Serializable identifier); |
||||||
|
|
||||||
|
/** |
||||||
|
* Evicts the entity data for a particular entity "instance". |
||||||
|
* |
||||||
|
* @param entityClass The entity class. |
||||||
|
* @param identifier The entity identifier |
||||||
|
*/ |
||||||
|
public void evictEntity(Class entityClass, Serializable identifier); |
||||||
|
|
||||||
|
/** |
||||||
|
* Evicts the entity data for a particular entity "instance". |
||||||
|
* |
||||||
|
* @param entityName The entity name. |
||||||
|
* @param identifier The entity identifier |
||||||
|
*/ |
||||||
|
public void evictEntity(String entityName, Serializable identifier); |
||||||
|
|
||||||
|
/** |
||||||
|
* Evicts all entity data from the given region (i.e. for all entities of |
||||||
|
* type). |
||||||
|
* |
||||||
|
* @param entityClass The entity class. |
||||||
|
*/ |
||||||
|
public void evictEntityRegion(Class entityClass); |
||||||
|
|
||||||
|
/** |
||||||
|
* Evicts all entity data from the given region (i.e. for all entities of |
||||||
|
* type). |
||||||
|
* |
||||||
|
* @param entityName The entity name. |
||||||
|
*/ |
||||||
|
public void evictEntityRegion(String entityName); |
||||||
|
|
||||||
|
/** |
||||||
|
* Evict data from all entity regions. |
||||||
|
*/ |
||||||
|
public void evictEntityRegions(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Evicts all naturalId data from the given region (i.e. for all entities of |
||||||
|
* type). |
||||||
|
* |
||||||
|
* @param naturalIdClass The naturalId class. |
||||||
|
*/ |
||||||
|
@SuppressWarnings( {"UnusedDeclaration"}) |
||||||
|
public void evictNaturalIdRegion(Class naturalIdClass); |
||||||
|
|
||||||
|
/** |
||||||
|
* Evicts all naturalId data from the given region (i.e. for all entities of |
||||||
|
* type). |
||||||
|
* |
||||||
|
* @param naturalIdName The naturalId name. |
||||||
|
*/ |
||||||
|
public void evictNaturalIdRegion(String naturalIdName); |
||||||
|
|
||||||
|
/** |
||||||
|
* Evict data from all naturalId regions. |
||||||
|
*/ |
||||||
|
public void evictNaturalIdRegions(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Determine whether the cache contains data for the given collection. |
||||||
|
* <p/> |
||||||
|
* The semantic here is whether the cache contains data visible for the |
||||||
|
* current call context. |
||||||
|
* |
||||||
|
* @param role The name of the collection role (in form |
||||||
|
* [owner-entity-name].[collection-property-name]) whose regions should be |
||||||
|
* evicted. |
||||||
|
* @param ownerIdentifier The identifier of the owning entity |
||||||
|
* |
||||||
|
* @return True if the underlying cache contains corresponding data; false otherwise. |
||||||
|
*/ |
||||||
|
@SuppressWarnings( {"UnusedDeclaration"}) |
||||||
|
public boolean containsCollection(String role, Serializable ownerIdentifier); |
||||||
|
|
||||||
|
/** |
||||||
|
* Evicts the cache data for the given identified collection instance. |
||||||
|
* |
||||||
|
* @param role The "collection role" (in form [owner-entity-name].[collection-property-name]). |
||||||
|
* @param ownerIdentifier The identifier of the owning entity |
||||||
|
*/ |
||||||
|
public void evictCollection(String role, Serializable ownerIdentifier); |
||||||
|
|
||||||
|
/** |
||||||
|
* Evicts all entity data from the given region (i.e. evicts cached data |
||||||
|
* for all of the specified collection role). |
||||||
|
* |
||||||
|
* @param role The "collection role" (in form [owner-entity-name].[collection-property-name]). |
||||||
|
*/ |
||||||
|
public void evictCollectionRegion(String role); |
||||||
|
|
||||||
|
/** |
||||||
|
* Evict data from all collection regions. |
||||||
|
*/ |
||||||
|
public void evictCollectionRegions(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Determine whether the cache contains data for the given query. |
||||||
|
* <p/> |
||||||
|
* The semantic here is whether the cache contains any data for the given |
||||||
|
* region name since query result caches are not transactionally isolated. |
||||||
|
* |
||||||
|
* @param regionName The cache name given to the query. |
||||||
|
* |
||||||
|
* @return True if the underlying cache contains corresponding data; false otherwise. |
||||||
|
*/ |
||||||
|
@SuppressWarnings( {"UnusedDeclaration"}) |
||||||
|
public boolean containsQuery(String regionName); |
||||||
|
|
||||||
|
/** |
||||||
|
* Evicts all cached query results from the default region. |
||||||
|
*/ |
||||||
|
public void evictDefaultQueryRegion(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Evicts all cached query results under the given name. |
||||||
|
* |
||||||
|
* @param regionName The cache name associated to the queries being cached. |
||||||
|
*/ |
||||||
|
public void evictQueryRegion(String regionName); |
||||||
|
|
||||||
|
/** |
||||||
|
* Evict data from all query regions. |
||||||
|
*/ |
||||||
|
public void evictQueryRegions(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Evict all data from the cache. |
||||||
|
*/ |
||||||
|
public void evictAllRegions(); |
||||||
|
} |
@ -0,0 +1,94 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.util.Locale; |
||||||
|
|
||||||
|
/** |
||||||
|
* Controls how the session interacts with the second-level cache and query cache. |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
* @author Strong Liu |
||||||
|
* @see Session#setCacheMode(CacheMode) |
||||||
|
*/ |
||||||
|
public enum CacheMode { |
||||||
|
/** |
||||||
|
* The session may read items from the cache, and add items to the cache. |
||||||
|
*/ |
||||||
|
NORMAL( true, true ), |
||||||
|
/** |
||||||
|
* The session will never interact with the cache, except to invalidate |
||||||
|
* cache items when updates occur. |
||||||
|
*/ |
||||||
|
IGNORE( false, false ), |
||||||
|
/** |
||||||
|
* The session may read items from the cache, but will not add items, |
||||||
|
* except to invalidate items when updates occur. |
||||||
|
*/ |
||||||
|
GET( false, true ), |
||||||
|
/** |
||||||
|
* The session will never read items from the cache, but will add items |
||||||
|
* to the cache as it reads them from the database. |
||||||
|
*/ |
||||||
|
PUT( true, false ), |
||||||
|
/** |
||||||
|
* The session will never read items from the cache, but will add items |
||||||
|
* to the cache as it reads them from the database. In this mode, the |
||||||
|
* effect of <tt>hibernate.cache.use_minimal_puts</tt> is bypassed, in |
||||||
|
* order to <em>force</em> a cache refresh. |
||||||
|
*/ |
||||||
|
REFRESH( true, false ); |
||||||
|
|
||||||
|
|
||||||
|
private final boolean isPutEnabled; |
||||||
|
private final boolean isGetEnabled; |
||||||
|
|
||||||
|
private CacheMode( boolean isPutEnabled, boolean isGetEnabled) { |
||||||
|
this.isPutEnabled = isPutEnabled; |
||||||
|
this.isGetEnabled = isGetEnabled; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Does this cache mode indicate that reads are allowed? |
||||||
|
* |
||||||
|
* @return {@code true} if cache reads are allowed; {@code false} otherwise. |
||||||
|
*/ |
||||||
|
public boolean isGetEnabled() { |
||||||
|
return isGetEnabled; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Does this cache mode indicate that writes are allowed? |
||||||
|
* |
||||||
|
* @return {@code true} if cache writes are allowed; {@code false} otherwise. |
||||||
|
*/ |
||||||
|
public boolean isPutEnabled() { |
||||||
|
return isPutEnabled; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Used to interpret externalized forms of this enum. |
||||||
|
* |
||||||
|
* @param setting The externalized form. |
||||||
|
* |
||||||
|
* @return The matching enum value. |
||||||
|
* |
||||||
|
* @throws MappingException Indicates the external form was not recognized as a valid enum value. |
||||||
|
*/ |
||||||
|
public static CacheMode interpretExternalSetting(String setting) { |
||||||
|
if (setting == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
try { |
||||||
|
return CacheMode.valueOf( setting.toUpperCase(Locale.ROOT) ); |
||||||
|
} |
||||||
|
catch ( IllegalArgumentException e ) { |
||||||
|
throw new MappingException( "Unknown Cache Mode: " + setting ); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Intended to be thrown from {@link com.fr.third.org.hibernate.classic.Lifecycle} and {@link Interceptor} callbacks. |
||||||
|
* <p/> |
||||||
|
* IMPL NOTE : This is a legacy exception type from back in the day before Hibernate moved to a untyped (runtime) |
||||||
|
* exception strategy. |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class CallbackException extends HibernateException { |
||||||
|
/** |
||||||
|
* Creates a CallbackException using the given underlying cause. |
||||||
|
* |
||||||
|
* @param cause The underlying cause |
||||||
|
*/ |
||||||
|
public CallbackException(Exception cause) { |
||||||
|
this( "An exception occurred in a callback", cause ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Creates a CallbackException using the given message. |
||||||
|
* |
||||||
|
* @param message The message explaining the reason for the exception |
||||||
|
*/ |
||||||
|
public CallbackException(String message) { |
||||||
|
super( message ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Creates a CallbackException using the given message and underlying cause. |
||||||
|
* |
||||||
|
* @param message The message explaining the reason for the exception |
||||||
|
* @param cause The underlying cause |
||||||
|
*/ |
||||||
|
public CallbackException(String message, Exception cause) { |
||||||
|
super( message, cause ); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Indicates the manner in which JDBC Connections should be acquired. Inverse to |
||||||
|
* {@link com.fr.third.org.hibernate.ConnectionReleaseMode}. |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public enum ConnectionAcquisitionMode { |
||||||
|
/** |
||||||
|
* The Connection will be acquired as soon as the Hibernate Session is opened. This |
||||||
|
* also circumvents ConnectionReleaseMode, as the Connection will then be held until the |
||||||
|
* Session is closed. |
||||||
|
*/ |
||||||
|
IMMEDIATELY, |
||||||
|
/** |
||||||
|
* The legacy behavior. A Connection is only acquired when (if) it is actually needed. |
||||||
|
*/ |
||||||
|
AS_NEEDED; |
||||||
|
|
||||||
|
public static ConnectionAcquisitionMode interpret(String value) { |
||||||
|
if ( value != null |
||||||
|
&& ( "immediate".equalsIgnoreCase( value ) || "immediately".equalsIgnoreCase( value ) ) ) { |
||||||
|
return IMMEDIATELY; |
||||||
|
} |
||||||
|
|
||||||
|
return AS_NEEDED; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,51 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.util.Locale; |
||||||
|
|
||||||
|
/** |
||||||
|
* Defines the various policies by which Hibernate might release its underlying |
||||||
|
* JDBC connection. Inverse of {@link ConnectionAcquisitionMode}. |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public enum ConnectionReleaseMode{ |
||||||
|
/** |
||||||
|
* Indicates that JDBC connection should be aggressively released after each |
||||||
|
* SQL statement is executed. In this mode, the application <em>must</em> |
||||||
|
* explicitly close all iterators and scrollable results. This mode may |
||||||
|
* only be used with a JTA datasource. |
||||||
|
*/ |
||||||
|
AFTER_STATEMENT, |
||||||
|
|
||||||
|
/** |
||||||
|
* Indicates that JDBC connections should be released after each transaction |
||||||
|
* ends (works with both JTA-registered synch and HibernateTransaction API). |
||||||
|
* This mode may not be used with an application server JTA datasource. |
||||||
|
* <p/> |
||||||
|
* This is the default mode starting in 3.1; was previously {@link #ON_CLOSE}. |
||||||
|
*/ |
||||||
|
AFTER_TRANSACTION, |
||||||
|
|
||||||
|
/** |
||||||
|
* Indicates that connections should only be released when the Session is explicitly closed |
||||||
|
* or disconnected; this is the legacy (Hibernate2 and pre-3.1) behavior. |
||||||
|
*/ |
||||||
|
ON_CLOSE; |
||||||
|
|
||||||
|
/** |
||||||
|
* Alias for {@link ConnectionReleaseMode#valueOf(String)} using upper-case version of the incoming name. |
||||||
|
* |
||||||
|
* @param name The name to parse |
||||||
|
* |
||||||
|
* @return The matched enum value. |
||||||
|
*/ |
||||||
|
public static ConnectionReleaseMode parse(final String name) { |
||||||
|
return ConnectionReleaseMode.valueOf( name.toUpperCase(Locale.ROOT) ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,566 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.criterion.CriteriaSpecification; |
||||||
|
import com.fr.third.org.hibernate.criterion.Criterion; |
||||||
|
import com.fr.third.org.hibernate.criterion.Order; |
||||||
|
import com.fr.third.org.hibernate.criterion.Projection; |
||||||
|
import com.fr.third.org.hibernate.sql.JoinType; |
||||||
|
import com.fr.third.org.hibernate.transform.ResultTransformer; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* <tt>Criteria</tt> is a simplified API for retrieving entities |
||||||
|
* by composing <tt>Criterion</tt> objects. This is a very |
||||||
|
* convenient approach for functionality like "search" screens |
||||||
|
* where there is a variable number of conditions to be placed |
||||||
|
* upon the result set.<br> |
||||||
|
* <br> |
||||||
|
* The <tt>Session</tt> is a factory for <tt>Criteria</tt>. |
||||||
|
* <tt>Criterion</tt> instances are usually obtained via |
||||||
|
* the factory methods on <tt>Restrictions</tt>. eg. |
||||||
|
* <pre> |
||||||
|
* List cats = session.createCriteria(Cat.class) |
||||||
|
* .add( Restrictions.like("name", "Iz%") ) |
||||||
|
* .add( Restrictions.gt( "weight", new Float(minWeight) ) ) |
||||||
|
* .addOrder( Order.asc("age") ) |
||||||
|
* .list(); |
||||||
|
* </pre> |
||||||
|
* You may navigate associations using <tt>createAlias()</tt> or |
||||||
|
* <tt>createCriteria()</tt>. |
||||||
|
* <pre> |
||||||
|
* List cats = session.createCriteria(Cat.class) |
||||||
|
* .createCriteria("kittens") |
||||||
|
* .add( Restrictions.like("name", "Iz%") ) |
||||||
|
* .list(); |
||||||
|
* </pre> |
||||||
|
* <pre> |
||||||
|
* List cats = session.createCriteria(Cat.class) |
||||||
|
* .createAlias("kittens", "kit") |
||||||
|
* .add( Restrictions.like("kit.name", "Iz%") ) |
||||||
|
* .list(); |
||||||
|
* </pre> |
||||||
|
* You may specify projection and aggregation using <tt>Projection</tt> |
||||||
|
* instances obtained via the factory methods on <tt>Projections</tt>. |
||||||
|
* <pre> |
||||||
|
* List cats = session.createCriteria(Cat.class) |
||||||
|
* .setProjection( Projections.projectionList() |
||||||
|
* .add( Projections.rowCount() ) |
||||||
|
* .add( Projections.avg("weight") ) |
||||||
|
* .add( Projections.max("weight") ) |
||||||
|
* .add( Projections.min("weight") ) |
||||||
|
* .add( Projections.groupProperty("color") ) |
||||||
|
* ) |
||||||
|
* .addOrder( Order.asc("color") ) |
||||||
|
* .list(); |
||||||
|
* </pre> |
||||||
|
* |
||||||
|
* @see Session#createCriteria(java.lang.Class) |
||||||
|
* @see com.fr.third.org.hibernate.criterion.Restrictions |
||||||
|
* @see com.fr.third.org.hibernate.criterion.Projections |
||||||
|
* @see com.fr.third.org.hibernate.criterion.Order |
||||||
|
* @see com.fr.third.org.hibernate.criterion.Criterion |
||||||
|
* @see com.fr.third.org.hibernate.criterion.Projection |
||||||
|
* @see com.fr.third.org.hibernate.criterion.DetachedCriteria a disconnected version of this API |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public interface Criteria extends CriteriaSpecification { |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the alias of the entity encapsulated by this criteria instance. |
||||||
|
* |
||||||
|
* @return The alias for the encapsulated entity. |
||||||
|
*/ |
||||||
|
public String getAlias(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Used to specify that the query results will be a projection (scalar in |
||||||
|
* nature). Implicitly specifies the {@link #PROJECTION} result transformer. |
||||||
|
* <p/> |
||||||
|
* The individual components contained within the given |
||||||
|
* {@link Projection projection} determines the overall "shape" of the |
||||||
|
* query result. |
||||||
|
* |
||||||
|
* @param projection The projection representing the overall "shape" of the |
||||||
|
* query results. |
||||||
|
* @return this (for method chaining) |
||||||
|
*/ |
||||||
|
public Criteria setProjection(Projection projection); |
||||||
|
|
||||||
|
/** |
||||||
|
* Add a {@link Criterion restriction} to constrain the results to be |
||||||
|
* retrieved. |
||||||
|
* |
||||||
|
* @param criterion The {@link Criterion criterion} object representing the |
||||||
|
* restriction to be applied. |
||||||
|
* @return this (for method chaining) |
||||||
|
*/ |
||||||
|
public Criteria add(Criterion criterion); |
||||||
|
|
||||||
|
/** |
||||||
|
* Add an {@link Order ordering} to the result set. |
||||||
|
* |
||||||
|
* @param order The {@link Order order} object representing an ordering |
||||||
|
* to be applied to the results. |
||||||
|
* @return this (for method chaining) |
||||||
|
*/ |
||||||
|
public Criteria addOrder(Order order); |
||||||
|
|
||||||
|
/** |
||||||
|
* Specify an association fetching strategy for an association or a |
||||||
|
* collection of values. |
||||||
|
* |
||||||
|
* @param associationPath a dot separated property path |
||||||
|
* @param mode The fetch mode for the referenced association |
||||||
|
* |
||||||
|
* @return this (for method chaining) |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem applying the given fetch mode |
||||||
|
*/ |
||||||
|
public Criteria setFetchMode(String associationPath, FetchMode mode) throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the lock mode of the current entity. |
||||||
|
* |
||||||
|
* @param lockMode The lock mode to be applied |
||||||
|
* |
||||||
|
* @return this (for method chaining) |
||||||
|
*/ |
||||||
|
public Criteria setLockMode(LockMode lockMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the lock mode of the aliased entity. |
||||||
|
* |
||||||
|
* @param alias The previously assigned alias representing the entity to |
||||||
|
* which the given lock mode should apply. |
||||||
|
* @param lockMode The lock mode to be applied |
||||||
|
* |
||||||
|
* @return this (for method chaining) |
||||||
|
*/ |
||||||
|
public Criteria setLockMode(String alias, LockMode lockMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Join an association, assigning an alias to the joined association. |
||||||
|
* <p/> |
||||||
|
* Functionally equivalent to {@link #createAlias(String, String, JoinType )} using |
||||||
|
* {@link JoinType#INNER_JOIN} for the joinType. |
||||||
|
* |
||||||
|
* @param associationPath A dot-separated property path |
||||||
|
* @param alias The alias to assign to the joined association (for later reference). |
||||||
|
* |
||||||
|
* @return this (for method chaining) |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem creating the sub criteria |
||||||
|
*/ |
||||||
|
public Criteria createAlias(String associationPath, String alias) throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Join an association using the specified join-type, assigning an alias |
||||||
|
* to the joined association. |
||||||
|
* <p/> |
||||||
|
* The joinType is expected to be one of {@link JoinType#INNER_JOIN} (the default), |
||||||
|
* {@link JoinType#FULL_JOIN}, or {@link JoinType#LEFT_OUTER_JOIN}. |
||||||
|
* |
||||||
|
* @param associationPath A dot-separated property path |
||||||
|
* @param alias The alias to assign to the joined association (for later reference). |
||||||
|
* @param joinType The type of join to use. |
||||||
|
* |
||||||
|
* @return this (for method chaining) |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem creating the sub criteria |
||||||
|
*/ |
||||||
|
public Criteria createAlias(String associationPath, String alias, JoinType joinType) throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Join an association using the specified join-type, assigning an alias |
||||||
|
* to the joined association. |
||||||
|
* <p/> |
||||||
|
* The joinType is expected to be one of {@link #INNER_JOIN} (the default), |
||||||
|
* {@link #FULL_JOIN}, or {@link #LEFT_JOIN}. |
||||||
|
* |
||||||
|
* @param associationPath A dot-separated property path |
||||||
|
* @param alias The alias to assign to the joined association (for later reference). |
||||||
|
* @param joinType The type of join to use. |
||||||
|
* |
||||||
|
* @return this (for method chaining) |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem creating the sub criteria |
||||||
|
* @deprecated use {@link #createAlias(String, String, com.fr.third.org.hibernate.sql.JoinType)} |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public Criteria createAlias(String associationPath, String alias, int joinType) throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Join an association using the specified join-type, assigning an alias |
||||||
|
* to the joined association. |
||||||
|
* <p/> |
||||||
|
* The joinType is expected to be one of {@link JoinType#INNER_JOIN} (the default), |
||||||
|
* {@link JoinType#FULL_JOIN}, or {@link JoinType#LEFT_OUTER_JOIN}. |
||||||
|
* |
||||||
|
* @param associationPath A dot-separated property path |
||||||
|
* @param alias The alias to assign to the joined association (for later reference). |
||||||
|
* @param joinType The type of join to use. |
||||||
|
* @param withClause The criteria to be added to the join condition (<tt>ON</tt> clause) |
||||||
|
* |
||||||
|
* @return this (for method chaining) |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem creating the sub criteria |
||||||
|
*/ |
||||||
|
public Criteria createAlias(String associationPath, String alias, JoinType joinType, Criterion withClause) throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Join an association using the specified join-type, assigning an alias |
||||||
|
* to the joined association. |
||||||
|
* <p/> |
||||||
|
* The joinType is expected to be one of {@link #INNER_JOIN} (the default), |
||||||
|
* {@link #FULL_JOIN}, or {@link #LEFT_JOIN}. |
||||||
|
* |
||||||
|
* @param associationPath A dot-separated property path |
||||||
|
* @param alias The alias to assign to the joined association (for later reference). |
||||||
|
* @param joinType The type of join to use. |
||||||
|
* @param withClause The criteria to be added to the join condition (<tt>ON</tt> clause) |
||||||
|
* |
||||||
|
* @return this (for method chaining) |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem creating the sub criteria |
||||||
|
* @deprecated use {@link #createAlias(String, String, JoinType, Criterion)} |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public Criteria createAlias(String associationPath, String alias, int joinType, Criterion withClause) throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity. |
||||||
|
* <p/> |
||||||
|
* Functionally equivalent to {@link #createCriteria(String, com.fr.third.org.hibernate.sql.JoinType)} using |
||||||
|
* {@link JoinType#INNER_JOIN} for the joinType. |
||||||
|
* |
||||||
|
* @param associationPath A dot-separated property path |
||||||
|
* |
||||||
|
* @return the created "sub criteria" |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem creating the sub criteria |
||||||
|
*/ |
||||||
|
public Criteria createCriteria(String associationPath) throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity, using the |
||||||
|
* specified join type. |
||||||
|
* |
||||||
|
* @param associationPath A dot-separated property path |
||||||
|
* @param joinType The type of join to use. |
||||||
|
* |
||||||
|
* @return the created "sub criteria" |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem creating the sub criteria |
||||||
|
*/ |
||||||
|
public Criteria createCriteria(String associationPath, JoinType joinType) throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity, using the |
||||||
|
* specified join type. |
||||||
|
* |
||||||
|
* @param associationPath A dot-separated property path |
||||||
|
* @param joinType The type of join to use. |
||||||
|
* |
||||||
|
* @return the created "sub criteria" |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem creating the sub criteria |
||||||
|
* @deprecated use {@link #createAlias(String, String, com.fr.third.org.hibernate.sql.JoinType)} |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public Criteria createCriteria(String associationPath, int joinType) throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity, |
||||||
|
* assigning the given alias. |
||||||
|
* <p/> |
||||||
|
* Functionally equivalent to {@link #createCriteria(String, String, com.fr.third.org.hibernate.sql.JoinType)} using |
||||||
|
* {@link JoinType#INNER_JOIN} for the joinType. |
||||||
|
* |
||||||
|
* @param associationPath A dot-separated property path |
||||||
|
* @param alias The alias to assign to the joined association (for later reference). |
||||||
|
* |
||||||
|
* @return the created "sub criteria" |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem creating the sub criteria |
||||||
|
*/ |
||||||
|
public Criteria createCriteria(String associationPath, String alias) throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity, |
||||||
|
* assigning the given alias and using the specified join type. |
||||||
|
* |
||||||
|
* @param associationPath A dot-separated property path |
||||||
|
* @param alias The alias to assign to the joined association (for later reference). |
||||||
|
* @param joinType The type of join to use. |
||||||
|
* |
||||||
|
* @return the created "sub criteria" |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem creating the sub criteria |
||||||
|
*/ |
||||||
|
public Criteria createCriteria(String associationPath, String alias, JoinType joinType) throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity, |
||||||
|
* assigning the given alias and using the specified join type. |
||||||
|
* |
||||||
|
* @param associationPath A dot-separated property path |
||||||
|
* @param alias The alias to assign to the joined association (for later reference). |
||||||
|
* @param joinType The type of join to use. |
||||||
|
* |
||||||
|
* @return the created "sub criteria" |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem creating the sub criteria |
||||||
|
* @deprecated use {@link #createCriteria(String, com.fr.third.org.hibernate.sql.JoinType)} |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public Criteria createCriteria(String associationPath, String alias, int joinType) throws HibernateException; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity, |
||||||
|
* assigning the given alias and using the specified join type. |
||||||
|
* |
||||||
|
* @param associationPath A dot-separated property path |
||||||
|
* @param alias The alias to assign to the joined association (for later reference). |
||||||
|
* @param joinType The type of join to use. |
||||||
|
* @param withClause The criteria to be added to the join condition (<tt>ON</tt> clause) |
||||||
|
* |
||||||
|
* @return the created "sub criteria" |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem creating the sub criteria |
||||||
|
*/ |
||||||
|
public Criteria createCriteria(String associationPath, String alias, JoinType joinType, Criterion withClause) throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new <tt>Criteria</tt>, "rooted" at the associated entity, |
||||||
|
* assigning the given alias and using the specified join type. |
||||||
|
* |
||||||
|
* @param associationPath A dot-separated property path |
||||||
|
* @param alias The alias to assign to the joined association (for later reference). |
||||||
|
* @param joinType The type of join to use. |
||||||
|
* @param withClause The criteria to be added to the join condition (<tt>ON</tt> clause) |
||||||
|
* |
||||||
|
* @return the created "sub criteria" |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem creating the sub criteria |
||||||
|
* @deprecated use {@link #createCriteria(String, String, com.fr.third.org.hibernate.sql.JoinType, com.fr.third.org.hibernate.criterion.Criterion)} |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public Criteria createCriteria(String associationPath, String alias, int joinType, Criterion withClause) throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Set a strategy for handling the query results. This determines the |
||||||
|
* "shape" of the query result. |
||||||
|
* |
||||||
|
* @param resultTransformer The transformer to apply |
||||||
|
* @return this (for method chaining) |
||||||
|
* |
||||||
|
* @see #ROOT_ENTITY |
||||||
|
* @see #DISTINCT_ROOT_ENTITY |
||||||
|
* @see #ALIAS_TO_ENTITY_MAP |
||||||
|
* @see #PROJECTION |
||||||
|
*/ |
||||||
|
public Criteria setResultTransformer(ResultTransformer resultTransformer); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set a limit upon the number of objects to be retrieved. |
||||||
|
* |
||||||
|
* @param maxResults the maximum number of results |
||||||
|
* @return this (for method chaining) |
||||||
|
*/ |
||||||
|
public Criteria setMaxResults(int maxResults); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the first result to be retrieved. |
||||||
|
* |
||||||
|
* @param firstResult the first result to retrieve, numbered from <tt>0</tt> |
||||||
|
* @return this (for method chaining) |
||||||
|
*/ |
||||||
|
public Criteria setFirstResult(int firstResult); |
||||||
|
|
||||||
|
/** |
||||||
|
* Was the read-only/modifiable mode explicitly initialized? |
||||||
|
* |
||||||
|
* @return true, the read-only/modifiable mode was explicitly initialized; false, otherwise. |
||||||
|
* |
||||||
|
* @see Criteria#setReadOnly(boolean) |
||||||
|
*/ |
||||||
|
public boolean isReadOnlyInitialized(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Should entities and proxies loaded by this Criteria be put in read-only mode? If the |
||||||
|
* read-only/modifiable setting was not initialized, then the default |
||||||
|
* read-only/modifiable setting for the persistence context is returned instead. |
||||||
|
* @see Criteria#setReadOnly(boolean) |
||||||
|
* @see com.fr.third.org.hibernate.engine.spi.PersistenceContext#isDefaultReadOnly() |
||||||
|
* |
||||||
|
* The read-only/modifiable setting has no impact on entities/proxies returned by the |
||||||
|
* Criteria that existed in the session before the Criteria was executed. |
||||||
|
* |
||||||
|
* @return true, entities and proxies loaded by the criteria will be put in read-only mode |
||||||
|
* false, entities and proxies loaded by the criteria will be put in modifiable mode |
||||||
|
* @throws IllegalStateException if <code>isReadOnlyInitialized()</code> returns <code>false</code> |
||||||
|
* and this Criteria is not associated with a session. |
||||||
|
* @see Criteria#isReadOnlyInitialized() |
||||||
|
*/ |
||||||
|
public boolean isReadOnly(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the read-only/modifiable mode for entities and proxies |
||||||
|
* loaded by this Criteria. This setting overrides the default setting |
||||||
|
* for the persistence context. |
||||||
|
* @see com.fr.third.org.hibernate.engine.spi.PersistenceContext#isDefaultReadOnly() |
||||||
|
* |
||||||
|
* To set the default read-only/modifiable setting used for |
||||||
|
* entities and proxies that are loaded into the session: |
||||||
|
* @see com.fr.third.org.hibernate.engine.spi.PersistenceContext#setDefaultReadOnly(boolean) |
||||||
|
* @see com.fr.third.org.hibernate.Session#setDefaultReadOnly(boolean) |
||||||
|
* |
||||||
|
* Read-only entities are not dirty-checked and snapshots of persistent |
||||||
|
* state are not maintained. Read-only entities can be modified, but |
||||||
|
* changes are not persisted. |
||||||
|
* |
||||||
|
* When a proxy is initialized, the loaded entity will have the same |
||||||
|
* read-only/modifiable setting as the uninitialized |
||||||
|
* proxy has, regardless of the session's current setting. |
||||||
|
* |
||||||
|
* The read-only/modifiable setting has no impact on entities/proxies |
||||||
|
* returned by the criteria that existed in the session before the criteria was executed. |
||||||
|
* |
||||||
|
* @param readOnly true, entities and proxies loaded by the criteria will be put in read-only mode |
||||||
|
* false, entities and proxies loaded by the criteria will be put in modifiable mode |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Criteria setReadOnly(boolean readOnly); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set a fetch size for the underlying JDBC query. |
||||||
|
* |
||||||
|
* @param fetchSize the fetch size |
||||||
|
* @return this (for method chaining) |
||||||
|
* |
||||||
|
* @see java.sql.Statement#setFetchSize |
||||||
|
*/ |
||||||
|
public Criteria setFetchSize(int fetchSize); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set a timeout for the underlying JDBC query. |
||||||
|
* |
||||||
|
* @param timeout The timeout value to apply. |
||||||
|
* @return this (for method chaining) |
||||||
|
* |
||||||
|
* @see java.sql.Statement#setQueryTimeout |
||||||
|
*/ |
||||||
|
public Criteria setTimeout(int timeout); |
||||||
|
|
||||||
|
/** |
||||||
|
* Enable caching of this query result, provided query caching is enabled |
||||||
|
* for the underlying session factory. |
||||||
|
* |
||||||
|
* @param cacheable Should the result be considered cacheable; default is |
||||||
|
* to not cache (false). |
||||||
|
* @return this (for method chaining) |
||||||
|
*/ |
||||||
|
public Criteria setCacheable(boolean cacheable); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the name of the cache region to use for query result caching. |
||||||
|
* |
||||||
|
* @param cacheRegion the name of a query cache region, or <tt>null</tt> |
||||||
|
* for the default query cache |
||||||
|
* @return this (for method chaining) |
||||||
|
* |
||||||
|
* @see #setCacheable |
||||||
|
*/ |
||||||
|
public Criteria setCacheRegion(String cacheRegion); |
||||||
|
|
||||||
|
/** |
||||||
|
* Add a comment to the generated SQL. |
||||||
|
* |
||||||
|
* @param comment a human-readable string |
||||||
|
* @return this (for method chaining) |
||||||
|
*/ |
||||||
|
public Criteria setComment(String comment); |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Add a DB query hint to the SQL. These differ from JPA's {@link javax.persistence.QueryHint}, which is specific |
||||||
|
* to the JPA implementation and ignores DB vendor-specific hints. Instead, these are intended solely for the |
||||||
|
* vendor-specific hints, such as Oracle's optimizers. Multiple query hints are supported; the Dialect will |
||||||
|
* determine concatenation and placement. |
||||||
|
* |
||||||
|
* @param hint The database specific query hint to add. |
||||||
|
* @return this (for method chaining) |
||||||
|
*/ |
||||||
|
public Criteria addQueryHint(String hint); |
||||||
|
|
||||||
|
/** |
||||||
|
* Override the flush mode for this particular query. |
||||||
|
* |
||||||
|
* @param flushMode The flush mode to use. |
||||||
|
* @return this (for method chaining) |
||||||
|
*/ |
||||||
|
public Criteria setFlushMode(FlushMode flushMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Override the cache mode for this particular query. |
||||||
|
* |
||||||
|
* @param cacheMode The cache mode to use. |
||||||
|
* @return this (for method chaining) |
||||||
|
*/ |
||||||
|
public Criteria setCacheMode(CacheMode cacheMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the results. |
||||||
|
* |
||||||
|
* @return The list of matched query results. |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem either translating the criteria to SQL, |
||||||
|
* exeucting the SQL or processing the SQL results. |
||||||
|
*/ |
||||||
|
public List list() throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the results as an instance of {@link ScrollableResults}. |
||||||
|
* |
||||||
|
* @return The {@link ScrollableResults} representing the matched |
||||||
|
* query results. |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem either translating the criteria to SQL, |
||||||
|
* exeucting the SQL or processing the SQL results. |
||||||
|
*/ |
||||||
|
public ScrollableResults scroll() throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the results as an instance of {@link ScrollableResults} based on the |
||||||
|
* given scroll mode. |
||||||
|
* |
||||||
|
* @param scrollMode Indicates the type of underlying database cursor to |
||||||
|
* request. |
||||||
|
* |
||||||
|
* @return The {@link ScrollableResults} representing the matched |
||||||
|
* query results. |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem either translating the criteria to SQL, |
||||||
|
* exeucting the SQL or processing the SQL results. |
||||||
|
*/ |
||||||
|
public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to return a single instance that matches |
||||||
|
* the query, or null if the query returns no results. |
||||||
|
* |
||||||
|
* @return the single result or <tt>null</tt> |
||||||
|
* @throws HibernateException if there is more than one matching result |
||||||
|
*/ |
||||||
|
public Object uniqueResult() throws HibernateException; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,157 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.persister.entity.EntityPersister; |
||||||
|
import com.fr.third.org.hibernate.type.Type; |
||||||
|
|
||||||
|
/** |
||||||
|
* During a flush cycle, Hibernate needs to determine which of the entities associated with a {@link Session}. |
||||||
|
* Dirty entities are the ones that get {@literal UPDATE}ed to the database. |
||||||
|
* <p/> |
||||||
|
* In some circumstances, that process of determining whether an entity is dirty can take a significant time as |
||||||
|
* by default Hibernate must check each of the entity's attribute values one-by-one. Oftentimes applications |
||||||
|
* already have knowledge of an entity's dirtiness and using that information instead would be more performant. |
||||||
|
* The purpose of this contract then is to allow applications such a plug-in point. |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public interface CustomEntityDirtinessStrategy { |
||||||
|
/** |
||||||
|
* Is this strategy capable of telling whether the given entity is dirty? A return of {@code true} means that |
||||||
|
* {@link #isDirty} will be called next as the definitive means to determine whether the entity is dirty. |
||||||
|
* |
||||||
|
* @param entity The entity to be check. |
||||||
|
* @param persister The persister corresponding to the given entity |
||||||
|
* @param session The session from which this check originates. |
||||||
|
* |
||||||
|
* @return {@code true} indicates the dirty check can be done; {@code false} indicates it cannot. |
||||||
|
*/ |
||||||
|
public boolean canDirtyCheck(Object entity, EntityPersister persister, Session session); |
||||||
|
|
||||||
|
/** |
||||||
|
* The callback used by Hibernate to determine if the given entity is dirty. Only called if the previous |
||||||
|
* {@link #canDirtyCheck} returned {@code true} |
||||||
|
* |
||||||
|
* @param entity The entity to check. |
||||||
|
* @param persister The persister corresponding to the given entity |
||||||
|
* @param session The session from which this check originates. |
||||||
|
* |
||||||
|
* @return {@code true} indicates the entity is dirty; {@link false} indicates the entity is not dirty. |
||||||
|
*/ |
||||||
|
public boolean isDirty(Object entity, EntityPersister persister, Session session); |
||||||
|
|
||||||
|
/** |
||||||
|
* Callback used by Hibernate to signal that the entity dirty flag should be cleared. Generally this |
||||||
|
* happens after previous dirty changes were written to the database. |
||||||
|
* |
||||||
|
* @param entity The entity to reset |
||||||
|
* @param persister The persister corresponding to the given entity |
||||||
|
* @param session The session from which this call originates. |
||||||
|
*/ |
||||||
|
public void resetDirty(Object entity, EntityPersister persister, Session session); |
||||||
|
|
||||||
|
/** |
||||||
|
* Callback used to hook into Hibernate algorithm for determination of which attributes have changed. Applications |
||||||
|
* wanting to hook in to this would call back into the given {@link DirtyCheckContext#doDirtyChecking} |
||||||
|
* method passing along an appropriate {@link AttributeChecker} implementation. |
||||||
|
* |
||||||
|
* @param entity The entity being checked |
||||||
|
* @param persister The persister corresponding to the given entity |
||||||
|
* @param session The session from which this call originates. |
||||||
|
* @param dirtyCheckContext The callback context |
||||||
|
*/ |
||||||
|
public void findDirty(Object entity, EntityPersister persister, Session session, DirtyCheckContext dirtyCheckContext); |
||||||
|
|
||||||
|
/** |
||||||
|
* A callback to drive dirty checking. Handed to the {@link CustomEntityDirtinessStrategy#findDirty} method |
||||||
|
* so that it can callback on to it if it wants to handle dirty checking rather than using Hibernate's default |
||||||
|
* checking |
||||||
|
* |
||||||
|
* @see CustomEntityDirtinessStrategy#findDirty |
||||||
|
*/ |
||||||
|
public static interface DirtyCheckContext { |
||||||
|
/** |
||||||
|
* The callback to indicate that dirty checking (the dirty attribute determination phase) should be handled |
||||||
|
* by the calling {@link CustomEntityDirtinessStrategy} using the given {@link AttributeChecker}. |
||||||
|
* |
||||||
|
* @param attributeChecker The delegate usable by the context for determining which attributes are dirty. |
||||||
|
*/ |
||||||
|
public void doDirtyChecking(AttributeChecker attributeChecker); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Responsible for identifying when attributes are dirty. |
||||||
|
*/ |
||||||
|
public static interface AttributeChecker { |
||||||
|
/** |
||||||
|
* Do the attribute dirty check. |
||||||
|
* |
||||||
|
* @param attributeInformation Information about the attribute which is useful to help determine if it is |
||||||
|
* dirty. |
||||||
|
* |
||||||
|
* @return {@code true} indicates the attribute value has changed; {@code false} indicates it has not. |
||||||
|
*/ |
||||||
|
public boolean isDirty(AttributeInformation attributeInformation); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Provides {@link AttributeChecker} with meta information about the attributes being checked. |
||||||
|
*/ |
||||||
|
@SuppressWarnings( {"UnusedDeclaration"}) |
||||||
|
public static interface AttributeInformation { |
||||||
|
/** |
||||||
|
* Get a reference to the persister for the entity containing this attribute. |
||||||
|
* |
||||||
|
* @return The entity persister. |
||||||
|
*/ |
||||||
|
public EntityPersister getContainingPersister(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Many of Hibernate internals use arrays to define information about attributes. This value |
||||||
|
* provides this index into those arrays for this particular attribute. |
||||||
|
* <p/> |
||||||
|
* It can be useful if needing to leverage those Hibernate internals. |
||||||
|
* |
||||||
|
* @return The attribute index. |
||||||
|
*/ |
||||||
|
public int getAttributeIndex(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the name of this attribute. |
||||||
|
* |
||||||
|
* @return The attribute name |
||||||
|
*/ |
||||||
|
public String getName(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the mapping type of this attribute. |
||||||
|
* |
||||||
|
* @return The mapping type. |
||||||
|
*/ |
||||||
|
public Type getType(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the current value of this attribute. |
||||||
|
* |
||||||
|
* @return The attributes current value |
||||||
|
*/ |
||||||
|
public Object getCurrentValue(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the loaded value of this attribute. |
||||||
|
* <p/> |
||||||
|
* <b>NOTE : A call to this method may require hitting the database in cases where the loaded state is |
||||||
|
* not known. In those cases the db hit is incurred only once per entity, not for each attribute.</b> |
||||||
|
* |
||||||
|
* @return The attributes loaded value |
||||||
|
*/ |
||||||
|
public Object getLoadedValue(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,128 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Raised whenever a duplicate for a certain type occurs. Duplicate class, table, property name etc. |
||||||
|
* |
||||||
|
* @author Max Rydahl Andersen |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public class DuplicateMappingException extends MappingException { |
||||||
|
/** |
||||||
|
* Enumeration of the types of things that can be duplicated. |
||||||
|
*/ |
||||||
|
public static enum Type { |
||||||
|
/** |
||||||
|
* A duplicate entity definition was encountered. |
||||||
|
*/ |
||||||
|
ENTITY( "entity" ), |
||||||
|
/** |
||||||
|
* A duplicate collection role was encountered |
||||||
|
*/ |
||||||
|
COLLECTION( "collection" ), |
||||||
|
/** |
||||||
|
* A duplicate table definition was encountered. |
||||||
|
*/ |
||||||
|
TABLE( "table" ), |
||||||
|
/** |
||||||
|
* A duplicate property/attribute definition was encountered. |
||||||
|
*/ |
||||||
|
PROPERTY( "property" ), |
||||||
|
/** |
||||||
|
* A duplicate column definition was encountered. |
||||||
|
*/ |
||||||
|
COLUMN( "column" ), |
||||||
|
/** |
||||||
|
* A duplicate column definition was encountered. |
||||||
|
*/ |
||||||
|
COLUMN_BINDING( "column-binding" ), |
||||||
|
/** |
||||||
|
* A duplicate named entity graph was encountered |
||||||
|
*/ |
||||||
|
NAMED_ENTITY_GRAPH( "NamedEntityGraph" ), |
||||||
|
/** |
||||||
|
* A duplicate named query (ql or native) was encountered |
||||||
|
*/ |
||||||
|
QUERY( "query" ), |
||||||
|
/** |
||||||
|
* A duplicate ResultSetMapping was encountered |
||||||
|
*/ |
||||||
|
RESULT_SET_MAPPING( "ResultSetMapping" ), |
||||||
|
/** |
||||||
|
* A duplicate NamedStoredProcedureQuery was encountered |
||||||
|
*/ |
||||||
|
PROCEDURE( "NamedStoredProcedureQuery" ); |
||||||
|
|
||||||
|
private final String text; |
||||||
|
|
||||||
|
Type(String text) { |
||||||
|
this.text = text; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private final String name; |
||||||
|
private final String type; |
||||||
|
|
||||||
|
/** |
||||||
|
* Creates a DuplicateMappingException using the given type and name. |
||||||
|
* |
||||||
|
* @param type The type of the duplicated thing. |
||||||
|
* @param name The name of the duplicated thing. |
||||||
|
*/ |
||||||
|
public DuplicateMappingException(Type type, String name) { |
||||||
|
this( type.text, name ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Creates a DuplicateMappingException using the given type and name. |
||||||
|
* |
||||||
|
* @param type The type of the duplicated thing. |
||||||
|
* @param name The name of the duplicated thing. |
||||||
|
* |
||||||
|
* @deprecated Use the for taking {@link Type} instead. |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public DuplicateMappingException(String type, String name) { |
||||||
|
this( "Duplicate " + type + " mapping " + name, type, name ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Creates a DuplicateMappingException using the given customMessage, type and name. |
||||||
|
* |
||||||
|
* @param customMessage A custom exception message explaining the exception condition |
||||||
|
* @param type The type of the duplicated thing. |
||||||
|
* @param name The name of the duplicated thing. |
||||||
|
*/ |
||||||
|
public DuplicateMappingException(String customMessage, Type type, String name) { |
||||||
|
this( customMessage, type.name(), name ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Creates a DuplicateMappingException using the given customMessage, type and name. |
||||||
|
* |
||||||
|
* @param customMessage A custom exception message explaining the exception condition |
||||||
|
* @param type The type of the duplicated thing. |
||||||
|
* @param name The name of the duplicated thing. |
||||||
|
* |
||||||
|
* @deprecated Use the for taking {@link Type} instead. |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public DuplicateMappingException(String customMessage, String type, String name) { |
||||||
|
super( customMessage ); |
||||||
|
this.type=type; |
||||||
|
this.name=name; |
||||||
|
} |
||||||
|
|
||||||
|
public String getType() { |
||||||
|
return type; |
||||||
|
} |
||||||
|
|
||||||
|
public String getName() { |
||||||
|
return name; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,134 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.Iterator; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.type.Type; |
||||||
|
|
||||||
|
/** |
||||||
|
* An interceptor that does nothing. May be used as a base class for application-defined custom interceptors. |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class EmptyInterceptor implements Interceptor, Serializable { |
||||||
|
/** |
||||||
|
* The singleton reference. |
||||||
|
*/ |
||||||
|
public static final Interceptor INSTANCE = new EmptyInterceptor(); |
||||||
|
|
||||||
|
protected EmptyInterceptor() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onDelete( |
||||||
|
Object entity, |
||||||
|
Serializable id, |
||||||
|
Object[] state, |
||||||
|
String[] propertyNames, |
||||||
|
Type[] types) {} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean onFlushDirty( |
||||||
|
Object entity, |
||||||
|
Serializable id, |
||||||
|
Object[] currentState, |
||||||
|
Object[] previousState, |
||||||
|
String[] propertyNames, |
||||||
|
Type[] types) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean onLoad( |
||||||
|
Object entity, |
||||||
|
Serializable id, |
||||||
|
Object[] state, |
||||||
|
String[] propertyNames, |
||||||
|
Type[] types) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean onSave( |
||||||
|
Object entity, |
||||||
|
Serializable id, |
||||||
|
Object[] state, |
||||||
|
String[] propertyNames, |
||||||
|
Type[] types) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void postFlush(Iterator entities) { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void preFlush(Iterator entities) { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Boolean isTransient(Object entity) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object instantiate(String entityName, EntityMode entityMode, Serializable id) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int[] findDirty( |
||||||
|
Object entity, |
||||||
|
Serializable id, |
||||||
|
Object[] currentState, |
||||||
|
Object[] previousState, |
||||||
|
String[] propertyNames, |
||||||
|
Type[] types) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getEntityName(Object object) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object getEntity(String entityName, Serializable id) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void afterTransactionBegin(Transaction tx) { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void afterTransactionCompletion(Transaction tx) { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void beforeTransactionCompletion(Transaction tx) { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String onPrepareStatement(String sql) { |
||||||
|
return sql; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onCollectionRemove(Object collection, Serializable key) throws CallbackException { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException { |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,61 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.util.Locale; |
||||||
|
|
||||||
|
/** |
||||||
|
* Defines the representation modes available for entities. |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public enum EntityMode { |
||||||
|
/** |
||||||
|
* The {@code pojo} entity mode describes an entity model made up of entity classes (loosely) following |
||||||
|
* the java bean convention. |
||||||
|
*/ |
||||||
|
POJO( "pojo" ), |
||||||
|
|
||||||
|
/** |
||||||
|
* The {@code dynamic-map} entity mode describes an entity model defined using {@link java.util.Map} references. |
||||||
|
*/ |
||||||
|
MAP( "dynamic-map" ); |
||||||
|
|
||||||
|
private final String externalName; |
||||||
|
|
||||||
|
private EntityMode(String externalName) { |
||||||
|
this.externalName = externalName; |
||||||
|
} |
||||||
|
|
||||||
|
public String getExternalName() { |
||||||
|
return externalName; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return externalName; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Legacy-style entity-mode name parsing. <b>Case insensitive</b> |
||||||
|
* |
||||||
|
* @param entityMode The entity mode name to evaluate |
||||||
|
* |
||||||
|
* @return The appropriate entity mode; {@code null} for incoming {@code entityMode} param is treated by returning |
||||||
|
* {@link #POJO}. |
||||||
|
*/ |
||||||
|
public static EntityMode parse(String entityMode) { |
||||||
|
if ( entityMode == null ) { |
||||||
|
return POJO; |
||||||
|
} |
||||||
|
if ( MAP.externalName.equalsIgnoreCase( entityMode ) ) { |
||||||
|
return MAP; |
||||||
|
} |
||||||
|
return valueOf( entityMode.toUpperCase( Locale.ENGLISH ) ); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Contract for resolving an entity-name from a given entity instance. |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public interface EntityNameResolver { |
||||||
|
/** |
||||||
|
* Given an entity instance, determine its entity-name. |
||||||
|
* |
||||||
|
* @param entity The entity instance. |
||||||
|
* |
||||||
|
* @return The corresponding entity-name, or null if this impl does not know how to perform resolution |
||||||
|
* for the given entity instance. |
||||||
|
*/ |
||||||
|
public String resolveEntityName(Object entity); |
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Represents an association fetching strategy. This is used |
||||||
|
* together with the <tt>Criteria</tt> API to specify runtime |
||||||
|
* fetching strategies.<br> |
||||||
|
* <br> |
||||||
|
* For HQL queries, use the <tt>FETCH</tt> keyword instead. |
||||||
|
* |
||||||
|
* @see Criteria#setFetchMode(java.lang.String, FetchMode) |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public enum FetchMode { |
||||||
|
/** |
||||||
|
* Default to the setting configured in the mapping file. |
||||||
|
*/ |
||||||
|
DEFAULT, |
||||||
|
|
||||||
|
/** |
||||||
|
* Fetch using an outer join. Equivalent to <tt>fetch="join"</tt>. |
||||||
|
*/ |
||||||
|
JOIN, |
||||||
|
/** |
||||||
|
* Fetch eagerly, using a separate select. Equivalent to |
||||||
|
* <tt>fetch="select"</tt>. |
||||||
|
*/ |
||||||
|
SELECT; |
||||||
|
|
||||||
|
/** |
||||||
|
* Fetch lazily. Equivalent to <tt>outer-join="false"</tt>. |
||||||
|
* |
||||||
|
* @deprecated use <tt>FetchMode.SELECT</tt> |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public static final FetchMode LAZY = SELECT; |
||||||
|
/** |
||||||
|
* Fetch eagerly, using an outer join. Equivalent to <tt>outer-join="true"</tt>. |
||||||
|
* |
||||||
|
* @deprecated use <tt>FetchMode.JOIN</tt> |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public static final FetchMode EAGER = JOIN; |
||||||
|
} |
@ -0,0 +1,72 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
import java.util.Collection; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.engine.spi.FilterDefinition; |
||||||
|
|
||||||
|
/** |
||||||
|
* Type definition of Filter. Filter defines the user's view into enabled dynamic filters, |
||||||
|
* allowing them to set filter parameter values. |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public interface Filter { |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the name of this filter. |
||||||
|
* |
||||||
|
* @return This filter's name. |
||||||
|
*/ |
||||||
|
public String getName(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the filter definition containing additional information about the |
||||||
|
* filter (such as default-condition and expected parameter names/types). |
||||||
|
* |
||||||
|
* @return The filter definition |
||||||
|
*/ |
||||||
|
public FilterDefinition getFilterDefinition(); |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Set the named parameter's value for this filter. |
||||||
|
* |
||||||
|
* @param name The parameter's name. |
||||||
|
* @param value The value to be applied. |
||||||
|
* @return This FilterImpl instance (for method chaining). |
||||||
|
*/ |
||||||
|
public Filter setParameter(String name, Object value); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the named parameter's value list for this filter. Used |
||||||
|
* in conjunction with IN-style filter criteria. |
||||||
|
* |
||||||
|
* @param name The parameter's name. |
||||||
|
* @param values The values to be expanded into an SQL IN list. |
||||||
|
* @return This FilterImpl instance (for method chaining). |
||||||
|
*/ |
||||||
|
public Filter setParameterList(String name, Collection values); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the named parameter's value list for this filter. Used |
||||||
|
* in conjunction with IN-style filter criteria. |
||||||
|
* |
||||||
|
* @param name The parameter's name. |
||||||
|
* @param values The values to be expanded into an SQL IN list. |
||||||
|
* @return This FilterImpl instance (for method chaining). |
||||||
|
*/ |
||||||
|
public Filter setParameterList(String name, Object[] values); |
||||||
|
|
||||||
|
/** |
||||||
|
* Perform validation of the filter state. This is used to verify the |
||||||
|
* state of the filter after its enablement and before its use. |
||||||
|
* |
||||||
|
* @throws HibernateException If the state is not currently valid. |
||||||
|
*/ |
||||||
|
public void validate() throws HibernateException; |
||||||
|
} |
@ -0,0 +1,113 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.util.Locale; |
||||||
|
|
||||||
|
/** |
||||||
|
* Represents a flushing strategy. The flush process synchronizes |
||||||
|
* database state with session state by detecting state changes |
||||||
|
* and executing SQL statements. |
||||||
|
* |
||||||
|
* @see Session#setFlushMode(FlushMode) |
||||||
|
* @see Query#setFlushMode(FlushMode) |
||||||
|
* @see Criteria#setFlushMode(FlushMode) |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public enum FlushMode { |
||||||
|
/** |
||||||
|
* The {@link Session} is never flushed unless {@link Session#flush} |
||||||
|
* is explicitly called by the application. This mode is very |
||||||
|
* efficient for read only transactions. |
||||||
|
* |
||||||
|
* @deprecated use {@link #MANUAL} instead. |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
NEVER ( 0 ), |
||||||
|
|
||||||
|
/** |
||||||
|
* The {@link Session} is only ever flushed when {@link Session#flush} |
||||||
|
* is explicitly called by the application. This mode is very |
||||||
|
* efficient for read only transactions. |
||||||
|
*/ |
||||||
|
MANUAL( 0 ), |
||||||
|
|
||||||
|
/** |
||||||
|
* The {@link Session} is flushed when {@link Transaction#commit} |
||||||
|
* is called. |
||||||
|
*/ |
||||||
|
COMMIT(5 ), |
||||||
|
|
||||||
|
/** |
||||||
|
* The {@link Session} is sometimes flushed before query execution |
||||||
|
* in order to ensure that queries never return stale state. This |
||||||
|
* is the default flush mode. |
||||||
|
*/ |
||||||
|
AUTO(10 ), |
||||||
|
|
||||||
|
/** |
||||||
|
* The {@link Session} is flushed before every query. This is |
||||||
|
* almost always unnecessary and inefficient. |
||||||
|
*/ |
||||||
|
ALWAYS(20 ); |
||||||
|
|
||||||
|
private final int level; |
||||||
|
|
||||||
|
private FlushMode(int level) { |
||||||
|
this.level = level; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Checks to see if {@code this} flush mode is less than the given flush mode. |
||||||
|
* |
||||||
|
* @param other THe flush mode value to be checked against {@code this} |
||||||
|
* |
||||||
|
* @return {@code true} indicates {@code other} is less than {@code this}; {@code false} otherwise |
||||||
|
*/ |
||||||
|
public boolean lessThan(FlushMode other) { |
||||||
|
return this.level < other.level; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Checks to see if the given mode is the same as {@link #MANUAL}. |
||||||
|
* |
||||||
|
* @param mode The mode to check |
||||||
|
* |
||||||
|
* @return true/false |
||||||
|
* |
||||||
|
* @deprecated Just use equality check against {@link #MANUAL}. Legacy from before this was an enum |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public static boolean isManualFlushMode(FlushMode mode) { |
||||||
|
return MANUAL.level == mode.level; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Interprets an external representation of the flush mode. {@code null} is returned as {@code null}, otherwise |
||||||
|
* {@link FlushMode#valueOf(String)} is used with the upper-case version of the incoming value. An unknown, |
||||||
|
* non-null value results in a MappingException being thrown. |
||||||
|
* |
||||||
|
* @param externalName The external representation |
||||||
|
* |
||||||
|
* @return The interpreted FlushMode value. |
||||||
|
* |
||||||
|
* @throws MappingException Indicates an unrecognized external representation |
||||||
|
*/ |
||||||
|
public static FlushMode interpretExternalSetting(String externalName) { |
||||||
|
if ( externalName == null ) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
try { |
||||||
|
return FlushMode.valueOf( externalName.toUpperCase(Locale.ROOT) ); |
||||||
|
} |
||||||
|
catch ( IllegalArgumentException e ) { |
||||||
|
throw new MappingException( "unknown FlushMode : " + externalName ); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,183 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.util.Iterator; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor; |
||||||
|
import com.fr.third.org.hibernate.collection.spi.PersistentCollection; |
||||||
|
import com.fr.third.org.hibernate.engine.HibernateIterator; |
||||||
|
import com.fr.third.org.hibernate.engine.jdbc.LobCreator; |
||||||
|
import com.fr.third.org.hibernate.engine.jdbc.spi.JdbcServices; |
||||||
|
import com.fr.third.org.hibernate.engine.spi.PersistentAttributeInterceptable; |
||||||
|
import com.fr.third.org.hibernate.engine.spi.PersistentAttributeInterceptor; |
||||||
|
import com.fr.third.org.hibernate.engine.spi.SessionImplementor; |
||||||
|
import com.fr.third.org.hibernate.proxy.HibernateProxy; |
||||||
|
import com.fr.third.org.hibernate.proxy.LazyInitializer; |
||||||
|
|
||||||
|
/** |
||||||
|
* <ul> |
||||||
|
* <li>Provides access to the full range of Hibernate built-in types. <tt>Type</tt> |
||||||
|
* instances may be used to bind values to query parameters. |
||||||
|
* <li>A factory for new <tt>Blob</tt>s and <tt>Clob</tt>s. |
||||||
|
* <li>Defines static methods for manipulation of proxies. |
||||||
|
* </ul> |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
* @see java.sql.Clob |
||||||
|
* @see java.sql.Blob |
||||||
|
* @see com.fr.third.org.hibernate.type.Type |
||||||
|
*/ |
||||||
|
|
||||||
|
public final class Hibernate { |
||||||
|
/** |
||||||
|
* Cannot be instantiated. |
||||||
|
*/ |
||||||
|
private Hibernate() { |
||||||
|
throw new UnsupportedOperationException(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Force initialization of a proxy or persistent collection. |
||||||
|
* <p/> |
||||||
|
* Note: This only ensures intialization of a proxy object or collection; |
||||||
|
* it is not guaranteed that the elements INSIDE the collection will be initialized/materialized. |
||||||
|
* |
||||||
|
* @param proxy a persistable object, proxy, persistent collection or <tt>null</tt> |
||||||
|
* @throws HibernateException if we can't initialize the proxy at this time, eg. the <tt>Session</tt> was closed |
||||||
|
*/ |
||||||
|
public static void initialize(Object proxy) throws HibernateException { |
||||||
|
if ( proxy == null ) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if ( proxy instanceof HibernateProxy ) { |
||||||
|
( (HibernateProxy) proxy ).getHibernateLazyInitializer().initialize(); |
||||||
|
} |
||||||
|
else if ( proxy instanceof PersistentCollection ) { |
||||||
|
( (PersistentCollection) proxy ).forceInitialization(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Check if the proxy or persistent collection is initialized. |
||||||
|
* |
||||||
|
* @param proxy a persistable object, proxy, persistent collection or <tt>null</tt> |
||||||
|
* @return true if the argument is already initialized, or is not a proxy or collection |
||||||
|
*/ |
||||||
|
@SuppressWarnings("SimplifiableIfStatement") |
||||||
|
public static boolean isInitialized(Object proxy) { |
||||||
|
if ( proxy instanceof HibernateProxy ) { |
||||||
|
return !( (HibernateProxy) proxy ).getHibernateLazyInitializer().isUninitialized(); |
||||||
|
} |
||||||
|
else if ( proxy instanceof PersistentCollection ) { |
||||||
|
return ( (PersistentCollection) proxy ).wasInitialized(); |
||||||
|
} |
||||||
|
else { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the true, underlying class of a proxied persistent class. This operation |
||||||
|
* will initialize a proxy by side-effect. |
||||||
|
* |
||||||
|
* @param proxy a persistable object or proxy |
||||||
|
* @return the true class of the instance |
||||||
|
* @throws HibernateException |
||||||
|
*/ |
||||||
|
public static Class getClass(Object proxy) { |
||||||
|
if ( proxy instanceof HibernateProxy ) { |
||||||
|
return ( (HibernateProxy) proxy ).getHibernateLazyInitializer() |
||||||
|
.getImplementation() |
||||||
|
.getClass(); |
||||||
|
} |
||||||
|
else { |
||||||
|
return proxy.getClass(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtain a lob creator for the given session. |
||||||
|
* |
||||||
|
* @param session The session for which to obtain a lob creator |
||||||
|
* |
||||||
|
* @return The log creator reference |
||||||
|
*/ |
||||||
|
public static LobCreator getLobCreator(Session session) { |
||||||
|
return getLobCreator( (SessionImplementor) session ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtain a lob creator for the given session. |
||||||
|
* |
||||||
|
* @param session The session for which to obtain a lob creator |
||||||
|
* |
||||||
|
* @return The log creator reference |
||||||
|
*/ |
||||||
|
public static LobCreator getLobCreator(SessionImplementor session) { |
||||||
|
return session.getFactory() |
||||||
|
.getServiceRegistry() |
||||||
|
.getService( JdbcServices.class ) |
||||||
|
.getLobCreator( session ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Close an {@link Iterator} instances obtained from {@link com.fr.third.org.hibernate.Query#iterate()} immediately |
||||||
|
* instead of waiting until the session is closed or disconnected. |
||||||
|
* |
||||||
|
* @param iterator an Iterator created by iterate() |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem closing the Hibernate iterator. |
||||||
|
* @throws IllegalArgumentException If the Iterator is not a "Hibernate Iterator". |
||||||
|
* |
||||||
|
* @see Query#iterate() |
||||||
|
*/ |
||||||
|
public static void close(Iterator iterator) throws HibernateException { |
||||||
|
if ( iterator instanceof HibernateIterator ) { |
||||||
|
( (HibernateIterator) iterator ).close(); |
||||||
|
} |
||||||
|
else { |
||||||
|
throw new IllegalArgumentException( "not a Hibernate iterator" ); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Check if the property is initialized. If the named property does not exist |
||||||
|
* or is not persistent, this method always returns <tt>true</tt>. |
||||||
|
* |
||||||
|
* @param proxy The potential proxy |
||||||
|
* @param propertyName the name of a persistent attribute of the object |
||||||
|
* @return true if the named property of the object is not listed as uninitialized; false otherwise |
||||||
|
*/ |
||||||
|
public static boolean isPropertyInitialized(Object proxy, String propertyName) { |
||||||
|
final Object entity; |
||||||
|
if ( proxy instanceof HibernateProxy ) { |
||||||
|
final LazyInitializer li = ( (HibernateProxy) proxy ).getHibernateLazyInitializer(); |
||||||
|
if ( li.isUninitialized() ) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
else { |
||||||
|
entity = li.getImplementation(); |
||||||
|
} |
||||||
|
} |
||||||
|
else { |
||||||
|
entity = proxy; |
||||||
|
} |
||||||
|
|
||||||
|
if ( entity instanceof PersistentAttributeInterceptable ) { |
||||||
|
PersistentAttributeInterceptor interceptor = ( (PersistentAttributeInterceptable) entity ).$$_hibernate_getInterceptor(); |
||||||
|
if ( interceptor != null && interceptor instanceof LazyAttributeLoadingInterceptor ) { |
||||||
|
return ( (LazyAttributeLoadingInterceptor) interceptor ).isAttributeLoaded( propertyName ); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Marks a group of exceptions that generally indicate an internal Hibernate error or bug. |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public class HibernateError extends HibernateException { |
||||||
|
/** |
||||||
|
* Constructs HibernateError with the condition message. |
||||||
|
* |
||||||
|
* @param message Message explaining the exception/error condition |
||||||
|
*/ |
||||||
|
public HibernateError(String message) { |
||||||
|
super( message ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs HibernateError with the condition message and cause. |
||||||
|
* |
||||||
|
* @param message Message explaining the exception/error condition |
||||||
|
* @param cause The underlying cause. |
||||||
|
*/ |
||||||
|
public HibernateError(String message, Throwable cause) { |
||||||
|
super( message, cause ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* The base exception type for Hibernate exceptions. |
||||||
|
* <p/> |
||||||
|
* Note that all {@link java.sql.SQLException SQLExceptions} will be wrapped in some form of |
||||||
|
* {@link JDBCException}. |
||||||
|
* |
||||||
|
* @see JDBCException |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class HibernateException extends RuntimeException { |
||||||
|
/** |
||||||
|
* Constructs a HibernateException using the given exception message. |
||||||
|
* |
||||||
|
* @param message The message explaining the reason for the exception |
||||||
|
*/ |
||||||
|
public HibernateException(String message) { |
||||||
|
super( message ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a HibernateException using the given message and underlying cause. |
||||||
|
* |
||||||
|
* @param cause The underlying cause. |
||||||
|
*/ |
||||||
|
public HibernateException(Throwable cause) { |
||||||
|
super( cause ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a HibernateException using the given message and underlying cause. |
||||||
|
* |
||||||
|
* @param message The message explaining the reason for the exception. |
||||||
|
* @param cause The underlying cause. |
||||||
|
*/ |
||||||
|
public HibernateException(String message, Throwable cause) { |
||||||
|
super( message, cause ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,60 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* Loads an entity by its primary identifier. |
||||||
|
* |
||||||
|
* @author Eric Dalquist |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public interface IdentifierLoadAccess<T> { |
||||||
|
/** |
||||||
|
* Specify the {@link LockOptions} to use when retrieving the entity. |
||||||
|
* |
||||||
|
* @param lockOptions The lock options to use. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
IdentifierLoadAccess<T> with(LockOptions lockOptions); |
||||||
|
|
||||||
|
/** |
||||||
|
* Specify the {@link CacheMode} to use when retrieving the entity. |
||||||
|
* |
||||||
|
* @param cacheMode The CacheMode to use. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
IdentifierLoadAccess<T> with(CacheMode cacheMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the persistent instance with the given identifier, assuming that the instance exists. This method |
||||||
|
* might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed. |
||||||
|
* |
||||||
|
* You should not use this method to determine if an instance exists; to check for existence, use {@link #load} |
||||||
|
* instead. Use this only to retrieve an instance that you assume exists, where non-existence would be an |
||||||
|
* actual error. |
||||||
|
* |
||||||
|
* @param id The identifier for which to obtain a reference |
||||||
|
* |
||||||
|
* @return the persistent instance or proxy |
||||||
|
*/ |
||||||
|
T getReference(Serializable id); |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the persistent instance with the given identifier, or null if there is no such persistent instance. |
||||||
|
* If the instance is already associated with the session, return that instance, initializing it if needed. This |
||||||
|
* method never returns an uninitialized instance. |
||||||
|
* |
||||||
|
* @param id The identifier |
||||||
|
* |
||||||
|
* @return The persistent instance or {@code null} |
||||||
|
*/ |
||||||
|
T load(Serializable id); |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.lang.annotation.Retention; |
||||||
|
import java.lang.annotation.Target; |
||||||
|
|
||||||
|
import static java.lang.annotation.ElementType.PACKAGE; |
||||||
|
import static java.lang.annotation.ElementType.METHOD; |
||||||
|
import static java.lang.annotation.ElementType.TYPE; |
||||||
|
import static java.lang.annotation.RetentionPolicy.CLASS; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
@Target({PACKAGE, TYPE, METHOD}) |
||||||
|
@Retention(CLASS) |
||||||
|
public @interface Incubating { |
||||||
|
} |
@ -0,0 +1,77 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Thrown if Hibernate can't instantiate a class at runtime. |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class InstantiationException extends HibernateException { |
||||||
|
private final Class clazz; |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a InstantiationException. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
* @param clazz The Class we are attempting to instantiate |
||||||
|
* @param cause The underlying exception |
||||||
|
*/ |
||||||
|
public InstantiationException(String message, Class clazz, Throwable cause) { |
||||||
|
super( message, cause ); |
||||||
|
this.clazz = clazz; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a InstantiationException. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
* @param clazz The Class we are attempting to instantiate |
||||||
|
*/ |
||||||
|
public InstantiationException(String message, Class clazz) { |
||||||
|
this( message, clazz, null ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a InstantiationException. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
* @param clazz The Class we are attempting to instantiate |
||||||
|
* @param cause The underlying exception |
||||||
|
*/ |
||||||
|
public InstantiationException(String message, Class clazz, Exception cause) { |
||||||
|
super( message, cause ); |
||||||
|
this.clazz = clazz; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the Class we were attempting to instantiate. |
||||||
|
* |
||||||
|
* @deprecated Use {@link #getUninstantiatableClass} instead |
||||||
|
* |
||||||
|
* @return The class we are unable to instantiate |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public Class getPersistentClass() { |
||||||
|
return clazz; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the Class we were attempting to instantiate. |
||||||
|
* |
||||||
|
* @return The class we are unable to instantiate |
||||||
|
*/ |
||||||
|
public Class getUninstantiatableClass() { |
||||||
|
return clazz; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMessage() { |
||||||
|
return super.getMessage() + " : " + clazz.getName(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,276 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.Iterator; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.type.Type; |
||||||
|
|
||||||
|
/** |
||||||
|
* Allows user code to inspect and/or change property values. |
||||||
|
* |
||||||
|
* Inspection occurs before property values are written and after they are read |
||||||
|
* from the database. |
||||||
|
* |
||||||
|
* There might be a single instance of <tt>Interceptor</tt> for a <tt>SessionFactory</tt>, or a new instance |
||||||
|
* might be specified for each <tt>Session</tt>. Whichever approach is used, the interceptor must be |
||||||
|
* serializable if the <tt>Session</tt> is to be serializable. This means that <tt>SessionFactory</tt>-scoped |
||||||
|
* interceptors should implement <tt>readResolve()</tt>. |
||||||
|
* |
||||||
|
* The <tt>Session</tt> may not be invoked from a callback (nor may a callback cause a collection or proxy to |
||||||
|
* be lazily initialized). |
||||||
|
* |
||||||
|
* Instead of implementing this interface directly, it is usually better to extend <tt>EmptyInterceptor</tt> |
||||||
|
* and override only the callback methods of interest. |
||||||
|
* |
||||||
|
* @see SessionBuilder#interceptor(Interceptor) |
||||||
|
* @see SharedSessionBuilder#interceptor() |
||||||
|
* @see com.fr.third.org.hibernate.cfg.Configuration#setInterceptor(Interceptor) |
||||||
|
* @see EmptyInterceptor |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public interface Interceptor { |
||||||
|
/** |
||||||
|
* Called just before an object is initialized. The interceptor may change the <tt>state</tt>, which will |
||||||
|
* be propagated to the persistent object. Note that when this method is called, <tt>entity</tt> will be |
||||||
|
* an empty uninitialized instance of the class. |
||||||
|
* <p/> |
||||||
|
* NOTE: The indexes across the <tt>state</tt>, <tt>propertyNames</tt> and <tt>types</tt> arrays match. |
||||||
|
* |
||||||
|
* @param entity The entity instance being loaded |
||||||
|
* @param id The identifier value being loaded |
||||||
|
* @param state The entity state (which will be pushed into the entity instance) |
||||||
|
* @param propertyNames The names of the entity properties, corresponding to the <tt>state</tt>. |
||||||
|
* @param types The types of the entity properties, corresponding to the <tt>state</tt>. |
||||||
|
* |
||||||
|
* @return {@code true} if the user modified the <tt>state</tt> in any way. |
||||||
|
* |
||||||
|
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback. |
||||||
|
*/ |
||||||
|
boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Called when an object is detected to be dirty, during a flush. The interceptor may modify the detected |
||||||
|
* <tt>currentState</tt>, which will be propagated to both the database and the persistent object. |
||||||
|
* Note that not all flushes end in actual synchronization with the database, in which case the |
||||||
|
* new <tt>currentState</tt> will be propagated to the object, but not necessarily (immediately) to |
||||||
|
* the database. It is strongly recommended that the interceptor <b>not</b> modify the <tt>previousState</tt>. |
||||||
|
* <p/> |
||||||
|
* NOTE: The indexes across the <tt>currentState</tt>, <tt>previousState</tt>, <tt>propertyNames</tt> and |
||||||
|
* <tt>types</tt> arrays match. |
||||||
|
* |
||||||
|
* @param entity The entity instance detected as being dirty and being flushed |
||||||
|
* @param id The identifier of the entity |
||||||
|
* @param currentState The entity's current state |
||||||
|
* @param previousState The entity's previous (load time) state. |
||||||
|
* @param propertyNames The names of the entity properties |
||||||
|
* @param types The types of the entity properties |
||||||
|
* |
||||||
|
* @return {@code true} if the user modified the <tt>currentState</tt> in any way. |
||||||
|
* |
||||||
|
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback. |
||||||
|
*/ |
||||||
|
boolean onFlushDirty( |
||||||
|
Object entity, |
||||||
|
Serializable id, |
||||||
|
Object[] currentState, |
||||||
|
Object[] previousState, |
||||||
|
String[] propertyNames, |
||||||
|
Type[] types) throws CallbackException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Called before an object is saved. The interceptor may modify the <tt>state</tt>, which will be used for |
||||||
|
* the SQL <tt>INSERT</tt> and propagated to the persistent object. |
||||||
|
* |
||||||
|
* @param entity The entity instance whose state is being inserted |
||||||
|
* @param id The identifier of the entity |
||||||
|
* @param state The state of the entity which will be inserted |
||||||
|
* @param propertyNames The names of the entity properties. |
||||||
|
* @param types The types of the entity properties |
||||||
|
* |
||||||
|
* @return <tt>true</tt> if the user modified the <tt>state</tt> in any way. |
||||||
|
* |
||||||
|
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback. |
||||||
|
*/ |
||||||
|
boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Called before an object is deleted. It is not recommended that the interceptor modify the <tt>state</tt>. |
||||||
|
* |
||||||
|
* @param entity The entity instance being deleted |
||||||
|
* @param id The identifier of the entity |
||||||
|
* @param state The state of the entity |
||||||
|
* @param propertyNames The names of the entity properties. |
||||||
|
* @param types The types of the entity properties |
||||||
|
* |
||||||
|
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback. |
||||||
|
*/ |
||||||
|
void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Called before a collection is (re)created. |
||||||
|
* |
||||||
|
* @param collection The collection instance. |
||||||
|
* @param key The collection key value. |
||||||
|
* |
||||||
|
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback. |
||||||
|
*/ |
||||||
|
void onCollectionRecreate(Object collection, Serializable key) throws CallbackException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Called before a collection is deleted. |
||||||
|
* |
||||||
|
* @param collection The collection instance. |
||||||
|
* @param key The collection key value. |
||||||
|
* |
||||||
|
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback. |
||||||
|
*/ |
||||||
|
void onCollectionRemove(Object collection, Serializable key) throws CallbackException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Called before a collection is updated. |
||||||
|
* |
||||||
|
* @param collection The collection instance. |
||||||
|
* @param key The collection key value. |
||||||
|
* |
||||||
|
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback. |
||||||
|
*/ |
||||||
|
void onCollectionUpdate(Object collection, Serializable key) throws CallbackException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Called before a flush. |
||||||
|
* |
||||||
|
* @param entities The entities to be flushed. |
||||||
|
* |
||||||
|
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback. |
||||||
|
*/ |
||||||
|
void preFlush(Iterator entities) throws CallbackException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Called after a flush that actually ends in execution of the SQL statements required to synchronize |
||||||
|
* in-memory state with the database. |
||||||
|
* |
||||||
|
* @param entities The entities that were flushed. |
||||||
|
* |
||||||
|
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback. |
||||||
|
*/ |
||||||
|
void postFlush(Iterator entities) throws CallbackException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Called to distinguish between transient and detached entities. The return value determines the |
||||||
|
* state of the entity with respect to the current session. |
||||||
|
* <ul> |
||||||
|
* <li><tt>Boolean.TRUE</tt> - the entity is transient |
||||||
|
* <li><tt>Boolean.FALSE</tt> - the entity is detached |
||||||
|
* <li><tt>null</tt> - Hibernate uses the <tt>unsaved-value</tt> mapping and other heuristics to |
||||||
|
* determine if the object is unsaved |
||||||
|
* </ul> |
||||||
|
* @param entity a transient or detached entity |
||||||
|
* @return Boolean or <tt>null</tt> to choose default behaviour |
||||||
|
*/ |
||||||
|
Boolean isTransient(Object entity); |
||||||
|
|
||||||
|
/** |
||||||
|
* Called from <tt>flush()</tt>. The return value determines whether the entity is updated |
||||||
|
* <ul> |
||||||
|
* <li>an array of property indices - the entity is dirty |
||||||
|
* <li>an empty array - the entity is not dirty |
||||||
|
* <li><tt>null</tt> - use Hibernate's default dirty-checking algorithm |
||||||
|
* </ul> |
||||||
|
* |
||||||
|
* @param entity The entity for which to find dirty properties. |
||||||
|
* @param id The identifier of the entity |
||||||
|
* @param currentState The current entity state as taken from the entity instance |
||||||
|
* @param previousState The state of the entity when it was last synchronized (generally when it was loaded) |
||||||
|
* @param propertyNames The names of the entity properties. |
||||||
|
* @param types The types of the entity properties |
||||||
|
* |
||||||
|
* @return array of dirty property indices or {@code null} to indicate Hibernate should perform default behaviour |
||||||
|
* |
||||||
|
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback. |
||||||
|
*/ |
||||||
|
int[] findDirty( |
||||||
|
Object entity, |
||||||
|
Serializable id, |
||||||
|
Object[] currentState, |
||||||
|
Object[] previousState, |
||||||
|
String[] propertyNames, |
||||||
|
Type[] types); |
||||||
|
/** |
||||||
|
* Instantiate the entity class. Return <tt>null</tt> to indicate that Hibernate should use |
||||||
|
* the default constructor of the class. The identifier property of the returned instance |
||||||
|
* should be initialized with the given identifier. |
||||||
|
* |
||||||
|
* @param entityName the name of the entity |
||||||
|
* @param entityMode The type of entity instance to be returned. |
||||||
|
* @param id the identifier of the new instance |
||||||
|
* |
||||||
|
* @return an instance of the class, or <tt>null</tt> to choose default behaviour |
||||||
|
* |
||||||
|
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback. |
||||||
|
*/ |
||||||
|
Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the entity name for a persistent or transient instance. |
||||||
|
* |
||||||
|
* @param object an entity instance |
||||||
|
* |
||||||
|
* @return the name of the entity |
||||||
|
* |
||||||
|
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback. |
||||||
|
*/ |
||||||
|
String getEntityName(Object object) throws CallbackException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Get a fully loaded entity instance that is cached externally. |
||||||
|
* |
||||||
|
* @param entityName the name of the entity |
||||||
|
* @param id the instance identifier |
||||||
|
* |
||||||
|
* @return a fully initialized entity |
||||||
|
* |
||||||
|
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback. |
||||||
|
*/ |
||||||
|
Object getEntity(String entityName, Serializable id) throws CallbackException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Called when a Hibernate transaction is begun via the Hibernate <tt>Transaction</tt> |
||||||
|
* API. Will not be called if transactions are being controlled via some other |
||||||
|
* mechanism (CMT, for example). |
||||||
|
* |
||||||
|
* @param tx The Hibernate transaction facade object |
||||||
|
*/ |
||||||
|
void afterTransactionBegin(Transaction tx); |
||||||
|
|
||||||
|
/** |
||||||
|
* Called before a transaction is committed (but not before rollback). |
||||||
|
* |
||||||
|
* @param tx The Hibernate transaction facade object |
||||||
|
*/ |
||||||
|
void beforeTransactionCompletion(Transaction tx); |
||||||
|
|
||||||
|
/** |
||||||
|
* Called after a transaction is committed or rolled back. |
||||||
|
* |
||||||
|
* @param tx The Hibernate transaction facade object |
||||||
|
*/ |
||||||
|
void afterTransactionCompletion(Transaction tx); |
||||||
|
|
||||||
|
/** |
||||||
|
* Called when sql string is being prepared. |
||||||
|
* @param sql sql to be prepared |
||||||
|
* @return original or modified sql |
||||||
|
* |
||||||
|
* @deprecated Supply a {@link com.fr.third.org.hibernate.resource.jdbc.spi.StatementInspector} instead, if you wish |
||||||
|
* to inspect and alter SQL statements. |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
String onPrepareStatement(String sql); |
||||||
|
} |
@ -0,0 +1,132 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.boot.jaxb.Origin; |
||||||
|
import com.fr.third.org.hibernate.internal.util.xml.XmlDocument; |
||||||
|
|
||||||
|
/** |
||||||
|
* Thrown when a mapping is found to be invalid. |
||||||
|
* |
||||||
|
* Similar to MappingException, but this contains more info about the path and type of |
||||||
|
* mapping (e.g. file, resource or url) |
||||||
|
* |
||||||
|
* @author Max Rydahl Andersen |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public class InvalidMappingException extends MappingException { |
||||||
|
private final String path; |
||||||
|
private final String type; |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs an InvalidMappingException using the given information. |
||||||
|
* |
||||||
|
* @param customMessage The custom message explaining the exception condition |
||||||
|
* @param type The type of invalid mapping document |
||||||
|
* @param path The path (type specific) of the invalid mapping document |
||||||
|
* @param cause The underlying cause |
||||||
|
*/ |
||||||
|
public InvalidMappingException(String customMessage, String type, String path, Throwable cause) { |
||||||
|
super( customMessage, cause ); |
||||||
|
this.type = type; |
||||||
|
this.path = path; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs an InvalidMappingException using the given information. |
||||||
|
* |
||||||
|
* @param customMessage The custom message explaining the exception condition |
||||||
|
* @param type The type of invalid mapping document |
||||||
|
* @param path The path (type specific) of the invalid mapping document |
||||||
|
*/ |
||||||
|
public InvalidMappingException(String customMessage, String type, String path) { |
||||||
|
super( customMessage ); |
||||||
|
this.type=type; |
||||||
|
this.path=path; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs an InvalidMappingException using the given information. |
||||||
|
* |
||||||
|
* @param customMessage The custom message explaining the exception condition |
||||||
|
* @param xmlDocument The document that was invalid |
||||||
|
* @param cause The underlying cause |
||||||
|
*/ |
||||||
|
public InvalidMappingException(String customMessage, XmlDocument xmlDocument, Throwable cause) { |
||||||
|
this( customMessage, xmlDocument.getOrigin().getType(), xmlDocument.getOrigin().getName(), cause ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs an InvalidMappingException using the given information. |
||||||
|
* |
||||||
|
* @param customMessage The custom message explaining the exception condition |
||||||
|
* @param xmlDocument The document that was invalid |
||||||
|
*/ |
||||||
|
public InvalidMappingException(String customMessage, XmlDocument xmlDocument) { |
||||||
|
this( customMessage, xmlDocument.getOrigin().getType(), xmlDocument.getOrigin().getName() ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs an InvalidMappingException using the given information. |
||||||
|
* |
||||||
|
* @param customMessage The custom message explaining the exception condition |
||||||
|
* @param origin The origin of the invalid mapping document |
||||||
|
*/ |
||||||
|
public InvalidMappingException(String customMessage, Origin origin) { |
||||||
|
this( customMessage, origin.getType().getLegacyTypeText(), origin.getName() ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs an InvalidMappingException using the given information and a standard message. |
||||||
|
* |
||||||
|
* @param type The type of invalid mapping document |
||||||
|
* @param path The path (type specific) of the invalid mapping document |
||||||
|
*/ |
||||||
|
public InvalidMappingException(String type, String path) { |
||||||
|
this( "Could not parse mapping document from " + type + (path==null?"":" " + path), type, path ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs an InvalidMappingException using the given information and a standard message. |
||||||
|
* |
||||||
|
* @param type The type of invalid mapping document |
||||||
|
* @param path The path (type specific) of the invalid mapping document |
||||||
|
* @param cause The underlying cause |
||||||
|
*/ |
||||||
|
public InvalidMappingException(String type, String path, Throwable cause) { |
||||||
|
this( "Could not parse mapping document from " + type + (path==null?"":" " + path), type, path, cause ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs an InvalidMappingException using the given information. |
||||||
|
* |
||||||
|
* @param customMessage The custom message explaining the exception condition |
||||||
|
* @param origin The origin of the invalid mapping document |
||||||
|
* @param cause The underlying cause |
||||||
|
*/ |
||||||
|
public InvalidMappingException(String customMessage, com.fr.third.org.hibernate.internal.util.xml.Origin origin, Exception cause) { |
||||||
|
this( customMessage, origin.getType(), origin.getName(), cause ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs an InvalidMappingException using the given information. |
||||||
|
* |
||||||
|
* @param customMessage The custom message explaining the exception condition |
||||||
|
* @param origin The origin of the invalid mapping document |
||||||
|
*/ |
||||||
|
public InvalidMappingException(String customMessage, com.fr.third.org.hibernate.internal.util.xml.Origin origin) { |
||||||
|
this( customMessage, origin, null ); |
||||||
|
} |
||||||
|
|
||||||
|
public String getType() { |
||||||
|
return type; |
||||||
|
} |
||||||
|
|
||||||
|
public String getPath() { |
||||||
|
return path; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,85 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.sql.SQLException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Wraps a {@link SQLException}. Indicates that an exception occurred during a JDBC call. |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
* |
||||||
|
* @see java.sql.SQLException |
||||||
|
*/ |
||||||
|
public class JDBCException extends HibernateException { |
||||||
|
private final SQLException sqlException; |
||||||
|
private final String sql; |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a JDBCException using the given information. |
||||||
|
* |
||||||
|
* @param message The message explaining the exception condition |
||||||
|
* @param cause The underlying cause |
||||||
|
*/ |
||||||
|
public JDBCException(String message, SQLException cause) { |
||||||
|
this( message, cause, null ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a JDBCException using the given information. |
||||||
|
* |
||||||
|
* @param message The message explaining the exception condition |
||||||
|
* @param cause The underlying cause |
||||||
|
* @param sql The sql being executed when the exception occurred |
||||||
|
*/ |
||||||
|
public JDBCException(String message, SQLException cause, String sql) { |
||||||
|
super( message, cause ); |
||||||
|
this.sqlException = cause; |
||||||
|
this.sql = sql; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the X/Open or ANSI SQL SQLState error code from the underlying {@link SQLException}. |
||||||
|
* |
||||||
|
* @return The X/Open or ANSI SQL SQLState error code; may return null. |
||||||
|
* |
||||||
|
* @see java.sql.SQLException#getSQLState() |
||||||
|
*/ |
||||||
|
public String getSQLState() { |
||||||
|
return sqlException.getSQLState(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the vendor specific error code from the underlying {@link SQLException}. |
||||||
|
* |
||||||
|
* @return The vendor specific error code |
||||||
|
* |
||||||
|
* @see java.sql.SQLException#getErrorCode() |
||||||
|
*/ |
||||||
|
public int getErrorCode() { |
||||||
|
return sqlException.getErrorCode(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the underlying {@link SQLException}. |
||||||
|
* |
||||||
|
* @return The SQLException |
||||||
|
*/ |
||||||
|
public SQLException getSQLException() { |
||||||
|
return sqlException; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the actual SQL statement being executed when the exception occurred. |
||||||
|
* |
||||||
|
* @return The SQL statement; may return null. |
||||||
|
*/ |
||||||
|
public String getSQL() { |
||||||
|
return sql; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.internal.CoreMessageLogger; |
||||||
|
|
||||||
|
import com.fr.third.org.jboss.logging.Logger; |
||||||
|
|
||||||
|
/** |
||||||
|
* Indicates an attempt to access not-yet-fetched data outside of a session context. |
||||||
|
* |
||||||
|
* For example, when an uninitialized proxy or collection is accessed after the session was closed. |
||||||
|
* |
||||||
|
* @see Hibernate#initialize(java.lang.Object) |
||||||
|
* @see Hibernate#isInitialized(java.lang.Object) |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class LazyInitializationException extends HibernateException { |
||||||
|
|
||||||
|
private static final CoreMessageLogger LOG = Logger.getMessageLogger( |
||||||
|
CoreMessageLogger.class, |
||||||
|
LazyInitializationException.class.getName() |
||||||
|
); |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a LazyInitializationException using the given message. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
*/ |
||||||
|
public LazyInitializationException(String message) { |
||||||
|
super( message ); |
||||||
|
LOG.trace( message, this ); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,78 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.io.InputStream; |
||||||
|
import java.io.Reader; |
||||||
|
import java.sql.Blob; |
||||||
|
import java.sql.Clob; |
||||||
|
import java.sql.NClob; |
||||||
|
|
||||||
|
/** |
||||||
|
* A {@link Session session's} helper for creating LOB data. |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public interface LobHelper { |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new {@link Blob} from bytes. |
||||||
|
* |
||||||
|
* @param bytes a byte array |
||||||
|
* |
||||||
|
* @return the created Blob |
||||||
|
*/ |
||||||
|
public Blob createBlob(byte[] bytes); |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new {@link Blob} from stream data. |
||||||
|
* |
||||||
|
* @param stream a binary stream |
||||||
|
* @param length the number of bytes in the stream |
||||||
|
|
||||||
|
* @return the create Blob |
||||||
|
*/ |
||||||
|
public Blob createBlob(InputStream stream, long length); |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new {@link java.sql.Clob} from content. |
||||||
|
* |
||||||
|
* @param string The string data |
||||||
|
* |
||||||
|
* @return The created {@link java.sql.Clob} |
||||||
|
*/ |
||||||
|
public Clob createClob(String string); |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new {@link Clob} from character reader. |
||||||
|
* |
||||||
|
* @param reader a character stream |
||||||
|
* @param length the number of characters in the stream |
||||||
|
* |
||||||
|
* @return The created {@link Clob} |
||||||
|
*/ |
||||||
|
public Clob createClob(Reader reader, long length); |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new {@link NClob} from content. |
||||||
|
* |
||||||
|
* @param string The string data |
||||||
|
* |
||||||
|
* @return The created {@link NClob} |
||||||
|
*/ |
||||||
|
public NClob createNClob(String string); |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new {@link NClob} from character reader. |
||||||
|
* |
||||||
|
* @param reader a character stream |
||||||
|
* @param length the number of characters in the stream |
||||||
|
* |
||||||
|
* @return The created {@link NClob} |
||||||
|
*/ |
||||||
|
public NClob createNClob(Reader reader, long length); |
||||||
|
} |
@ -0,0 +1,158 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Instances represent a lock mode for a row of a relational |
||||||
|
* database table. It is not intended that users spend much |
||||||
|
* time worrying about locking since Hibernate usually |
||||||
|
* obtains exactly the right lock level automatically. |
||||||
|
* Some "advanced" users may wish to explicitly specify lock |
||||||
|
* levels. |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
* |
||||||
|
* @see Session#lock(Object, LockMode) |
||||||
|
*/ |
||||||
|
public enum LockMode { |
||||||
|
/** |
||||||
|
* No lock required. If an object is requested with this lock |
||||||
|
* mode, a <tt>READ</tt> lock will be obtained if it is |
||||||
|
* necessary to actually read the state from the database, |
||||||
|
* rather than pull it from a cache.<br> |
||||||
|
* <br> |
||||||
|
* This is the "default" lock mode. |
||||||
|
*/ |
||||||
|
NONE( 0, "none" ), |
||||||
|
/** |
||||||
|
* A shared lock. Objects in this lock mode were read from |
||||||
|
* the database in the current transaction, rather than being |
||||||
|
* pulled from a cache. |
||||||
|
*/ |
||||||
|
READ( 5, "read" ), |
||||||
|
/** |
||||||
|
* An upgrade lock. Objects loaded in this lock mode are |
||||||
|
* materialized using an SQL <tt>select ... for update</tt>. |
||||||
|
* |
||||||
|
* @deprecated instead use PESSIMISTIC_WRITE |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
UPGRADE( 10, "upgrade" ), |
||||||
|
/** |
||||||
|
* Attempt to obtain an upgrade lock, using an Oracle-style |
||||||
|
* <tt>select for update nowait</tt>. The semantics of |
||||||
|
* this lock mode, once obtained, are the same as |
||||||
|
* <tt>UPGRADE</tt>. |
||||||
|
*/ |
||||||
|
UPGRADE_NOWAIT( 10, "upgrade-nowait" ), |
||||||
|
|
||||||
|
/** |
||||||
|
* Attempt to obtain an upgrade lock, using an Oracle-style |
||||||
|
* <tt>select for update skip locked</tt>. The semantics of |
||||||
|
* this lock mode, once obtained, are the same as |
||||||
|
* <tt>UPGRADE</tt>. |
||||||
|
*/ |
||||||
|
UPGRADE_SKIPLOCKED( 10, "upgrade-skiplocked" ), |
||||||
|
|
||||||
|
/** |
||||||
|
* A <tt>WRITE</tt> lock is obtained when an object is updated |
||||||
|
* or inserted. This lock mode is for internal use only and is |
||||||
|
* not a valid mode for <tt>load()</tt> or <tt>lock()</tt> (both |
||||||
|
* of which throw exceptions if WRITE is specified). |
||||||
|
*/ |
||||||
|
WRITE( 10, "write" ), |
||||||
|
|
||||||
|
/** |
||||||
|
* Similar to {@link #UPGRADE} except that, for versioned entities, |
||||||
|
* it results in a forced version increment. |
||||||
|
* |
||||||
|
* @deprecated instead use PESSIMISTIC_FORCE_INCREMENT |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
FORCE( 15, "force" ), |
||||||
|
|
||||||
|
/** |
||||||
|
* start of javax.persistence.LockModeType equivalent modes |
||||||
|
*/ |
||||||
|
|
||||||
|
/** |
||||||
|
* Optimistically assume that transaction will not experience contention for |
||||||
|
* entities. The entity version will be verified near the transaction end. |
||||||
|
*/ |
||||||
|
OPTIMISTIC( 6, "optimistic" ), |
||||||
|
|
||||||
|
/** |
||||||
|
* Optimistically assume that transaction will not experience contention for |
||||||
|
* entities. The entity version will be verified and incremented near the transaction end. |
||||||
|
*/ |
||||||
|
OPTIMISTIC_FORCE_INCREMENT( 7, "optimistic_force_increment" ), |
||||||
|
|
||||||
|
/** |
||||||
|
* Implemented as PESSIMISTIC_WRITE. |
||||||
|
* TODO: introduce separate support for PESSIMISTIC_READ |
||||||
|
*/ |
||||||
|
PESSIMISTIC_READ( 12, "pessimistic_read" ), |
||||||
|
|
||||||
|
/** |
||||||
|
* Transaction will obtain a database lock immediately. |
||||||
|
* TODO: add PESSIMISTIC_WRITE_NOWAIT |
||||||
|
*/ |
||||||
|
PESSIMISTIC_WRITE( 13, "pessimistic_write" ), |
||||||
|
|
||||||
|
/** |
||||||
|
* Transaction will immediately increment the entity version. |
||||||
|
*/ |
||||||
|
PESSIMISTIC_FORCE_INCREMENT( 17, "pessimistic_force_increment" ); |
||||||
|
|
||||||
|
private final int level; |
||||||
|
private final String externalForm; |
||||||
|
|
||||||
|
private LockMode(int level, String externalForm) { |
||||||
|
this.level = level; |
||||||
|
this.externalForm = externalForm; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Check if this lock mode is more restrictive than the given lock mode. |
||||||
|
* |
||||||
|
* @param mode LockMode to check |
||||||
|
* |
||||||
|
* @return true if this lock mode is more restrictive than given lock mode |
||||||
|
*/ |
||||||
|
public boolean greaterThan(LockMode mode) { |
||||||
|
return level > mode.level; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Check if this lock mode is less restrictive than the given lock mode. |
||||||
|
* |
||||||
|
* @param mode LockMode to check |
||||||
|
* |
||||||
|
* @return true if this lock mode is less restrictive than given lock mode |
||||||
|
*/ |
||||||
|
public boolean lessThan(LockMode mode) { |
||||||
|
return level < mode.level; |
||||||
|
} |
||||||
|
|
||||||
|
public String toExternalForm() { |
||||||
|
return externalForm; |
||||||
|
} |
||||||
|
|
||||||
|
public static LockMode fromExternalForm(String externalForm) { |
||||||
|
if ( externalForm == null ) { |
||||||
|
return NONE; |
||||||
|
} |
||||||
|
|
||||||
|
for ( LockMode lockMode : LockMode.values() ) { |
||||||
|
if ( lockMode.externalForm.equalsIgnoreCase( externalForm ) ) { |
||||||
|
return lockMode; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
throw new IllegalArgumentException( "Unable to interpret LockMode reference from incoming external form : " + externalForm ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,300 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.Collections; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Iterator; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* Contains locking details (LockMode, Timeout and Scope). |
||||||
|
* |
||||||
|
* @author Scott Marlow |
||||||
|
*/ |
||||||
|
public class LockOptions implements Serializable { |
||||||
|
/** |
||||||
|
* Represents LockMode.NONE (timeout + scope do not apply). |
||||||
|
*/ |
||||||
|
public static final LockOptions NONE = new LockOptions(LockMode.NONE); |
||||||
|
|
||||||
|
/** |
||||||
|
* Represents LockMode.READ (timeout + scope do not apply). |
||||||
|
*/ |
||||||
|
public static final LockOptions READ = new LockOptions(LockMode.READ); |
||||||
|
|
||||||
|
/** |
||||||
|
* Represents LockMode.UPGRADE (will wait forever for lock and scope of false meaning only entity is locked). |
||||||
|
*/ |
||||||
|
@SuppressWarnings("deprecation") |
||||||
|
public static final LockOptions UPGRADE = new LockOptions(LockMode.UPGRADE); |
||||||
|
|
||||||
|
/** |
||||||
|
* Indicates that the database should not wait at all to acquire the pessimistic lock. |
||||||
|
* @see #getTimeOut |
||||||
|
*/ |
||||||
|
public static final int NO_WAIT = 0; |
||||||
|
|
||||||
|
/** |
||||||
|
* Indicates that there is no timeout for the acquisition. |
||||||
|
* @see #getTimeOut |
||||||
|
*/ |
||||||
|
public static final int WAIT_FOREVER = -1; |
||||||
|
|
||||||
|
/** |
||||||
|
* Indicates that rows that are already locked should be skipped. |
||||||
|
* @see #getTimeOut() |
||||||
|
*/ |
||||||
|
public static final int SKIP_LOCKED = -2; |
||||||
|
|
||||||
|
private LockMode lockMode = LockMode.NONE; |
||||||
|
private int timeout = WAIT_FOREVER; |
||||||
|
|
||||||
|
private Map<String,LockMode> aliasSpecificLockModes; |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a LockOptions with all default options. |
||||||
|
*/ |
||||||
|
public LockOptions() { |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a LockOptions with the given lock mode. |
||||||
|
* |
||||||
|
* @param lockMode The lock mode to use |
||||||
|
*/ |
||||||
|
public LockOptions( LockMode lockMode) { |
||||||
|
this.lockMode = lockMode; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Retrieve the overall lock mode in effect for this set of options. |
||||||
|
* <p/> |
||||||
|
* In certain contexts (hql and criteria), lock-modes can be defined in an |
||||||
|
* even more granular {@link #setAliasSpecificLockMode(String, LockMode) per-alias} fashion |
||||||
|
* |
||||||
|
* @return The overall lock mode. |
||||||
|
*/ |
||||||
|
public LockMode getLockMode() { |
||||||
|
return lockMode; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the overall {@link LockMode} to be used. The default is |
||||||
|
* {@link LockMode#NONE} |
||||||
|
* |
||||||
|
* @param lockMode The new overall lock mode to use. |
||||||
|
* |
||||||
|
* @return this (for method chaining). |
||||||
|
*/ |
||||||
|
public LockOptions setLockMode(LockMode lockMode) { |
||||||
|
this.lockMode = lockMode; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Specify the {@link LockMode} to be used for a specific query alias. |
||||||
|
* |
||||||
|
* @param alias used to reference the LockMode. |
||||||
|
* @param lockMode The lock mode to apply to the given alias |
||||||
|
* @return this LockRequest instance for operation chaining. |
||||||
|
* |
||||||
|
* @see Query#setLockMode(String, LockMode) |
||||||
|
* @see Criteria#setLockMode(LockMode) |
||||||
|
* @see Criteria#setLockMode(String, LockMode) |
||||||
|
*/ |
||||||
|
public LockOptions setAliasSpecificLockMode(String alias, LockMode lockMode) { |
||||||
|
if ( aliasSpecificLockModes == null ) { |
||||||
|
aliasSpecificLockModes = new HashMap<String,LockMode>(); |
||||||
|
} |
||||||
|
aliasSpecificLockModes.put( alias, lockMode ); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the {@link LockMode} explicitly specified for the given alias via |
||||||
|
* {@link #setAliasSpecificLockMode} |
||||||
|
* <p/> |
||||||
|
* Differs from {@link #getEffectiveLockMode} in that here we only return |
||||||
|
* explicitly specified alias-specific lock modes. |
||||||
|
* |
||||||
|
* @param alias The alias for which to locate the explicit lock mode. |
||||||
|
* |
||||||
|
* @return The explicit lock mode for that alias. |
||||||
|
*/ |
||||||
|
public LockMode getAliasSpecificLockMode(String alias) { |
||||||
|
if ( aliasSpecificLockModes == null ) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return aliasSpecificLockModes.get( alias ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Determine the {@link LockMode} to apply to the given alias. If no |
||||||
|
* mode was explicitly {@link #setAliasSpecificLockMode set}, the |
||||||
|
* {@link #getLockMode overall mode} is returned. If the overall lock mode is |
||||||
|
* <tt>null</tt> as well, {@link LockMode#NONE} is returned. |
||||||
|
* <p/> |
||||||
|
* Differs from {@link #getAliasSpecificLockMode} in that here we fallback to we only return |
||||||
|
* the overall lock mode. |
||||||
|
* |
||||||
|
* @param alias The alias for which to locate the effective lock mode. |
||||||
|
* |
||||||
|
* @return The effective lock mode. |
||||||
|
*/ |
||||||
|
public LockMode getEffectiveLockMode(String alias) { |
||||||
|
LockMode lockMode = getAliasSpecificLockMode( alias ); |
||||||
|
if ( lockMode == null ) { |
||||||
|
lockMode = this.lockMode; |
||||||
|
} |
||||||
|
return lockMode == null ? LockMode.NONE : lockMode; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Does this LockOptions object define alias-specific lock modes? |
||||||
|
* |
||||||
|
* @return {@code true} if this LockOptions object define alias-specific lock modes; {@code false} otherwise. |
||||||
|
*/ |
||||||
|
public boolean hasAliasSpecificLockModes() { |
||||||
|
return aliasSpecificLockModes != null |
||||||
|
&& ! aliasSpecificLockModes.isEmpty(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the number of aliases that have specific lock modes defined. |
||||||
|
* |
||||||
|
* @return the number of explicitly defined alias lock modes. |
||||||
|
*/ |
||||||
|
public int getAliasLockCount() { |
||||||
|
if ( aliasSpecificLockModes == null ) { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
return aliasSpecificLockModes.size(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Iterator for accessing Alias (key) and LockMode (value) as Map.Entry. |
||||||
|
* |
||||||
|
* @return Iterator for accessing the Map.Entry's |
||||||
|
*/ |
||||||
|
public Iterator getAliasLockIterator() { |
||||||
|
if ( aliasSpecificLockModes == null ) { |
||||||
|
return Collections.emptyList().iterator(); |
||||||
|
} |
||||||
|
return aliasSpecificLockModes.entrySet().iterator(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Currently needed for follow-on locking. |
||||||
|
* |
||||||
|
* @return The greatest of all requested lock modes. |
||||||
|
*/ |
||||||
|
public LockMode findGreatestLockMode() { |
||||||
|
LockMode lockModeToUse = getLockMode(); |
||||||
|
if ( lockModeToUse == null ) { |
||||||
|
lockModeToUse = LockMode.NONE; |
||||||
|
} |
||||||
|
|
||||||
|
if ( aliasSpecificLockModes == null ) { |
||||||
|
return lockModeToUse; |
||||||
|
} |
||||||
|
|
||||||
|
for ( LockMode lockMode : aliasSpecificLockModes.values() ) { |
||||||
|
if ( lockMode.greaterThan( lockModeToUse ) ) { |
||||||
|
lockModeToUse = lockMode; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return lockModeToUse; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Retrieve the current timeout setting. |
||||||
|
* <p/> |
||||||
|
* The timeout is the amount of time, in milliseconds, we should instruct the database |
||||||
|
* to wait for any requested pessimistic lock acquisition. |
||||||
|
* <p/> |
||||||
|
* {@link #NO_WAIT}, {@link #WAIT_FOREVER} or {@link #SKIP_LOCKED} represent 3 "magic" values. |
||||||
|
* |
||||||
|
* @return timeout in milliseconds, {@link #NO_WAIT}, {@link #WAIT_FOREVER} or {@link #SKIP_LOCKED} |
||||||
|
*/ |
||||||
|
public int getTimeOut() { |
||||||
|
return timeout; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the timeout setting. |
||||||
|
* <p/> |
||||||
|
* See {@link #getTimeOut} for a discussion of meaning. |
||||||
|
* |
||||||
|
* @param timeout The new timeout setting. |
||||||
|
* |
||||||
|
* @return this (for method chaining). |
||||||
|
* |
||||||
|
* @see #getTimeOut |
||||||
|
*/ |
||||||
|
public LockOptions setTimeOut(int timeout) { |
||||||
|
this.timeout = timeout; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
private boolean scope; |
||||||
|
|
||||||
|
/** |
||||||
|
* Retrieve the current lock scope setting. |
||||||
|
* <p/> |
||||||
|
* "scope" is a JPA defined term. It is basically a cascading of the lock to associations. |
||||||
|
* |
||||||
|
* @return true if locking will be extended to owned associations |
||||||
|
*/ |
||||||
|
public boolean getScope() { |
||||||
|
return scope; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the scope. |
||||||
|
* |
||||||
|
* @param scope The new scope setting |
||||||
|
* |
||||||
|
* @return this (for method chaining). |
||||||
|
*/ |
||||||
|
public LockOptions setScope(boolean scope) { |
||||||
|
this.scope = scope; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Make a copy. |
||||||
|
* |
||||||
|
* @return The copy |
||||||
|
*/ |
||||||
|
public LockOptions makeCopy() { |
||||||
|
final LockOptions copy = new LockOptions(); |
||||||
|
copy( this, copy ); |
||||||
|
return copy; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Perform a shallow copy. |
||||||
|
* |
||||||
|
* @param source Source for the copy (copied from) |
||||||
|
* @param destination Destination for the copy (copied to) |
||||||
|
* |
||||||
|
* @return destination |
||||||
|
*/ |
||||||
|
public static LockOptions copy(LockOptions source, LockOptions destination) { |
||||||
|
destination.setLockMode( source.getLockMode() ); |
||||||
|
destination.setScope( source.getScope() ); |
||||||
|
destination.setTimeOut( source.getTimeOut() ); |
||||||
|
if ( source.aliasSpecificLockModes != null ) { |
||||||
|
destination.aliasSpecificLockModes = new HashMap<String,LockMode>( source.aliasSpecificLockModes ); |
||||||
|
} |
||||||
|
return destination; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,44 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* An exception that occurs while reading mapping sources (xml/annotations),usually as a result of something |
||||||
|
* screwy in the O-R mappings. |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class MappingException extends HibernateException { |
||||||
|
/** |
||||||
|
* Constructs a MappingException using the given information. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
* @param cause The underlying cause |
||||||
|
*/ |
||||||
|
public MappingException(String message, Throwable cause) { |
||||||
|
super( message, cause ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a MappingException using the given information. |
||||||
|
* |
||||||
|
* @param cause The underlying cause |
||||||
|
*/ |
||||||
|
public MappingException(Throwable cause) { |
||||||
|
super( cause ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a MappingException using the given information. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
*/ |
||||||
|
public MappingException(String message) { |
||||||
|
super( message ); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,76 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Thrown when a resource for a mapping could not be found. |
||||||
|
* |
||||||
|
* @author Max Rydahl Andersen |
||||||
|
* |
||||||
|
* @deprecated Use {@link com.fr.third.org.hibernate.boot.MappingNotFoundException} instead. |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public class MappingNotFoundException extends MappingException { |
||||||
|
private final String path; |
||||||
|
private final String type; |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a MappingNotFoundException using the given information. |
||||||
|
* |
||||||
|
* @param customMessage A message explaining the exception condition |
||||||
|
* @param type The type of mapping that could not be found |
||||||
|
* @param path The path (type specific) of the mapping that could not be found |
||||||
|
* @param cause The underlying cause |
||||||
|
*/ |
||||||
|
public MappingNotFoundException(String customMessage, String type, String path, Throwable cause) { |
||||||
|
super( customMessage, cause ); |
||||||
|
this.type = type; |
||||||
|
this.path = path; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a MappingNotFoundException using the given information. |
||||||
|
* |
||||||
|
* @param customMessage A message explaining the exception condition |
||||||
|
* @param type The type of mapping that could not be found |
||||||
|
* @param path The path (type specific) of the mapping that could not be found |
||||||
|
*/ |
||||||
|
public MappingNotFoundException(String customMessage, String type, String path) { |
||||||
|
super( customMessage ); |
||||||
|
this.type = type; |
||||||
|
this.path = path; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a MappingNotFoundException using the given information, using a standard message. |
||||||
|
* |
||||||
|
* @param type The type of mapping that could not be found |
||||||
|
* @param path The path (type specific) of the mapping that could not be found |
||||||
|
*/ |
||||||
|
public MappingNotFoundException(String type, String path) { |
||||||
|
this( type + ": " + path + " not found", type, path ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a MappingNotFoundException using the given information, using a standard message. |
||||||
|
* |
||||||
|
* @param type The type of mapping that could not be found |
||||||
|
* @param path The path (type specific) of the mapping that could not be found |
||||||
|
* @param cause The underlying cause |
||||||
|
*/ |
||||||
|
public MappingNotFoundException(String type, String path, Throwable cause) { |
||||||
|
this( type + ": " + path + " not found", type, path, cause ); |
||||||
|
} |
||||||
|
|
||||||
|
public String getType() { |
||||||
|
return type; |
||||||
|
} |
||||||
|
|
||||||
|
public String getPath() { |
||||||
|
return path; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,119 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Loads multiple entities at once by identifiers, ultimately via one of the |
||||||
|
* {@link #multiLoad} methods, using the various options specified (if any) |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public interface MultiIdentifierLoadAccess<T> { |
||||||
|
/** |
||||||
|
* Specify the {@link LockOptions} to use when retrieving the entity. |
||||||
|
* |
||||||
|
* @param lockOptions The lock options to use. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
MultiIdentifierLoadAccess<T> with(LockOptions lockOptions); |
||||||
|
|
||||||
|
/** |
||||||
|
* Specify the {@link CacheMode} to use when retrieving the entity. |
||||||
|
* |
||||||
|
* @param cacheMode The CacheMode to use. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
MultiIdentifierLoadAccess<T> with(CacheMode cacheMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Specify a batch size for loading the entities (how many at a time). The default is |
||||||
|
* to use a batch sizing strategy defined by the Dialect in use. Any greater-than-one |
||||||
|
* value here will override that default behavior. If giving an explicit value here, |
||||||
|
* care should be taken to not exceed the capabilities of of the underlying database. |
||||||
|
* <p/> |
||||||
|
* Note that overall a batch-size is considered a hint. How the underlying loading |
||||||
|
* mechanism interprets that is completely up to that underlying loading mechanism. |
||||||
|
* |
||||||
|
* @param batchSize The batch size |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
MultiIdentifierLoadAccess<T> withBatchSize(int batchSize); |
||||||
|
|
||||||
|
/** |
||||||
|
* Specify whether we should check the Session to see whether it already contains any of the |
||||||
|
* entities to be loaded in a managed state <b>for the purpose of not including those |
||||||
|
* ids to the batch-load SQL</b>. |
||||||
|
* |
||||||
|
* @param enabled {@code true} enables this checking; {@code false} (the default) disables it. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
MultiIdentifierLoadAccess<T> enableSessionCheck(boolean enabled); |
||||||
|
|
||||||
|
/** |
||||||
|
* Should the multi-load operation be allowed to return entities that are locally |
||||||
|
* deleted? A locally deleted entity is one which has been passed to this |
||||||
|
* Session's {@link Session#delete} / {@link Session#remove} method, but not |
||||||
|
* yet flushed. The default behavior is to handle them as null in the return |
||||||
|
* (see {@link #enableOrderedReturn}). |
||||||
|
* |
||||||
|
* @param enabled {@code true} enables returning the deleted entities; |
||||||
|
* {@code false} (the default) disables it. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
MultiIdentifierLoadAccess<T> enableReturnOfDeletedEntities(boolean enabled); |
||||||
|
|
||||||
|
/** |
||||||
|
* Should the return List be ordered and positional in relation to the |
||||||
|
* incoming ids? If enabled (the default), the return List is ordered and |
||||||
|
* positional relative to the incoming ids. In other words, a request to |
||||||
|
* {@code multiLoad([2,1,3])} will return {@code [Entity#2, Entity#1, Entity#3]}. |
||||||
|
* <p/> |
||||||
|
* An important distinction is made here in regards to the handling of |
||||||
|
* unknown entities depending on this "ordered return" setting. If enabled |
||||||
|
* a null is inserted into the List at the proper position(s). If disabled, |
||||||
|
* the nulls are not put into the return List. In other words, consumers of |
||||||
|
* the returned ordered List would need to be able to handle null elements. |
||||||
|
* |
||||||
|
* @param enabled {@code true} (the default) enables ordering; |
||||||
|
* {@code false} disables it. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
MultiIdentifierLoadAccess<T> enableOrderedReturn(boolean enabled); |
||||||
|
|
||||||
|
/** |
||||||
|
* Perform a load of multiple entities by identifiers. See {@link #enableOrderedReturn} |
||||||
|
* and {@link #enableReturnOfDeletedEntities} for options which effect |
||||||
|
* the size and "shape" of the return list. |
||||||
|
* |
||||||
|
* @param ids The ids to load |
||||||
|
* @param <K> The identifier type |
||||||
|
* |
||||||
|
* @return The persistent entities. |
||||||
|
*/ |
||||||
|
<K extends Serializable> List<T> multiLoad(K... ids); |
||||||
|
|
||||||
|
/** |
||||||
|
* Perform a load of multiple entities by identifiers. See {@link #enableOrderedReturn} |
||||||
|
* and {@link #enableReturnOfDeletedEntities} for options which effect |
||||||
|
* the size and "shape" of the return list. |
||||||
|
* |
||||||
|
* @param ids The ids to load |
||||||
|
* @param <K> The identifier type |
||||||
|
* |
||||||
|
* @return The persistent entities. |
||||||
|
*/ |
||||||
|
<K extends Serializable> List<T> multiLoad(List<K> ids); |
||||||
|
} |
@ -0,0 +1,82 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.util.Locale; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.cfg.Environment; |
||||||
|
import com.fr.third.org.hibernate.internal.CoreMessageLogger; |
||||||
|
|
||||||
|
import com.fr.third.org.jboss.logging.Logger; |
||||||
|
|
||||||
|
/** |
||||||
|
* Describes the methods for multi-tenancy understood by Hibernate. |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public enum MultiTenancyStrategy { |
||||||
|
/** |
||||||
|
* Multi-tenancy implemented by use of discriminator columns. |
||||||
|
*/ |
||||||
|
DISCRIMINATOR, |
||||||
|
/** |
||||||
|
* Multi-tenancy implemented as separate schemas. |
||||||
|
*/ |
||||||
|
SCHEMA, |
||||||
|
/** |
||||||
|
* Multi-tenancy implemented as separate databases. |
||||||
|
*/ |
||||||
|
DATABASE, |
||||||
|
/** |
||||||
|
* No multi-tenancy. |
||||||
|
*/ |
||||||
|
NONE; |
||||||
|
|
||||||
|
private static final CoreMessageLogger LOG = Logger.getMessageLogger( |
||||||
|
CoreMessageLogger.class, |
||||||
|
MultiTenancyStrategy.class.getName() |
||||||
|
); |
||||||
|
|
||||||
|
/** |
||||||
|
* Does this strategy indicate a requirement for the specialized |
||||||
|
* {@link com.fr.third.org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider}, rather than the |
||||||
|
* traditional {@link com.fr.third.org.hibernate.engine.jdbc.connections.spi.ConnectionProvider}? |
||||||
|
* |
||||||
|
* @return {@code true} indicates a MultiTenantConnectionProvider is required; {@code false} indicates it is not. |
||||||
|
*/ |
||||||
|
public boolean requiresMultiTenantConnectionProvider() { |
||||||
|
return this == DATABASE || this == SCHEMA; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Extract the MultiTenancyStrategy from the setting map. |
||||||
|
* |
||||||
|
* @param properties The map of settings. |
||||||
|
* |
||||||
|
* @return The selected strategy. {@link #NONE} is always the default. |
||||||
|
*/ |
||||||
|
public static MultiTenancyStrategy determineMultiTenancyStrategy(Map properties) { |
||||||
|
final Object strategy = properties.get( Environment.MULTI_TENANT ); |
||||||
|
if ( strategy == null ) { |
||||||
|
return MultiTenancyStrategy.NONE; |
||||||
|
} |
||||||
|
|
||||||
|
if ( MultiTenancyStrategy.class.isInstance( strategy ) ) { |
||||||
|
return (MultiTenancyStrategy) strategy; |
||||||
|
} |
||||||
|
|
||||||
|
final String strategyName = strategy.toString(); |
||||||
|
try { |
||||||
|
return MultiTenancyStrategy.valueOf( strategyName.toUpperCase(Locale.ROOT) ); |
||||||
|
} |
||||||
|
catch ( RuntimeException e ) { |
||||||
|
LOG.warn( "Unknown multi tenancy strategy [ " +strategyName +" ], using MultiTenancyStrategy.NONE." ); |
||||||
|
return MultiTenancyStrategy.NONE; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,76 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Loads an entity by its natural identifier. |
||||||
|
* |
||||||
|
* @author Eric Dalquist |
||||||
|
* @author Steve Ebersole |
||||||
|
* |
||||||
|
* @see com.fr.third.org.hibernate.annotations.NaturalId |
||||||
|
*/ |
||||||
|
public interface NaturalIdLoadAccess<T> { |
||||||
|
/** |
||||||
|
* Specify the {@link LockOptions} to use when retrieving the entity. |
||||||
|
* |
||||||
|
* @param lockOptions The lock options to use. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public NaturalIdLoadAccess<T> with(LockOptions lockOptions); |
||||||
|
|
||||||
|
/** |
||||||
|
* Add a NaturalId attribute value. |
||||||
|
* |
||||||
|
* @param attributeName The entity attribute name that is marked as a NaturalId |
||||||
|
* @param value The value of the attribute |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public NaturalIdLoadAccess<T> using(String attributeName, Object value); |
||||||
|
|
||||||
|
/** |
||||||
|
* For entities with mutable natural ids, should Hibernate perform "synchronization" prior to performing |
||||||
|
* lookups? The default is to perform "synchronization" (for correctness). |
||||||
|
* <p/> |
||||||
|
* "synchronization" here indicates updating the natural-id -> pk cross reference maintained as part of the |
||||||
|
* session. When enabled, prior to performing the lookup, Hibernate will check all entities of the given |
||||||
|
* type associated with the session to see if its natural-id values have changed and, if so, update the |
||||||
|
* cross reference. There is a performance impact associated with this, so if application developers are |
||||||
|
* certain the natural-ids in play have not changed, this setting can be disabled to circumvent that impact. |
||||||
|
* However, disabling this setting when natural-ids values have changed can result in incorrect results! |
||||||
|
* |
||||||
|
* @param enabled Should synchronization be performed? {@code true} indicates synchronization will be performed; |
||||||
|
* {@code false} indicates it will be circumvented. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public NaturalIdLoadAccess<T> setSynchronizationEnabled(boolean enabled); |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the persistent instance with the natural id value(s) defined by the call(s) to {@link #using}. This |
||||||
|
* method might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed. |
||||||
|
* |
||||||
|
* You should not use this method to determine if an instance exists; to check for existence, use {@link #load} |
||||||
|
* instead. Use this only to retrieve an instance that you assume exists, where non-existence would be an |
||||||
|
* actual error. |
||||||
|
* |
||||||
|
* @return the persistent instance or proxy |
||||||
|
*/ |
||||||
|
public T getReference(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the persistent instance with the natural id value(s) defined by the call(s) to {@link #using}, or |
||||||
|
* {@code null} if there is no such persistent instance. If the instance is already associated with the session, |
||||||
|
* return that instance, initializing it if needed. This method never returns an uninitialized instance. |
||||||
|
* |
||||||
|
* @return The persistent instance or {@code null} |
||||||
|
*/ |
||||||
|
public T load(); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.pretty.MessageHelper; |
||||||
|
|
||||||
|
/** |
||||||
|
* This exception is thrown when an operation would break session-scoped identity. This occurs if the |
||||||
|
* user tries to associate two different instances of the same Java class with a particular identifier, |
||||||
|
* in the scope of a single Session. |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class NonUniqueObjectException extends HibernateException { |
||||||
|
private final Serializable identifier; |
||||||
|
private final String entityName; |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a NonUniqueObjectException using the given information. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
* @param entityId The identifier of the entity |
||||||
|
* @param entityName The name of the entity |
||||||
|
*/ |
||||||
|
public NonUniqueObjectException(String message, Serializable entityId, String entityName) { |
||||||
|
super( message ); |
||||||
|
this.entityName = entityName; |
||||||
|
this.identifier = entityId; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a NonUniqueObjectException using the given information, using a standard message. |
||||||
|
* |
||||||
|
* @param entityId The identifier of the entity |
||||||
|
* @param entityName The name of the entity |
||||||
|
*/ |
||||||
|
public NonUniqueObjectException(Serializable entityId, String entityName) { |
||||||
|
this( |
||||||
|
"A different object with the same identifier value was already associated with the session", |
||||||
|
entityId, |
||||||
|
entityName |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
public String getEntityName() { |
||||||
|
return entityName; |
||||||
|
} |
||||||
|
|
||||||
|
public Serializable getIdentifier() { |
||||||
|
return identifier; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMessage() { |
||||||
|
return super.getMessage() + " : " + MessageHelper.infoString( entityName, identifier ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Thrown when the application calls <tt>Query.uniqueResult()</tt> and |
||||||
|
* the query returned more than one result. Unlike all other Hibernate |
||||||
|
* exceptions, this one is recoverable! |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class NonUniqueResultException extends HibernateException { |
||||||
|
/** |
||||||
|
* Constructs a NonUniqueResultException. |
||||||
|
* |
||||||
|
* @param resultCount The number of actual results. |
||||||
|
*/ |
||||||
|
public NonUniqueResultException(int resultCount) { |
||||||
|
super( "query did not return a unique result: " + resultCount ); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Defines precedence of null values within {@code ORDER BY} clause. |
||||||
|
* |
||||||
|
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) |
||||||
|
*/ |
||||||
|
public enum NullPrecedence { |
||||||
|
/** |
||||||
|
* Null precedence not specified. Relies on the RDBMS implementation. |
||||||
|
*/ |
||||||
|
NONE, |
||||||
|
|
||||||
|
/** |
||||||
|
* Null values appear at the beginning of the sorted collection. |
||||||
|
*/ |
||||||
|
FIRST, |
||||||
|
|
||||||
|
/** |
||||||
|
* Null values appear at the end of the sorted collection. |
||||||
|
*/ |
||||||
|
LAST; |
||||||
|
|
||||||
|
/** |
||||||
|
* Interprets a string representation of a NullPrecedence, returning {@code null} by default. For |
||||||
|
* alternative default handling, see {@link #parse(String, NullPrecedence)} |
||||||
|
* |
||||||
|
* @param name The String representation to interpret |
||||||
|
* |
||||||
|
* @return The recognized NullPrecedence, or {@code null} |
||||||
|
*/ |
||||||
|
public static NullPrecedence parse(String name) { |
||||||
|
if ( "none".equalsIgnoreCase( name ) ) { |
||||||
|
return NullPrecedence.NONE; |
||||||
|
} |
||||||
|
else if ( "first".equalsIgnoreCase( name ) ) { |
||||||
|
return NullPrecedence.FIRST; |
||||||
|
} |
||||||
|
else if ( "last".equalsIgnoreCase( name ) ) { |
||||||
|
return NullPrecedence.LAST; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Interprets a string representation of a NullPrecedence, returning the specified default if not recognized. |
||||||
|
* |
||||||
|
* @param name The String representation to interpret |
||||||
|
* @param defaultValue The default value to use |
||||||
|
* |
||||||
|
* @return The recognized NullPrecedence, or {@code defaultValue}. |
||||||
|
*/ |
||||||
|
public static NullPrecedence parse(String name, NullPrecedence defaultValue) { |
||||||
|
final NullPrecedence value = parse( name ); |
||||||
|
return value != null ? value : defaultValue; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* Thrown when the user tries to do something illegal with a deleted object. |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class ObjectDeletedException extends UnresolvableObjectException { |
||||||
|
/** |
||||||
|
* Constructs an ObjectDeletedException using the given information. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
* @param identifier The identifier of the entity |
||||||
|
* @param entityName The name of the entity |
||||||
|
*/ |
||||||
|
public ObjectDeletedException(String message, Serializable identifier, String entityName) { |
||||||
|
super( message, identifier, entityName ); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* Thrown when <tt>Session.load()</tt> fails to select a row with |
||||||
|
* the given primary key (identifier value). This exception might not |
||||||
|
* be thrown when <tt>load()</tt> is called, even if there was no |
||||||
|
* row on the database, because <tt>load()</tt> returns a proxy if |
||||||
|
* possible. Applications should use <tt>Session.get()</tt> to test if |
||||||
|
* a row exists in the database.<br> |
||||||
|
* <br> |
||||||
|
* Like all Hibernate exceptions, this exception is considered |
||||||
|
* unrecoverable. |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class ObjectNotFoundException extends UnresolvableObjectException { |
||||||
|
/** |
||||||
|
* Constructs a ObjectNotFoundException using the given information. |
||||||
|
* |
||||||
|
* @param identifier The identifier of the entity |
||||||
|
* @param entityName The name of the entity |
||||||
|
*/ |
||||||
|
public ObjectNotFoundException(Serializable identifier, String entityName) { |
||||||
|
super( identifier, entityName ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.dialect.lock.OptimisticEntityLockException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Throw when an optimistic locking conflict occurs. |
||||||
|
* |
||||||
|
* @author Scott Marlow |
||||||
|
* |
||||||
|
* @deprecated Use {@link com.fr.third.org.hibernate.dialect.lock.OptimisticEntityLockException} instead |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public class OptimisticLockException extends OptimisticEntityLockException { |
||||||
|
/** |
||||||
|
* Constructs a OptimisticLockException using the specified information. |
||||||
|
* |
||||||
|
* @param entity The entity instance that could not be locked |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
*/ |
||||||
|
public OptimisticLockException(Object entity, String message) { |
||||||
|
super( entity, message ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Thrown when the user passes a persistent instance to a <tt>Session</tt> |
||||||
|
* method that expects a transient instance. |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class PersistentObjectException extends HibernateException { |
||||||
|
/** |
||||||
|
* Constructs a PersistentObjectException using the given message. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
*/ |
||||||
|
public PersistentObjectException(String message) { |
||||||
|
super( message ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.sql.SQLException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Thrown when a pessimistic locking conflict occurs. |
||||||
|
* |
||||||
|
* @author Scott Marlow |
||||||
|
*/ |
||||||
|
public class PessimisticLockException extends JDBCException { |
||||||
|
/** |
||||||
|
* Constructs a PessimisticLockException using the specified information. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
* @param sqlException The underlying SQL exception |
||||||
|
* @param sql The sql that led to the exception (may be null, though usually should not be) |
||||||
|
*/ |
||||||
|
public PessimisticLockException(String message, SQLException sqlException, String sql) { |
||||||
|
super( message, sqlException, sql ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,67 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.internal.util.StringHelper; |
||||||
|
|
||||||
|
/** |
||||||
|
* A problem occurred accessing a property of an instance of a |
||||||
|
* persistent class by reflection, or via CGLIB. There are a |
||||||
|
* number of possible underlying causes, including |
||||||
|
* <ul> |
||||||
|
* <li>failure of a security check |
||||||
|
* <li>an exception occurring inside the getter or setter method |
||||||
|
* <li>a nullable database column was mapped to a primitive-type property |
||||||
|
* <li>the Hibernate type was not castable to the property type (or vice-versa) |
||||||
|
* </ul> |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class PropertyAccessException extends HibernateException { |
||||||
|
private final Class persistentClass; |
||||||
|
private final String propertyName; |
||||||
|
private final boolean wasSetter; |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a PropertyAccessException using the specified information. |
||||||
|
* |
||||||
|
* @param cause The underlying cause |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
* @param wasSetter Was the attempting to access the setter the cause of the exception? |
||||||
|
* @param persistentClass The class which is supposed to contain the property in question |
||||||
|
* @param propertyName The name of the property. |
||||||
|
*/ |
||||||
|
public PropertyAccessException( |
||||||
|
Throwable cause, |
||||||
|
String message, |
||||||
|
boolean wasSetter, |
||||||
|
Class persistentClass, |
||||||
|
String propertyName) { |
||||||
|
super( message, cause ); |
||||||
|
this.persistentClass = persistentClass; |
||||||
|
this.wasSetter = wasSetter; |
||||||
|
this.propertyName = propertyName; |
||||||
|
} |
||||||
|
|
||||||
|
public Class getPersistentClass() { |
||||||
|
return persistentClass; |
||||||
|
} |
||||||
|
|
||||||
|
public String getPropertyName() { |
||||||
|
return propertyName; |
||||||
|
} |
||||||
|
|
||||||
|
protected String originalMessage() { |
||||||
|
return super.getMessage(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMessage() { |
||||||
|
return originalMessage() |
||||||
|
+ ( wasSetter ? " setter of " : " getter of " ) |
||||||
|
+ StringHelper.qualify( persistentClass.getName(), propertyName ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Indicates that an expected getter or setter method could not be |
||||||
|
* found on a class. |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class PropertyNotFoundException extends MappingException { |
||||||
|
/** |
||||||
|
* Constructs a PropertyNotFoundException given the specified message. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
*/ |
||||||
|
public PropertyNotFoundException(String message) { |
||||||
|
super( message ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,51 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public class PropertySetterAccessException extends PropertyAccessException { |
||||||
|
/** |
||||||
|
* Constructs a PropertyAccessException using the specified information. |
||||||
|
* |
||||||
|
* @param cause The underlying cause |
||||||
|
* @param persistentClass The class which is supposed to contain the property in question |
||||||
|
* @param propertyName The name of the property. |
||||||
|
* @param expectedType The expected property type |
||||||
|
* @param target The target, which should be of type 'persistentClass' |
||||||
|
* @param value The property value we are trying to set |
||||||
|
*/ |
||||||
|
public PropertySetterAccessException( |
||||||
|
Throwable cause, |
||||||
|
Class persistentClass, |
||||||
|
String propertyName, |
||||||
|
Class expectedType, |
||||||
|
Object target, |
||||||
|
Object value) { |
||||||
|
super( |
||||||
|
cause, |
||||||
|
String.format( |
||||||
|
"IllegalArgumentException occurred while calling setter for property [%s.%s (expected type = %s)]; " + |
||||||
|
"target = [%s], property value = [%s]", |
||||||
|
persistentClass.getName(), |
||||||
|
propertyName, |
||||||
|
expectedType.getName(), |
||||||
|
target, |
||||||
|
value |
||||||
|
), |
||||||
|
true, |
||||||
|
persistentClass, |
||||||
|
propertyName |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return super.originalMessage(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,49 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.internal.util.StringHelper; |
||||||
|
|
||||||
|
/** |
||||||
|
* Thrown when the (illegal) value of a property can not be persisted. |
||||||
|
* There are two main causes: |
||||||
|
* <ul> |
||||||
|
* <li>a property declared <tt>not-null="true"</tt> is null |
||||||
|
* <li>an association references an unsaved transient instance |
||||||
|
* </ul> |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class PropertyValueException extends HibernateException { |
||||||
|
private final String entityName; |
||||||
|
private final String propertyName; |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a PropertyValueException using the specified information. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
* @param entityName The name of the entity, containing the property |
||||||
|
* @param propertyName The name of the property being accessed. |
||||||
|
*/ |
||||||
|
public PropertyValueException(String message, String entityName, String propertyName) { |
||||||
|
super( message ); |
||||||
|
this.entityName = entityName; |
||||||
|
this.propertyName = propertyName; |
||||||
|
} |
||||||
|
|
||||||
|
public String getEntityName() { |
||||||
|
return entityName; |
||||||
|
} |
||||||
|
|
||||||
|
public String getPropertyName() { |
||||||
|
return propertyName; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMessage() { |
||||||
|
return super.getMessage() + " : " + StringHelper.qualify( entityName, propertyName ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,853 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.math.BigInteger; |
||||||
|
import java.util.Calendar; |
||||||
|
import java.util.Collection; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.Iterator; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Locale; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.transform.ResultTransformer; |
||||||
|
import com.fr.third.org.hibernate.type.Type; |
||||||
|
|
||||||
|
/** |
||||||
|
* An object-oriented representation of a Hibernate query. A <tt>Query</tt> |
||||||
|
* instance is obtained by calling <tt>Session.createQuery()</tt>. This |
||||||
|
* interface exposes some extra functionality beyond that provided by |
||||||
|
* <tt>Session.iterate()</tt> and <tt>Session.find()</tt>: |
||||||
|
* <ul> |
||||||
|
* <li>a particular page of the result set may be selected by calling <tt> |
||||||
|
* setMaxResults(), setFirstResult()</tt> |
||||||
|
* <li>named query parameters may be used |
||||||
|
* <li>the results may be returned as an instance of <tt>ScrollableResults</tt> |
||||||
|
* </ul> |
||||||
|
* <br> |
||||||
|
* Named query parameters are tokens of the form <tt>:name</tt> in the |
||||||
|
* query string. A value is bound to the <tt>integer</tt> parameter |
||||||
|
* <tt>:foo</tt> by calling<br> |
||||||
|
* <br> |
||||||
|
* <tt>setParameter("foo", foo, Hibernate.INTEGER);</tt><br> |
||||||
|
* <br> |
||||||
|
* for example. A name may appear multiple times in the query string.<br> |
||||||
|
* <br> |
||||||
|
* JDBC-style <tt>?</tt> parameters are also supported. To bind a |
||||||
|
* value to a JDBC-style parameter use a set method that accepts an |
||||||
|
* <tt>int</tt> positional argument (numbered from zero, contrary |
||||||
|
* to JDBC).<br> |
||||||
|
* <br> |
||||||
|
* You may not mix and match JDBC-style parameters and named parameters |
||||||
|
* in the same query.<br> |
||||||
|
* <br> |
||||||
|
* Queries are executed by calling <tt>list()</tt>, <tt>scroll()</tt> or |
||||||
|
* <tt>iterate()</tt>. A query may be re-executed by subsequent invocations. |
||||||
|
* Its lifespan is, however, bounded by the lifespan of the <tt>Session</tt> |
||||||
|
* that created it.<br> |
||||||
|
* <br> |
||||||
|
* Implementors are not intended to be threadsafe. |
||||||
|
* |
||||||
|
* @see com.fr.third.org.hibernate.Session#createQuery(java.lang.String) |
||||||
|
* @see com.fr.third.org.hibernate.ScrollableResults |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
@SuppressWarnings("UnusedDeclaration") |
||||||
|
public interface Query extends BasicQueryContract { |
||||||
|
/** |
||||||
|
* Get the query string. |
||||||
|
* |
||||||
|
* @return the query string |
||||||
|
*/ |
||||||
|
public String getQueryString(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtains the limit set on the maximum number of rows to retrieve. No set limit means there is no limit set |
||||||
|
* on the number of rows returned. Technically both {@code null} and any negative values are interpreted as no |
||||||
|
* limit; however, this method should always return null in such case. |
||||||
|
* |
||||||
|
* @return The |
||||||
|
*/ |
||||||
|
public Integer getMaxResults(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the maximum number of rows to retrieve. |
||||||
|
* |
||||||
|
* @param maxResults the maximum number of rows |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
* |
||||||
|
* @see #getMaxResults() |
||||||
|
*/ |
||||||
|
public Query setMaxResults(int maxResults); |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtain the value specified (if any) for the first row to be returned from the query results; zero-based. Used, |
||||||
|
* in conjunction with {@link #getMaxResults()} in "paginated queries". No value specified means the first result |
||||||
|
* is returned. Zero and negative numbers are the same as no setting. |
||||||
|
* |
||||||
|
* @return The first result number. |
||||||
|
*/ |
||||||
|
public Integer getFirstResult(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the first row to retrieve. |
||||||
|
* |
||||||
|
* @param firstResult a row number, numbered from <tt>0</tt> |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
* |
||||||
|
* @see #getFirstResult() |
||||||
|
*/ |
||||||
|
public Query setFirstResult(int firstResult); |
||||||
|
|
||||||
|
@Override |
||||||
|
public Query setFlushMode(FlushMode flushMode); |
||||||
|
|
||||||
|
@Override |
||||||
|
public Query setCacheMode(CacheMode cacheMode); |
||||||
|
|
||||||
|
@Override |
||||||
|
public Query setCacheable(boolean cacheable); |
||||||
|
|
||||||
|
@Override |
||||||
|
public Query setCacheRegion(String cacheRegion); |
||||||
|
|
||||||
|
@Override |
||||||
|
public Query setTimeout(int timeout); |
||||||
|
|
||||||
|
@Override |
||||||
|
public Query setFetchSize(int fetchSize); |
||||||
|
|
||||||
|
@Override |
||||||
|
public Query setReadOnly(boolean readOnly); |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtains the LockOptions in effect for this query. |
||||||
|
* |
||||||
|
* @return The LockOptions |
||||||
|
* |
||||||
|
* @see LockOptions |
||||||
|
*/ |
||||||
|
public LockOptions getLockOptions(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the lock options for the query. Specifically only the following are taken into consideration:<ol> |
||||||
|
* <li>{@link LockOptions#getLockMode()}</li> |
||||||
|
* <li>{@link LockOptions#getScope()}</li> |
||||||
|
* <li>{@link LockOptions#getTimeOut()}</li> |
||||||
|
* </ol> |
||||||
|
* For alias-specific locking, use {@link #setLockMode(String, LockMode)}. |
||||||
|
* |
||||||
|
* @param lockOptions The lock options to apply to the query. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
* |
||||||
|
* @see #getLockOptions() |
||||||
|
*/ |
||||||
|
public Query setLockOptions(LockOptions lockOptions); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the LockMode to use for specific alias (as defined in the query's <tt>FROM</tt> clause). |
||||||
|
* |
||||||
|
* The alias-specific lock modes specified here are added to the query's internal |
||||||
|
* {@link #getLockOptions() LockOptions}. |
||||||
|
* |
||||||
|
* The effect of these alias-specific LockModes is somewhat dependent on the driver/database in use. Generally |
||||||
|
* speaking, for maximum portability, this method should only be used to mark that the rows corresponding to |
||||||
|
* the given alias should be included in pessimistic locking ({@link LockMode#PESSIMISTIC_WRITE}). |
||||||
|
* |
||||||
|
* @param alias a query alias, or {@code "this"} for a collection filter |
||||||
|
* @param lockMode The lock mode to apply. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
* |
||||||
|
* @see #getLockOptions() |
||||||
|
*/ |
||||||
|
public Query setLockMode(String alias, LockMode lockMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtain the comment currently associated with this query. Provided SQL commenting is enabled |
||||||
|
* (generally by enabling the {@code hibernate.use_sql_comments} config setting), this comment will also be added |
||||||
|
* to the SQL query sent to the database. Often useful for identifying the source of troublesome queries on the |
||||||
|
* database side. |
||||||
|
* |
||||||
|
* @return The comment. |
||||||
|
*/ |
||||||
|
public String getComment(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the comment for this query. |
||||||
|
* |
||||||
|
* @param comment The human-readable comment |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
* |
||||||
|
* @see #getComment() |
||||||
|
*/ |
||||||
|
public Query setComment(String comment); |
||||||
|
|
||||||
|
/** |
||||||
|
* Add a DB query hint to the SQL. These differ from JPA's {@link javax.persistence.QueryHint}, which is specific |
||||||
|
* to the JPA implementation and ignores DB vendor-specific hints. Instead, these are intended solely for the |
||||||
|
* vendor-specific hints, such as Oracle's optimizers. Multiple query hints are supported; the Dialect will |
||||||
|
* determine concatenation and placement. |
||||||
|
* |
||||||
|
* @param hint The database specific query hint to add. |
||||||
|
*/ |
||||||
|
public Query addQueryHint(String hint); |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the HQL select clause aliases, if any. |
||||||
|
* |
||||||
|
* @return an array of aliases as strings |
||||||
|
*/ |
||||||
|
public String[] getReturnAliases(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the names of all named parameters of the query. |
||||||
|
* |
||||||
|
* @return the parameter names, in no particular order |
||||||
|
*/ |
||||||
|
public String[] getNamedParameters(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the query results as an <tt>Iterator</tt>. If the query |
||||||
|
* contains multiple results pre row, the results are returned in |
||||||
|
* an instance of <tt>Object[]</tt>.<br> |
||||||
|
* <br> |
||||||
|
* Entities returned as results are initialized on demand. The first |
||||||
|
* SQL query returns identifiers only.<br> |
||||||
|
* |
||||||
|
* @return the result iterator |
||||||
|
*/ |
||||||
|
public Iterator iterate(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the query results as <tt>ScrollableResults</tt>. The |
||||||
|
* scrollability of the returned results depends upon JDBC driver |
||||||
|
* support for scrollable <tt>ResultSet</tt>s.<br> |
||||||
|
* |
||||||
|
* @see ScrollableResults |
||||||
|
* |
||||||
|
* @return the result iterator |
||||||
|
*/ |
||||||
|
public ScrollableResults scroll(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the query results as ScrollableResults. The scrollability of the returned results |
||||||
|
* depends upon JDBC driver support for scrollable ResultSets. |
||||||
|
* |
||||||
|
* @param scrollMode The scroll mode |
||||||
|
* |
||||||
|
* @return the result iterator |
||||||
|
* |
||||||
|
* @see ScrollableResults |
||||||
|
* @see ScrollMode |
||||||
|
* |
||||||
|
*/ |
||||||
|
public ScrollableResults scroll(ScrollMode scrollMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the query results as a <tt>List</tt>. If the query contains |
||||||
|
* multiple results per row, the results are returned in an instance |
||||||
|
* of <tt>Object[]</tt>. |
||||||
|
* |
||||||
|
* @return the result list |
||||||
|
*/ |
||||||
|
public List list(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to return a single instance that matches |
||||||
|
* the query, or null if the query returns no results. |
||||||
|
* |
||||||
|
* @return the single result or <tt>null</tt> |
||||||
|
* |
||||||
|
* @throws NonUniqueResultException if there is more than one matching result |
||||||
|
*/ |
||||||
|
public Object uniqueResult(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Execute the update or delete statement. |
||||||
|
* |
||||||
|
* The semantics are compliant with the ejb3 Query.executeUpdate() method. |
||||||
|
* |
||||||
|
* @return The number of entities updated or deleted. |
||||||
|
*/ |
||||||
|
public int executeUpdate(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a value to a JDBC-style query parameter. |
||||||
|
* |
||||||
|
* @param position the position of the parameter in the query |
||||||
|
* string, numbered from <tt>0</tt>. |
||||||
|
* @param val the possibly-null parameter value |
||||||
|
* @param type the Hibernate type |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setParameter(int position, Object val, Type type); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a value to a named query parameter. |
||||||
|
* |
||||||
|
* @param name the name of the parameter |
||||||
|
* @param val the possibly-null parameter value |
||||||
|
* @param type the Hibernate type |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setParameter(String name, Object val, Type type); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a value to a JDBC-style query parameter. The Hibernate type of the parameter is |
||||||
|
* first detected via the usage/position in the query and if not sufficient secondly |
||||||
|
* guessed from the class of the given object. |
||||||
|
* |
||||||
|
* @param position the position of the parameter in the query |
||||||
|
* string, numbered from <tt>0</tt>. |
||||||
|
* @param val the non-null parameter value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setParameter(int position, Object val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a value to a named query parameter. The Hibernate type of the parameter is |
||||||
|
* first detected via the usage/position in the query and if not sufficient secondly |
||||||
|
* guessed from the class of the given object. |
||||||
|
* |
||||||
|
* @param name the name of the parameter |
||||||
|
* @param val the non-null parameter value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setParameter(String name, Object val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind values and types to positional parameters. Allows binding more than one at a time; no real performance |
||||||
|
* impact. |
||||||
|
* |
||||||
|
* The number of elements in each array should match. That is, element number-0 in types array corresponds to |
||||||
|
* element-0 in the values array, etc, |
||||||
|
* |
||||||
|
* @param types The types |
||||||
|
* @param values The values |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setParameters(Object[] values, Type[] types); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind multiple values to a named query parameter. This is useful for binding |
||||||
|
* a list of values to an expression such as <tt>foo.bar in (:value_list)</tt>. |
||||||
|
* |
||||||
|
* @param name the name of the parameter |
||||||
|
* @param values a collection of values to list |
||||||
|
* @param type the Hibernate type of the values |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setParameterList(String name, Collection values, Type type); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind multiple values to a named query parameter. The Hibernate type of the parameter is |
||||||
|
* first detected via the usage/position in the query and if not sufficient secondly |
||||||
|
* guessed from the class of the first object in the collection. This is useful for binding a list of values |
||||||
|
* to an expression such as <tt>foo.bar in (:value_list)</tt>. |
||||||
|
* |
||||||
|
* @param name the name of the parameter |
||||||
|
* @param values a collection of values to list |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setParameterList(String name, Collection values); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind multiple values to a named query parameter. This is useful for binding |
||||||
|
* a list of values to an expression such as <tt>foo.bar in (:value_list)</tt>. |
||||||
|
* |
||||||
|
* @param name the name of the parameter |
||||||
|
* @param values a collection of values to list |
||||||
|
* @param type the Hibernate type of the values |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setParameterList(String name, Object[] values, Type type); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind multiple values to a named query parameter. The Hibernate type of the parameter is |
||||||
|
* first detected via the usage/position in the query and if not sufficient secondly |
||||||
|
* guessed from the class of the first object in the array. This is useful for binding a list of values |
||||||
|
* to an expression such as <tt>foo.bar in (:value_list)</tt>. |
||||||
|
* |
||||||
|
* @param name the name of the parameter |
||||||
|
* @param values a collection of values to list |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setParameterList(String name, Object[] values); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind the property values of the given bean to named parameters of the query, |
||||||
|
* matching property names with parameter names and mapping property types to |
||||||
|
* Hibernate types using heuristics. |
||||||
|
* |
||||||
|
* @param bean any JavaBean or POJO |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setProperties(Object bean); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind the values of the given Map for each named parameters of the query, |
||||||
|
* matching key names with parameter names and mapping value types to |
||||||
|
* Hibernate types using heuristics. |
||||||
|
* |
||||||
|
* @param bean a java.util.Map |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setProperties(Map bean); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional String-valued parameter. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setString(int position, String val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional char-valued parameter. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setCharacter(int position, char val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional boolean-valued parameter. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setBoolean(int position, boolean val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional byte-valued parameter. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setByte(int position, byte val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional short-valued parameter. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setShort(int position, short val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional int-valued parameter. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setInteger(int position, int val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional long-valued parameter. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setLong(int position, long val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional float-valued parameter. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setFloat(int position, float val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional double-valued parameter. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setDouble(int position, double val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional binary-valued parameter. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setBinary(int position, byte[] val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional String-valued parameter using streaming. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setText(int position, String val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional binary-valued parameter using serialization. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setSerializable(int position, Serializable val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional Locale-valued parameter. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param locale The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setLocale(int position, Locale locale); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional BigDecimal-valued parameter. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param number The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setBigDecimal(int position, BigDecimal number); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional BigDecimal-valued parameter. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param number The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setBigInteger(int position, BigInteger number); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional Date-valued parameter using just the Date portion. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param date The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setDate(int position, Date date); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional Date-valued parameter using just the Time portion. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param date The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setTime(int position, Date date); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional Date-valued parameter using the full Timestamp. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param date The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setTimestamp(int position, Date date); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional Calendar-valued parameter using the full Timestamp portion. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param calendar The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setCalendar(int position, Calendar calendar); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a positional Calendar-valued parameter using just the Date portion. |
||||||
|
* |
||||||
|
* @param position The parameter position |
||||||
|
* @param calendar The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setCalendarDate(int position, Calendar calendar); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named String-valued parameter. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setString(String name, String val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named char-valued parameter. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setCharacter(String name, char val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named boolean-valued parameter. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setBoolean(String name, boolean val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named byte-valued parameter. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setByte(String name, byte val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named short-valued parameter. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setShort(String name, short val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named int-valued parameter. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setInteger(String name, int val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named long-valued parameter. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setLong(String name, long val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named float-valued parameter. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setFloat(String name, float val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named double-valued parameter. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setDouble(String name, double val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named binary-valued parameter. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setBinary(String name, byte[] val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named String-valued parameter using streaming. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setText(String name, String val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named binary-valued parameter using serialization. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param val The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setSerializable(String name, Serializable val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named Locale-valued parameter. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param locale The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setLocale(String name, Locale locale); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named BigDecimal-valued parameter. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param number The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setBigDecimal(String name, BigDecimal number); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named BigInteger-valued parameter. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param number The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setBigInteger(String name, BigInteger number); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind the date (time is truncated) of a given Date object to a named query parameter. |
||||||
|
* |
||||||
|
* @param name The name of the parameter |
||||||
|
* @param date The date object |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setDate(String name, Date date); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind the time (date is truncated) of a given Date object to a named query parameter. |
||||||
|
* |
||||||
|
* @param name The name of the parameter |
||||||
|
* @param date The date object |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setTime(String name, Date date); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind the date and the time of a given Date object to a named query parameter. |
||||||
|
* |
||||||
|
* @param name The name of the parameter |
||||||
|
* @param date The date object |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setTimestamp(String name, Date date); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named Calendar-valued parameter using the full Timestamp. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param calendar The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setCalendar(String name, Calendar calendar); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind a named Calendar-valued parameter using just the Date portion. |
||||||
|
* |
||||||
|
* @param name The parameter name |
||||||
|
* @param calendar The bind value |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setCalendarDate(String name, Calendar calendar); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind an instance of a mapped persistent class to a JDBC-style query parameter. |
||||||
|
* Use {@link #setParameter(int, Object)} for null values. |
||||||
|
* |
||||||
|
* @param position the position of the parameter in the query |
||||||
|
* string, numbered from <tt>0</tt>. |
||||||
|
* @param val a non-null instance of a persistent class
|
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setEntity(int position, Object val); |
||||||
|
|
||||||
|
/** |
||||||
|
* Bind an instance of a mapped persistent class to a named query parameter. Use |
||||||
|
* {@link #setParameter(String, Object)} for null values. |
||||||
|
* |
||||||
|
* @param name the name of the parameter |
||||||
|
* @param val a non-null instance of a persistent class
|
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public Query setEntity(String name, Object val); |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Set a strategy for handling the query results. This can be used to change |
||||||
|
* "shape" of the query result. |
||||||
|
* |
||||||
|
* @param transformer The transformer to apply |
||||||
|
* @return this (for method chaining) |
||||||
|
*/ |
||||||
|
public Query setResultTransformer(ResultTransformer transformer); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,122 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* A problem occurred translating a Hibernate query to SQL due to invalid query syntax, etc. |
||||||
|
*/ |
||||||
|
public class QueryException extends HibernateException { |
||||||
|
private final String queryString; |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a QueryException using the specified exception message. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
*/ |
||||||
|
public QueryException(String message) { |
||||||
|
this( message, null, null ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a QueryException using the specified exception message and cause. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
* @param cause The underlying cause |
||||||
|
*/ |
||||||
|
public QueryException(String message, Exception cause) { |
||||||
|
this( message, null, cause ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a QueryException using the specified exception message and query-string. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
* @param queryString The query being evaluated when the exception occurred |
||||||
|
*/ |
||||||
|
public QueryException(String message, String queryString) { |
||||||
|
this( message, queryString, null ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a QueryException using the specified exception message and query-string. |
||||||
|
* |
||||||
|
* @param message A message explaining the exception condition |
||||||
|
* @param queryString The query being evaluated when the exception occurred |
||||||
|
* @param cause The underlying cause |
||||||
|
*/ |
||||||
|
public QueryException(String message, String queryString, Exception cause) { |
||||||
|
super( message, cause ); |
||||||
|
this.queryString = queryString; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a QueryException using the specified cause. |
||||||
|
* |
||||||
|
* @param cause The underlying cause |
||||||
|
*/ |
||||||
|
public QueryException(Exception cause) { |
||||||
|
this( "A query exception occurred", null, cause ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Retrieve the query being evaluated when the exception occurred. May be null, but generally should not. |
||||||
|
* |
||||||
|
* @return The query string |
||||||
|
*/ |
||||||
|
public String getQueryString() { |
||||||
|
return queryString; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMessage() { |
||||||
|
String msg = getOriginalMessage(); |
||||||
|
if ( queryString != null ) { |
||||||
|
msg += " [" + queryString + ']'; |
||||||
|
} |
||||||
|
return msg; |
||||||
|
} |
||||||
|
|
||||||
|
protected final String getOriginalMessage() { |
||||||
|
return super.getMessage(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Wraps this exception with another, of same kind, with the specified queryString. If this exception already |
||||||
|
* has a queryString defined, the same exception ({@code this}) is returned. Otherwise the protected |
||||||
|
* {@link #generateQueryException(String)} is called, to allow subclasses to properly create the correct |
||||||
|
* subclass for return. |
||||||
|
* |
||||||
|
* @param queryString The query string that led to the QueryException |
||||||
|
* |
||||||
|
* @return {@code this}, if {@code this} has {@code null} for {@link #getQueryString()}; otherwise a new |
||||||
|
* QueryException (or subclass) is returned. |
||||||
|
*/ |
||||||
|
public final QueryException wrapWithQueryString(String queryString) { |
||||||
|
if ( this.getQueryString() != null ) { |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
return generateQueryException( queryString ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Called from {@link #wrapWithQueryString(String)} when we really need to generate a new QueryException |
||||||
|
* (or subclass). |
||||||
|
* <p/> |
||||||
|
* NOTE : implementors should take care to use {@link #getOriginalMessage()} for the message, not |
||||||
|
* {@link #getMessage()} |
||||||
|
* |
||||||
|
* @param queryString The query string |
||||||
|
* |
||||||
|
* @return The generated QueryException (or subclass) |
||||||
|
* |
||||||
|
* @see #getOriginalMessage() |
||||||
|
*/ |
||||||
|
protected QueryException generateQueryException(String queryString) { |
||||||
|
return new QueryException( getOriginalMessage(), queryString, this ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Parameter invalid or not found in the query. |
||||||
|
* |
||||||
|
* @author Emmanuel Bernard |
||||||
|
*/ |
||||||
|
public class QueryParameterException extends QueryException { |
||||||
|
/** |
||||||
|
* Constructs a QueryParameterException using the supplied exception message. |
||||||
|
* |
||||||
|
* @param message The message explaining the exception condition |
||||||
|
*/ |
||||||
|
public QueryParameterException(String message) { |
||||||
|
super( message ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a QueryParameterException |
||||||
|
* |
||||||
|
* @param message The message explaining the exception condition |
||||||
|
* @param queryString The query that led to the exception |
||||||
|
* @param cause The underlying cause |
||||||
|
*/ |
||||||
|
public QueryParameterException(String message, String queryString, Exception cause) { |
||||||
|
super( message, queryString, cause ); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected QueryException generateQueryException(String queryString) { |
||||||
|
return new QueryParameterException( super.getOriginalMessage(), queryString, this ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.sql.SQLException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Thrown when a database query timeout occurs. |
||||||
|
* |
||||||
|
* @author Scott Marlow |
||||||
|
*/ |
||||||
|
public class QueryTimeoutException extends JDBCException { |
||||||
|
/** |
||||||
|
* Constructs a QueryTimeoutException using the supplied information. |
||||||
|
* |
||||||
|
* @param message The message explaining the exception condition |
||||||
|
* @param sqlException The underlying SQLException |
||||||
|
* @param sql The sql being executed when the exception occurred. |
||||||
|
*/ |
||||||
|
public QueryTimeoutException(String message, SQLException sqlException, String sql) { |
||||||
|
super( message, sqlException, sql ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,69 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.type.VersionType; |
||||||
|
|
||||||
|
/** |
||||||
|
* Represents a replication strategy. |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
* @see Session#replicate(Object, ReplicationMode) |
||||||
|
*/ |
||||||
|
public enum ReplicationMode { |
||||||
|
/** |
||||||
|
* Throw an exception when a row already exists. |
||||||
|
*/ |
||||||
|
EXCEPTION { |
||||||
|
@Override |
||||||
|
public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) { |
||||||
|
throw new AssertionFailure( "should not be called" ); |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* Ignore replicated entities when a row already exists. |
||||||
|
*/ |
||||||
|
IGNORE { |
||||||
|
@Override |
||||||
|
public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* Overwrite existing rows when a row already exists. |
||||||
|
*/ |
||||||
|
OVERWRITE { |
||||||
|
@Override |
||||||
|
public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* When a row already exists, choose the latest version. |
||||||
|
*/ |
||||||
|
LATEST_VERSION { |
||||||
|
@Override |
||||||
|
@SuppressWarnings("unchecked") |
||||||
|
public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) { |
||||||
|
// always overwrite non-versioned data (because we don't know which is newer)
|
||||||
|
return versionType == null || versionType.getComparator().compare( currentVersion, newVersion ) <= 0; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Determine whether the mode dictates that the data being replicated should overwrite the data found. |
||||||
|
* |
||||||
|
* @param entity The entity being replicated |
||||||
|
* @param currentVersion The version currently on the target database table. |
||||||
|
* @param newVersion The replicating version |
||||||
|
* @param versionType The version type |
||||||
|
* |
||||||
|
* @return {@code true} indicates the data should be overwritten; {@code false} indicates it should not. |
||||||
|
*/ |
||||||
|
public abstract boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Indicates an attempt was made to use a closed resource (Session, SessionFactory, etc). |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public class ResourceClosedException extends HibernateException { |
||||||
|
/** |
||||||
|
* Constructs a ResourceClosedException using the supplied message. |
||||||
|
* |
||||||
|
* @param message The message explaining the exception condition |
||||||
|
*/ |
||||||
|
public ResourceClosedException(String message) { |
||||||
|
super( message ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,329 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.engine.query.spi.sql.NativeSQLQueryReturn; |
||||||
|
import com.fr.third.org.hibernate.type.Type; |
||||||
|
|
||||||
|
/** |
||||||
|
* Represents a "native sql" query. |
||||||
|
* |
||||||
|
* Allows the user to define certain aspects about its execution, such as:<ul> |
||||||
|
* <li> |
||||||
|
* result-set value mapping (see below) |
||||||
|
* </li> |
||||||
|
* <li> |
||||||
|
* Tables used via {@link #addSynchronizedQuerySpace}, {@link #addSynchronizedEntityName} and |
||||||
|
* {@link #addSynchronizedEntityClass}. This allows Hibernate to know how to properly deal with |
||||||
|
* auto-flush checking as well as cached query results if the results of the query are being |
||||||
|
* cached. |
||||||
|
* </li> |
||||||
|
* </ul> |
||||||
|
* |
||||||
|
* In terms of result-set mapping, there are 3 approaches to defining:<ul> |
||||||
|
* <li> |
||||||
|
* If this represents a named sql query, the mapping could be associated with the query as part |
||||||
|
* of its metadata |
||||||
|
* </li> |
||||||
|
* <li> |
||||||
|
* A pre-defined (defined in metadata and named) mapping can be associated with |
||||||
|
* {@link #setResultSetMapping} |
||||||
|
* </li> |
||||||
|
* <li> |
||||||
|
* Defined locally per the various {@link #addEntity}, {@link #addRoot}, {@link #addJoin}, |
||||||
|
* {@link #addFetch} and {@link #addScalar} methods |
||||||
|
* </li> |
||||||
|
* </ul> |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public interface SQLQuery extends Query, SynchronizeableQuery { |
||||||
|
@Override |
||||||
|
SQLQuery addSynchronizedQuerySpace(String querySpace); |
||||||
|
|
||||||
|
@Override |
||||||
|
SQLQuery addSynchronizedEntityName(String entityName) throws MappingException; |
||||||
|
|
||||||
|
@Override |
||||||
|
SQLQuery addSynchronizedEntityClass(Class entityClass) throws MappingException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Use a predefined named result-set mapping. This might be defined by a {@code <result-set/>} element in a |
||||||
|
* Hibernate <tt>hbm.xml</tt> file or through a {@link javax.persistence.SqlResultSetMapping} annotation. |
||||||
|
* |
||||||
|
* @param name The name of the mapping to use. |
||||||
|
* |
||||||
|
* @return this, for method chaining |
||||||
|
*/ |
||||||
|
public SQLQuery setResultSetMapping(String name); |
||||||
|
|
||||||
|
/** |
||||||
|
* Is this native-SQL query known to be callable? |
||||||
|
* |
||||||
|
* @return {@code true} if the query is known to be callable; {@code false} otherwise. |
||||||
|
*/ |
||||||
|
public boolean isCallable(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Retrieve the returns associated with this query. |
||||||
|
* |
||||||
|
* @return The return descriptors |
||||||
|
*/ |
||||||
|
public List<NativeSQLQueryReturn> getQueryReturns(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Declare a scalar query result. Hibernate will attempt to automatically detect the underlying type. |
||||||
|
* <p/> |
||||||
|
* Functions like {@code <return-scalar/>} in {@code hbm.xml} or {@link javax.persistence.ColumnResult} |
||||||
|
* |
||||||
|
* @param columnAlias The column alias in the result-set to be processed as a scalar result |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SQLQuery addScalar(String columnAlias); |
||||||
|
|
||||||
|
/** |
||||||
|
* Declare a scalar query result. |
||||||
|
* <p/> |
||||||
|
* Functions like {@code <return-scalar/>} in {@code hbm.xml} or {@link javax.persistence.ColumnResult} |
||||||
|
* |
||||||
|
* @param columnAlias The column alias in the result-set to be processed as a scalar result |
||||||
|
* @param type The Hibernate type as which to treat the value. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SQLQuery addScalar(String columnAlias, Type type); |
||||||
|
|
||||||
|
/** |
||||||
|
* Add a new root return mapping, returning a {@link RootReturn} to allow further definition. |
||||||
|
* |
||||||
|
* @param tableAlias The SQL table alias to map to this entity |
||||||
|
* @param entityName The name of the entity. |
||||||
|
* |
||||||
|
* @return The return config object for further control. |
||||||
|
* |
||||||
|
* @since 3.6 |
||||||
|
*/ |
||||||
|
public RootReturn addRoot(String tableAlias, String entityName); |
||||||
|
|
||||||
|
/** |
||||||
|
* Add a new root return mapping, returning a {@link RootReturn} to allow further definition. |
||||||
|
* |
||||||
|
* @param tableAlias The SQL table alias to map to this entity |
||||||
|
* @param entityType The java type of the entity. |
||||||
|
* |
||||||
|
* @return The return config object for further control. |
||||||
|
* |
||||||
|
* @since 3.6 |
||||||
|
*/ |
||||||
|
public RootReturn addRoot(String tableAlias, Class entityType); |
||||||
|
|
||||||
|
/** |
||||||
|
* Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the |
||||||
|
* same as the unqualified entity name |
||||||
|
* <p/> |
||||||
|
* Use {@link #addRoot} if you need further control of the mapping |
||||||
|
* |
||||||
|
* @param entityName The entity name that is the root return of the query. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SQLQuery addEntity(String entityName); |
||||||
|
|
||||||
|
/** |
||||||
|
* Declare a "root" entity. |
||||||
|
* |
||||||
|
* @param tableAlias The SQL table alias |
||||||
|
* @param entityName The entity name |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SQLQuery addEntity(String tableAlias, String entityName); |
||||||
|
|
||||||
|
/** |
||||||
|
* Declare a "root" entity, specifying a lock mode. |
||||||
|
* |
||||||
|
* @param tableAlias The SQL table alias |
||||||
|
* @param entityName The entity name |
||||||
|
* @param lockMode The lock mode for this return. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SQLQuery addEntity(String tableAlias, String entityName, LockMode lockMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the |
||||||
|
* same as the unqualified entity name |
||||||
|
* |
||||||
|
* @param entityType The java type of the entity to add as a root |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SQLQuery addEntity(Class entityType); |
||||||
|
|
||||||
|
/** |
||||||
|
* Declare a "root" entity. |
||||||
|
* |
||||||
|
* @param tableAlias The SQL table alias |
||||||
|
* @param entityType The java type of the entity to add as a root |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SQLQuery addEntity(String tableAlias, Class entityType); |
||||||
|
|
||||||
|
/** |
||||||
|
* Declare a "root" entity, specifying a lock mode. |
||||||
|
* |
||||||
|
* @param tableAlias The SQL table alias |
||||||
|
* @param entityName The entity name |
||||||
|
* @param lockMode The lock mode for this return. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SQLQuery addEntity(String tableAlias, Class entityName, LockMode lockMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Declare a join fetch result. |
||||||
|
* |
||||||
|
* @param tableAlias The SQL table alias for the data to be mapped to this fetch |
||||||
|
* @param ownerTableAlias Identify the table alias of the owner of this association. Should match the alias of a |
||||||
|
* previously added root or fetch |
||||||
|
* @param joinPropertyName The name of the property being join fetched. |
||||||
|
* |
||||||
|
* @return The return config object for further control. |
||||||
|
* |
||||||
|
* @since 3.6 |
||||||
|
*/ |
||||||
|
public FetchReturn addFetch(String tableAlias, String ownerTableAlias, String joinPropertyName); |
||||||
|
|
||||||
|
/** |
||||||
|
* Declare a join fetch result. |
||||||
|
* |
||||||
|
* @param tableAlias The SQL table alias for the data to be mapped to this fetch |
||||||
|
* @param path The association path ([owner-alias].[property-name]). |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SQLQuery addJoin(String tableAlias, String path); |
||||||
|
|
||||||
|
/** |
||||||
|
* Declare a join fetch result. |
||||||
|
* |
||||||
|
* @param tableAlias The SQL table alias for the data to be mapped to this fetch |
||||||
|
* @param ownerTableAlias Identify the table alias of the owner of this association. Should match the alias of a |
||||||
|
* previously added root or fetch |
||||||
|
* @param joinPropertyName The name of the property being join fetched. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
* |
||||||
|
* @since 3.6 |
||||||
|
*/ |
||||||
|
public SQLQuery addJoin(String tableAlias, String ownerTableAlias, String joinPropertyName); |
||||||
|
|
||||||
|
/** |
||||||
|
* Declare a join fetch result, specifying a lock mode. |
||||||
|
* |
||||||
|
* @param tableAlias The SQL table alias for the data to be mapped to this fetch |
||||||
|
* @param path The association path ([owner-alias].[property-name]). |
||||||
|
* @param lockMode The lock mode for this return. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SQLQuery addJoin(String tableAlias, String path, LockMode lockMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Allows access to further control how properties within a root or join fetch are mapped back from the result set. |
||||||
|
* Generally used in composite value scenarios. |
||||||
|
*/ |
||||||
|
public static interface ReturnProperty { |
||||||
|
/** |
||||||
|
* Add a column alias to this property mapping. |
||||||
|
* |
||||||
|
* @param columnAlias The column alias. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public ReturnProperty addColumnAlias(String columnAlias); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Allows access to further control how root returns are mapped back from result sets. |
||||||
|
*/ |
||||||
|
public static interface RootReturn { |
||||||
|
/** |
||||||
|
* Set the lock mode for this return. |
||||||
|
* |
||||||
|
* @param lockMode The new lock mode. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public RootReturn setLockMode(LockMode lockMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Name the column alias that identifies the entity's discriminator. |
||||||
|
* |
||||||
|
* @param columnAlias The discriminator column alias |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public RootReturn setDiscriminatorAlias(String columnAlias); |
||||||
|
|
||||||
|
/** |
||||||
|
* Add a simple property-to-one-column mapping. |
||||||
|
* |
||||||
|
* @param propertyName The name of the property. |
||||||
|
* @param columnAlias The name of the column |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public RootReturn addProperty(String propertyName, String columnAlias); |
||||||
|
|
||||||
|
/** |
||||||
|
* Add a property, presumably with more than one column. |
||||||
|
* |
||||||
|
* @param propertyName The name of the property. |
||||||
|
* |
||||||
|
* @return The config object for further control. |
||||||
|
*/ |
||||||
|
public ReturnProperty addProperty(String propertyName); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Allows access to further control how join fetch returns are mapped back from result sets. |
||||||
|
*/ |
||||||
|
public static interface FetchReturn { |
||||||
|
/** |
||||||
|
* Set the lock mode for this return. |
||||||
|
* |
||||||
|
* @param lockMode The new lock mode. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public FetchReturn setLockMode(LockMode lockMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Add a simple property-to-one-column mapping. |
||||||
|
* |
||||||
|
* @param propertyName The name of the property. |
||||||
|
* @param columnAlias The name of the column |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public FetchReturn addProperty(String propertyName, String columnAlias); |
||||||
|
|
||||||
|
/** |
||||||
|
* Add a property, presumably with more than one column. |
||||||
|
* |
||||||
|
* @param propertyName The name of the property. |
||||||
|
* |
||||||
|
* @return The config object for further control. |
||||||
|
*/ |
||||||
|
public ReturnProperty addProperty(String propertyName); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,68 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.sql.ResultSet; |
||||||
|
|
||||||
|
/** |
||||||
|
* Specifies the type of JDBC scrollable result set to use underneath a {@link ScrollableResults}. |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public enum ScrollMode { |
||||||
|
/** |
||||||
|
* Requests a scrollable result that is only scrollable forwards. |
||||||
|
* |
||||||
|
* @see java.sql.ResultSet#TYPE_FORWARD_ONLY |
||||||
|
*/ |
||||||
|
FORWARD_ONLY( ResultSet.TYPE_FORWARD_ONLY ), |
||||||
|
|
||||||
|
/** |
||||||
|
* Requests a scrollable result which is sensitive to changes in the underlying data. |
||||||
|
* |
||||||
|
* @see java.sql.ResultSet#TYPE_SCROLL_SENSITIVE |
||||||
|
*/ |
||||||
|
SCROLL_SENSITIVE( ResultSet.TYPE_SCROLL_SENSITIVE ), |
||||||
|
|
||||||
|
/** |
||||||
|
* Requests a scrollable result which is insensitive to changes in the underlying data. |
||||||
|
* |
||||||
|
* Note that since the Hibernate session acts as a cache, you |
||||||
|
* might need to explicitly evict objects, if you need to see |
||||||
|
* changes made by other transactions. |
||||||
|
* |
||||||
|
* @see java.sql.ResultSet#TYPE_SCROLL_INSENSITIVE |
||||||
|
*/ |
||||||
|
SCROLL_INSENSITIVE( ResultSet.TYPE_SCROLL_INSENSITIVE ); |
||||||
|
|
||||||
|
private final int resultSetType; |
||||||
|
|
||||||
|
private ScrollMode(int level) { |
||||||
|
this.resultSetType = level; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the corresponding JDBC scroll type code constant value. |
||||||
|
* |
||||||
|
* @return the JDBC result set type code |
||||||
|
*/ |
||||||
|
public int toResultSetType() { |
||||||
|
return resultSetType; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Determine if {@code this} mode is "less than" the provided mode. |
||||||
|
* |
||||||
|
* @param other The provided mode |
||||||
|
* |
||||||
|
* @return {@code true} if this mode is less than the other. |
||||||
|
*/ |
||||||
|
public boolean lessThan(ScrollMode other) { |
||||||
|
return this.resultSetType < other.resultSetType; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,358 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.math.BigInteger; |
||||||
|
import java.sql.Blob; |
||||||
|
import java.sql.Clob; |
||||||
|
import java.util.Calendar; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.Locale; |
||||||
|
import java.util.TimeZone; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.type.Type; |
||||||
|
|
||||||
|
/** |
||||||
|
* A result iterator that allows moving around within the results |
||||||
|
* by arbitrary increments. The <tt>Query</tt> / <tt>ScrollableResults</tt> |
||||||
|
* pattern is very similar to the JDBC <tt>PreparedStatement</tt>/ |
||||||
|
* <tt>ResultSet</tt> pattern and the semantics of methods of this interface
|
||||||
|
* are similar to the similarly named methods on <tt>ResultSet</tt>.<br> |
||||||
|
* <br> |
||||||
|
* Contrary to JDBC, columns of results are numbered from zero. |
||||||
|
* |
||||||
|
* @see Query#scroll() |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public interface ScrollableResults extends java.io.Closeable { |
||||||
|
/** |
||||||
|
* Advance to the next result. |
||||||
|
* |
||||||
|
* @return {@code true} if there is another result |
||||||
|
*/ |
||||||
|
public boolean next(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Retreat to the previous result. |
||||||
|
* |
||||||
|
* @return {@code true} if there is a previous result |
||||||
|
*/ |
||||||
|
public boolean previous(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Scroll the specified number of positions from the current position. |
||||||
|
* |
||||||
|
* @param positions a positive (forward) or negative (backward) number of rows |
||||||
|
* |
||||||
|
* @return {@code true} if there is a result at the new location |
||||||
|
*/ |
||||||
|
public boolean scroll(int positions); |
||||||
|
|
||||||
|
/** |
||||||
|
* Go to the last result. |
||||||
|
* |
||||||
|
* @return {@code true} if there are any results |
||||||
|
*/ |
||||||
|
public boolean last(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Go to the first result. |
||||||
|
* |
||||||
|
* @return {@code true} if there are any results |
||||||
|
*/ |
||||||
|
public boolean first(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Go to a location just before first result, This is the location of the cursor on a newly returned |
||||||
|
* scrollable result. |
||||||
|
*/ |
||||||
|
public void beforeFirst(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Go to a location just after the last result. |
||||||
|
*/ |
||||||
|
public void afterLast(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Is this the first result? |
||||||
|
* |
||||||
|
* @return {@code true} if this is the first row of results, otherwise {@code false} |
||||||
|
*/ |
||||||
|
public boolean isFirst(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Is this the last result? |
||||||
|
* |
||||||
|
* @return {@code true} if this is the last row of results. |
||||||
|
*/ |
||||||
|
public boolean isLast(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the current position in the results. The first position is number 0 (unlike JDBC). |
||||||
|
* |
||||||
|
* @return The current position number, numbered from 0; -1 indicates that there is no current row |
||||||
|
*/ |
||||||
|
public int getRowNumber(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the current position in the result set. Can be numbered from the first position (positive number) or |
||||||
|
* the last row (negative number). |
||||||
|
* |
||||||
|
* @param rowNumber the row number. A positive number indicates a value numbered from the first row; a |
||||||
|
* negative number indicates a value numbered from the last row. |
||||||
|
* |
||||||
|
* @return true if there is a row at that row number |
||||||
|
*/ |
||||||
|
public boolean setRowNumber(int rowNumber); |
||||||
|
|
||||||
|
/** |
||||||
|
* Release resources immediately. |
||||||
|
*/ |
||||||
|
public void close(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the current row of results. |
||||||
|
* |
||||||
|
* @return The array of results |
||||||
|
*/ |
||||||
|
public Object[] get(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the <tt>i</tt>th object in the current row of results, without |
||||||
|
* initializing any other results in the row. This method may be used |
||||||
|
* safely, regardless of the type of the column (ie. even for scalar |
||||||
|
* results). |
||||||
|
* |
||||||
|
* @param i the column, numbered from zero |
||||||
|
* |
||||||
|
* @return The requested result object; may return {@code null} |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If i is an invalid index. |
||||||
|
*/ |
||||||
|
public Object get(int i); |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the type of the <tt>i</tt>th column of results. |
||||||
|
* |
||||||
|
* @param i the column, numbered from zero |
||||||
|
* |
||||||
|
* @return the Hibernate type |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If i is an invalid index. |
||||||
|
*/ |
||||||
|
public Type getType(int i); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read an integer. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as an integer |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public Integer getInteger(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a long. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a long |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public Long getLong(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a float. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a float |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public Float getFloat(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a boolean. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a boolean |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public Boolean getBoolean(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a double. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a double |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public Double getDouble(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a short. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a short |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public Short getShort(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a byte. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a byte |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public Byte getByte(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a char. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a char |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public Character getCharacter(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a binary (byte[]). |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a binary (byte[]) |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public byte[] getBinary(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a String using streaming. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a String |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public String getText(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a blob. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a Blob |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public Blob getBlob(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a clob. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a Clob |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public Clob getClob(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a string. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a String |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public String getString(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a BigDecimal. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a BigDecimal |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public BigDecimal getBigDecimal(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a BigInteger. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a BigInteger |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public BigInteger getBigInteger(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a Date. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a Date |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public Date getDate(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a Locale. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a Locale |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public Locale getLocale(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a Calendar. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a Calendar |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public Calendar getCalendar(int col); |
||||||
|
|
||||||
|
/** |
||||||
|
* Convenience method to read a TimeZone. |
||||||
|
* |
||||||
|
* @param col The column, numbered from zero |
||||||
|
* |
||||||
|
* @return The column value as a TimeZone |
||||||
|
* |
||||||
|
* @throws IndexOutOfBoundsException If col is an invalid index. |
||||||
|
*/ |
||||||
|
public TimeZone getTimeZone(int col); |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,131 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.sql.Connection; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.resource.jdbc.spi.StatementInspector; |
||||||
|
|
||||||
|
/** |
||||||
|
* Represents a consolidation of all session creation options into a builder style delegate. |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public interface SessionBuilder { |
||||||
|
/** |
||||||
|
* Opens a session with the specified options. |
||||||
|
* |
||||||
|
* @return The session |
||||||
|
*/ |
||||||
|
public Session openSession(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Adds a specific interceptor to the session options. |
||||||
|
* |
||||||
|
* @param interceptor The interceptor to use. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SessionBuilder interceptor(Interceptor interceptor); |
||||||
|
|
||||||
|
/** |
||||||
|
* Signifies that no {@link Interceptor} should be used. |
||||||
|
* <p/> |
||||||
|
* By default the {@link Interceptor} associated with the {@link SessionFactory} is passed to the |
||||||
|
* {@link Session} whenever we open one without the user having specified a specific interceptor to |
||||||
|
* use. |
||||||
|
* <p/> |
||||||
|
* Calling {@link #interceptor(Interceptor)} with null has the same net effect. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SessionBuilder noInterceptor(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Applies a specific StatementInspector to the session options. |
||||||
|
* |
||||||
|
* @param statementInspector The StatementInspector to use. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SessionBuilder statementInspector(StatementInspector statementInspector); |
||||||
|
|
||||||
|
/** |
||||||
|
* Adds a specific connection to the session options. |
||||||
|
* |
||||||
|
* @param connection The connection to use. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SessionBuilder connection(Connection connection); |
||||||
|
|
||||||
|
/** |
||||||
|
* Use a specific connection release mode for these session options. |
||||||
|
* |
||||||
|
* @param connectionReleaseMode The connection release mode to use. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SessionBuilder connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode); |
||||||
|
|
||||||
|
/** |
||||||
|
* Should the session built automatically join in any ongoing JTA transactions. |
||||||
|
* |
||||||
|
* @param autoJoinTransactions Should JTA transactions be automatically joined |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SessionBuilder autoJoinTransactions(boolean autoJoinTransactions); |
||||||
|
|
||||||
|
/** |
||||||
|
* Should the session be automatically closed after transaction completion. |
||||||
|
* |
||||||
|
* @param autoClose Should the session be automatically closed |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
* |
||||||
|
* @deprecated Only integrations can specify autoClosing behavior of individual sessions. See |
||||||
|
* {@link com.fr.third.org.hibernate.engine.spi.SessionOwner} |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public SessionBuilder autoClose(boolean autoClose); |
||||||
|
|
||||||
|
/** |
||||||
|
* Should the session be automatically flushed during the "before completion" phase of transaction handling. |
||||||
|
* |
||||||
|
* @param flushBeforeCompletion Should the session be automatically flushed |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SessionBuilder flushBeforeCompletion(boolean flushBeforeCompletion); |
||||||
|
|
||||||
|
/** |
||||||
|
* Define the tenant identifier to be associated with the opened session. |
||||||
|
* |
||||||
|
* @param tenantIdentifier The tenant identifier. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SessionBuilder tenantIdentifier(String tenantIdentifier); |
||||||
|
|
||||||
|
/** |
||||||
|
* Apply one or more SessionEventListener instances to the listeners for the Session to be built. |
||||||
|
* |
||||||
|
* @param listeners The listeners to incorporate into the built Session |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SessionBuilder eventListeners(SessionEventListener... listeners); |
||||||
|
|
||||||
|
/** |
||||||
|
* Remove all listeners intended for the built Session currently held here, including any auto-apply ones; in other |
||||||
|
* words, start with a clean slate. |
||||||
|
* |
||||||
|
* {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SessionBuilder clearEventListeners(); |
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* NOTE : Consider this an incubating API, likely to change as wider usage indicates changes that need to be made |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public interface SessionEventListener extends Serializable { |
||||||
|
public void transactionCompletion(boolean successful); |
||||||
|
|
||||||
|
public void jdbcConnectionAcquisitionStart(); |
||||||
|
public void jdbcConnectionAcquisitionEnd(); |
||||||
|
|
||||||
|
public void jdbcConnectionReleaseStart(); |
||||||
|
public void jdbcConnectionReleaseEnd(); |
||||||
|
|
||||||
|
public void jdbcPrepareStatementStart(); |
||||||
|
public void jdbcPrepareStatementEnd(); |
||||||
|
|
||||||
|
public void jdbcExecuteStatementStart(); |
||||||
|
public void jdbcExecuteStatementEnd(); |
||||||
|
|
||||||
|
public void jdbcExecuteBatchStart(); |
||||||
|
public void jdbcExecuteBatchEnd(); |
||||||
|
|
||||||
|
public void cachePutStart(); |
||||||
|
public void cachePutEnd(); |
||||||
|
|
||||||
|
public void cacheGetStart(); |
||||||
|
public void cacheGetEnd(boolean hit); |
||||||
|
|
||||||
|
public void flushStart(); |
||||||
|
public void flushEnd(int numberOfEntities, int numberOfCollections); |
||||||
|
|
||||||
|
public void partialFlushStart(); |
||||||
|
public void partialFlushEnd(int numberOfEntities, int numberOfCollections); |
||||||
|
|
||||||
|
public void dirtyCalculationStart(); |
||||||
|
public void dirtyCalculationEnd(boolean dirty); |
||||||
|
|
||||||
|
public void end(); |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Thrown when the user calls a method of a {@link Session} that is in an inappropriate state for the given call (for |
||||||
|
* example, the the session is closed or disconnected). |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
*/ |
||||||
|
public class SessionException extends HibernateException { |
||||||
|
/** |
||||||
|
* Constructs a new SessionException with the given message. |
||||||
|
* |
||||||
|
* @param message The message indicating the specific problem. |
||||||
|
*/ |
||||||
|
public SessionException(String message) { |
||||||
|
super( message ); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructs a new SessionException with the given message. |
||||||
|
* |
||||||
|
* @param message The message indicating the specific problem. |
||||||
|
* @param cause An exception which caused this exception to be created. |
||||||
|
*/ |
||||||
|
public SessionException(String message, Throwable cause) { |
||||||
|
super( message, cause ); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,228 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.sql.Connection; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.Set; |
||||||
|
import javax.naming.Referenceable; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.boot.spi.SessionFactoryOptions; |
||||||
|
import com.fr.third.org.hibernate.engine.spi.FilterDefinition; |
||||||
|
import com.fr.third.org.hibernate.metadata.ClassMetadata; |
||||||
|
import com.fr.third.org.hibernate.metadata.CollectionMetadata; |
||||||
|
import com.fr.third.org.hibernate.stat.Statistics; |
||||||
|
|
||||||
|
/** |
||||||
|
* The main contract here is the creation of {@link Session} instances. Usually |
||||||
|
* an application has a single {@link SessionFactory} instance and threads |
||||||
|
* servicing client requests obtain {@link Session} instances from this factory. |
||||||
|
* <p/> |
||||||
|
* The internal state of a {@link SessionFactory} is immutable. Once it is created |
||||||
|
* this internal state is set. This internal state includes all of the metadata |
||||||
|
* about Object/Relational Mapping. |
||||||
|
* <p/> |
||||||
|
* Implementors <strong>must</strong> be threadsafe. |
||||||
|
* |
||||||
|
* @see com.fr.third.org.hibernate.cfg.Configuration |
||||||
|
* |
||||||
|
* @author Gavin King |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public interface SessionFactory extends Referenceable, Serializable, java.io.Closeable { |
||||||
|
/** |
||||||
|
* Get the special options used to build the factory. |
||||||
|
* |
||||||
|
* @return The special options used to build the factory. |
||||||
|
*/ |
||||||
|
SessionFactoryOptions getSessionFactoryOptions(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtain a {@link Session} builder. |
||||||
|
* |
||||||
|
* @return The session builder |
||||||
|
*/ |
||||||
|
SessionBuilder withOptions(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Open a {@link Session}. |
||||||
|
* <p/> |
||||||
|
* JDBC {@link Connection connection(s} will be obtained from the |
||||||
|
* configured {@link com.fr.third.org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} as needed |
||||||
|
* to perform requested work. |
||||||
|
* |
||||||
|
* @return The created session. |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates a problem opening the session; pretty rare here. |
||||||
|
*/ |
||||||
|
Session openSession() throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtains the current session. The definition of what exactly "current" |
||||||
|
* means controlled by the {@link com.fr.third.org.hibernate.context.spi.CurrentSessionContext} impl configured |
||||||
|
* for use. |
||||||
|
* <p/> |
||||||
|
* Note that for backwards compatibility, if a {@link com.fr.third.org.hibernate.context.spi.CurrentSessionContext} |
||||||
|
* is not configured but JTA is configured this will default to the {@link com.fr.third.org.hibernate.context.internal.JTASessionContext} |
||||||
|
* impl. |
||||||
|
* |
||||||
|
* @return The current session. |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates an issue locating a suitable current session. |
||||||
|
*/ |
||||||
|
Session getCurrentSession() throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtain a {@link StatelessSession} builder. |
||||||
|
* |
||||||
|
* @return The stateless session builder |
||||||
|
*/ |
||||||
|
StatelessSessionBuilder withStatelessOptions(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Open a new stateless session. |
||||||
|
* |
||||||
|
* @return The created stateless session. |
||||||
|
*/ |
||||||
|
StatelessSession openStatelessSession(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Open a new stateless session, utilizing the specified JDBC |
||||||
|
* {@link Connection}. |
||||||
|
* |
||||||
|
* @param connection Connection provided by the application. |
||||||
|
* |
||||||
|
* @return The created stateless session. |
||||||
|
*/ |
||||||
|
StatelessSession openStatelessSession(Connection connection); |
||||||
|
|
||||||
|
/** |
||||||
|
* Retrieve the {@link ClassMetadata} associated with the given entity class. |
||||||
|
* |
||||||
|
* @param entityClass The entity class
|
||||||
|
* |
||||||
|
* @return The metadata associated with the given entity; may be null if no such |
||||||
|
* entity was mapped. |
||||||
|
* |
||||||
|
* @throws HibernateException Generally null is returned instead of throwing. |
||||||
|
*/ |
||||||
|
ClassMetadata getClassMetadata(Class entityClass); |
||||||
|
|
||||||
|
/** |
||||||
|
* Retrieve the {@link ClassMetadata} associated with the given entity class. |
||||||
|
* |
||||||
|
* @param entityName The entity class
|
||||||
|
* |
||||||
|
* @return The metadata associated with the given entity; may be null if no such |
||||||
|
* entity was mapped. |
||||||
|
* |
||||||
|
* @throws HibernateException Generally null is returned instead of throwing. |
||||||
|
* @since 3.0 |
||||||
|
*/ |
||||||
|
ClassMetadata getClassMetadata(String entityName); |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the {@link CollectionMetadata} associated with the named collection role. |
||||||
|
* |
||||||
|
* @param roleName The collection role (in form [owning-entity-name].[collection-property-name]). |
||||||
|
* |
||||||
|
* @return The metadata associated with the given collection; may be null if no such |
||||||
|
* collection was mapped. |
||||||
|
* |
||||||
|
* @throws HibernateException Generally null is returned instead of throwing. |
||||||
|
*/ |
||||||
|
CollectionMetadata getCollectionMetadata(String roleName); |
||||||
|
|
||||||
|
/** |
||||||
|
* Retrieve the {@link ClassMetadata} for all mapped entities. |
||||||
|
* |
||||||
|
* @return A map containing all {@link ClassMetadata} keyed by the |
||||||
|
* corresponding {@link String} entity-name. |
||||||
|
* |
||||||
|
* @throws HibernateException Generally empty map is returned instead of throwing. |
||||||
|
* |
||||||
|
* @since 3.0 changed key from {@link Class} to {@link String}. |
||||||
|
*/ |
||||||
|
Map<String,ClassMetadata> getAllClassMetadata(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the {@link CollectionMetadata} for all mapped collections. |
||||||
|
* |
||||||
|
* @return a map from <tt>String</tt> to <tt>CollectionMetadata</tt> |
||||||
|
* |
||||||
|
* @throws HibernateException Generally empty map is returned instead of throwing. |
||||||
|
*/ |
||||||
|
Map getAllCollectionMetadata(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Retrieve the statistics fopr this factory. |
||||||
|
* |
||||||
|
* @return The statistics. |
||||||
|
*/ |
||||||
|
Statistics getStatistics(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Destroy this <tt>SessionFactory</tt> and release all resources (caches, |
||||||
|
* connection pools, etc). |
||||||
|
* <p/> |
||||||
|
* It is the responsibility of the application to ensure that there are no |
||||||
|
* open {@link Session sessions} before calling this method as the impact |
||||||
|
* on those {@link Session sessions} is indeterminate. |
||||||
|
* <p/> |
||||||
|
* No-ops if already {@link #isClosed closed}. |
||||||
|
* |
||||||
|
* @throws HibernateException Indicates an issue closing the factory. |
||||||
|
*/ |
||||||
|
void close() throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Is this factory already closed? |
||||||
|
* |
||||||
|
* @return True if this factory is already closed; false otherwise. |
||||||
|
*/ |
||||||
|
boolean isClosed(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtain direct access to the underlying cache regions. |
||||||
|
* |
||||||
|
* @return The direct cache access API. |
||||||
|
*/ |
||||||
|
Cache getCache(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtain a set of the names of all filters defined on this SessionFactory. |
||||||
|
* |
||||||
|
* @return The set of filter names. |
||||||
|
*/ |
||||||
|
Set getDefinedFilterNames(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Obtain the definition of a filter by name. |
||||||
|
* |
||||||
|
* @param filterName The name of the filter for which to obtain the definition. |
||||||
|
* @return The filter definition. |
||||||
|
* @throws HibernateException If no filter defined with the given name. |
||||||
|
*/ |
||||||
|
FilterDefinition getFilterDefinition(String filterName) throws HibernateException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Determine if this session factory contains a fetch profile definition |
||||||
|
* registered under the given name. |
||||||
|
* |
||||||
|
* @param name The name to check |
||||||
|
* @return True if there is such a fetch profile; false otherwise. |
||||||
|
*/ |
||||||
|
boolean containsFetchProfileDefinition(String name); |
||||||
|
|
||||||
|
/** |
||||||
|
* Retrieve this factory's {@link TypeHelper}. |
||||||
|
* |
||||||
|
* @return The factory's {@link TypeHelper} |
||||||
|
*/ |
||||||
|
TypeHelper getTypeHelper(); |
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* Allows reaction to basic {@link SessionFactory} occurrences. |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public interface SessionFactoryObserver extends Serializable { |
||||||
|
/** |
||||||
|
* Callback to indicate that the given factory has been created and is now ready for use. |
||||||
|
* |
||||||
|
* @param factory The factory initialized. |
||||||
|
*/ |
||||||
|
public void sessionFactoryCreated(SessionFactory factory); |
||||||
|
|
||||||
|
/** |
||||||
|
* Callback to indicate that the given factory has been closed. Care should be taken |
||||||
|
* in how (if at all) the passed factory reference is used since it is closed. |
||||||
|
* |
||||||
|
* @param factory The factory closed. |
||||||
|
*/ |
||||||
|
public void sessionFactoryClosed(SessionFactory factory); |
||||||
|
} |
@ -0,0 +1,90 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.sql.Connection; |
||||||
|
|
||||||
|
/** |
||||||
|
* Specialized {@link SessionBuilder} with access to stuff from another session. |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public interface SharedSessionBuilder extends SessionBuilder { |
||||||
|
/** |
||||||
|
* Signifies the interceptor from the original session should be used to create the new session. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SharedSessionBuilder interceptor(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Signifies that the connection from the original session should be used to create the new session. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SharedSessionBuilder connection(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Signifies that the connection release mode from the original session should be used to create the new session. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SharedSessionBuilder connectionReleaseMode(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Signifies that the autoJoinTransaction flag from the original session should be used to create the new session. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SharedSessionBuilder autoJoinTransactions(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Signifies that the autoClose flag from the original session should be used to create the new session. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
* |
||||||
|
* @deprecated For same reasons as {@link SessionBuilder#autoClose(boolean)} was deprecated. However, shared |
||||||
|
* session builders can use {@link #autoClose(boolean)} since they do not "inherit" the owner. |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public SharedSessionBuilder autoClose(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Signifies that the flushBeforeCompletion flag from the original session should be used to create the new session. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SharedSessionBuilder flushBeforeCompletion(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Signifies that the transaction context from the original session should be used to create the new session. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SharedSessionBuilder transactionContext(); |
||||||
|
|
||||||
|
@Override |
||||||
|
SharedSessionBuilder interceptor(Interceptor interceptor); |
||||||
|
|
||||||
|
@Override |
||||||
|
SharedSessionBuilder noInterceptor(); |
||||||
|
|
||||||
|
@Override |
||||||
|
SharedSessionBuilder connection(Connection connection); |
||||||
|
|
||||||
|
@Override |
||||||
|
SharedSessionBuilder connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode); |
||||||
|
|
||||||
|
@Override |
||||||
|
SharedSessionBuilder autoJoinTransactions(boolean autoJoinTransactions); |
||||||
|
|
||||||
|
@Override |
||||||
|
SharedSessionBuilder autoClose(boolean autoClose); |
||||||
|
|
||||||
|
@Override |
||||||
|
SharedSessionBuilder flushBeforeCompletion(boolean flushBeforeCompletion); |
||||||
|
} |
@ -0,0 +1,151 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
import com.fr.third.org.hibernate.procedure.ProcedureCall; |
||||||
|
|
||||||
|
/** |
||||||
|
* Contract methods shared between {@link Session} and {@link StatelessSession}. |
||||||
|
* |
||||||
|
* @author Steve Ebersole |
||||||
|
*/ |
||||||
|
public interface SharedSessionContract extends Serializable { |
||||||
|
/** |
||||||
|
* Obtain the tenant identifier associated with this session. |
||||||
|
* |
||||||
|
* @return The tenant identifier associated with this session, or {@code null} |
||||||
|
*/ |
||||||
|
public String getTenantIdentifier(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Begin a unit of work and return the associated {@link Transaction} object. If a new underlying transaction is |
||||||
|
* required, begin the transaction. Otherwise continue the new work in the context of the existing underlying |
||||||
|
* transaction. |
||||||
|
* |
||||||
|
* @return a Transaction instance |
||||||
|
* |
||||||
|
* @see #getTransaction |
||||||
|
*/ |
||||||
|
public Transaction beginTransaction(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the {@link Transaction} instance associated with this session. The concrete type of the returned |
||||||
|
* {@link Transaction} object is determined by the {@code hibernate.transaction_factory} property. |
||||||
|
* |
||||||
|
* @return a Transaction instance |
||||||
|
*/ |
||||||
|
public Transaction getTransaction(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a {@link Query} instance for the named query string defined in the metadata. |
||||||
|
* |
||||||
|
* @param queryName the name of a query defined externally |
||||||
|
* |
||||||
|
* @return The query instance for manipulation and execution |
||||||
|
*/ |
||||||
|
public Query getNamedQuery(String queryName); |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a {@link Query} instance for the given HQL query string. |
||||||
|
* |
||||||
|
* @param queryString The HQL query |
||||||
|
* |
||||||
|
* @return The query instance for manipulation and execution |
||||||
|
*/ |
||||||
|
public Query createQuery(String queryString); |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a {@link SQLQuery} instance for the given SQL query string. |
||||||
|
* |
||||||
|
* @param queryString The SQL query |
||||||
|
* |
||||||
|
* @return The query instance for manipulation and execution |
||||||
|
*/ |
||||||
|
public SQLQuery createSQLQuery(String queryString); |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets a ProcedureCall based on a named template |
||||||
|
* |
||||||
|
* @param name The name given to the template |
||||||
|
* |
||||||
|
* @return The ProcedureCall |
||||||
|
* |
||||||
|
* @see javax.persistence.NamedStoredProcedureQuery |
||||||
|
*/ |
||||||
|
public ProcedureCall getNamedProcedureCall(String name); |
||||||
|
|
||||||
|
/** |
||||||
|
* Creates a call to a stored procedure. |
||||||
|
* |
||||||
|
* @param procedureName The name of the procedure. |
||||||
|
* |
||||||
|
* @return The representation of the procedure call. |
||||||
|
*/ |
||||||
|
public ProcedureCall createStoredProcedureCall(String procedureName); |
||||||
|
|
||||||
|
/** |
||||||
|
* Creates a call to a stored procedure with specific result set entity mappings. Each class named |
||||||
|
* is considered a "root return". |
||||||
|
* |
||||||
|
* @param procedureName The name of the procedure. |
||||||
|
* @param resultClasses The entity(s) to map the result on to. |
||||||
|
* |
||||||
|
* @return The representation of the procedure call. |
||||||
|
*/ |
||||||
|
public ProcedureCall createStoredProcedureCall(String procedureName, Class... resultClasses); |
||||||
|
|
||||||
|
/** |
||||||
|
* Creates a call to a stored procedure with specific result set entity mappings. |
||||||
|
* |
||||||
|
* @param procedureName The name of the procedure. |
||||||
|
* @param resultSetMappings The explicit result set mapping(s) to use for mapping the results |
||||||
|
* |
||||||
|
* @return The representation of the procedure call. |
||||||
|
*/ |
||||||
|
public ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings); |
||||||
|
|
||||||
|
/** |
||||||
|
* Create {@link Criteria} instance for the given class (entity or subclasses/implementors). |
||||||
|
* |
||||||
|
* @param persistentClass The class, which is an entity, or has entity subclasses/implementors |
||||||
|
* |
||||||
|
* @return The criteria instance for manipulation and execution |
||||||
|
*/ |
||||||
|
public Criteria createCriteria(Class persistentClass); |
||||||
|
|
||||||
|
/** |
||||||
|
* Create {@link Criteria} instance for the given class (entity or subclasses/implementors), using a specific |
||||||
|
* alias. |
||||||
|
* |
||||||
|
* @param persistentClass The class, which is an entity, or has entity subclasses/implementors |
||||||
|
* @param alias The alias to use |
||||||
|
* |
||||||
|
* @return The criteria instance for manipulation and execution |
||||||
|
*/ |
||||||
|
public Criteria createCriteria(Class persistentClass, String alias); |
||||||
|
|
||||||
|
/** |
||||||
|
* Create {@link Criteria} instance for the given entity name. |
||||||
|
* |
||||||
|
* @param entityName The entity name |
||||||
|
|
||||||
|
* @return The criteria instance for manipulation and execution |
||||||
|
*/ |
||||||
|
public Criteria createCriteria(String entityName); |
||||||
|
|
||||||
|
/** |
||||||
|
* Create {@link Criteria} instance for the given entity name, using a specific alias. |
||||||
|
* |
||||||
|
* @param entityName The entity name |
||||||
|
* @param alias The alias to use |
||||||
|
* |
||||||
|
* @return The criteria instance for manipulation and execution |
||||||
|
*/ |
||||||
|
public Criteria createCriteria(String entityName, String alias); |
||||||
|
} |
@ -0,0 +1,66 @@ |
|||||||
|
/* |
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java |
||||||
|
* |
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/ |
||||||
|
package com.fr.third.org.hibernate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Loads an entity by its natural identifier. |
||||||
|
* |
||||||
|
* @author Eric Dalquist |
||||||
|
* @author Steve Ebersole |
||||||
|
* |
||||||
|
* @see com.fr.third.org.hibernate.annotations.NaturalId |
||||||
|
* @see NaturalIdLoadAccess |
||||||
|
*/ |
||||||
|
public interface SimpleNaturalIdLoadAccess<T> { |
||||||
|
/** |
||||||
|
* Specify the {@link com.fr.third.org.hibernate.LockOptions} to use when retrieving the entity. |
||||||
|
* |
||||||
|
* @param lockOptions The lock options to use. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SimpleNaturalIdLoadAccess<T> with(LockOptions lockOptions); |
||||||
|
|
||||||
|
/** |
||||||
|
* For entities with mutable natural ids, should Hibernate perform "synchronization" prior to performing |
||||||
|
* lookups? The default is to perform "synchronization" (for correctness). |
||||||
|
* <p/> |
||||||
|
* See {@link NaturalIdLoadAccess#setSynchronizationEnabled} for detailed discussion. |
||||||
|
* |
||||||
|
* @param enabled Should synchronization be performed? {@code true} indicates synchronization will be performed; |
||||||
|
* {@code false} indicates it will be circumvented. |
||||||
|
* |
||||||
|
* @return {@code this}, for method chaining |
||||||
|
*/ |
||||||
|
public SimpleNaturalIdLoadAccess<T> setSynchronizationEnabled(boolean enabled); |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the persistent instance with the given natural id value, assuming that the instance exists. This method |
||||||
|
* might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed. |
||||||
|
* |
||||||
|
* You should not use this method to determine if an instance exists; to check for existence, use {@link #load} |
||||||
|
* instead. Use this only to retrieve an instance that you assume exists, where non-existence would be an |
||||||
|
* actual error. |
||||||
|
* |
||||||
|
* @param naturalIdValue The value of the natural-id for the entity to retrieve |
||||||
|
* |
||||||
|
* @return The persistent instance or proxy, if an instance exists. Otherwise, {@code null}. |
||||||
|
*/ |
||||||
|
public T getReference(Object naturalIdValue); |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the persistent instance with the given natural id value, or {@code null} if there is no such persistent |
||||||
|
* instance. If the instance is already associated with the session, return that instance, initializing it if |
||||||
|
* needed. This method never returns an uninitialized instance. |
||||||
|
* |
||||||
|
* @param naturalIdValue The value of the natural-id for the entity to retrieve |
||||||
|
* |
||||||
|
* @return The persistent instance or {@code null} |
||||||
|
*/ |
||||||
|
public T load(Object naturalIdValue); |
||||||
|
|
||||||
|
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue