Hibernate SVN: r17919 - in annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg: annotations and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2009-11-05 00:21:01 -0500 (Thu, 05 Nov 2009)
New Revision: 17919
Modified:
annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/Ejb3JoinColumn.java
annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/TableBinder.java
Log:
JBPAPP-3060 ANN-748 @JoinColumn overrides scale and percision in ManyToOne map..
Modified: annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/Ejb3JoinColumn.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/Ejb3JoinColumn.java 2009-11-05 04:28:31 UTC (rev 17918)
+++ annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/Ejb3JoinColumn.java 2009-11-05 05:21:01 UTC (rev 17919)
@@ -36,7 +36,7 @@
private String mappedByTableName;
private String mappedByEntityName;
- //FIXME hacky solution to get the information at proeprty ref resolution
+ //FIXME hacky solution to get the information at property ref resolution
public String getManyToManyOwnerSideEntityName() {
return manyToManyOwnerSideEntityName;
}
@@ -443,12 +443,25 @@
return PK_REFERENCE;
}
}
-
- public void overrideSqlTypeIfNecessary(org.hibernate.mapping.Column column) {
+
+ /**
+ * Called to apply column definitions from the referenced FK column to this column.
+ *
+ * @param column the referenced column.
+ */
+ public void overrideFromReferencedColumnIfNecessary(org.hibernate.mapping.Column column) {
+
+ // columnDefinition can also be specified using @JoinColumn, hence we have to check
+ // whether it is set or not
if ( StringHelper.isEmpty( sqlType ) ) {
sqlType = column.getSqlType();
if ( getMappingColumn() != null ) getMappingColumn().setSqlType( sqlType );
}
+
+ // these properties can only be applied on the referenced column - we can just take them over
+ getMappingColumn().setLength(column.getLength());
+ getMappingColumn().setPrecision(column.getPrecision());
+ getMappingColumn().setScale(column.getScale());
}
@Override
Modified: annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/TableBinder.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/TableBinder.java 2009-11-05 04:28:31 UTC (rev 17918)
+++ annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/TableBinder.java 2009-11-05 05:21:01 UTC (rev 17919)
@@ -32,6 +32,7 @@
*
* @author Emmanuel Bernard
*/
+@SuppressWarnings("unchecked")
public class TableBinder {
//TODO move it to a getter/setter strategy
private static Log log = LogFactory.getLog( TableBinder.class );
@@ -205,7 +206,8 @@
}
while ( mappedByColumns.hasNext() ) {
Column column = (Column) mappedByColumns.next();
- columns[0].overrideSqlTypeIfNecessary( column );
+ //columns[0].overrideSqlTypeIfNecessary( column );
+ columns[0].overrideFromReferencedColumnIfNecessary( column );
columns[0].linkValueUsingAColumnCopy( column, value );
}
}
@@ -223,7 +225,7 @@
}
while ( idColumns.hasNext() ) {
Column column = (Column) idColumns.next();
- columns[0].overrideSqlTypeIfNecessary( column );
+ columns[0].overrideFromReferencedColumnIfNecessary( column );
columns[0].linkValueUsingDefaultColumnNaming( column, referencedEntity, value );
}
}
@@ -310,7 +312,7 @@
else {
joinCol.linkWithValue( value );
}
- joinCol.overrideSqlTypeIfNecessary( col );
+ joinCol.overrideFromReferencedColumnIfNecessary( col );
match = true;
break;
}
@@ -342,8 +344,9 @@
}
else {
joinCol.linkWithValue( value );
+ joinCol.overrideFromReferencedColumnIfNecessary( synthCol );
}
- joinCol.overrideSqlTypeIfNecessary( synthCol );
+
}
}
15 years, 1 month
Hibernate SVN: r17918 - annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2009-11-04 23:28:31 -0500 (Wed, 04 Nov 2009)
New Revision: 17918
Modified:
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Bunny.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java
Log:
JBPAPP-1061 HHH-4397 Tests using sequences are run on databases which doesn't supports sequences
Modified: annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Bunny.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Bunny.java 2009-11-05 03:17:54 UTC (rev 17917)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Bunny.java 2009-11-05 04:28:31 UTC (rev 17918)
@@ -26,7 +26,7 @@
public class Bunny implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY, generator = "java5_uuid")
- @GenericGenerator(name = "java5_uuid", strategy = "org.hibernate.test.annotations.id.UUIDGenerator")
+ @GenericGenerator(name = "java5_uuid", strategy = "org.hibernate.test.annotations.id.sequences.UUIDGenerator")
@Column(name = "id", precision = 128, scale = 0)
private BigInteger id;
Modified: annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java 2009-11-05 03:17:54 UTC (rev 17917)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java 2009-11-05 04:28:31 UTC (rev 17918)
@@ -26,7 +26,7 @@
public class PointyTooth implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY, generator = "java5_uuid")
- @GenericGenerator(name = "java5_uuid", strategy = "org.hibernate.test.annotations.id.UUIDGenerator")
+ @GenericGenerator(name = "java5_uuid", strategy = "org.hibernate.test.annotations.id.sequences.UUIDGenerator")
@Column(name = "id", precision = 128, scale = 0)
private BigInteger id;
Modified: annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java 2009-11-05 03:17:54 UTC (rev 17917)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java 2009-11-05 04:28:31 UTC (rev 17918)
@@ -25,7 +25,7 @@
public class TwinkleToes implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY, generator = "java5_uuid")
- @GenericGenerator(name = "java5_uuid", strategy = "org.hibernate.test.annotations.id.UUIDGenerator")
+ @GenericGenerator(name = "java5_uuid", strategy = "org.hibernate.test.annotations.id.sequences.UUIDGenerator")
@Column(name = "id", precision = 128, scale = 0)
private BigInteger id;
15 years, 1 month
Hibernate SVN: r17917 - core/trunk/core/src/main/java/org/hibernate/jdbc.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-11-04 22:17:54 -0500 (Wed, 04 Nov 2009)
New Revision: 17917
Modified:
core/trunk/core/src/main/java/org/hibernate/jdbc/BorrowedConnectionProxy.java
Log:
HHH-3529 - ConnectionWrapper is not visible from class loader
Modified: core/trunk/core/src/main/java/org/hibernate/jdbc/BorrowedConnectionProxy.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/jdbc/BorrowedConnectionProxy.java 2009-11-04 23:32:27 UTC (rev 17916)
+++ core/trunk/core/src/main/java/org/hibernate/jdbc/BorrowedConnectionProxy.java 2009-11-05 03:17:54 UTC (rev 17917)
@@ -132,10 +132,6 @@
* @return The class loader appropriate for proxy construction.
*/
public static ClassLoader getProxyClassLoader() {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if ( cl == null ) {
- cl = BorrowedConnectionProxy.class.getClassLoader();
- }
- return cl;
+ return ConnectionWrapper.class.getClassLoader();
}
}
15 years, 1 month
Hibernate SVN: r17916 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-11-04 18:32:27 -0500 (Wed, 04 Nov 2009)
New Revision: 17916
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/association_mapping.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/batch.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/collection_mapping.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/component_mapping.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/configuration.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/events.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/example_mappings.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/example_parentchild.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/example_weblog.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/filters.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/inheritance_mapping.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/performance.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/persistent_classes.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/portability.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/query_criteria.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/query_hql.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/query_sql.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/session_api.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/toolset_guide.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/transactions.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/tutorial.xml
core/trunk/documentation/manual/src/main/docbook/en-US/content/xml.xml
Log:
HHH-4000 - Utlize jhighlight hooks for rendered syntax coloration of XML and Java based programlisting docbook elements
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/association_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/association_mapping.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/association_mapping.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -65,7 +65,7 @@
common kind of unidirectional association.
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
@@ -94,7 +94,7 @@
is almost identical. The only difference is the column unique constraint.
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
@@ -120,7 +120,7 @@
of the association:
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
@@ -149,7 +149,7 @@
is an unusual case, and is not recommended.
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
@@ -190,7 +190,7 @@
changes the multiplicity from many-to-many to one-to-many.
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
@@ -223,7 +223,7 @@
is common when the association is optional. For example:
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
@@ -257,7 +257,7 @@
but extremely unusual.
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
@@ -292,7 +292,7 @@
Finally, here is an example of a <emphasis>unidirectional many-to-many association</emphasis>.
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
@@ -330,7 +330,7 @@
relationship.
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
@@ -362,7 +362,7 @@
<literal>update="false"</literal> and <literal>insert="false"</literal>:
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id"/>
...
<many-to-one name="address"
@@ -402,7 +402,7 @@
is common:
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
@@ -429,7 +429,7 @@
uses the special id generator:
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
@@ -466,7 +466,7 @@
association, on the collection, or on the join.
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
@@ -508,7 +508,7 @@
but extremely unusual.
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
@@ -553,7 +553,7 @@
Here is an example of a <emphasis>bidirectional many-to-many association</emphasis>.
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
@@ -597,7 +597,7 @@
and <literal>effectiveStartDate</literal>columns, it would be mapped as follows:
</para>
- <programlisting><![CDATA[<properties name="currentAccountKey">
+ <programlisting role="XML"><![CDATA[<properties name="currentAccountKey">
<property name="accountNumber" type="string" not-null="true"/>
<property name="currentAccount" type="boolean">
<formula>case when effectiveEndDate is null then 1 else 0 end</formula>
@@ -611,7 +611,7 @@
the one with null <literal>effectiveEndDate</literal>, by using:
</para>
- <programlisting><![CDATA[<many-to-one name="currentAccountInfo"
+ <programlisting role="XML"><![CDATA[<many-to-one name="currentAccountInfo"
property-ref="currentAccountKey"
class="AccountInfo">
<column name="accountNumber"/>
@@ -626,7 +626,7 @@
the one with the most recent <literal>startDate</literal>, could be mapped in the following way:
</para>
- <programlisting><![CDATA[<join>
+ <programlisting role="XML"><![CDATA[<join>
<key column="employeeId"/>
<subselect>
select employeeId, orgId
@@ -646,6 +646,5 @@
</sect1>
-
</chapter>
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -48,7 +48,7 @@
Here is an example mapping:
</para>
- <programlisting id="mapping-declaration-ex1" revision="1"><![CDATA[<?xml version="1.0"?>
+ <programlisting id="mapping-declaration-ex1" role="XML"><![CDATA[<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
@@ -166,7 +166,7 @@
<para>
The following is an example of utilizing user namespacing:
</para>
- <programlisting><![CDATA[<?xml version="1.0"?>
+ <programlisting role="XML"><![CDATA[<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" [
@@ -202,7 +202,7 @@
to use unqualified class names in the query language.
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="hm1" coords="2 55"/>
<area id="hm2" coords="3 55"/>
@@ -212,7 +212,7 @@
<area id="hm6" coords="7 55"/>
<area id="hm7" coords="8 55"/>
</areaspec>
- <programlisting><![CDATA[<hibernate-mapping
+ <programlisting role="XML"><![CDATA[<hibernate-mapping
schema="schemaName"
catalog="catalogName"
default-cascade="cascade_style"
@@ -293,7 +293,7 @@
You can declare a persistent class using the <literal>class</literal> element. For example:
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="class1" coords="2 55"/>
<area id="class2" coords="3 55" />
@@ -317,7 +317,7 @@
<area id="class20" coords="21 55"/>
<area id="class21" coords="22 55"/>
</areaspec>
- <programlisting><![CDATA[<class
+ <programlisting role="XML"><![CDATA[<class
name="ClassName"
table="tableName"
discriminator-value="discriminator_value"
@@ -581,7 +581,7 @@
immutable and read-only entity to a given SQL subselect expression:
</para>
- <programlisting><![CDATA[<class name="Summary">
+ <programlisting role="XML"><![CDATA[<class name="Summary">
<subselect>
select item.name, max(bid.amount), count(*)
from item
@@ -613,7 +613,7 @@
property to the primary key column.
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="id1" coords="2 70"/>
<area id="id2" coords="3 70" />
@@ -621,7 +621,7 @@
<area id="id4" coords="5 70" />
<area id="id5" coords="6 70" />
</areaspec>
- <programlisting><![CDATA[<id
+ <programlisting role="XML"><![CDATA[<id
name="propertyName"
type="typename"
column="column_name"
@@ -689,7 +689,7 @@
<literal><param></literal> element.
</para>
- <programlisting><![CDATA[<id name="id" type="long" column="cat_id">
+ <programlisting role="XML"><![CDATA[<id name="id" type="long" column="cat_id">
<generator class="org.hibernate.id.TableHiLoGenerator">
<param name="table">uid_table</param>
<param name="column">next_hi_value_column</param>
@@ -840,7 +840,7 @@
Where supported, the second uses an Oracle-style sequence.
</para>
- <programlisting><![CDATA[<id name="id" type="long" column="cat_id">
+ <programlisting role="XML"><![CDATA[<id name="id" type="long" column="cat_id">
<generator class="hilo">
<param name="table">hi_value</param>
<param name="column">next_value</param>
@@ -848,7 +848,7 @@
</generator>
</id>]]></programlisting>
- <programlisting><![CDATA[<id name="id" type="long" column="cat_id">
+ <programlisting role="XML"><![CDATA[<id name="id" type="long" column="cat_id">
<generator class="seqhilo">
<param name="sequence">hi_value</param>
<param name="max_lo">100</param>
@@ -883,13 +883,13 @@
two SQL queries to insert a new object. For example:
</para>
- <programlisting><![CDATA[<id name="id" type="long" column="person_id">
+ <programlisting role="XML"><![CDATA[<id name="id" type="long" column="person_id">
<generator class="sequence">
<param name="sequence">person_id_sequence</param>
</generator>
</id>]]></programlisting>
- <programlisting><![CDATA[<id name="id" type="long" column="person_id" unsaved-value="0">
+ <programlisting role="XML"><![CDATA[<id name="id" type="long" column="person_id" unsaved-value="0">
<generator class="identity"/>
</id>]]></programlisting>
@@ -926,7 +926,7 @@
Hibernate does not generate DDL with triggers. It is for legacy schemas only.
</para>
- <programlisting><![CDATA[<id name="id" type="long" column="person_id">
+ <programlisting role="XML"><![CDATA[<id name="id" type="long" column="person_id">
<generator class="select">
<param name="key">socialSecurityNumber</param>
</generator>
@@ -1112,7 +1112,7 @@
<sect2 id="mapping-declaration-compositeid" revision="3">
<title>composite-id</title>
- <programlisting><![CDATA[<composite-id
+ <programlisting role="XML"><![CDATA[<composite-id
name="propertyName"
class="ClassName"
mapped="true|false"
@@ -1131,7 +1131,7 @@
<literal><key-many-to-one></literal> mappings as child elements.
</para>
- <programlisting><![CDATA[<composite-id>
+ <programlisting role="XML"><![CDATA[<composite-id>
<key-property name="medicareNumber"/>
<key-property name="dependent"/>
</composite-id>]]></programlisting>
@@ -1157,7 +1157,7 @@
element are duplicated on both the persistent class and a separate identifier class.
</para>
- <programlisting><![CDATA[<composite-id class="MedicareId" mapped="true">
+ <programlisting role="XML"><![CDATA[<composite-id class="MedicareId" mapped="true">
<key-property name="medicareNumber"/>
<key-property name="dependent"/>
</composite-id>]]></programlisting>
@@ -1239,7 +1239,7 @@
<literal>yes_no</literal>, <literal>true_false</literal>.
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="discriminator1" coords="2 60"/>
<area id="discriminator2" coords="3 60" />
@@ -1247,7 +1247,7 @@
<area id="discriminator4" coords="5 60" />
<area id="discriminator5" coords="6 60" />
</areaspec>
- <programlisting><![CDATA[<discriminator
+ <programlisting role="XML"><![CDATA[<discriminator
column="discriminator_column"
type="discriminator_type"
force="true|false"
@@ -1308,7 +1308,7 @@
that will be used to evaluate the type of a row. For example:
</para>
- <programlisting><![CDATA[<discriminator
+ <programlisting role="XML"><![CDATA[<discriminator
formula="case when CLASS_TYPE in ('a', 'b', 'c') then 0 else 1 end"
type="integer"/>]]></programlisting>
@@ -1323,7 +1323,7 @@
use <emphasis>long transactions</emphasis>. See below for more information:
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="version1" coords="2 70"/>
<area id="version2" coords="3 70"/>
@@ -1333,7 +1333,7 @@
<area id="version6" coords="7 70"/>
<area id="version7" coords="8 70"/>
</areaspec>
- <programlisting><![CDATA[<version
+ <programlisting role="XML"><![CDATA[<version
column="version_column"
name="propertyName"
type="typename"
@@ -1419,7 +1419,7 @@
use the timestamps in other ways.
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="timestamp1" coords="2 70"/>
<area id="timestamp2" coords="3 70" />
@@ -1428,7 +1428,7 @@
<area id="timestamp5" coords="6 70" />
<area id="timestamp6" coords="7 70" />
</areaspec>
- <programlisting><![CDATA[<timestamp
+ <programlisting role="XML"><![CDATA[<timestamp
column="timestamp_column"
name="propertyName"
access="field|property|ClassName"
@@ -1510,7 +1510,7 @@
property of the class.
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="property1" coords="2 70"/>
<area id="property2" coords="3 70"/>
@@ -1527,7 +1527,7 @@
<area id="property11" coords="12 70"/>
<area id="property12" coords="13 70"/>
</areaspec>
- <programlisting><![CDATA[<property
+ <programlisting role="XML"><![CDATA[<property
name="propertyName"
column="column_name"
type="typename"
@@ -1681,7 +1681,7 @@
clause subquery in the SQL query that loads an instance:
</para>
- <programlisting><![CDATA[
+ <programlisting role="XML"><![CDATA[
<property name="totalPrice"
formula="( SELECT SUM (li.quantity*p.price) FROM LineItem li, Product p
WHERE li.productId = p.productId
@@ -1707,7 +1707,7 @@
the primary key column(s) of the target table.
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="manytoone1" coords="2 70"/>
<area id="manytoone2" coords="3 70"/>
@@ -1728,7 +1728,7 @@
<area id="manytoone15" coords="16 70"/>
<area id="manytoone16" coords="17 70"/>
</areaspec>
- <programlisting><![CDATA[<many-to-one
+ <programlisting role="XML"><![CDATA[<many-to-one
name="propertyName"
column="column_name"
class="ClassName"
@@ -1874,7 +1874,7 @@
Here is an example of a typical <literal>many-to-one</literal> declaration:
</para>
- <programlisting><![CDATA[<many-to-one name="product" class="Product" column="PRODUCT_ID"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<many-to-one name="product" class="Product" column="PRODUCT_ID"/>]]></programlisting>
<para>
The <literal>property-ref</literal> attribute should only be used for mapping legacy
@@ -1885,13 +1885,13 @@
the SchemaExport tool.
</para>
- <programlisting><![CDATA[<property name="serialNumber" unique="true" type="string" column="SERIAL_NUMBER"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<property name="serialNumber" unique="true" type="string" column="SERIAL_NUMBER"/>]]></programlisting>
<para>
Then the mapping for <literal>OrderItem</literal> might use:
</para>
- <programlisting><![CDATA[<many-to-one name="product" property-ref="serialNumber" column="PRODUCT_SERIAL_NUMBER"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<many-to-one name="product" property-ref="serialNumber" column="PRODUCT_SERIAL_NUMBER"/>]]></programlisting>
<para>
This is not encouraged, however.
@@ -1906,7 +1906,7 @@
If the referenced unique key is the property of a component, you can specify a property path:
</para>
- <programlisting><![CDATA[<many-to-one name="owner" property-ref="identity.ssn" column="OWNER_SSN"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<many-to-one name="owner" property-ref="identity.ssn" column="OWNER_SSN"/>]]></programlisting>
</sect2>
@@ -1918,7 +1918,7 @@
<literal>one-to-one</literal> element.
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="onetoone1" coords="2 70"/>
<area id="onetoone2" coords="3 70"/>
@@ -1931,7 +1931,7 @@
<area id="onetoone9" coords="10 70"/>
<area id="onetoone10" coords="11 70"/>
</areaspec>
- <programlisting><![CDATA[<one-to-one
+ <programlisting role="XML"><![CDATA[<one-to-one
name="propertyName"
class="ClassName"
cascade="cascade_style"
@@ -2043,8 +2043,8 @@
<literal>Person</literal> respectively:
</para>
- <programlisting><![CDATA[<one-to-one name="person" class="Person"/>]]></programlisting>
- <programlisting><![CDATA[<one-to-one name="employee" class="Employee" constrained="true"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<one-to-one name="person" class="Person"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<one-to-one name="employee" class="Employee" constrained="true"/>]]></programlisting>
<para>
Ensure that the primary keys of the related rows in the PERSON and
@@ -2052,7 +2052,7 @@
called <literal>foreign</literal>:
</para>
- <programlisting><![CDATA[<class name="person" table="PERSON">
+ <programlisting role="XML"><![CDATA[<class name="person" table="PERSON">
<id name="id" column="PERSON_ID">
<generator class="foreign">
<param name="property">employee</param>
@@ -2075,21 +2075,21 @@
<literal>Person</literal>, can be expressed as:
</para>
- <programlisting><![CDATA[<many-to-one name="person" class="Person" column="PERSON_ID" unique="true"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<many-to-one name="person" class="Person" column="PERSON_ID" unique="true"/>]]></programlisting>
<para>
This association can be made bidirectional by adding the following to the
<literal>Person</literal> mapping:
</para>
- <programlisting><![CDATA[<one-to-one name="employee" class="Employee" property-ref="person"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<one-to-one name="employee" class="Employee" property-ref="person"/>]]></programlisting>
</sect2>
<sect2 id="mapping-declaration-naturalid">
<title>Natural-id</title>
- <programlisting><![CDATA[<natural-id mutable="true|false"/>
+ <programlisting role="XML"><![CDATA[<natural-id mutable="true|false"/>
<property ... />
<many-to-one ... />
......
@@ -2134,7 +2134,7 @@
the "Component" examples below:
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="component1" coords="2 45"/>
<area id="component2" coords="3 45"/>
@@ -2145,7 +2145,7 @@
<area id="component7" coords="8 45"/>
<area id="component8" coords="9 45"/>
</areaspec>
- <programlisting><![CDATA[<component
+ <programlisting role="XML"><![CDATA[<component
name="propertyName"
class="className"
insert="true|false"
@@ -2246,7 +2246,7 @@
unique constraint. For example:
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="properties1" coords="2 45"/>
<area id="properties2" coords="3 45"/>
@@ -2254,7 +2254,7 @@
<area id="properties4" coords="5 45"/>
<area id="properties5" coords="6 45"/>
</areaspec>
- <programlisting><![CDATA[<properties
+ <programlisting role="XML"><![CDATA[<properties
name="logicalName"
insert="true|false"
update="true|false"
@@ -2307,7 +2307,7 @@
For example, if we have the following <literal><properties></literal> mapping:
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="personNumber"/>
...
@@ -2324,7 +2324,7 @@
the <literal>Person</literal> table, instead of to the primary key:
</para>
- <programlisting><![CDATA[<many-to-one name="person"
+ <programlisting role="XML"><![CDATA[<many-to-one name="person"
class="Person" property-ref="name">
<column name="firstName"/>
<column name="initial"/>
@@ -2347,14 +2347,14 @@
mapping strategy, the <literal><subclass></literal> declaration is used. For example:
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="subclass1" coords="2 55"/>
<area id="subclass2" coords="3 55"/>
<area id="subclass3" coords="4 55"/>
<area id="subclass4" coords="5 55"/>
</areaspec>
- <programlisting><![CDATA[<subclass
+ <programlisting role="XML"><![CDATA[<subclass
name="ClassName"
discriminator-value="discriminator_value"
proxy="ProxyInterface"
@@ -2418,14 +2418,14 @@
superclass. To do this you use the <literal><joined-subclass></literal> element. For example:
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="joinedsubclass1" coords="2 45"/>
<area id="joinedsubclass2" coords="3 45"/>
<area id="joinedsubclass3" coords="4 45"/>
<area id="joinedsubclass4" coords="5 45"/>
</areaspec>
- <programlisting><![CDATA[<joined-subclass
+ <programlisting role="XML"><![CDATA[<joined-subclass
name="ClassName"
table="tablename"
proxy="ProxyInterface"
@@ -2478,7 +2478,7 @@
would then be re-written as:
</para>
- <programlisting><![CDATA[<?xml version="1.0"?>
+ <programlisting role="XML"><![CDATA[<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
@@ -2530,14 +2530,14 @@
use the <literal><union-subclass></literal> mapping. For example:
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="unionsubclass1" coords="2 45"/>
<area id="unionsubclass2" coords="3 45"/>
<area id="unionsubclass3" coords="4 45"/>
<area id="unionsubclass4" coords="5 45"/>
</areaspec>
- <programlisting><![CDATA[<union-subclass
+ <programlisting role="XML"><![CDATA[<union-subclass
name="ClassName"
table="tablename"
proxy="ProxyInterface"
@@ -2600,7 +2600,7 @@
properties of one class to several tables that have a one-to-one relationship. For example:
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="join1" coords="2 50"/>
<area id="join2" coords="3 50"/>
@@ -2609,7 +2609,7 @@
<area id="join5" coords="6 50"/>
<area id="join6" coords="7 50"/>
</areaspec>
- <programlisting><![CDATA[<join
+ <programlisting role="XML"><![CDATA[<join
table="tablename"
schema="owner"
catalog="catalog"
@@ -2676,7 +2676,7 @@
table while preserving value type semantics for all properties:
</para>
- <programlisting><![CDATA[<class name="Person"
+ <programlisting role="XML"><![CDATA[<class name="Person"
table="PERSON">
<id name="id" column="PERSON_ID">...</id>
@@ -2708,7 +2708,7 @@
the primary key of the original table. It also defines the foreign key in the joined table:
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="key1" coords="2 50"/>
<area id="key2" coords="3 50"/>
@@ -2717,7 +2717,7 @@
<area id="key5" coords="6 50"/>
<area id="key6" coords="7 50"/>
</areaspec>
- <programlisting><![CDATA[<key
+ <programlisting role="XML"><![CDATA[<key
column="columnname"
on-delete="noaction|cascade"
property-ref="propertyName"
@@ -2796,7 +2796,7 @@
is an alternative to the <literal>formula</literal> attribute. For example:
</para>
- <programlisting><![CDATA[<column
+ <programlisting role="XML"><![CDATA[<column
name="column_name"
length="N"
precision="N"
@@ -2811,7 +2811,7 @@
read="SQL expression"
write="SQL expression"/>]]></programlisting>
- <programlisting><![CDATA[<formula>SQL expression</formula>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<formula>SQL expression</formula>]]></programlisting>
<para>
Most of the attributes on <literal>column</literal> provide a means of tailoring the
@@ -2827,7 +2827,7 @@
conditions.
</para>
- <programlisting><![CDATA[<many-to-one name="homeAddress" class="Address"
+ <programlisting role="XML"><![CDATA[<many-to-one name="homeAddress" class="Address"
insert="false" update="false">
<column name="person_id" not-null="true" length="10"/>
<formula>'MAILING'</formula>
@@ -2845,14 +2845,14 @@
classes and interfaces that are not explicitly mapped:
</para>
- <programlisting><![CDATA[<import class="java.lang.Object" rename="Universe"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<import class="java.lang.Object" rename="Universe"/>]]></programlisting>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="import1" coords="2 40"/>
<area id="import2" coords="3 40"/>
</areaspec>
- <programlisting><![CDATA[<import
+ <programlisting role="XML"><![CDATA[<import
class="ClassName"
rename="ShortName"
/>]]></programlisting>
@@ -2893,7 +2893,7 @@
the meta-type to class names.
</para>
- <programlisting><![CDATA[<any name="being" id-type="long" meta-type="string">
+ <programlisting role="XML"><![CDATA[<any name="being" id-type="long" meta-type="string">
<meta-value value="TBL_ANIMAL" class="Animal"/>
<meta-value value="TBL_HUMAN" class="Human"/>
<meta-value value="TBL_ALIEN" class="Alien"/>
@@ -2901,7 +2901,7 @@
<column name="id"/>
</any>]]></programlisting>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="any1" coords="2 50"/>
<area id="any2" coords="3 50"/>
@@ -2910,7 +2910,7 @@
<area id="any5" coords="6 50"/>
<area id="any6" coords="7 50"/>
</areaspec>
- <programlisting><![CDATA[<any
+ <programlisting role="XML"><![CDATA[<any
name="propertyName"
id-type="idtypename"
meta-type="metatypename"
@@ -3217,7 +3217,7 @@
are possible.
</para>
- <programlisting><![CDATA[<property name="twoStrings" type="org.hibernate.test.DoubleStringType">
+ <programlisting role="XML"><![CDATA[<property name="twoStrings" type="org.hibernate.test.DoubleStringType">
<column name="first_string"/>
<column name="second_string"/>
</property>]]></programlisting>
@@ -3241,7 +3241,7 @@
files.
</para>
- <programlisting><![CDATA[<property name="priority">
+ <programlisting role="XML"><![CDATA[<property name="priority">
<type name="com.mycompany.usertypes.DefaultValueIntegerType">
<param name="default">0</param>
</type>
@@ -3259,11 +3259,11 @@
parameter values if the type is parameterized.
</para>
- <programlisting><![CDATA[<typedef class="com.mycompany.usertypes.DefaultValueIntegerType" name="default_zero">
+ <programlisting role="XML"><![CDATA[<typedef class="com.mycompany.usertypes.DefaultValueIntegerType" name="default_zero">
<param name="default">0</param>
</typedef>]]></programlisting>
- <programlisting><![CDATA[<property name="priority" type="default_zero"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<property name="priority" type="default_zero"/>]]></programlisting>
<para>
It is also possible to override the parameters supplied in a typedef on a case-by-case basis
@@ -3329,7 +3329,7 @@
Server uses brackets and MySQL uses backticks.
</para>
- <programlisting><![CDATA[<class name="LineItem" table="`Line Item`">
+ <programlisting role="XML"><![CDATA[<class name="LineItem" table="`Line Item`">
<id name="id" column="`Item Id`"/><generator class="assigned"/></id>
<property name="itemNumber" column="`Item #`"/>
...
@@ -3355,7 +3355,7 @@
following example of the <literal>Cat</literal> class with XDoclet mappings:
</para>
- <programlisting><![CDATA[package eg;
+ <programlisting role="JAVA"><![CDATA[package eg;
import java.util.Set;
import java.util.Date;
@@ -3484,7 +3484,7 @@
This is an example of a POJO class annotated as an EJB entity bean:
</para>
- <programlisting><![CDATA[@Entity(access = AccessType.FIELD)
+ <programlisting role="JAVA"><![CDATA[@Entity(access = AccessType.FIELD)
public class Customer implements Serializable {
@Id;
@@ -3561,7 +3561,7 @@
of columns mapped to <link linkend="mapping-declaration-property">simple properties</link>.
For example, if your database provides a set of data encryption functions, you can
invoke them for individual columns like this:
- <programlisting><![CDATA[<property name="creditCardNumber">
+ <programlisting role="XML"><![CDATA[<property name="creditCardNumber">
<column
name="credit_card_num"
read="decrypt(credit_card_num)"
@@ -3607,7 +3607,7 @@
The first mode is to explicitly list the CREATE and DROP commands in the mapping
file:
</para>
- <programlisting><![CDATA[<hibernate-mapping>
+ <programlisting role="XML"><![CDATA[<hibernate-mapping>
...
<database-object>
<create>CREATE TRIGGER my_trigger ...</create>
@@ -3619,7 +3619,7 @@
CREATE and DROP commands. This custom class must implement the
<literal>org.hibernate.mapping.AuxiliaryDatabaseObject</literal> interface.
</para>
- <programlisting><![CDATA[<hibernate-mapping>
+ <programlisting role="XML"><![CDATA[<hibernate-mapping>
...
<database-object>
<definition class="MyTriggerDefinition"/>
@@ -3629,7 +3629,7 @@
Additionally, these database objects can be optionally scoped so that they only
apply when certain dialects are used.
</para>
- <programlisting><![CDATA[<hibernate-mapping>
+ <programlisting role="XML"><![CDATA[<hibernate-mapping>
...
<database-object>
<definition class="MyTriggerDefinition"/>
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/batch.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/batch.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/batch.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -33,7 +33,7 @@
look like this:
</para>
-<programlisting><![CDATA[Session session = sessionFactory.openSession();
+<programlisting role="JAVA"><![CDATA[Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
for ( int i=0; i<100000; i++ ) {
Customer customer = new Customer(.....);
@@ -84,7 +84,7 @@
the first-level cache.
</para>
-<programlisting><![CDATA[Session session = sessionFactory.openSession();
+<programlisting role="JAVA"><![CDATA[Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
for ( int i=0; i<100000; i++ ) {
@@ -111,7 +111,7 @@
queries that return many rows of data.
</para>
-<programlisting><![CDATA[Session session = sessionFactory.openSession();
+<programlisting role="JAVA"><![CDATA[Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
ScrollableResults customers = session.getNamedQuery("GetCustomers")
@@ -150,7 +150,7 @@
session is a lower-level abstraction that is much closer to the underlying JDBC.
</para>
-<programlisting><![CDATA[StatelessSession session = sessionFactory.openStatelessSession();
+<programlisting role="JAVA"><![CDATA[StatelessSession session = sessionFactory.openStatelessSession();
Transaction tx = session.beginTransaction();
ScrollableResults customers = session.getNamedQuery("GetCustomers")
@@ -237,7 +237,7 @@
those familiar with JDBC's <literal>PreparedStatement.executeUpdate()</literal>:
</para>
-<programlisting><![CDATA[Session session = sessionFactory.openSession();
+<programlisting role="JAVA"><![CDATA[Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
String hqlUpdate = "update Customer c set c.name = :newName where c.name = :oldName";
@@ -259,7 +259,7 @@
This is achieved by adding the <literal>VERSIONED</literal> keyword after the <literal>UPDATE</literal>
keyword.
</para>
-<programlisting><![CDATA[Session session = sessionFactory.openSession();
+<programlisting role="JAVA"><![CDATA[Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
String hqlVersionedUpdate = "update versioned Customer set name = :newName where name = :oldName";
int updatedEntities = s.createQuery( hqlUpdate )
@@ -279,7 +279,7 @@
method:
</para>
-<programlisting><![CDATA[Session session = sessionFactory.openSession();
+<programlisting role="JAVA"><![CDATA[Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
String hqlDelete = "delete Customer c where c.name = :oldName";
@@ -363,7 +363,7 @@
The following is an example of an HQL <literal>INSERT</literal> statement execution:
</para>
-<programlisting><![CDATA[Session session = sessionFactory.openSession();
+<programlisting role="JAVA"><![CDATA[Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
String hqlInsert = "insert into DelinquentAccount (id, name) select c.id, c.name from Customer c where ...";
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/collection_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/collection_mapping.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/collection_mapping.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -36,7 +36,7 @@
as an interface type. For example:
</para>
- <programlisting><![CDATA[public class Product {
+ <programlisting role="JAVA"><![CDATA[public class Product {
private String serialNumber;
private Set parts = new HashSet();
@@ -65,7 +65,7 @@
Be aware of the following errors:
</para>
- <programlisting><![CDATA[Cat cat = new DomesticCat();
+ <programlisting role="JAVA"><![CDATA[Cat cat = new DomesticCat();
Cat kitten = new DomesticCat();
....
Set kittens = new HashSet();
@@ -118,7 +118,7 @@
element is used for mapping properties of type <literal>Set</literal>.
</para>
- <programlisting><![CDATA[<class name="Product">
+ <programlisting role="JAVA"><![CDATA[<class name="Product">
<id name="serialNumber" column="productSerialNumber"/>
<set name="parts">
<key column="productSerialNumber" not-null="true"/>
@@ -134,7 +134,7 @@
<literal><map></literal> element is representative:
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="mappingcollection1" coords="2 65"/>
<area id="mappingcollection2" coords="3 65"/>
@@ -151,7 +151,7 @@
<area id="mappingcollection13" coords="14 65"/>
<area id="mappingcollection14" coords="15 65"/>
</areaspec>
- <programlisting><![CDATA[<map
+ <programlisting role="XML"><![CDATA[<map
name="propertyName"
table="table_name"
schema="schema_name"
@@ -288,13 +288,13 @@
<literal>not-null="true"</literal>.
</para>
- <programlisting><![CDATA[<key column="productSerialNumber" not-null="true"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<key column="productSerialNumber" not-null="true"/>]]></programlisting>
<para>
The foreign key constraint can use <literal>ON DELETE CASCADE</literal>.
</para>
- <programlisting><![CDATA[<key column="productSerialNumber" on-delete="cascade"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<key column="productSerialNumber" on-delete="cascade"/>]]></programlisting>
<para>
See the previous chapter for a full definition of the <literal><key></literal>
@@ -342,12 +342,12 @@
sequential integers that are numbered from zero by default.
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="index1" coords="2 45"/>
<area id="index2" coords="3 45"/>
</areaspec>
- <programlisting><![CDATA[<list-index
+ <programlisting role="XML"><![CDATA[<list-index
column="column_name"
base="0|1|..."/>]]></programlisting>
<calloutlist>
@@ -366,13 +366,13 @@
</calloutlist>
</programlistingco>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="mapkey1" coords="2 45"/>
<area id="mapkey2" coords="3 45"/>
<area id="mapkey3" coords="4 45"/>
</areaspec>
- <programlisting><![CDATA[<map-key
+ <programlisting role="XML"><![CDATA[<map-key
column="column_name"
formula="any SQL expression"
type="type_name"
@@ -399,13 +399,13 @@
</calloutlist>
</programlistingco>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="indexmanytomany1" coords="2 45"/>
<area id="indexmanytomany2" coords="3 45"/>
<area id="indexmanytomany3" coords="3 45"/>
</areaspec>
- <programlisting><![CDATA[<map-key-many-to-many
+ <programlisting role="XML"><![CDATA[<map-key-many-to-many
column="column_name"
formula="any SQL expression"
class="ClassName"
@@ -455,13 +455,13 @@
For a collection of values use the <literal><element></literal> tag. For example:
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="element1b" coords="2 50"/>
<area id="element2b" coords="3 50"/>
<area id="element3b" coords="4 50"/>
</areaspec>
- <programlisting><![CDATA[<element
+ <programlisting role="XML"><![CDATA[<element
column="column_name"
formula="any SQL expression"
type="typename"
@@ -498,7 +498,7 @@
<literal><many-to-many></literal> element.
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="manytomany1" coords="2 60"/>
<area id="manytomany2" coords="3 60"/>
@@ -509,7 +509,7 @@
<area id="manytomany7" coords="8 60"/>
<area id="manytomany8" coords="9 60"/>
</areaspec>
- <programlisting><![CDATA[<many-to-many
+ <programlisting role="XML"><![CDATA[<many-to-many
column="column_name"
formula="any SQL expression"
class="ClassName"
@@ -586,7 +586,7 @@
A set of strings:
</para>
- <programlisting><![CDATA[<set name="names" table="person_names">
+ <programlisting role="XML"><![CDATA[<set name="names" table="person_names">
<key column="person_id"/>
<element column="person_name" type="string"/>
</set>]]></programlisting>
@@ -596,7 +596,7 @@
<literal>order-by</literal> attribute:
</para>
- <programlisting><![CDATA[<bag name="sizes"
+ <programlisting role="XML"><![CDATA[<bag name="sizes"
table="item_sizes"
order-by="size asc">
<key column="item_id"/>
@@ -607,7 +607,7 @@
An array of entities, in this case, a many-to-many association:
</para>
- <programlisting><![CDATA[<array name="addresses"
+ <programlisting role="XML"><![CDATA[<array name="addresses"
table="PersonAddress"
cascade="persist">
<key column="personId"/>
@@ -619,7 +619,7 @@
A map from string indices to dates:
</para>
- <programlisting><![CDATA[<map name="holidays"
+ <programlisting role="XML"><![CDATA[<map name="holidays"
table="holidays"
schema="dbo"
order-by="hol_name asc">
@@ -632,7 +632,7 @@
A list of components (this is discussed in the next chapter):
</para>
- <programlisting><![CDATA[<list name="carComponents"
+ <programlisting role="XML"><![CDATA[<list name="carComponents"
table="CarComponents">
<key column="carId"/>
<list-index column="sortOrder"/>
@@ -676,13 +676,13 @@
association.
</para>
- <programlistingco>
+ <programlistingco role="XML">
<areaspec>
<area id="onetomany1" coords="2 60"/>
<area id="onetomany2" coords="3 60"/>
<area id="onetomany3" coords="4 60"/>
</areaspec>
- <programlisting><![CDATA[<one-to-many
+ <programlisting role="XML"><![CDATA[<one-to-many
class="ClassName"
not-found="ignore|exception"
entity-name="EntityName"
@@ -734,7 +734,7 @@
Notice the use of a formula-based index:
</para>
- <programlisting><![CDATA[<map name="parts"
+ <programlisting role="XML"><![CDATA[<map name="parts"
cascade="all">
<key column="productId" not-null="true"/>
<map-key formula="partName"/>
@@ -755,7 +755,7 @@
<literal>java.util.SortedSet</literal>. You must specify a comparator in the mapping file:
</para>
- <programlisting><![CDATA[<set name="aliases"
+ <programlisting role="XML"><![CDATA[<set name="aliases"
table="person_aliases"
sort="natural">
<key column="person"/>
@@ -788,7 +788,7 @@
not in the memory.
</para>
- <programlisting><![CDATA[<set name="aliases" table="person_aliases" order-by="lower(name) asc">
+ <programlisting role="XML"><![CDATA[<set name="aliases" table="person_aliases" order-by="lower(name) asc">
<key column="person"/>
<element column="name" type="string"/>
</set>
@@ -812,7 +812,7 @@
<literal>filter()</literal>:
</para>
- <programlisting><![CDATA[sortedUsers = s.createFilter( group.getUsers(), "order by this.name" ).list();]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[sortedUsers = s.createFilter( group.getUsers(), "order by this.name" ).list();]]></programlisting>
</sect2>
@@ -857,7 +857,7 @@
have many items and each item can be in many categories:
</para>
- <programlisting><![CDATA[<class name="Category">
+ <programlisting role="XML"><![CDATA[<class name="Category">
<id name="id" column="CATEGORY_ID"/>
...
<bag name="items" table="CATEGORY_ITEM">
@@ -885,7 +885,7 @@
a many-to-many relationship in Javais created:
</para>
- <programlisting><![CDATA[
+ <programlisting role="JAVA"><![CDATA[
category.getItems().add(item); // The category now "knows" about the relationship
item.getCategories().add(category); // The item now "knows" about the relationship
@@ -902,7 +902,7 @@
end <literal>inverse="true"</literal>.
</para>
- <programlisting><![CDATA[<class name="Parent">
+ <programlisting role="XML"><![CDATA[<class name="Parent">
<id name="id" column="parent_id"/>
....
<set name="children" inverse="true">
@@ -936,7 +936,7 @@
<literal>inverse="true"</literal> on the collection mapping:
</para>
- <programlisting><![CDATA[<class name="Parent">
+ <programlisting role="XML"><![CDATA[<class name="Parent">
<id name="id" column="parent_id"/>
....
<map name="children" inverse="true">
@@ -965,7 +965,7 @@
<literal>inverse="true"</literal>. Instead, you could use the following mapping:
</para>
- <programlisting><![CDATA[<class name="Parent">
+ <programlisting role="XML"><![CDATA[<class name="Parent">
<id name="id" column="parent_id"/>
....
<map name="children">
@@ -1003,13 +1003,13 @@
<literal>Map</literal> with an association as its index:
</para>
- <programlisting><![CDATA[<map name="contracts">
+ <programlisting role="XML"><![CDATA[<map name="contracts">
<key column="employer_id" not-null="true"/>
<map-key-many-to-many column="employee_id" class="Employee"/>
<one-to-many class="Contract"/>
</map>]]></programlisting>
- <programlisting><![CDATA[<map name="connections">
+ <programlisting role="XML"><![CDATA[<map name="connections">
<key column="incoming_node_id"/>
<map-key-many-to-many column="outgoing_node_id" class="Node"/>
<many-to-many column="connection_id" class="Connection"/>
@@ -1044,7 +1044,7 @@
(or <literal>Collection</literal>) with bag semantics. For example:
</para>
-<programlisting><![CDATA[<idbag name="lovers" table="LOVERS">
+<programlisting role="XML"><![CDATA[<idbag name="lovers" table="LOVERS">
<collection-id column="ID" type="long">
<generator class="sequence"/>
</collection-id>
@@ -1099,7 +1099,7 @@
The following class has a collection of <literal>Child</literal> instances:
</para>
- <programlisting><![CDATA[package eg;
+ <programlisting role="JAVA"><![CDATA[package eg;
import java.util.Set;
public class Parent {
@@ -1122,7 +1122,7 @@
</para>
- <programlisting><![CDATA[<hibernate-mapping>
+ <programlisting role="XML"><![CDATA[<hibernate-mapping>
<class name="Parent">
<id name="id">
@@ -1147,7 +1147,7 @@
This maps to the following table definitions:
</para>
- <programlisting><![CDATA[create table parent ( id bigint not null primary key )
+ <programlisting role="XML"><![CDATA[create table parent ( id bigint not null primary key )
create table child ( id bigint not null primary key, name varchar(255), parent_id bigint )
alter table child add constraint childfk0 (parent_id) references parent]]></programlisting>
@@ -1156,7 +1156,7 @@
association:
</para>
- <programlisting><![CDATA[<hibernate-mapping>
+ <programlisting role="XML"><![CDATA[<hibernate-mapping>
<class name="Parent">
<id name="id">
@@ -1182,7 +1182,7 @@
Notice the <literal>NOT NULL</literal> constraint:
</para>
- <programlisting><![CDATA[create table parent ( id bigint not null primary key )
+ <programlisting role="XML"><![CDATA[create table parent ( id bigint not null primary key )
create table child ( id bigint not null
primary key,
name varchar(255),
@@ -1195,7 +1195,7 @@
mapping:
</para>
- <programlisting><![CDATA[<hibernate-mapping>
+ <programlisting role="XML"><![CDATA[<hibernate-mapping>
<class name="Parent">
<id name="id">
@@ -1221,7 +1221,7 @@
association is appropriate:
</para>
- <programlisting><![CDATA[<hibernate-mapping>
+ <programlisting role="XML"><![CDATA[<hibernate-mapping>
<class name="Parent">
<id name="id">
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/component_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/component_mapping.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/component_mapping.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -42,7 +42,7 @@
and not to architecture-level components. For example, you can model a person like this:
</para>
- <programlisting><![CDATA[public class Person {
+ <programlisting role="JAVA"><![CDATA[public class Person {
private java.util.Date birthday;
private Name name;
private String key;
@@ -68,7 +68,7 @@
......
}]]></programlisting>
-<programlisting><![CDATA[public class Name {
+<programlisting role="JAVA"><![CDATA[public class Name {
char initial;
String first;
String last;
@@ -103,7 +103,7 @@
Our Hibernate mapping would look like this:
</para>
- <programlisting><![CDATA[<class name="eg.Person" table="person">
+ <programlisting role="XML"><![CDATA[<class name="eg.Person" table="person">
<id name="Key" column="pid" type="string">
<generator class="uuid"/>
</id>
@@ -144,7 +144,7 @@
containing entity.
</para>
- <programlisting><![CDATA[<class name="eg.Person" table="person">
+ <programlisting role="XML"><![CDATA[<class name="eg.Person" table="person">
<id name="Key" column="pid" type="string">
<generator class="uuid"/>
</id>
@@ -169,7 +169,7 @@
<literal><composite-element></literal> tag:
</para>
- <programlisting><![CDATA[<set name="someNames" table="some_names" lazy="true">
+ <programlisting role="XML"><![CDATA[<set name="someNames" table="some_names" lazy="true">
<key column="id"/>
<composite-element class="eg.Name"> <!-- class attribute required -->
<property name="initial"/>
@@ -219,7 +219,7 @@
<literal>quantity</literal> are properties of the association:
</para>
- <programlisting><![CDATA[<class name="eg.Order" .... >
+ <programlisting role="XML"><![CDATA[<class name="eg.Order" .... >
....
<set name="purchasedItems" table="purchase_items" lazy="true">
<key column="order_id">
@@ -242,7 +242,7 @@
<para>Even ternary (or quaternary, etc) associations are possible:</para>
- <programlisting><![CDATA[<class name="eg.Order" .... >
+ <programlisting role="XML"><![CDATA[<class name="eg.Order" .... >
....
<set name="purchasedItems" table="purchase_items" lazy="true">
<key column="order_id">
@@ -315,7 +315,7 @@
the (composite) primary key of <literal>Order</literal>.
</para>
- <programlisting><![CDATA[<class name="OrderLine">
+ <programlisting role="XML"><![CDATA[<class name="OrderLine">
<composite-id name="id" class="OrderLineId">
<key-property name="lineId"/>
@@ -340,7 +340,7 @@
to <literal>OrderLine</literal> is mapped like this:
</para>
- <programlisting><![CDATA[<many-to-one name="orderLine" class="OrderLine">
+ <programlisting role="XML"><![CDATA[<many-to-one name="orderLine" class="OrderLine">
<!-- the "class" attribute is optional, as usual -->
<column name="lineId"/>
<column name="orderId"/>
@@ -362,7 +362,7 @@
uses the composite foreign key:
</para>
- <programlisting><![CDATA[<set name="undeliveredOrderLines">
+ <programlisting role="XML"><![CDATA[<set name="undeliveredOrderLines">
<key column name="warehouseId"/>
<many-to-many class="OrderLine">
<column name="lineId"/>
@@ -376,7 +376,7 @@
use:
</para>
- <programlisting><![CDATA[<set name="orderLines" inverse="true">
+ <programlisting role="XML"><![CDATA[<set name="orderLines" inverse="true">
<key>
<column name="orderId"/>
<column name="customerId"/>
@@ -393,7 +393,7 @@
foreign key.
</para>
- <programlisting><![CDATA[<class name="OrderLine">
+ <programlisting role="XML"><![CDATA[<class name="OrderLine">
....
....
<list name="deliveryAttempts">
@@ -418,7 +418,7 @@
You can also map a property of type <literal>Map</literal>:
</para>
- <programlisting><![CDATA[<dynamic-component name="userAttributes">
+ <programlisting role="XML"><![CDATA[<dynamic-component name="userAttributes">
<property name="foo" column="FOO" type="string"/>
<property name="bar" column="BAR" type="integer"/>
<many-to-one name="baz" class="Baz" column="BAZ_ID"/>
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/configuration.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/configuration.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/configuration.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -52,7 +52,7 @@
use <literal>addResource()</literal>. For example:
</para>
- <programlisting><![CDATA[Configuration cfg = new Configuration()
+ <programlisting role="JAVA"><![CDATA[Configuration cfg = new Configuration()
.addResource("Item.hbm.xml")
.addResource("Bid.hbm.xml");]]></programlisting>
@@ -61,7 +61,7 @@
allow Hibernate to find the mapping document for you:
</para>
- <programlisting><![CDATA[Configuration cfg = new Configuration()
+ <programlisting role="JAVA"><![CDATA[Configuration cfg = new Configuration()
.addClass(org.hibernate.auction.Item.class)
.addClass(org.hibernate.auction.Bid.class);]]></programlisting>
@@ -76,7 +76,7 @@
properties. For example:
</para>
- <programlisting><![CDATA[Configuration cfg = new Configuration()
+ <programlisting role="JAVA"><![CDATA[Configuration cfg = new Configuration()
.addClass(org.hibernate.auction.Item.class)
.addClass(org.hibernate.auction.Bid.class)
.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLInnoDBDialect")
@@ -133,7 +133,7 @@
This factory is intended to be shared by all application threads:
</para>
- <programlisting><![CDATA[SessionFactory sessions = cfg.buildSessionFactory();]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[SessionFactory sessions = cfg.buildSessionFactory();]]></programlisting>
<para>
Hibernate does allow your application to instantiate more than one
@@ -152,7 +152,7 @@
is as simple as:
</para>
- <programlisting><![CDATA[Session session = sessions.openSession(); // open a new Session]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[Session session = sessions.openSession(); // open a new Session]]></programlisting>
<para>
Once you start a task that requires access to the database, a JDBC connection will be obtained from
@@ -1344,7 +1344,7 @@
<literal>Configuration.setNamingStrategy()</literal> before adding mappings:
</para>
- <programlisting><![CDATA[SessionFactory sf = new Configuration()
+ <programlisting role="JAVA"><![CDATA[SessionFactory sf = new Configuration()
.setNamingStrategy(ImprovedNamingStrategy.INSTANCE)
.addFile("Item.hbm.xml")
.addFile("Bid.hbm.xml")
@@ -1372,7 +1372,7 @@
your <literal>CLASSPATH</literal>. Here is an example:
</para>
- <programlisting><![CDATA[<?xml version='1.0' encoding='utf-8'?>
+ <programlisting role="XML"><![CDATA[<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
@@ -1418,13 +1418,13 @@
With the XML configuration, starting Hibernate is then as simple as:
</para>
- <programlisting><![CDATA[SessionFactory sf = new Configuration().configure().buildSessionFactory();]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[SessionFactory sf = new Configuration().configure().buildSessionFactory();]]></programlisting>
<para>
You can select a different XML configuration file using:
</para>
- <programlisting><![CDATA[SessionFactory sf = new Configuration()
+ <programlisting role="JAVA"><![CDATA[SessionFactory sf = new Configuration()
.configure("catdb.cfg.xml")
.buildSessionFactory();]]></programlisting>
@@ -1701,7 +1701,7 @@
<literal>jboss-service.xml</literal> for JBoss 4.0.x:
</para>
- <programlisting><![CDATA[<?xml version="1.0"?>
+ <programlisting role="XML"><![CDATA[<?xml version="1.0"?>
<server>
<mbean code="org.hibernate.jmx.HibernateService"
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/events.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/events.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/events.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -53,7 +53,7 @@
<literal>EmptyInterceptor</literal>.
</para>
- <programlisting><![CDATA[package org.hibernate.test;
+ <programlisting role="JAVA"><![CDATA[package org.hibernate.test;
import java.io.Serializable;
import java.util.Date;
@@ -147,7 +147,7 @@
methods accepting an <literal>Interceptor</literal>.
</para>
- <programlisting><![CDATA[Session session = sf.openSession( new AuditInterceptor() );]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[Session session = sf.openSession( new AuditInterceptor() );]]></programlisting>
<para>
A <literal>SessionFactory</literal>-scoped interceptor is registered with the <literal>Configuration</literal>
@@ -158,7 +158,7 @@
sessions will use this interceptor potentially concurrently.
</para>
- <programlisting><![CDATA[new Configuration().setInterceptor( new AuditInterceptor() );]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[new Configuration().setInterceptor( new AuditInterceptor() );]]></programlisting>
</sect1>
@@ -201,7 +201,7 @@
example of a custom load event listener:
</para>
- <programlisting><![CDATA[public class MyLoadListener implements LoadEventListener {
+ <programlisting role="JAVA"><![CDATA[public class MyLoadListener implements LoadEventListener {
// this is the single method defined by the LoadEventListener interface
public void onLoad(LoadEvent event, LoadEventListener.LoadType loadType)
throws HibernateException {
@@ -216,7 +216,7 @@
to the default listener:
</para>
-<programlisting><![CDATA[<hibernate-configuration>
+<programlisting role="XML"><![CDATA[<hibernate-configuration>
<session-factory>
...
<event type="load">
@@ -230,7 +230,7 @@
Instead, you can register it programmatically:
</para>
- <programlisting><![CDATA[Configuration cfg = new Configuration();
+ <programlisting role="JAVA"><![CDATA[Configuration cfg = new Configuration();
LoadEventListener[] stack = { new MyLoadListener(), new DefaultLoadEventListener() };
cfg.EventListeners().setLoadEventListeners(stack);]]></programlisting>
@@ -264,7 +264,7 @@
authorization.
</para>
- <programlisting><![CDATA[<listener type="pre-delete" class="org.hibernate.secure.JACCPreDeleteEventListener"/>
+ <programlisting role="XML"><![CDATA[<listener type="pre-delete" class="org.hibernate.secure.JACCPreDeleteEventListener"/>
<listener type="pre-update" class="org.hibernate.secure.JACCPreUpdateEventListener"/>
<listener type="pre-insert" class="org.hibernate.secure.JACCPreInsertEventListener"/>
<listener type="pre-load" class="org.hibernate.secure.JACCPreLoadEventListener"/>]]></programlisting>
@@ -279,7 +279,7 @@
Next, while still in <literal>hibernate.cfg.xml</literal>, bind the permissions to roles:
</para>
- <programlisting><![CDATA[<grant role="admin" entity-name="User" actions="insert,update,read"/>
+ <programlisting role="XML"><![CDATA[<grant role="admin" entity-name="User" actions="insert,update,read"/>
<grant role="su" entity-name="User" actions="*"/>]]></programlisting>
<para>
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/example_mappings.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/example_mappings.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/example_mappings.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -57,7 +57,7 @@
Here is a possible mapping document:
</para>
- <programlisting><![CDATA[<hibernate-mapping>
+ <programlisting role="XML"><![CDATA[<hibernate-mapping>
<class name="Employer" table="employers">
<id name="id">
@@ -171,7 +171,7 @@
The following mapping document correctly represents these relationships:
</para>
- <programlisting><![CDATA[<hibernate-mapping>
+ <programlisting role="XML"><![CDATA[<hibernate-mapping>
<class name="Work" table="works" discriminator-value="W">
@@ -295,7 +295,7 @@
The mapping document will look like this:
</para>
- <programlisting><![CDATA[<hibernate-mapping>
+ <programlisting role="XML"><![CDATA[<hibernate-mapping>
<class name="Customer" table="customers">
<id name="id">
@@ -389,7 +389,7 @@
<sect2 id="example-mappings-typed-onetone">
<title>"Typed" one-to-one association</title>
-<programlisting><![CDATA[<class name="Person">
+<programlisting role="XML"><![CDATA[<class name="Person">
<id name="name"/>
<one-to-one name="address"
cascade="all">
@@ -419,7 +419,7 @@
<sect2 id="example-mappings-composite-key">
<title>Composite key example</title>
-<programlisting><![CDATA[<class name="Customer">
+<programlisting role="XML"><![CDATA[<class name="Customer">
<id name="customerId"
length="10">
@@ -536,7 +536,7 @@
<sect2 id="example-mappings-composite-key-manytomany">
<title>Many-to-many with shared composite key attribute</title>
-<programlisting><![CDATA[<class name="User" table="`User`">
+<programlisting role="XML"><![CDATA[<class name="User" table="`User`">
<composite-id>
<key-property name="name"/>
<key-property name="org"/>
@@ -575,7 +575,7 @@
<sect2 id="example-mappings-content-discrimination">
<title>Content based discrimination</title>
-<programlisting><![CDATA[<class name="Person"
+<programlisting role="XML"><![CDATA[<class name="Person"
discriminator-value="P">
<id name="id"
@@ -629,7 +629,7 @@
<sect2 id="example-mappings-association-alternatekeys" revision="2">
<title>Associations on alternate keys</title>
-<programlisting><![CDATA[<class name="Person">
+<programlisting role="XML"><![CDATA[<class name="Person">
<id name="id">
<generator class="hilo"/>
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/example_parentchild.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/example_parentchild.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/example_parentchild.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -92,7 +92,7 @@
<literal>Parent</literal> to <literal>Child</literal>.
</para>
- <programlisting><![CDATA[<set name="children">
+ <programlisting role="XML"><![CDATA[<set name="children">
<key column="parent_id"/>
<one-to-many class="Child"/>
</set>]]></programlisting>
@@ -101,7 +101,7 @@
If we were to execute the following code:
</para>
- <programlisting><![CDATA[Parent p = .....;
+ <programlisting role="JAVA"><![CDATA[Parent p = .....;
Child c = new Child();
p.getChildren().add(c);
session.save(c);
@@ -129,7 +129,7 @@
<literal>not-null="true"</literal> in the collection mapping:
</para>
- <programlisting><![CDATA[<set name="children">
+ <programlisting role="XML"><![CDATA[<set name="children">
<key column="parent_id" not-null="true"/>
<one-to-many class="Child"/>
</set>]]></programlisting>
@@ -144,7 +144,7 @@
solution is to make the link part of the <literal>Child</literal> mapping.
</para>
- <programlisting><![CDATA[<many-to-one name="parent" column="parent_id" not-null="true"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<many-to-one name="parent" column="parent_id" not-null="true"/>]]></programlisting>
<para>
You also need to add the <literal>parent</literal> property to the <literal>Child</literal> class.
@@ -155,7 +155,7 @@
not to update the link. We use the <literal>inverse</literal> attribute to do this:
</para>
- <programlisting><![CDATA[<set name="children" inverse="true">
+ <programlisting role="XML"><![CDATA[<set name="children" inverse="true">
<key column="parent_id"/>
<one-to-many class="Child"/>
</set>]]></programlisting>
@@ -164,7 +164,7 @@
The following code would be used to add a new <literal>Child</literal>:
</para>
- <programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
+ <programlisting role="JAVA"><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
Child c = new Child();
c.setParent(p);
p.getChildren().add(c);
@@ -180,7 +180,7 @@
<literal>Parent</literal>.
</para>
- <programlisting><![CDATA[public void addChild(Child c) {
+ <programlisting role="JAVA"><![CDATA[public void addChild(Child c) {
c.setParent(this);
children.add(c);
}]]></programlisting>
@@ -189,7 +189,7 @@
The code to add a <literal>Child</literal> looks like this:
</para>
- <programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
+ <programlisting role="JAVA"><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
Child c = new Child();
p.addChild(c);
session.save(c);
@@ -205,7 +205,7 @@
using cascades.
</para>
- <programlisting><![CDATA[<set name="children" inverse="true" cascade="all">
+ <programlisting role="XML"><![CDATA[<set name="children" inverse="true" cascade="all">
<key column="parent_id"/>
<one-to-many class="Child"/>
</set>]]></programlisting>
@@ -214,7 +214,7 @@
This simplifies the code above to:
</para>
- <programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
+ <programlisting role="JAVA"><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
Child c = new Child();
p.addChild(c);
session.flush();]]></programlisting>
@@ -224,7 +224,7 @@
The following removes <literal>p</literal> and all its children from the database.
</para>
- <programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
+ <programlisting role="JAVA"><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
session.delete(p);
session.flush();]]></programlisting>
@@ -232,7 +232,7 @@
However, the following code:
</para>
- <programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
+ <programlisting role="JAVA"><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
Child c = (Child) p.getChildren().iterator().next();
p.getChildren().remove(c);
c.setParent(null);
@@ -244,7 +244,7 @@
<literal>delete()</literal> the <literal>Child</literal>.
</para>
- <programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
+ <programlisting role="JAVA"><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
Child c = (Child) p.getChildren().iterator().next();
p.getChildren().remove(c);
session.delete(c);
@@ -256,7 +256,7 @@
use <literal>cascade="all-delete-orphan"</literal>.
</para>
- <programlisting><![CDATA[<set name="children" inverse="true" cascade="all-delete-orphan">
+ <programlisting role="XML"><![CDATA[<set name="children" inverse="true" cascade="all-delete-orphan">
<key column="parent_id"/>
<one-to-many class="Child"/>
</set>]]></programlisting>
@@ -290,7 +290,7 @@
<literal>newChild</literal>:
</para>
- <programlisting><![CDATA[//parent and child were both loaded in a previous session
+ <programlisting role="JAVA"><![CDATA[//parent and child were both loaded in a previous session
parent.addChild(child);
Child newChild = new Child();
parent.addChild(newChild);
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/example_weblog.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/example_weblog.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/example_weblog.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -37,7 +37,7 @@
relationship, but we will use an ordered bag, instead of a set:
</para>
- <programlisting><![CDATA[package eg;
+ <programlisting role="JAVA"><![CDATA[package eg;
import java.util.List;
@@ -66,7 +66,7 @@
}
}]]></programlisting>
- <programlisting><![CDATA[package eg;
+ <programlisting role="JAVA"><![CDATA[package eg;
import java.text.DateFormat;
import java.util.Calendar;
@@ -119,7 +119,7 @@
The XML mappings are now straightforward. For example:
</para>
- <programlisting><![CDATA[<?xml version="1.0"?>
+ <programlisting role="XML"><![CDATA[<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
@@ -159,7 +159,7 @@
</hibernate-mapping>]]></programlisting>
- <programlisting><![CDATA[<?xml version="1.0"?>
+ <programlisting role="XML"><![CDATA[<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
@@ -213,7 +213,7 @@
we can do with these classes using Hibernate:
</para>
- <programlisting><![CDATA[package eg;
+ <programlisting role="JAVA"><![CDATA[package eg;
import java.util.ArrayList;
import java.util.Calendar;
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/filters.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/filters.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/filters.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -53,7 +53,7 @@
within a <literal><hibernate-mapping/></literal> element:
</para>
- <programlisting><![CDATA[<filter-def name="myFilter">
+ <programlisting role="XML"><![CDATA[<filter-def name="myFilter">
<filter-param name="myFilterParam" type="string"/>
</filter-def>]]></programlisting>
@@ -61,7 +61,7 @@
This filter can then be attached to a class:
</para>
- <programlisting><![CDATA[<class name="myClass" ...>
+ <programlisting role="XML"><![CDATA[<class name="myClass" ...>
...
<filter name="myFilter" condition=":myFilterParam = MY_FILTERED_COLUMN"/>
</class>]]></programlisting>
@@ -70,7 +70,7 @@
Or, to a collection:
</para>
- <programlisting><![CDATA[<set ...>
+ <programlisting role="XML"><![CDATA[<set ...>
<filter name="myFilter" condition=":myFilterParam = MY_FILTERED_COLUMN"/>
</set>]]></programlisting>
@@ -87,7 +87,7 @@
look like this:
</para>
- <programlisting><![CDATA[session.enableFilter("myFilter").setParameter("myFilterParam", "some-value");]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[session.enableFilter("myFilter").setParameter("myFilterParam", "some-value");]]></programlisting>
<para>
Methods on the org.hibernate.Filter interface do allow the method-chaining common to much of Hibernate.
@@ -97,7 +97,7 @@
The following is a full example, using temporal data with an effective record date pattern:
</para>
- <programlisting><![CDATA[<filter-def name="effectiveDate">
+ <programlisting role="XML"><![CDATA[<filter-def name="effectiveDate">
<filter-param name="asOfDate" type="date"/>
</filter-def>
@@ -130,7 +130,7 @@
enable the filter on the session prior to retrieving employee data:
</para>
-<programlisting><![CDATA[Session session = ...;
+<programlisting role="JAVA"><![CDATA[Session session = ...;
session.enableFilter("effectiveDate").setParameter("asOfDate", new Date());
List results = session.createQuery("from Employee as e where e.salary > :targetSalary")
.setLong("targetSalary", new Long(1000000))
@@ -157,7 +157,7 @@
allows you to definine a default condition, either as an attribute or CDATA:
</para>
- <programlisting><![CDATA[<filter-def name="myFilter" condition="abc > xyz">...</filter-def>
+ <programlisting role="XML"><![CDATA[<filter-def name="myFilter" condition="abc > xyz">...</filter-def>
<filter-def name="myOtherFilter">abc=xyz</filter-def>]]></programlisting>
<para>
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/inheritance_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/inheritance_mapping.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/inheritance_mapping.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -91,7 +91,7 @@
before subclasses.
</para>
- <programlisting><![CDATA[
+ <programlisting role="XML"><![CDATA[
<hibernate-mapping>
<subclass name="DomesticCat" extends="Cat" discriminator-value="D">
<property name="name" type="string"/>
@@ -109,7 +109,7 @@
display in the following way:
</para>
- <programlisting><![CDATA[<class name="Payment" table="PAYMENT">
+ <programlisting role="XML"><![CDATA[<class name="Payment" table="PAYMENT">
<id name="id" type="long" column="PAYMENT_ID">
<generator class="native"/>
</id>
@@ -143,7 +143,7 @@
A table per subclass mapping looks like this:
</para>
- <programlisting><![CDATA[<class name="Payment" table="PAYMENT">
+ <programlisting role="XML"><![CDATA[<class name="Payment" table="PAYMENT">
<id name="id" type="long" column="PAYMENT_ID">
<generator class="native"/>
</id>
@@ -187,7 +187,7 @@
<literal><join></literal>, as follows:
</para>
- <programlisting><![CDATA[<class name="Payment" table="PAYMENT">
+ <programlisting role="XML"><![CDATA[<class name="Payment" table="PAYMENT">
<id name="id" type="long" column="PAYMENT_ID">
<generator class="native"/>
</id>
@@ -231,7 +231,7 @@
using the following approach:
</para>
- <programlisting><![CDATA[<class name="Payment" table="PAYMENT">
+ <programlisting role="XML"><![CDATA[<class name="Payment" table="PAYMENT">
<id name="id" type="long" column="PAYMENT_ID">
<generator class="native"/>
</id>
@@ -258,7 +258,7 @@
<literal><many-to-one></literal>.
</para>
- <programlisting><![CDATA[<many-to-one name="payment" column="PAYMENT_ID" class="Payment"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<many-to-one name="payment" column="PAYMENT_ID" class="Payment"/>]]></programlisting>
</sect2>
@@ -270,7 +270,7 @@
strategy. First, you can use <literal><union-subclass></literal>.
</para>
- <programlisting><![CDATA[<class name="Payment">
+ <programlisting role="XML"><![CDATA[<class name="Payment">
<id name="id" type="long" column="PAYMENT_ID">
<generator class="sequence"/>
</id>
@@ -318,7 +318,7 @@
An alternative approach is to make use of implicit polymorphism:
</para>
- <programlisting><![CDATA[<class name="CreditCardPayment" table="CREDIT_PAYMENT">
+ <programlisting role="XML"><![CDATA[<class name="CreditCardPayment" table="CREDIT_PAYMENT">
<id name="id" type="long" column="CREDIT_PAYMENT_ID">
<generator class="native"/>
</id>
@@ -362,7 +362,7 @@
is usually mapped using <literal><any></literal>.
</para>
- <programlisting><![CDATA[<any name="payment" meta-type="string" id-type="long">
+ <programlisting role="XML"><![CDATA[<any name="payment" meta-type="string" id-type="long">
<meta-value value="CREDIT" class="CreditCardPayment"/>
<meta-value value="CASH" class="CashPayment"/>
<meta-value value="CHEQUE" class="ChequePayment"/>
@@ -383,7 +383,7 @@
queries against the <literal>Payment</literal> interface.
</para>
- <programlisting><![CDATA[<class name="CreditCardPayment" table="CREDIT_PAYMENT">
+ <programlisting role="XML"><![CDATA[<class name="CreditCardPayment" table="CREDIT_PAYMENT">
<id name="id" type="long" column="CREDIT_PAYMENT_ID">
<generator class="native"/>
</id>
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/performance.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/performance.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/performance.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -161,7 +161,7 @@
in an exception. For example:
</para>
- <programlisting><![CDATA[s = sessions.openSession();
+ <programlisting role="JAVA"><![CDATA[s = sessions.openSession();
Transaction tx = s.beginTransaction();
User u = (User) s.createQuery("from User u where u.name=:userName")
@@ -208,13 +208,13 @@
so we might want to enable join fetching in the mapping document:
</para>
- <programlisting><![CDATA[<set name="permissions"
+ <programlisting role="XML"><![CDATA[<set name="permissions"
fetch="join">
<key column="userId"/>
<one-to-many class="Permission"/>
</set]]></programlisting>
- <programlisting><![CDATA[<many-to-one name="mother" class="Cat" fetch="join"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<many-to-one name="mother" class="Cat" fetch="join"/>]]></programlisting>
<para>
The <literal>fetch</literal> strategy defined in the mapping document affects:
@@ -264,7 +264,7 @@
<literal>Criteria</literal> query. For example:
</para>
- <programlisting><![CDATA[User user = (User) session.createCriteria(User.class)
+ <programlisting role="JAVA"><![CDATA[User user = (User) session.createCriteria(User.class)
.setFetchMode("permissions", FetchMode.JOIN)
.add( Restrictions.idEq(userId) )
.uniqueResult();]]></programlisting>
@@ -308,7 +308,7 @@
There are potential problems to note when extending this approach to polymorphic classes.For example:
</para>
- <programlisting><![CDATA[<class name="Cat" proxy="Cat">
+ <programlisting role="XML"><![CDATA[<class name="Cat" proxy="Cat">
......
<subclass name="DomesticCat">
.....
@@ -321,7 +321,7 @@
instance of <literal>DomesticCat</literal>:
</para>
- <programlisting><![CDATA[Cat cat = (Cat) session.load(Cat.class, id); // instantiate a proxy (does not hit the db)
+ <programlisting role="JAVA"><![CDATA[Cat cat = (Cat) session.load(Cat.class, id); // instantiate a proxy (does not hit the db)
if ( cat.isDomesticCat() ) { // hit the db to initialize the proxy
DomesticCat dc = (DomesticCat) cat; // Error!
....
@@ -331,7 +331,7 @@
Secondly, it is possible to break proxy <literal>==</literal>:
</para>
- <programlisting><![CDATA[Cat cat = (Cat) session.load(Cat.class, id); // instantiate a Cat proxy
+ <programlisting role="JAVA"><![CDATA[Cat cat = (Cat) session.load(Cat.class, id); // instantiate a Cat proxy
DomesticCat dc =
(DomesticCat) session.load(DomesticCat.class, id); // acquire new DomesticCat proxy!
System.out.println(cat==dc); // false]]></programlisting>
@@ -341,7 +341,7 @@
to different proxy objects, the underlying instance will still be the same object:
</para>
- <programlisting><![CDATA[cat.setWeight(11.0); // hit the db to initialize the proxy
+ <programlisting role="JAVA"><![CDATA[cat.setWeight(11.0); // hit the db to initialize the proxy
System.out.println( dc.getWeight() ); // 11.0]]></programlisting>
<para>
@@ -363,7 +363,7 @@
implements the interface <literal>DomesticCat</literal>. For example:
</para>
- <programlisting><![CDATA[<class name="CatImpl" proxy="Cat">
+ <programlisting role="XML"><![CDATA[<class name="CatImpl" proxy="Cat">
......
<subclass name="DomesticCatImpl" proxy="DomesticCat">
.....
@@ -375,7 +375,7 @@
by <literal>load()</literal> or <literal>iterate()</literal>.
</para>
- <programlisting><![CDATA[Cat cat = (Cat) session.load(CatImpl.class, catid);
+ <programlisting role="JAVA"><![CDATA[Cat cat = (Cat) session.load(CatImpl.class, catid);
Iterator iter = session.createQuery("from CatImpl as cat where cat.name='fritz'").iterate();
Cat fritz = (Cat) iter.next();]]></programlisting>
@@ -512,14 +512,14 @@
You can use a collection filter to get the size of a collection without initializing it:
</para>
- <programlisting><![CDATA[( (Integer) s.createFilter( collection, "select count(*)" ).list().get(0) ).intValue()]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[( (Integer) s.createFilter( collection, "select count(*)" ).list().get(0) ).intValue()]]></programlisting>
<para>
The <literal>createFilter()</literal> method is also used to efficiently retrieve subsets
of a collection without needing to initialize the whole collection:
</para>
- <programlisting><![CDATA[s.createFilter( lazyCollection, "").setFirstResult(0).setMaxResults(10).list();]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[s.createFilter( lazyCollection, "").setFirstResult(0).setMaxResults(10).list();]]></programlisting>
</sect2>
@@ -542,7 +542,7 @@
behavior by specifying a <literal>batch-size</literal> in the mapping of <literal>Person</literal>:
</para>
- <programlisting><![CDATA[<class name="Person" batch-size="10">...</class>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<class name="Person" batch-size="10">...</class>]]></programlisting>
<para>
Hibernate will now execute only three queries: the pattern is 10, 10, 5.
@@ -557,7 +557,7 @@
collections:
</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<set name="cats" batch-size="3">
...
</set>
@@ -605,7 +605,7 @@
So what does that mean? Well lets explain that by way of an example. Say we have
the following mappings:
</para>
- <programlisting><![CDATA[<hibernate-mapping>
+ <programlisting role="XML"><![CDATA[<hibernate-mapping>
<class name="Customer">
...
<set name="orders" inverse="true">
@@ -625,7 +625,7 @@
to use "dynamic fetching" strategies via an HQL or criteria queries. But another option is
to use a fetch profile to achieve that. Just add the following to your mapping:
</para>
- <programlisting><![CDATA[<hibernate-mapping>
+ <programlisting role="XML"><![CDATA[<hibernate-mapping>
...
<fetch-profile name="customer-with-orders">
<fetch entity="Customer" association="orders" style="join"/>
@@ -634,7 +634,7 @@
<para>
or even:
</para>
- <programlisting><![CDATA[<hibernate-mapping>
+ <programlisting role="XML"><![CDATA[<hibernate-mapping>
<class name="Customer">
...
<fetch-profile name="customer-with-orders">
@@ -646,7 +646,7 @@
<para>
Now the following code will actually load both the customer <emphasis>and their orders</emphasis>:
</para>
- <programlisting><![CDATA[
+ <programlisting role="JAVA"><![CDATA[
Session session = ...;
session.enableFetchProfile( "customer-with-orders" ); // name matches from mapping
Customer customer = (Customer) session.get( Customer.class, customerId );
@@ -676,7 +676,7 @@
particular property mappings:
</para>
- <programlisting><![CDATA[<class name="Document">
+ <programlisting role="XML"><![CDATA[<class name="Document">
<id name="id">
<generator class="native"/>
</id>
@@ -695,7 +695,7 @@
For bytecode instrumentation, use the following Ant task:
</para>
- <programlisting><![CDATA[<target name="instrument" depends="compile">
+ <programlisting role="XML"><![CDATA[<target name="instrument" depends="compile">
<taskdef name="instrument" classname="org.hibernate.tool.instrument.InstrumentTask">
<classpath path="${jar.path}"/>
<classpath path="${classes.dir}"/>
@@ -823,7 +823,7 @@
<area id="cache2" coords="3 70"/>
<area id="cache3" coords="4 70"/>
</areaspec>
- <programlisting><![CDATA[<cache
+ <programlisting role="XML"><![CDATA[<cache
usage="transactional|read-write|nonstrict-read-write|read-only"
region="RegionName"
include="all|non-lazy"
@@ -876,7 +876,7 @@
strategy. It is even safe for use in a cluster.
</para>
- <programlisting><![CDATA[<class name="eg.Immutable" mutable="false">
+ <programlisting role="XML"><![CDATA[<class name="eg.Immutable" mutable="false">
<cache usage="read-only"/>
....
</class>]]></programlisting>
@@ -898,7 +898,7 @@
supports locking. The built-in cache providers <emphasis>do not</emphasis> support locking.
</para>
- <programlisting><![CDATA[<class name="eg.Cat" .... >
+ <programlisting role="XML"><![CDATA[<class name="eg.Cat" .... >
<cache usage="read-write"/>
....
<set name="kittens" ... >
@@ -1033,7 +1033,7 @@
from the first-level cache.
</para>
- <programlisting><![CDATA[ScrollableResult cats = sess.createQuery("from Cat as cat").scroll(); //a huge result set
+ <programlisting role="JAVA"><![CDATA[ScrollableResult cats = sess.createQuery("from Cat as cat").scroll(); //a huge result set
while ( cats.next() ) {
Cat cat = (Cat) cats.get(0);
doSomethingWithACat(cat);
@@ -1055,7 +1055,7 @@
role.
</para>
- <programlisting><![CDATA[sessionFactory.evict(Cat.class, catId); //evict a particular Cat
+ <programlisting role="JAVA"><![CDATA[sessionFactory.evict(Cat.class, catId); //evict a particular Cat
sessionFactory.evict(Cat.class); //evict all Cats
sessionFactory.evictCollection("Cat.kittens", catId); //evict a particular collection of kittens
sessionFactory.evictCollection("Cat.kittens"); //evict all kitten collections]]></programlisting>
@@ -1097,7 +1097,7 @@
API:
</para>
- <programlisting><![CDATA[Map cacheEntries = sessionFactory.getStatistics()
+ <programlisting role="JAVA"><![CDATA[Map cacheEntries = sessionFactory.getStatistics()
.getSecondLevelCacheStatistics(regionName)
.getEntries();]]></programlisting>
@@ -1144,7 +1144,7 @@
<literal>Query.setCacheRegion()</literal>.
</para>
- <programlisting><![CDATA[List blogs = sess.createQuery("from Blog blog where blog.blogger = :blogger")
+ <programlisting role="JAVA"><![CDATA[List blogs = sess.createQuery("from Blog blog where blog.blogger = :blogger")
.setEntity("blogger", blogger)
.setMaxResults(15)
.setCacheable(true)
@@ -1298,7 +1298,7 @@
make the following common code much faster:
</para>
- <programlisting><![CDATA[Parent p = (Parent) sess.load(Parent.class, id);
+ <programlisting role="JAVA"><![CDATA[Parent p = (Parent) sess.load(Parent.class, id);
Child c = new Child();
c.setParent(p);
p.getChildren().add(c); //no need to fetch the collection!
@@ -1382,7 +1382,7 @@
minimalistic configuration examples:
</para>
- <programlisting><![CDATA[// MBean service registration for a specific SessionFactory
+ <programlisting role="JAVA"><![CDATA[// MBean service registration for a specific SessionFactory
Hashtable tb = new Hashtable();
tb.put("type", "statistics");
tb.put("sessionFactory", "myFinancialApp");
@@ -1393,7 +1393,7 @@
server.registerMBean(stats, on); // Register the Mbean on the server]]></programlisting>
-<programlisting><![CDATA[// MBean service registration for all SessionFactory's
+<programlisting role="JAVA"><![CDATA[// MBean service registration for all SessionFactory's
Hashtable tb = new Hashtable();
tb.put("type", "statistics");
tb.put("sessionFactory", "all");
@@ -1475,7 +1475,7 @@
code is a simple example:
</para>
- <programlisting><![CDATA[Statistics stats = HibernateUtil.sessionFactory.getStatistics();
+ <programlisting role="JAVA"><![CDATA[Statistics stats = HibernateUtil.sessionFactory.getStatistics();
double queryCacheHitCount = stats.getQueryCacheHitCount();
double queryCacheMissCount = stats.getQueryCacheMissCount();
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/persistent_classes.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/persistent_classes.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/persistent_classes.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -50,7 +50,7 @@
Most Java applications require a persistent class representing felines. For example:
</para>
- <programlisting><![CDATA[package eg;
+ <programlisting role="JAVA"><![CDATA[package eg;
import java.util.Set;
import java.util.Date;
@@ -243,7 +243,7 @@
identifier property from the superclass, <literal>Cat</literal>. For example:
</para>
- <programlisting><![CDATA[package eg;
+ <programlisting role="JAVA"><![CDATA[package eg;
public class DomesticCat extends Cat {
private String name;
@@ -309,7 +309,7 @@
<emphasis>natural</emphasis> candidate key):
</para>
- <programlisting><![CDATA[public class Cat {
+ <programlisting role="JAVA"><![CDATA[public class Cat {
...
public boolean equals(Object other) {
@@ -374,7 +374,7 @@
instead of, or in addition to, a class name:
</para>
- <programlisting><![CDATA[<hibernate-mapping>
+ <programlisting role="XML"><![CDATA[<hibernate-mapping>
<class entity-name="Customer">
@@ -421,7 +421,7 @@
<literal>Map</literal>s of <literal>Map</literal>s:
</para>
- <programlisting><![CDATA[Session s = openSession();
+ <programlisting role="JAVA"><![CDATA[Session s = openSession();
Transaction tx = s.beginTransaction();
Session s = openSession();
@@ -456,7 +456,7 @@
basis:
</para>
- <programlisting><![CDATA[Session dynamicSession = pojoSession.getSession(EntityMode.MAP);
+ <programlisting role="JAVA"><![CDATA[Session dynamicSession = pojoSession.getSession(EntityMode.MAP);
// Create a customer
Map david = new HashMap();
@@ -517,7 +517,7 @@
are meant to manage. Going back to the example of our customer entity:
</para>
- <programlisting><![CDATA[<hibernate-mapping>
+ <programlisting role="XML"><![CDATA[<hibernate-mapping>
<class entity-name="Customer">
<!--
Override the dynamic-map entity-mode
@@ -572,7 +572,7 @@
for illustration.
</para>
- <programlisting>
+ <programlisting role="JAVA">
/**
* A very trivial JDK Proxy InvocationHandler implementation where we proxy an interface as
* the domain model and simply store persistent state in an internal Map. This is an extremely
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/portability.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/portability.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/portability.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -73,7 +73,7 @@
Starting with version 3.3, Hibernate has a fare more powerful way to automatically determine
which dialect to should be used by relying on a series of delegates which implement the
<interfacename>org.hibernate.dialect.resolver.DialectResolver</interfacename> which defines only a
- single method:<programlisting><![CDATA[public Dialect resolveDialect(DatabaseMetaData metaData) throws JDBCConnectionException]]></programlisting>.
+ single method:<programlisting role="JAVA"><![CDATA[public Dialect resolveDialect(DatabaseMetaData metaData) throws JDBCConnectionException]]></programlisting>.
The basic contract here is that if the resolver 'understands' the given database metadata then
it returns the corresponding Dialect; if not it returns null and the process continues to the next
resolver. The signature also identifies <exceptionname>org.hibernate.exception.JDBCConnectionException</exceptionname>
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/query_criteria.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/query_criteria.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/query_criteria.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -41,7 +41,7 @@
<literal>Criteria</literal> instances.
</para>
- <programlisting><![CDATA[Criteria crit = sess.createCriteria(Cat.class);
+ <programlisting role="JAVA"><![CDATA[Criteria crit = sess.createCriteria(Cat.class);
crit.setMaxResults(50);
List cats = crit.list();]]></programlisting>
@@ -58,7 +58,7 @@
<literal>Criterion</literal> types.
</para>
- <programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List cats = sess.createCriteria(Cat.class)
.add( Restrictions.like("name", "Fritz%") )
.add( Restrictions.between("weight", minWeight, maxWeight) )
.list();]]></programlisting>
@@ -67,7 +67,7 @@
Restrictions can be grouped logically.
</para>
- <programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List cats = sess.createCriteria(Cat.class)
.add( Restrictions.like("name", "Fritz%") )
.add( Restrictions.or(
Restrictions.eq( "age", new Integer(0) ),
@@ -75,7 +75,7 @@
) )
.list();]]></programlisting>
- <programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List cats = sess.createCriteria(Cat.class)
.add( Restrictions.in( "name", new String[] { "Fritz", "Izi", "Pk" } ) )
.add( Restrictions.disjunction()
.add( Restrictions.isNull("age") )
@@ -90,7 +90,7 @@
subclasses). One of the most useful allows you to specify SQL directly.
</para>
- <programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List cats = sess.createCriteria(Cat.class)
.add( Restrictions.sqlRestriction("lower({alias}.name) like lower(?)", "Fritz%", Hibernate.STRING) )
.list();]]></programlisting>
@@ -105,7 +105,7 @@
by calling <literal>Property.forName()</literal>:
</para>
- <programlisting><![CDATA[
+ <programlisting role="JAVA"><![CDATA[
Property age = Property.forName("age");
List cats = sess.createCriteria(Cat.class)
.add( Restrictions.disjunction()
@@ -126,14 +126,14 @@
You can order the results using <literal>org.hibernate.criterion.Order</literal>.
</para>
- <programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List cats = sess.createCriteria(Cat.class)
.add( Restrictions.like("name", "F%")
.addOrder( Order.asc("name") )
.addOrder( Order.desc("age") )
.setMaxResults(50)
.list();]]></programlisting>
- <programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List cats = sess.createCriteria(Cat.class)
.add( Property.forName("name").like("F%") )
.addOrder( Property.forName("name").asc() )
.addOrder( Property.forName("age").desc() )
@@ -150,7 +150,7 @@
associations using <literal>createCriteria()</literal> you can specify constraints upon related entities:
</para>
- <programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List cats = sess.createCriteria(Cat.class)
.add( Restrictions.like("name", "F%") )
.createCriteria("kittens")
.add( Restrictions.like("name", "F%") )
@@ -166,7 +166,7 @@
There is also an alternate form that is useful in certain circumstances:
</para>
- <programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List cats = sess.createCriteria(Cat.class)
.createAlias("kittens", "kt")
.createAlias("mate", "mt")
.add( Restrictions.eqProperty("kt.name", "mt.name") )
@@ -184,7 +184,7 @@
criteria, you must use a <literal>ResultTransformer</literal>.
</para>
- <programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List cats = sess.createCriteria(Cat.class)
.createCriteria("kittens", "kt")
.add( Restrictions.eq("name", "F%") )
.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP)
@@ -206,7 +206,7 @@
<literal>setFetchMode()</literal>.
</para>
- <programlisting><![CDATA[List cats = sess.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List cats = sess.createCriteria(Cat.class)
.add( Restrictions.like("name", "Fritz%") )
.setFetchMode("mate", FetchMode.EAGER)
.setFetchMode("kittens", FetchMode.EAGER)
@@ -227,7 +227,7 @@
you to construct a query criterion from a given instance.
</para>
- <programlisting><![CDATA[Cat cat = new Cat();
+ <programlisting role="JAVA"><![CDATA[Cat cat = new Cat();
cat.setSex('F');
cat.setColor(Color.BLACK);
List results = session.createCriteria(Cat.class)
@@ -243,7 +243,7 @@
You can adjust how the <literal>Example</literal> is applied.
</para>
- <programlisting><![CDATA[Example example = Example.create(cat)
+ <programlisting role="JAVA"><![CDATA[Example example = Example.create(cat)
.excludeZeroes() //exclude zero valued properties
.excludeProperty("color") //exclude the property named "color"
.ignoreCase() //perform case insensitive string comparisons
@@ -256,7 +256,7 @@
You can even use examples to place criteria upon associated objects.
</para>
- <programlisting><![CDATA[List results = session.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List results = session.createCriteria(Cat.class)
.add( Example.create(cat) )
.createCriteria("mate")
.add( Example.create( cat.getMate() ) )
@@ -272,12 +272,12 @@
projection to a query by calling <literal>setProjection()</literal>.
</para>
- <programlisting><![CDATA[List results = session.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List results = session.createCriteria(Cat.class)
.setProjection( Projections.rowCount() )
.add( Restrictions.eq("color", Color.BLACK) )
.list();]]></programlisting>
- <programlisting><![CDATA[List results = session.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List results = session.createCriteria(Cat.class)
.setProjection( Projections.projectionList()
.add( Projections.rowCount() )
.add( Projections.avg("weight") )
@@ -298,12 +298,12 @@
do this:
</para>
- <programlisting><![CDATA[List results = session.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List results = session.createCriteria(Cat.class)
.setProjection( Projections.alias( Projections.groupProperty("color"), "colr" ) )
.addOrder( Order.asc("colr") )
.list();]]></programlisting>
- <programlisting><![CDATA[List results = session.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List results = session.createCriteria(Cat.class)
.setProjection( Projections.groupProperty("color").as("colr") )
.addOrder( Order.asc("colr") )
.list();]]></programlisting>
@@ -315,7 +315,7 @@
projection list:
</para>
- <programlisting><![CDATA[List results = session.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List results = session.createCriteria(Cat.class)
.setProjection( Projections.projectionList()
.add( Projections.rowCount(), "catCountByColor" )
.add( Projections.avg("weight"), "avgWeight" )
@@ -326,7 +326,7 @@
.addOrder( Order.desc("avgWeight") )
.list();]]></programlisting>
- <programlisting><![CDATA[List results = session.createCriteria(Domestic.class, "cat")
+ <programlisting role="JAVA"><![CDATA[List results = session.createCriteria(Domestic.class, "cat")
.createAlias("kittens", "kit")
.setProjection( Projections.projectionList()
.add( Projections.property("cat.name"), "catName" )
@@ -340,12 +340,12 @@
You can also use <literal>Property.forName()</literal> to express projections:
</para>
- <programlisting><![CDATA[List results = session.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List results = session.createCriteria(Cat.class)
.setProjection( Property.forName("name") )
.add( Property.forName("color").eq(Color.BLACK) )
.list();]]></programlisting>
- <programlisting><![CDATA[List results = session.createCriteria(Cat.class)
+ <programlisting role="JAVA"><![CDATA[List results = session.createCriteria(Cat.class)
.setProjection( Projections.projectionList()
.add( Projections.rowCount().as("catCountByColor") )
.add( Property.forName("weight").avg().as("avgWeight") )
@@ -365,7 +365,7 @@
of a session and then execute it using an arbitrary <literal>Session</literal>.
</para>
- <programlisting><![CDATA[DetachedCriteria query = DetachedCriteria.forClass(Cat.class)
+ <programlisting role="JAVA"><![CDATA[DetachedCriteria query = DetachedCriteria.forClass(Cat.class)
.add( Property.forName("sex").eq('F') );
Session session = ....;
@@ -380,13 +380,13 @@
<literal>Property</literal>.
</para>
- <programlisting><![CDATA[DetachedCriteria avgWeight = DetachedCriteria.forClass(Cat.class)
+ <programlisting role="JAVA"><![CDATA[DetachedCriteria avgWeight = DetachedCriteria.forClass(Cat.class)
.setProjection( Property.forName("weight").avg() );
session.createCriteria(Cat.class)
.add( Property.forName("weight").gt(avgWeight) )
.list();]]></programlisting>
- <programlisting><![CDATA[DetachedCriteria weights = DetachedCriteria.forClass(Cat.class)
+ <programlisting role="JAVA"><![CDATA[DetachedCriteria weights = DetachedCriteria.forClass(Cat.class)
.setProjection( Property.forName("weight") );
session.createCriteria(Cat.class)
.add( Subqueries.geAll("weight", weights) )
@@ -396,7 +396,7 @@
Correlated subqueries are also possible:
</para>
- <programlisting><![CDATA[DetachedCriteria avgWeightForSex = DetachedCriteria.forClass(Cat.class, "cat2")
+ <programlisting role="JAVA"><![CDATA[DetachedCriteria avgWeightForSex = DetachedCriteria.forClass(Cat.class, "cat2")
.setProjection( Property.forName("weight").avg() )
.add( Property.forName("cat2.sex").eqProperty("cat.sex") );
session.createCriteria(Cat.class, "cat")
@@ -425,7 +425,7 @@
<literal><natural-id></literal> and enable use of the second-level cache.
</para>
- <programlisting><![CDATA[<class name="User">
+ <programlisting role="XML"><![CDATA[<class name="User">
<cache usage="read-write"/>
<id name="id">
<generator class="increment"/>
@@ -448,7 +448,7 @@
the more efficient cache algorithm.
</para>
- <programlisting><![CDATA[session.createCriteria(User.class)
+ <programlisting role="JAVA"><![CDATA[session.createCriteria(User.class)
.add( Restrictions.naturalId()
.set("name", "gavin")
.set("org", "hb")
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/query_hql.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/query_hql.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/query_hql.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -1119,7 +1119,7 @@
You can count the number of query results without returning them:
</para>
- <programlisting><![CDATA[( (Integer) session.createQuery("select count(*) from ....").iterate().next() ).intValue()]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[( (Integer) session.createQuery("select count(*) from ....").iterate().next() ).intValue()]]></programlisting>
<para>
To order a result by the size of a collection, use the following query:
@@ -1164,7 +1164,7 @@
Properties of a JavaBean can be bound to named query parameters:
</para>
- <programlisting><![CDATA[Query q = s.createQuery("from foo Foo as foo where foo.name=:name and foo.size=:size");
+ <programlisting role="JAVA"><![CDATA[Query q = s.createQuery("from foo Foo as foo where foo.name=:name and foo.size=:size");
q.setProperties(fooBean); // fooBean has getName() and getSize()
List foos = q.list();]]></programlisting>
@@ -1172,7 +1172,7 @@
Collections are pageable by using the <literal>Query</literal> interface with a filter:
</para>
- <programlisting><![CDATA[Query q = s.createFilter( collection, "" ); // the trivial filter
+ <programlisting role="JAVA"><![CDATA[Query q = s.createFilter( collection, "" ); // the trivial filter
q.setMaxResults(PAGE_SIZE);
q.setFirstResult(PAGE_SIZE * pageNumber);
List page = q.list();]]></programlisting>
@@ -1181,14 +1181,14 @@
Collection elements can be ordered or grouped using a query filter:
</para>
- <programlisting><![CDATA[Collection orderedCollection = s.filter( collection, "order by this.amount" );
+ <programlisting role="JAVA"><![CDATA[Collection orderedCollection = s.filter( collection, "order by this.amount" );
Collection counts = s.filter( collection, "select this.type, count(this) group by this.type" );]]></programlisting>
<para>
You can find the size of a collection without initializing it:
</para>
- <programlisting><![CDATA[( (Integer) session.createQuery("select count(*) from ....").iterate().next() ).intValue();]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[( (Integer) session.createQuery("select count(*) from ....").iterate().next() ).intValue();]]></programlisting>
</sect1>
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/query_sql.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/query_sql.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/query_sql.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -51,7 +51,7 @@
<para>The most basic SQL query is to get a list of scalars
(values).</para>
- <programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS").list();
+ <programlisting role="JAVA"><![CDATA[sess.createSQLQuery("SELECT * FROM CATS").list();
sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE FROM CATS").list();
]]></programlisting>
@@ -64,7 +64,7 @@
<literal>ResultSetMetadata</literal>, or simply to be more explicit in
what is returned, one can use <literal>addScalar()</literal>:</para>
- <programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS")
+ <programlisting role="JAVA"><![CDATA[sess.createSQLQuery("SELECT * FROM CATS")
.addScalar("ID", Hibernate.LONG)
.addScalar("NAME", Hibernate.STRING)
.addScalar("BIRTHDATE", Hibernate.DATE)
@@ -93,7 +93,7 @@
<para>It is possible to leave out the type information for all or some
of the scalars.</para>
- <programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS")
+ <programlisting role="JAVA"><![CDATA[sess.createSQLQuery("SELECT * FROM CATS")
.addScalar("ID", Hibernate.LONG)
.addScalar("NAME")
.addScalar("BIRTHDATE")
@@ -118,7 +118,7 @@
shows how to get entity objects from a native sql query via
<literal>addEntity()</literal>.</para>
- <programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS").addEntity(Cat.class);
+ <programlisting role="JAVA"><![CDATA[sess.createSQLQuery("SELECT * FROM CATS").addEntity(Cat.class);
sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE FROM CATS").addEntity(Cat.class);
]]></programlisting>
@@ -146,7 +146,7 @@
example for a <literal>many-to-one</literal> to a
<literal>Dog</literal>:</para>
- <programlisting><![CDATA[sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE, DOG_ID FROM CATS").addEntity(Cat.class);
+ <programlisting role="JAVA"><![CDATA[sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE, DOG_ID FROM CATS").addEntity(Cat.class);
]]></programlisting>
<para>This will allow cat.getDog() to function properly.</para>
@@ -160,7 +160,7 @@
done via the <literal>addJoin()</literal> method, which allows you to
join in an association or collection.</para>
- <programlisting><![CDATA[sess.createSQLQuery("SELECT c.ID, NAME, BIRTHDATE, DOG_ID, D_ID, D_NAME FROM CATS c, DOGS d WHERE c.DOG_ID = d.D_ID")
+ <programlisting role="JAVA"><![CDATA[sess.createSQLQuery("SELECT c.ID, NAME, BIRTHDATE, DOG_ID, D_ID, D_NAME FROM CATS c, DOGS d WHERE c.DOG_ID = d.D_ID")
.addEntity("cat", Cat.class)
.addJoin("cat.dog");
]]></programlisting>
@@ -173,7 +173,7 @@
<literal>Cat</literal> had a one-to-many to <literal>Dog</literal>
instead.</para>
- <programlisting><![CDATA[sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE, D_ID, D_NAME, CAT_ID FROM CATS c, DOGS d WHERE c.ID = d.CAT_ID")
+ <programlisting role="JAVA"><![CDATA[sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE, D_ID, D_NAME, CAT_ID FROM CATS c, DOGS d WHERE c.ID = d.CAT_ID")
.addEntity("cat", Cat.class)
.addJoin("cat.dogs");
]]></programlisting>
@@ -196,7 +196,7 @@
<para>Column alias injection is needed in the following query (which
most likely will fail):</para>
- <programlisting><![CDATA[sess.createSQLQuery("SELECT c.*, m.* FROM CATS c, CATS m WHERE c.MOTHER_ID = c.ID")
+ <programlisting role="JAVA"><![CDATA[sess.createSQLQuery("SELECT c.*, m.* FROM CATS c, CATS m WHERE c.MOTHER_ID = c.ID")
.addEntity("cat", Cat.class)
.addEntity("mother", Cat.class)
]]></programlisting>
@@ -215,7 +215,7 @@
<para>The following form is not vulnerable to column name
duplication:</para>
- <programlisting><![CDATA[sess.createSQLQuery("SELECT {cat.*}, {mother.*} FROM CATS c, CATS m WHERE c.MOTHER_ID = c.ID")
+ <programlisting role="JAVA"><![CDATA[sess.createSQLQuery("SELECT {cat.*}, {mother.*} FROM CATS c, CATS m WHERE c.MOTHER_ID = c.ID")
.addEntity("cat", Cat.class)
.addEntity("mother", Cat.class)
]]></programlisting>
@@ -242,7 +242,7 @@
declared in the mapping metadata. You can even use the
property aliases in the where clause.</para>
- <programlisting><![CDATA[String sql = "SELECT ID as {c.id}, NAME as {c.name}, " +
+ <programlisting role="JAVA"><![CDATA[String sql = "SELECT ID as {c.id}, NAME as {c.name}, " +
"BIRTHDATE as {c.birthDate}, MOTHER_ID as {c.mother}, {mother.*} " +
"FROM CAT_LOG c, CAT_LOG m WHERE {c.mother} = c.ID";
@@ -376,7 +376,7 @@
<para>It is possible to apply a ResultTransformer to native SQL queries, allowing it to return non-managed entities.</para>
- <programlisting><![CDATA[sess.createSQLQuery("SELECT NAME, BIRTHDATE FROM CATS")
+ <programlisting role="JAVA"><![CDATA[sess.createSQLQuery("SELECT NAME, BIRTHDATE FROM CATS")
.setResultTransformer(Transformers.aliasToBean(CatDTO.class))]]></programlisting>
<para>This query specified:</para>
@@ -411,7 +411,7 @@
<para>Native SQL queries support positional as well as named
parameters:</para>
- <programlisting><![CDATA[Query query = sess.createSQLQuery("SELECT * FROM CATS WHERE NAME like ?").addEntity(Cat.class);
+ <programlisting role="JAVA"><![CDATA[Query query = sess.createSQLQuery("SELECT * FROM CATS WHERE NAME like ?").addEntity(Cat.class);
List pusList = query.setString(0, "Pus%").list();
query = sess.createSQLQuery("SELECT * FROM CATS WHERE NAME like :name").addEntity(Cat.class);
@@ -430,7 +430,7 @@
<emphasis>not</emphasis> need to call
<literal>addEntity()</literal>.</para>
- <programlisting><![CDATA[<sql-query name="persons">
+ <programlisting role="XML"><![CDATA[<sql-query name="persons">
<return alias="person" class="eg.Person"/>
SELECT person.NAME AS {person.name},
person.AGE AS {person.age},
@@ -439,7 +439,7 @@
WHERE person.NAME LIKE :namePattern
</sql-query>]]></programlisting>
- <programlisting><![CDATA[List people = sess.getNamedQuery("persons")
+ <programlisting role="JAVA"><![CDATA[List people = sess.getNamedQuery("persons")
.setString("namePattern", namePattern)
.setMaxResults(50)
.list();]]></programlisting>
@@ -448,7 +448,7 @@
the <literal><load-collection></literal> element is used to define queries which initialize collections,
</para>
- <programlisting><![CDATA[<sql-query name="personsWith">
+ <programlisting role="XML"><![CDATA[<sql-query name="personsWith">
<return alias="person" class="eg.Person"/>
<return-join alias="address" property="person.mailingAddress"/>
SELECT person.NAME AS {person.name},
@@ -468,7 +468,7 @@
column alias and Hibernate type using the
<literal><return-scalar></literal> element:</para>
- <programlisting><![CDATA[<sql-query name="mySqlQuery">
+ <programlisting role="XML"><![CDATA[<sql-query name="mySqlQuery">
<return-scalar column="name" type="string"/>
<return-scalar column="age" type="long"/>
SELECT p.NAME AS name,
@@ -481,7 +481,7 @@
several named queries or through the
<literal>setResultSetMapping()</literal> API.</para>
- <programlisting><![CDATA[<resultset name="personAddress">
+ <programlisting role="XML"><![CDATA[<resultset name="personAddress">
<return alias="person" class="eg.Person"/>
<return-join alias="address" property="person.mailingAddress"/>
</resultset>
@@ -503,7 +503,7 @@
<para>You can, alternatively, use the resultset mapping information in your
hbm files directly in java code.</para>
- <programlisting><![CDATA[List cats = sess.createSQLQuery(
+ <programlisting role="JAVA"><![CDATA[List cats = sess.createSQLQuery(
"select {cat.*}, {kitten.*} from cats cat, cats kitten where kitten.mother = cat.id"
)
.setResultSetMapping("catAndKitten")
@@ -518,7 +518,7 @@
<literal>{}</literal>-syntax to let Hibernate inject its own
aliases.For example:</para>
- <programlisting><![CDATA[<sql-query name="mySqlQuery">
+ <programlisting role="XML"><![CDATA[<sql-query name="mySqlQuery">
<return alias="person" class="eg.Person">
<return-property name="name" column="myName"/>
<return-property name="age" column="myAge"/>
@@ -536,7 +536,7 @@
<literal>{}</literal>-syntax which cannot allow fine grained control of
multi-column properties.</para>
- <programlisting><![CDATA[<sql-query name="organizationCurrentEmployments">
+ <programlisting role="XML"><![CDATA[<sql-query name="organizationCurrentEmployments">
<return alias="emp" class="Employment">
<return-property name="salary">
<return-column name="VALUE"/>
@@ -571,7 +571,7 @@
out-parameter to be able to work with Hibernate. An example of such a
stored function in Oracle 9 and higher is as follows:</para>
- <programlisting><![CDATA[CREATE OR REPLACE FUNCTION selectAllEmployments
+ <programlisting role="XML"><![CDATA[CREATE OR REPLACE FUNCTION selectAllEmployments
RETURN SYS_REFCURSOR
AS
st_cursor SYS_REFCURSOR;
@@ -587,7 +587,7 @@
<para>To use this query in Hibernate you need to map it via a named
query.</para>
- <programlisting><![CDATA[<sql-query name="selectAllEmployees_SP" callable="true">
+ <programlisting role="XML"><![CDATA[<sql-query name="selectAllEmployees_SP" callable="true">
<return alias="emp" class="Employment">
<return-property name="employee" column="EMPLOYEE"/>
<return-property name="employer" column="EMPLOYER"/>
@@ -675,7 +675,7 @@
<literal><sql-delete></literal>, and
<literal><sql-update></literal> override these strings:</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id">
<generator class="increment"/>
</id>
@@ -692,7 +692,7 @@
<para>Stored procedures are supported if the <literal>callable</literal>
attribute is set:</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id">
<generator class="increment"/>
</id>
@@ -743,7 +743,7 @@
or at the statement level. Here is an example of a statement level override:
</para>
- <programlisting><![CDATA[<sql-query name="person">
+ <programlisting role="XML"><![CDATA[<sql-query name="person">
<return alias="pers" class="Person" lock-mode="upgrade"/>
SELECT NAME AS {pers.name}, ID AS {pers.id}
FROM PERSON
@@ -754,7 +754,7 @@
<para>This is just a named query declaration, as discussed earlier. You
can reference this named query in a class mapping:</para>
- <programlisting><![CDATA[<class name="Person">
+ <programlisting role="XML"><![CDATA[<class name="Person">
<id name="id">
<generator class="increment"/>
</id>
@@ -766,13 +766,13 @@
<para>You can even define a query for collection loading:</para>
- <programlisting><![CDATA[<set name="employments" inverse="true">
+ <programlisting role="XML"><![CDATA[<set name="employments" inverse="true">
<key/>
<one-to-many class="Employment"/>
<loader query-ref="employments"/>
</set>]]></programlisting>
- <programlisting><![CDATA[<sql-query name="employments">
+ <programlisting role="XML"><![CDATA[<sql-query name="employments">
<load-collection alias="emp" role="Person.employments"/>
SELECT {emp.*}
FROM EMPLOYMENT emp
@@ -783,7 +783,7 @@
<para>You can also define an entity loader that loads a collection by
join fetching:</para>
- <programlisting><![CDATA[<sql-query name="person">
+ <programlisting role="XML"><![CDATA[<sql-query name="person">
<return alias="pers" class="Person"/>
<return-join alias="emp" property="pers.employments"/>
SELECT NAME AS {pers.*}, {emp.*}
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/session_api.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/session_api.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/session_api.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -107,7 +107,7 @@
session:
</para>
- <programlisting><![CDATA[DomesticCat fritz = new DomesticCat();
+ <programlisting role="JAVA"><![CDATA[DomesticCat fritz = new DomesticCat();
fritz.setColor(Color.GINGER);
fritz.setSex('M');
fritz.setName("Fritz");
@@ -151,7 +151,7 @@
of <literal>save()</literal>.
</para>
-<programlisting><![CDATA[DomesticCat pk = new DomesticCat();
+<programlisting role="JAVA"><![CDATA[DomesticCat pk = new DomesticCat();
pk.setColor(Color.TABBY);
pk.setSex('F');
pk.setName("PK");
@@ -189,9 +189,9 @@
a newly instantiated instance of that class in a persistent state.
</para>
- <programlisting><![CDATA[Cat fritz = (Cat) sess.load(Cat.class, generatedId);]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[Cat fritz = (Cat) sess.load(Cat.class, generatedId);]]></programlisting>
-<programlisting><![CDATA[// you need to wrap primitive identifiers
+<programlisting role="JAVA"><![CDATA[// you need to wrap primitive identifiers
long id = 1234;
DomesticCat pk = (DomesticCat) sess.load( DomesticCat.class, new Long(id) );]]></programlisting>
@@ -199,7 +199,7 @@
Alternatively, you can load state into a given instance:
</para>
-<programlisting><![CDATA[Cat cat = new DomesticCat();
+<programlisting role="JAVA"><![CDATA[Cat cat = new DomesticCat();
// load pk's state into cat
sess.load( cat, new Long(pkId) );
Set kittens = cat.getKittens();]]></programlisting>
@@ -221,7 +221,7 @@
returns null if there is no matching row.
</para>
- <programlisting><![CDATA[Cat cat = (Cat) sess.get(Cat.class, id);
+ <programlisting role="JAVA"><![CDATA[Cat cat = (Cat) sess.get(Cat.class, id);
if (cat==null) {
cat = new Cat();
sess.save(cat, id);
@@ -233,7 +233,7 @@
using a <literal>LockMode</literal>. See the API documentation for more information.
</para>
- <programlisting><![CDATA[Cat cat = (Cat) sess.get(Cat.class, id, LockMode.UPGRADE);]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[Cat cat = (Cat) sess.get(Cat.class, id, LockMode.UPGRADE);]]></programlisting>
<para>
Any associated instances or contained collections will
@@ -248,7 +248,7 @@
initialize some of the properties of the object.
</para>
- <programlisting><![CDATA[sess.save(cat);
+ <programlisting role="JAVA"><![CDATA[sess.save(cat);
sess.flush(); //force the SQL INSERT
sess.refresh(cat); //re-read the state (after the trigger executes)]]></programlisting>
@@ -283,7 +283,7 @@
<literal>Session</literal>:
</para>
- <programlisting><![CDATA[List cats = session.createQuery(
+ <programlisting role="JAVA"><![CDATA[List cats = session.createQuery(
"from Cat as cat where cat.birthdate < ?")
.setDate(0, date)
.list();
@@ -333,7 +333,7 @@
and <emphasis>n</emphasis> additional selects to initialize the actual instances.
</para>
- <programlisting><![CDATA[// fetch ids
+ <programlisting role="JAVA"><![CDATA[// fetch ids
Iterator iter = sess.createQuery("from eg.Qux q order by q.likeliness").iterate();
while ( iter.hasNext() ) {
Qux qux = (Qux) iter.next(); // fetch the object
@@ -355,7 +355,7 @@
is returned as an array:
</para>
- <programlisting><![CDATA[Iterator kittensAndMothers = sess.createQuery(
+ <programlisting role="JAVA"><![CDATA[Iterator kittensAndMothers = sess.createQuery(
"select kitten, mother from Cat kitten join kitten.mother mother")
.list()
.iterator();
@@ -378,7 +378,7 @@
"scalar" results and not entities in persistent state.
</para>
- <programlisting><![CDATA[Iterator results = sess.createQuery(
+ <programlisting role="JAVA"><![CDATA[Iterator results = sess.createQuery(
"select cat.color, min(cat.birthdate), count(cat) from Cat cat " +
"group by cat.color")
.list()
@@ -424,17 +424,17 @@
</listitem>
</itemizedlist>
- <programlisting><![CDATA[//named parameter (preferred)
+ <programlisting role="JAVA"><![CDATA[//named parameter (preferred)
Query q = sess.createQuery("from DomesticCat cat where cat.name = :name");
q.setString("name", "Fritz");
Iterator cats = q.iterate();]]></programlisting>
- <programlisting><![CDATA[//positional parameter
+ <programlisting role="JAVA"><![CDATA[//positional parameter
Query q = sess.createQuery("from DomesticCat cat where cat.name = ?");
q.setString(0, "Izi");
Iterator cats = q.iterate();]]></programlisting>
- <programlisting><![CDATA[//named parameter list
+ <programlisting role="JAVA"><![CDATA[//named parameter list
List names = new ArrayList();
names.add("Izi");
names.add("Fritz");
@@ -453,7 +453,7 @@
use methods of the <literal>Query</literal> interface:
</para>
- <programlisting><![CDATA[Query q = sess.createQuery("from DomesticCat cat");
+ <programlisting role="JAVA"><![CDATA[Query q = sess.createQuery("from DomesticCat cat");
q.setFirstResult(20);
q.setMaxResults(10);
List cats = q.list();]]></programlisting>
@@ -475,7 +475,7 @@
navigation of the query results.
</para>
- <programlisting><![CDATA[Query q = sess.createQuery("select cat.name, cat from DomesticCat cat " +
+ <programlisting role="JAVA"><![CDATA[Query q = sess.createQuery("select cat.name, cat from DomesticCat cat " +
"order by cat.name");
ScrollableResults cats = q.scroll();
if ( cats.first() ) {
@@ -514,7 +514,7 @@
be interpreted as markup.
</para>
- <programlisting><![CDATA[<query name="ByNameAndMaximumWeight"><![CDATA[
+ <programlisting role="XML"><![CDATA[<query name="ByNameAndMaximumWeight"><![CDATA[
from eg.DomesticCat as cat
where cat.name = ?
and cat.weight > ?
@@ -524,7 +524,7 @@
Parameter binding and executing is done programatically:
</para>
- <programlisting><![CDATA[Query q = sess.getNamedQuery("ByNameAndMaximumWeight");
+ <programlisting role="JAVA"><![CDATA[Query q = sess.getNamedQuery("ByNameAndMaximumWeight");
q.setString(0, name);
q.setInt(1, minWeight);
List cats = q.list();]]></programlisting>
@@ -555,7 +555,7 @@
meaning the current collection element.
</para>
- <programlisting><![CDATA[Collection blackKittens = session.createFilter(
+ <programlisting role="JAVA"><![CDATA[Collection blackKittens = session.createFilter(
pk.getKittens(),
"where this.color = ?")
.setParameter( Color.BLACK, Hibernate.custom(ColorUserType.class) )
@@ -573,7 +573,7 @@
one if required. Filters are not limited to returning the collection elements themselves.
</para>
- <programlisting><![CDATA[Collection blackKittenMates = session.createFilter(
+ <programlisting role="JAVA"><![CDATA[Collection blackKittenMates = session.createFilter(
pk.getKittens(),
"select this.mate where this.color = eg.Color.BLACK.intValue")
.list();]]></programlisting>
@@ -583,7 +583,7 @@
large collection:
</para>
- <programlisting><![CDATA[Collection tenKittens = session.createFilter(
+ <programlisting role="JAVA"><![CDATA[Collection tenKittens = session.createFilter(
mother.getKittens(), "")
.setFirstResult(0).setMaxResults(10)
.list();]]></programlisting>
@@ -599,7 +599,7 @@
an intuitive <literal>Criteria</literal> query API for these cases:
</para>
- <programlisting><![CDATA[Criteria crit = session.createCriteria(Cat.class);
+ <programlisting role="JAVA"><![CDATA[Criteria crit = session.createCriteria(Cat.class);
crit.add( Restrictions.eq( "color", eg.Color.BLACK ) );
crit.setMaxResults(10);
List cats = crit.list();]]></programlisting>
@@ -622,11 +622,11 @@
Hibernate API, you must enclose SQL aliases in braces:
</para>
- <programlisting><![CDATA[List cats = session.createSQLQuery("SELECT {cat.*} FROM CAT {cat} WHERE ROWNUM<10")
+ <programlisting role="JAVA"><![CDATA[List cats = session.createSQLQuery("SELECT {cat.*} FROM CAT {cat} WHERE ROWNUM<10")
.addEntity("cat", Cat.class)
.list();]]></programlisting>
- <programlisting><![CDATA[List cats = session.createSQLQuery(
+ <programlisting role="JAVA"><![CDATA[List cats = session.createSQLQuery(
"SELECT {cat}.ID AS {cat.id}, {cat}.SEX AS {cat.sex}, " +
"{cat}.MATE AS {cat.mate}, {cat}.SUBCLASS AS {cat.class}, ... " +
"FROM CAT {cat} WHERE ROWNUM<10")
@@ -657,7 +657,7 @@
and then manipulate it directly while the <literal>Session</literal> is open:
</para>
- <programlisting><![CDATA[DomesticCat cat = (DomesticCat) sess.load( Cat.class, new Long(69) );
+ <programlisting role="JAVA"><![CDATA[DomesticCat cat = (DomesticCat) sess.load( Cat.class, new Long(69) );
cat.setName("PK");
sess.flush(); // changes to cat are automatically detected and persisted]]></programlisting>
@@ -700,7 +700,7 @@
methods:
</para>
- <programlisting><![CDATA[// in the first session
+ <programlisting role="JAVA"><![CDATA[// in the first session
Cat cat = (Cat) firstSession.load(Cat.class, catId);
Cat potentialMate = new Cat();
firstSession.save(potentialMate);
@@ -739,7 +739,7 @@
an object with a new session. However, the detached instance has to be unmodified.
</para>
- <programlisting><![CDATA[//just reassociate:
+ <programlisting role="JAVA"><![CDATA[//just reassociate:
sess.lock(fritz, LockMode.NONE);
//do a version check, then reassociate:
sess.lock(izi, LockMode.READ);
@@ -769,7 +769,7 @@
The <literal>saveOrUpdate()</literal> method implements this functionality.
</para>
- <programlisting><![CDATA[// in the first session
+ <programlisting role="JAVA"><![CDATA[// in the first session
Cat cat = (Cat) firstSession.load(Cat.class, catID);
// in a higher tier of the application
@@ -907,7 +907,7 @@
transient.
</para>
- <programlisting><![CDATA[sess.delete(cat);]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[sess.delete(cat);]]></programlisting>
<para>
You can delete objects in any order, without risk of foreign key
@@ -928,7 +928,7 @@
values.
</para>
- <programlisting><![CDATA[//retrieve a cat from one database
+ <programlisting role="JAVA"><![CDATA[//retrieve a cat from one database
Session session1 = factory1.openSession();
Transaction tx1 = session1.beginTransaction();
Cat cat = session1.get(Cat.class, catId);
@@ -1073,7 +1073,7 @@
a long time (see <xref linkend="transactions-optimistic-longsession"/>).
</para>
- <programlisting><![CDATA[sess = sf.openSession();
+ <programlisting role="JAVA"><![CDATA[sess = sf.openSession();
Transaction tx = sess.beginTransaction();
sess.setFlushMode(FlushMode.COMMIT); // allow queries to return stale state
@@ -1134,13 +1134,13 @@
document. For example:
</para>
- <programlisting><![CDATA[<one-to-one name="person" cascade="persist"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<one-to-one name="person" cascade="persist"/>]]></programlisting>
<para>
Cascade styles my be combined:
</para>
- <programlisting><![CDATA[<one-to-one name="person" cascade="persist,delete,lock"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<one-to-one name="person" cascade="persist,delete,lock"/>]]></programlisting>
<para>
You can even use <literal>cascade="all"</literal> to specify that <emphasis>all</emphasis>
@@ -1267,7 +1267,7 @@
<literal>SessionFactory</literal>.
</para>
- <programlisting><![CDATA[Cat fritz = ......;
+ <programlisting role="JAVA"><![CDATA[Cat fritz = ......;
ClassMetadata catMeta = sessionfactory.getClassMetadata(Cat.class);
Object[] propertyValues = catMeta.getPropertyValues(fritz);
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/toolset_guide.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/toolset_guide.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/toolset_guide.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -105,8 +105,8 @@
</para>
- <programlisting><![CDATA[<property name="zip" length="5"/>]]></programlisting>
- <programlisting><![CDATA[<property name="balance" precision="12" scale="2"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<property name="zip" length="5"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<property name="balance" precision="12" scale="2"/>]]></programlisting>
<para>
Some tags also accept a <literal>not-null</literal> attribute for generating a
@@ -114,9 +114,9 @@
attribute for generating <literal>UNIQUE</literal> constraint on table columns.
</para>
- <programlisting><![CDATA[<many-to-one name="bar" column="barId" not-null="true"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<many-to-one name="bar" column="barId" not-null="true"/>]]></programlisting>
- <programlisting><![CDATA[<element column="serialNumber" type="long" not-null="true" unique="true"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<element column="serialNumber" type="long" not-null="true" unique="true"/>]]></programlisting>
<para>
A <literal>unique-key</literal> attribute can be used to group columns in
@@ -126,7 +126,7 @@
the mapping file.
</para>
- <programlisting><![CDATA[<many-to-one name="org" column="orgId" unique-key="OrgEmployeeId"/>
+ <programlisting role="XML"><![CDATA[<many-to-one name="org" column="orgId" unique-key="OrgEmployeeId"/>
<property name="employeeId" unique-key="OrgEmployee"/>]]></programlisting>
<para>
@@ -135,7 +135,7 @@
grouped into the same index by simply specifying the same index name.
</para>
- <programlisting><![CDATA[<property name="lastName" index="CustName"/>
+ <programlisting role="XML"><![CDATA[<property name="lastName" index="CustName"/>
<property name="firstName" index="CustName"/>]]></programlisting>
<para>
@@ -143,14 +143,14 @@
of any generated foreign key constraint.
</para>
- <programlisting><![CDATA[<many-to-one name="bar" column="barId" foreign-key="FKFooBar"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<many-to-one name="bar" column="barId" foreign-key="FKFooBar"/>]]></programlisting>
<para>
Many mapping elements also accept a child <literal><column></literal> element.
This is particularly useful for mapping multi-column types:
</para>
- <programlisting><![CDATA[<property name="name" type="my.customtypes.Name"/>
+ <programlisting role="XML"><![CDATA[<property name="name" type="my.customtypes.Name"/>
<column name="last" not-null="true" index="bar_idx" length="30"/>
<column name="first" not-null="true" index="bar_idx" length="20"/>
<column name="initial"/>
@@ -162,11 +162,11 @@
saving a new instance of the mapped class.
</para>
- <programlisting><![CDATA[<property name="credits" type="integer" insert="false">
+ <programlisting role="XML"><![CDATA[<property name="credits" type="integer" insert="false">
<column name="credits" default="10"/>
</property>]]></programlisting>
- <programlisting><![CDATA[<version name="version" type="integer" insert="false">
+ <programlisting role="XML"><![CDATA[<version name="version" type="integer" insert="false">
<column name="version" default="0"/>
</property>]]></programlisting>
@@ -175,7 +175,7 @@
mapping of a Hibernate type to SQL datatype.
</para>
- <programlisting><![CDATA[<property name="balance" type="float">
+ <programlisting role="XML"><![CDATA[<property name="balance" type="float">
<column name="balance" sql-type="decimal(13,3)"/>
</property>]]></programlisting>
@@ -183,11 +183,11 @@
The <literal>check</literal> attribute allows you to specify a check constraint.
</para>
- <programlisting><![CDATA[<property name="foo" type="integer">
+ <programlisting role="XML"><![CDATA[<property name="foo" type="integer">
<column name="foo" check="foo > 10"/>
</property>]]></programlisting>
- <programlisting><![CDATA[<class name="Foo" table="foos" check="bar < 100.0">
+ <programlisting role="XML"><![CDATA[<class name="Foo" table="foos" check="bar < 100.0">
...
<property name="bar" type="float"/>
</class>]]></programlisting>
@@ -287,12 +287,12 @@
for the generated schema.
</para>
- <programlisting><![CDATA[<class name="Customer" table="CurCust">
+ <programlisting role="XML"><![CDATA[<class name="Customer" table="CurCust">
<comment>Current customers only</comment>
...
</class>]]></programlisting>
- <programlisting><![CDATA[<property name="balance">
+ <programlisting role="XML"><![CDATA[<property name="balance">
<column name="bal">
<comment>Balance in USD</comment>
</column>
@@ -381,7 +381,7 @@
You can even embed <literal>SchemaExport</literal> in your application:
</para>
- <programlisting><![CDATA[Configuration cfg = ....;
+ <programlisting role="JAVA"><![CDATA[Configuration cfg = ....;
new SchemaExport(cfg).create(false, true);]]></programlisting>
</sect2>
@@ -454,7 +454,7 @@
You can call <literal>SchemaExport</literal> from your Ant build script:
</para>
- <programlisting><![CDATA[<target name="schemaexport">
+ <programlisting role="XML"><![CDATA[<target name="schemaexport">
<taskdef name="schemaexport"
classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="class.path"/>
@@ -528,7 +528,7 @@
You can embed <literal>SchemaUpdate</literal> in your application:
</para>
- <programlisting><![CDATA[Configuration cfg = ....;
+ <programlisting role="JAVA"><![CDATA[Configuration cfg = ....;
new SchemaUpdate(cfg).execute(false);]]></programlisting>
</sect2>
@@ -540,7 +540,7 @@
You can call <literal>SchemaUpdate</literal> from the Ant script:
</para>
- <programlisting><![CDATA[<target name="schemaupdate">
+ <programlisting role="XML"><![CDATA[<target name="schemaupdate">
<taskdef name="schemaupdate"
classname="org.hibernate.tool.hbm2ddl.SchemaUpdateTask"
classpathref="class.path"/>
@@ -603,7 +603,7 @@
You can embed <literal>SchemaValidator</literal> in your application:
</para>
- <programlisting><![CDATA[Configuration cfg = ....;
+ <programlisting role="JAVA"><![CDATA[Configuration cfg = ....;
new SchemaValidator(cfg).validate();]]></programlisting>
</sect2>
@@ -615,7 +615,7 @@
You can call <literal>SchemaValidator</literal> from the Ant script:
</para>
- <programlisting><![CDATA[<target name="schemavalidate">
+ <programlisting role="XML"><![CDATA[<target name="schemavalidate">
<taskdef name="schemavalidator"
classname="org.hibernate.tool.hbm2ddl.SchemaValidatorTask"
classpathref="class.path"/>
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/transactions.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/transactions.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/transactions.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -457,7 +457,7 @@
like this:
</para>
- <programlisting><![CDATA[// Non-managed environment idiom
+ <programlisting role="JAVA"><![CDATA[// Non-managed environment idiom
Session sess = factory.openSession();
Transaction tx = null;
try {
@@ -490,7 +490,7 @@
management:
</para>
- <programlisting><![CDATA[// Non-managed environment idiom with getCurrentSession()
+ <programlisting role="JAVA"><![CDATA[// Non-managed environment idiom with getCurrentSession()
try {
factory.getCurrentSession().beginTransaction();
@@ -538,7 +538,7 @@
transaction management code is identical to the non-managed environment.
</para>
- <programlisting><![CDATA[// BMT idiom
+ <programlisting role="JAVA"><![CDATA[// BMT idiom
Session sess = factory.openSession();
Transaction tx = null;
try {
@@ -563,7 +563,7 @@
use the JTA <literal>UserTransaction</literal> API directly:
</para>
- <programlisting><![CDATA[// BMT idiom with getCurrentSession()
+ <programlisting role="JAVA"><![CDATA[// BMT idiom with getCurrentSession()
try {
UserTransaction tx = (UserTransaction)new InitialContext()
.lookup("java:comp/UserTransaction");
@@ -586,7 +586,7 @@
The code is reduced to:
</para>
- <programlisting><![CDATA[// CMT idiom
+ <programlisting role="JAVA"><![CDATA[// CMT idiom
Session sess = factory.getCurrentSession();
// do some work
@@ -716,7 +716,7 @@
<literal>Transaction</literal> object.
</para>
- <programlisting><![CDATA[
+ <programlisting role="JAVA"><![CDATA[
Session sess = factory.openSession();
try {
//set transaction timeout to 3 seconds
@@ -770,7 +770,7 @@
database access. It is the approach most similar to entity EJBs.
</para>
- <programlisting><![CDATA[// foo is an instance loaded by a previous Session
+ <programlisting role="JAVA"><![CDATA[// foo is an instance loaded by a previous Session
session = factory.openSession();
Transaction t = session.beginTransaction();
@@ -827,7 +827,7 @@
database transaction.
</para>
- <programlisting><![CDATA[// foo is an instance loaded earlier by the old session
+ <programlisting role="JAVA"><![CDATA[// foo is an instance loaded earlier by the old session
Transaction t = session.beginTransaction(); // Obtain a new JDBC connection, start transaction
foo.setProperty("bar");
@@ -896,7 +896,7 @@
<literal>Session.saveOrUpdate()</literal>, or <literal>Session.merge()</literal>.
</para>
- <programlisting><![CDATA[// foo is an instance loaded by a previous Session
+ <programlisting role="JAVA"><![CDATA[// foo is an instance loaded by a previous Session
foo.setProperty("bar");
session = factory.openSession();
Transaction t = session.beginTransaction();
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/tutorial.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/tutorial.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/tutorial.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -91,7 +91,7 @@
many IDEs to automatically set up a project for us based on the maven descriptor.
</para>
- <programlisting><![CDATA[<project xmlns="http://maven.apache.org/POM/4.0.0"
+ <programlisting role="XML"><![CDATA[<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -166,7 +166,7 @@
database; it is a simple JavaBean class with some properties:
</para>
- <programlisting><![CDATA[package org.hibernate.tutorial.domain;
+ <programlisting role="JAVA"><![CDATA[package org.hibernate.tutorial.domain;
import java.util.Date;
@@ -255,7 +255,7 @@
The basic structure of a mapping file looks like this:
</para>
- <programlisting><![CDATA[<?xml version="1.0"?>
+ <programlisting role="XML"><![CDATA[<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
@@ -290,7 +290,7 @@
a mapping to a table in the SQL database:
</para>
- <programlisting><![CDATA[<hibernate-mapping package="org.hibernate.tutorial.domain">
+ <programlisting role="XML"><![CDATA[<hibernate-mapping package="org.hibernate.tutorial.domain">
<class name="Event" table="EVENTS">
@@ -308,7 +308,7 @@
identifier generation strategy for a surrogate primary key column:
</para>
- <programlisting><![CDATA[<hibernate-mapping package="org.hibernate.tutorial.domain">
+ <programlisting role="XML"><![CDATA[<hibernate-mapping package="org.hibernate.tutorial.domain">
<class name="Event" table="EVENTS">
<id name="id" column="EVENT_ID">
@@ -352,7 +352,7 @@
persistent:
</para>
- <programlisting><![CDATA[
+ <programlisting role="XML"><![CDATA[
<hibernate-mapping package="org.hibernate.tutorial.domain">
<class name="Event" table="EVENTS">
@@ -465,7 +465,7 @@
programmatic setup. Most users prefer the XML configuration file:
</para>
- <programlisting><![CDATA[<?xml version='1.0' encoding='utf-8'?>
+ <programlisting role="XML"><![CDATA[<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
@@ -600,7 +600,7 @@
<interfacename>org.hibernate.SessionFactory</interfacename> more convenient.
</para>
- <programlisting><![CDATA[package org.hibernate.tutorial.util;
+ <programlisting role="JAVA"><![CDATA[package org.hibernate.tutorial.util;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
@@ -676,7 +676,7 @@
with a <literal>main()</literal> method:
</para>
- <programlisting><![CDATA[package org.hibernate.tutorial;
+ <programlisting role="JAVA"><![CDATA[package org.hibernate.tutorial;
import org.hibernate.Session;
@@ -817,7 +817,7 @@
To list stored events an option is added to the main method:
</para>
- <programlisting><![CDATA[ if (args[0].equals("store")) {
+ <programlisting role="JAVA"><![CDATA[ if (args[0].equals("store")) {
mgr.createAndStoreEvent("My Event", new Date());
}
else if (args[0].equals("list")) {
@@ -834,7 +834,7 @@
A new <literal>listEvents() method is also added</literal>:
</para>
- <programlisting><![CDATA[ private List listEvents() {
+ <programlisting role="JAVA"><![CDATA[ private List listEvents() {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
List result = session.createQuery("from Event").list();
@@ -876,7 +876,7 @@
The first cut of the <literal>Person</literal> class looks like this:
</para>
- <programlisting><![CDATA[package org.hibernate.tutorial.domain;
+ <programlisting role="JAVA"><![CDATA[package org.hibernate.tutorial.domain;
public class Person {
@@ -901,7 +901,7 @@
<filename>src/main/resources/org/hibernate/tutorial/domain/Person.hbm.xml</filename>
</para>
- <programlisting><![CDATA[<hibernate-mapping package="org.hibernate.tutorial.domain">
+ <programlisting role="XML"><![CDATA[<hibernate-mapping package="org.hibernate.tutorial.domain">
<class name="Person" table="PERSON">
<id name="id" column="PERSON_ID">
@@ -918,7 +918,7 @@
Finally, add the new mapping to Hibernate's configuration:
</para>
- <programlisting><![CDATA[<mapping resource="events/Event.hbm.xml"/>
+ <programlisting role="XML"><![CDATA[<mapping resource="events/Event.hbm.xml"/>
<mapping resource="events/Person.hbm.xml"/>]]></programlisting>
<para>
@@ -944,7 +944,7 @@
is not relevant to our examples:
</para>
- <programlisting><![CDATA[public class Person {
+ <programlisting role="JAVA"><![CDATA[public class Person {
private Set events = new HashSet();
@@ -970,7 +970,7 @@
association. Hence, we use Hibernate's many-to-many mapping:
</para>
- <programlisting><![CDATA[<class name="Person" table="PERSON">
+ <programlisting role="XML"><![CDATA[<class name="Person" table="PERSON">
<id name="id" column="PERSON_ID">
<generator class="native"/>
</id>
@@ -1028,7 +1028,7 @@
Now we will bring some people and events together in a new method in <literal>EventManager</literal>:
</para>
- <programlisting><![CDATA[ private void addPersonToEvent(Long personId, Long eventId) {
+ <programlisting role="JAVA"><![CDATA[ private void addPersonToEvent(Long personId, Long eventId) {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
@@ -1067,7 +1067,7 @@
modify a collection when it is detached:
</para>
- <programlisting><![CDATA[ private void addPersonToEvent(Long personId, Long eventId) {
+ <programlisting role="JAVA"><![CDATA[ private void addPersonToEvent(Long personId, Long eventId) {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
@@ -1109,7 +1109,7 @@
returns it (you might have to modify some of the previous methods to return that identifier):
</para>
- <programlisting><![CDATA[ else if (args[0].equals("addpersontoevent")) {
+ <programlisting role="JAVA"><![CDATA[ else if (args[0].equals("addpersontoevent")) {
Long eventId = mgr.createAndStoreEvent("My Event", new Date());
Long personId = mgr.createAndStorePerson("Foo", "Bar");
mgr.addPersonToEvent(personId, eventId);
@@ -1151,7 +1151,7 @@
<interfacename>java.util.Set</interfacename> of
<classname>java.lang.String</classname> instances:
</para>
- <programlisting><![CDATA[ private Set emailAddresses = new HashSet();
+ <programlisting role="JAVA"><![CDATA[ private Set emailAddresses = new HashSet();
public Set getEmailAddresses() {
return emailAddresses;
@@ -1165,7 +1165,7 @@
The mapping of this <literal>Set</literal> is as follows:
</para>
- <programlisting><![CDATA[ <set name="emailAddresses" table="PERSON_EMAIL_ADDR">
+ <programlisting role="XML"><![CDATA[ <set name="emailAddresses" table="PERSON_EMAIL_ADDR">
<key column="PERSON_ID"/>
<element type="string" column="EMAIL_ADDR"/>
</set>]]></programlisting>
@@ -1215,7 +1215,7 @@
linking persons and events. It is the same code in Java:
</para>
- <programlisting><![CDATA[ private void addEmailToPerson(Long personId, String emailAddress) {
+ <programlisting role="JAVA"><![CDATA[ private void addEmailToPerson(Long personId, String emailAddress) {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
@@ -1258,7 +1258,7 @@
<literal>Event</literal> class:
</para>
- <programlisting><![CDATA[ private Set participants = new HashSet();
+ <programlisting role="JAVA"><![CDATA[ private Set participants = new HashSet();
public Set getParticipants() {
return participants;
@@ -1272,7 +1272,7 @@
Now map this side of the association in <literal>Event.hbm.xml</literal>.
</para>
- <programlisting><![CDATA[ <set name="participants" table="PERSON_EVENT" inverse="true">
+ <programlisting role="XML"><![CDATA[ <set name="participants" table="PERSON_EVENT" inverse="true">
<key column="EVENT_ID"/>
<many-to-many column="PERSON_ID" class="events.Person"/>
</set>]]></programlisting>
@@ -1311,7 +1311,7 @@
correctly set both sides (for example, in <literal>Person</literal>):
</para>
- <programlisting><![CDATA[ protected Set getEvents() {
+ <programlisting role="JAVA"><![CDATA[ protected Set getEvents() {
return events;
}
@@ -1370,7 +1370,7 @@
will only implement the <literal>doGet()</literal> method:
</para>
- <programlisting><![CDATA[package org.hibernate.tutorial.web;
+ <programlisting role="JAVA"><![CDATA[package org.hibernate.tutorial.web;
// Imports
@@ -1450,7 +1450,7 @@
Now you can implement the processing of the request and the rendering of the page.
</para>
-<programlisting><![CDATA[ // Write HTML header
+<programlisting role="JAVA"><![CDATA[ // Write HTML header
PrintWriter out = response.getWriter();
out.println("<html><head><title>Event Manager</title></head><body>");
@@ -1487,7 +1487,7 @@
trivial and only outputs HTML:
</para>
- <programlisting><![CDATA[ private void printEventForm(PrintWriter out) {
+ <programlisting role="JAVA"><![CDATA[ private void printEventForm(PrintWriter out) {
out.println("<h2>Add new event:</h2>");
out.println("<form>");
out.println("Title: <input name='eventTitle' length='50'/><br/>");
@@ -1502,7 +1502,7 @@
a query:
</para>
- <programlisting><![CDATA[ private void listEvents(PrintWriter out, SimpleDateFormat dateFormatter) {
+ <programlisting role="JAVA"><![CDATA[ private void listEvents(PrintWriter out, SimpleDateFormat dateFormatter) {
List result = HibernateUtil.getSessionFactory()
.getCurrentSession().createCriteria(Event.class).list();
@@ -1531,7 +1531,7 @@
the <literal>Session</literal> of the current thread:
</para>
- <programlisting><![CDATA[ protected void createAndStoreEvent(String title, Date theDate) {
+ <programlisting role="JAVA"><![CDATA[ protected void createAndStoreEvent(String title, Date theDate) {
Event theEvent = new Event();
theEvent.setTitle(title);
theEvent.setDate(theDate);
@@ -1562,7 +1562,7 @@
as <filename>src/main/webapp/WEB-INF/web.xml</filename>
</para>
- <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+ <programlisting role="XML"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/xml.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/xml.xml 2009-11-04 22:28:47 UTC (rev 17915)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/xml.xml 2009-11-04 23:32:27 UTC (rev 17916)
@@ -71,7 +71,7 @@
Here is an example of mapping a POJO and XML simultaneously:
</para>
- <programlisting><![CDATA[<class name="Account"
+ <programlisting role="XML"><![CDATA[<class name="Account"
table="ACCOUNTS"
node="account">
@@ -100,7 +100,7 @@
Here is an example where there is no POJO class:
</para>
- <programlisting><![CDATA[<class entity-name="Account"
+ <programlisting role="XML"><![CDATA[<class entity-name="Account"
table="ACCOUNTS"
node="account">
@@ -177,7 +177,7 @@
too many associations, since XML does not deal well with circularity.
</para>
- <programlisting><![CDATA[<class name="Customer"
+ <programlisting role="XML"><![CDATA[<class name="Customer"
table="CUSTOMER"
node="customer">
@@ -223,7 +223,7 @@
would return datasets such as this:
</para>
- <programlisting><![CDATA[<customer id="123456789">
+ <programlisting role="XML"><![CDATA[<customer id="123456789">
<account short-desc="Savings">987632567</account>
<account short-desc="Credit Card">985612323</account>
<name>
@@ -239,7 +239,7 @@
mapping, the data might look more like this:
</para>
- <programlisting><![CDATA[<customer id="123456789">
+ <programlisting role="XML"><![CDATA[<customer id="123456789">
<account id="987632567" short-desc="Savings">
<customer id="123456789"/>
<balance>100.29</balance>
@@ -267,7 +267,7 @@
obtaining a dom4j session:
</para>
- <programlisting><![CDATA[Document doc = ....;
+ <programlisting role="JAVA"><![CDATA[Document doc = ....;
Session session = factory.openSession();
Session dom4jSession = session.getSession(EntityMode.DOM4J);
@@ -285,7 +285,7 @@
tx.commit();
session.close();]]></programlisting>
- <programlisting><![CDATA[Session session = factory.openSession();
+ <programlisting role="JAVA"><![CDATA[Session session = factory.openSession();
Session dom4jSession = session.getSession(EntityMode.DOM4J);
Transaction tx = session.beginTransaction();
15 years, 1 month
Hibernate SVN: r17915 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-11-04 17:28:47 -0500 (Wed, 04 Nov 2009)
New Revision: 17915
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/performance.xml
Log:
HHH-4006 - Document fetch profiles
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/performance.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/performance.xml 2009-11-04 21:21:36 UTC (rev 17914)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/performance.xml 2009-11-04 22:28:47 UTC (rev 17915)
@@ -589,7 +589,76 @@
<!-- TODO: Write more about this -->
</sect2>
-
+
+ <sect2 id="performance-fetching-profiles">
+ <title>Fetch profiles</title>
+
+ <para>
+ Another way to affect the fetching strategy for loading associated objects is through something
+ called a fetch profile, which is a named configuration associated with the
+ <interfacename>org.hibernate.SessionFactory</interfacename> but enabled, by name, on the
+ <interfacename>org.hibernate.Session</interfacename>. Once enabled on a
+ <interfacename>org.hibernate.Session</interfacename>, the fetch profile wull be in affect for
+ that <interfacename>org.hibernate.Session</interfacename> until it is explicitly disabled.
+ </para>
+ <para>
+ So what does that mean? Well lets explain that by way of an example. Say we have
+ the following mappings:
+ </para>
+ <programlisting><![CDATA[<hibernate-mapping>
+ <class name="Customer">
+ ...
+ <set name="orders" inverse="true">
+ <key column="cust_id"/>
+ <one-to-many class="Order"/>
+ </set>
+ </class>
+ <class name="Order">
+ ...
+ </class>
+</hibernate-mapping>]]></programlisting>
+ <para>
+ Now normally when you get a reference to a particular customer, that customer's set of
+ orders will be lazy meaning we will not yet have loaded those orders from the database.
+ Normally this is a good thing. Now lets say that you have a certain use case where
+ it is more efficient to load the customer and their orders together. One way certainly is
+ to use "dynamic fetching" strategies via an HQL or criteria queries. But another option is
+ to use a fetch profile to achieve that. Just add the following to your mapping:
+ </para>
+ <programlisting><![CDATA[<hibernate-mapping>
+ ...
+ <fetch-profile name="customer-with-orders">
+ <fetch entity="Customer" association="orders" style="join"/>
+ </fetch-profile>
+</hibernate-mapping>]]></programlisting>
+ <para>
+ or even:
+ </para>
+ <programlisting><![CDATA[<hibernate-mapping>
+ <class name="Customer">
+ ...
+ <fetch-profile name="customer-with-orders">
+ <fetch association="orders" style="join"/>
+ </fetch-profile>
+ </class>
+ ...
+</hibernate-mapping>]]></programlisting>
+ <para>
+ Now the following code will actually load both the customer <emphasis>and their orders</emphasis>:
+ </para>
+ <programlisting><![CDATA[
+ Session session = ...;
+ session.enableFetchProfile( "customer-with-orders" ); // name matches from mapping
+ Customer customer = (Customer) session.get( Customer.class, customerId );
+
+]]></programlisting>
+ <para>
+ Currently only join style fetch profiles are supported, but they plan is to support additional
+ styles. See <ulink url="http://opensource.atlassian.com/projects/hibernate/browse/HHH-3414">HHH-3414</ulink>
+ for details.
+ </para>
+ </sect2>
+
<sect2 id="performance-fetching-lazyproperties">
<title>Using lazy property fetching</title>
@@ -653,7 +722,6 @@
</para>
</sect2>
-
</sect1>
<sect1 id="performance-cache" revision="1">
15 years, 1 month
Hibernate SVN: r17914 - core/trunk/testsuite/src/test/java/org/hibernate/test/hql.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-11-04 16:21:36 -0500 (Wed, 04 Nov 2009)
New Revision: 17914
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java
Log:
HHH-4545 - Allow o.h.action.Executable to register for either (or both) before or after transaction completion callbacks
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java 2009-11-04 21:19:21 UTC (rev 17913)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java 2009-11-04 21:21:36 UTC (rev 17914)
@@ -527,14 +527,14 @@
assertEquals( 1, types.length );
assertTrue( types[0] instanceof ComponentType );
- // Test the ability to doAfterTransactionCompletion comparisions between component values
+ // Test the ability to perform comparisions between component values
s.createQuery( "from Human h where h.name = h.name" ).list();
s.createQuery( "from Human h where h.name = :name" ).setParameter( "name", new Name() ).list();
s.createQuery( "from Human where name = :name" ).setParameter( "name", new Name() ).list();
s.createQuery( "from Human h where :name = h.name" ).setParameter( "name", new Name() ).list();
s.createQuery( "from Human h where :name <> h.name" ).setParameter( "name", new Name() ).list();
- // Test the ability to doAfterTransactionCompletion comparisions between a component and an explicit row-value
+ // Test the ability to perform comparisions between a component and an explicit row-value
s.createQuery( "from Human h where h.name = ('John', 'X', 'Doe')" ).list();
s.createQuery( "from Human h where ('John', 'X', 'Doe') = h.name" ).list();
s.createQuery( "from Human h where ('John', 'X', 'Doe') <> h.name" ).list();
15 years, 1 month
Hibernate SVN: r17913 - in core/trunk: core/src/main/java/org/hibernate/context and 16 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-11-04 16:19:21 -0500 (Wed, 04 Nov 2009)
New Revision: 17913
Added:
core/trunk/core/src/main/java/org/hibernate/action/AfterTransactionCompletionProcess.java
core/trunk/core/src/main/java/org/hibernate/action/BeforeTransactionCompletionProcess.java
Modified:
core/trunk/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java
core/trunk/core/src/main/java/org/hibernate/action/CollectionAction.java
core/trunk/core/src/main/java/org/hibernate/action/EntityAction.java
core/trunk/core/src/main/java/org/hibernate/action/EntityDeleteAction.java
core/trunk/core/src/main/java/org/hibernate/action/EntityIdentityInsertAction.java
core/trunk/core/src/main/java/org/hibernate/action/EntityInsertAction.java
core/trunk/core/src/main/java/org/hibernate/action/EntityUpdateAction.java
core/trunk/core/src/main/java/org/hibernate/action/Executable.java
core/trunk/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java
core/trunk/core/src/main/java/org/hibernate/dialect/MySQLDialect.java
core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java
core/trunk/core/src/main/java/org/hibernate/engine/query/NativeSQLQueryPlan.java
core/trunk/core/src/main/java/org/hibernate/engine/transaction/Isolater.java
core/trunk/core/src/main/java/org/hibernate/event/def/DefaultFlushEntityEventListener.java
core/trunk/core/src/main/java/org/hibernate/hql/ast/QueryTranslatorImpl.java
core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/AbstractStatementExecutor.java
core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableDeleteExecutor.java
core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableUpdateExecutor.java
core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/FromClause.java
core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/IntoClause.java
core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java
core/trunk/core/src/main/java/org/hibernate/jdbc/Expectations.java
core/trunk/core/src/main/java/org/hibernate/loader/Loader.java
core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
core/trunk/core/src/main/java/org/hibernate/type/CollectionType.java
core/trunk/testsuite/src/test/java/org/hibernate/test/cid/CompositeIdWithGeneratorTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/jpa/lock/JPALockTest.java
Log:
HHH-4545 - Allow o.h.action.Executable to register for either (or both) before or after transaction completion callbacks
Added: core/trunk/core/src/main/java/org/hibernate/action/AfterTransactionCompletionProcess.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/AfterTransactionCompletionProcess.java (rev 0)
+++ core/trunk/core/src/main/java/org/hibernate/action/AfterTransactionCompletionProcess.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -0,0 +1,41 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.action;
+
+import org.hibernate.engine.SessionImplementor;
+
+/**
+ * Contract representing some process that needs to occur during after transaction completion.
+ *
+ * @author Steve Ebersole
+ */
+public interface AfterTransactionCompletionProcess {
+ /**
+ * Perform whatever processing is encapsulated here after completion of the transaction.
+ *
+ * @param success Did the transaction complete successfully? True means it did.
+ * @param session The session on which the transaction is completing.
+ */
+ public void doAfterTransactionCompletion(boolean success, SessionImplementor session);
+}
Added: core/trunk/core/src/main/java/org/hibernate/action/BeforeTransactionCompletionProcess.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/BeforeTransactionCompletionProcess.java (rev 0)
+++ core/trunk/core/src/main/java/org/hibernate/action/BeforeTransactionCompletionProcess.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -0,0 +1,40 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.action;
+
+import org.hibernate.engine.SessionImplementor;
+
+/**
+ * Contract representing some process that needs to occur during before transaction completion.
+ *
+ * @author Steve Ebersole
+ */
+public interface BeforeTransactionCompletionProcess {
+ /**
+ * Perform whatever processing is encapsulated here before completion of the transaction.
+ *
+ * @param session The session on which the transaction is preparing to complete.
+ */
+ public void doBeforeTransactionCompletion(SessionImplementor session);
+}
Modified: core/trunk/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -70,19 +70,13 @@
* @param session The session to which this request is tied.
* @param affectedQueryables The affected entity persisters.
*/
- public BulkOperationCleanupAction(
- SessionImplementor session,
- Queryable[] affectedQueryables) {
+ public BulkOperationCleanupAction(SessionImplementor session, Queryable[] affectedQueryables) {
SessionFactoryImplementor factory = session.getFactory();
ArrayList tmpSpaces = new ArrayList();
for ( int i = 0; i < affectedQueryables.length; i++ ) {
tmpSpaces.addAll( Arrays.asList( affectedQueryables[i].getQuerySpaces() ) );
if ( affectedQueryables[i].hasCache() ) {
- entityCleanups.add(
- new EntityCleanup(
- affectedQueryables[i].getCacheAccessStrategy()
- )
- );
+ entityCleanups.add( new EntityCleanup( affectedQueryables[i].getCacheAccessStrategy() ) );
}
Set roles = factory.getCollectionRolesByEntityParticipant( affectedQueryables[i].getEntityName() );
if ( roles != null ) {
@@ -91,11 +85,7 @@
String role = ( String ) itr.next();
CollectionPersister collectionPersister = factory.getCollectionPersister( role );
if ( collectionPersister.hasCache() ) {
- collectionCleanups.add(
- new CollectionCleanup(
- collectionPersister.getCacheAccessStrategy()
- )
- );
+ collectionCleanups.add( new CollectionCleanup( collectionPersister.getCacheAccessStrategy() ) );
}
}
}
@@ -129,11 +119,7 @@
if ( affectedEntity( tableSpaces, entitySpaces ) ) {
tmpSpaces.addAll( Arrays.asList( entitySpaces ) );
if ( persister.hasCache() ) {
- entityCleanups.add(
- new EntityCleanup(
- persister.getCacheAccessStrategy()
- )
- );
+ entityCleanups.add( new EntityCleanup( persister.getCacheAccessStrategy() ) );
}
Set roles = session.getFactory().getCollectionRolesByEntityParticipant( persister.getEntityName() );
if ( roles != null ) {
@@ -143,9 +129,7 @@
CollectionPersister collectionPersister = factory.getCollectionPersister( role );
if ( collectionPersister.hasCache() ) {
collectionCleanups.add(
- new CollectionCleanup(
- collectionPersister.getCacheAccessStrategy()
- )
+ new CollectionCleanup( collectionPersister.getCacheAccessStrategy() )
);
}
}
@@ -169,9 +153,7 @@
* @return True if there are affected table spaces and any of the incoming
* check table spaces occur in that set.
*/
- private boolean affectedEntity(
- Set affectedTableSpaces,
- Serializable[] checkTableSpaces) {
+ private boolean affectedEntity(Set affectedTableSpaces, Serializable[] checkTableSpaces) {
if ( affectedTableSpaces == null || affectedTableSpaces.isEmpty() ) {
return true;
}
@@ -188,22 +170,26 @@
return affectedTableSpaces;
}
- public boolean hasAfterTransactionCompletion() {
- return true;
+ public BeforeTransactionCompletionProcess getBeforeTransactionCompletionProcess() {
+ return null;
}
- public void afterTransactionCompletion(boolean success) throws HibernateException {
- Iterator itr = entityCleanups.iterator();
- while ( itr.hasNext() ) {
- final EntityCleanup cleanup = ( EntityCleanup ) itr.next();
- cleanup.release();
- }
+ public AfterTransactionCompletionProcess getAfterTransactionCompletionProcess() {
+ return new AfterTransactionCompletionProcess() {
+ public void doAfterTransactionCompletion(boolean success, SessionImplementor session) {
+ Iterator itr = entityCleanups.iterator();
+ while ( itr.hasNext() ) {
+ final EntityCleanup cleanup = ( EntityCleanup ) itr.next();
+ cleanup.release();
+ }
- itr = collectionCleanups.iterator();
- while ( itr.hasNext() ) {
- final CollectionCleanup cleanup = ( CollectionCleanup ) itr.next();
- cleanup.release();
- }
+ itr = collectionCleanups.iterator();
+ while ( itr.hasNext() ) {
+ final CollectionCleanup cleanup = ( CollectionCleanup ) itr.next();
+ cleanup.release();
+ }
+ }
+ };
}
public void beforeExecutions() throws HibernateException {
Modified: core/trunk/core/src/main/java/org/hibernate/action/CollectionAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/CollectionAction.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/action/CollectionAction.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -39,15 +39,13 @@
/**
* Any action relating to insert/update/delete of a collection
+ *
* @author Gavin King
*/
public abstract class CollectionAction implements Executable, Serializable, Comparable {
-
private transient CollectionPersister persister;
private final Serializable key;
- private Serializable finalKey;
private final SessionImplementor session;
- private SoftLock lock;
private final String collectionRole;
private final PersistentCollection collection;
@@ -62,33 +60,47 @@
this.collectionRole = persister.getRole();
this.collection = collection;
}
-
+
protected PersistentCollection getCollection() {
return collection;
}
- private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+ protected void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
ois.defaultReadObject();
persister = session.getFactory().getCollectionPersister( collectionRole );
}
- public void afterTransactionCompletion(boolean success) throws CacheException {
+ public final void beforeExecutions() throws CacheException {
+ // we need to obtain the lock before any actions are
+ // executed, since this may be an inverse="true"
+ // bidirectional association and it is one of the
+ // earlier entity actions which actually updates
+ // the database (this action is resposible for
+ // second-level cache invalidation only)
if ( persister.hasCache() ) {
- final CacheKey ck = new CacheKey(
- key,
- persister.getKeyType(),
- persister.getRole(),
- session.getEntityMode(),
- session.getFactory()
- );
- persister.getCacheAccessStrategy().unlockItem( ck, lock );
+ final CacheKey ck = new CacheKey(
+ key,
+ persister.getKeyType(),
+ persister.getRole(),
+ session.getEntityMode(),
+ session.getFactory()
+ );
+ final SoftLock lock = persister.getCacheAccessStrategy().lockItem( ck, null );
+ // the old behavior used key as opposed to getKey()
+ afterTransactionProcess = new CacheCleanupProcess( key, persister, lock );
}
}
- public boolean hasAfterTransactionCompletion() {
- return persister.hasCache();
+ public BeforeTransactionCompletionProcess getBeforeTransactionCompletionProcess() {
+ return null;
}
+ private AfterTransactionCompletionProcess afterTransactionProcess;
+
+ public AfterTransactionCompletionProcess getAfterTransactionCompletionProcess() {
+ return afterTransactionProcess;
+ }
+
public Serializable[] getPropertySpaces() {
return persister.getCollectionSpaces();
}
@@ -98,7 +110,7 @@
}
protected final Serializable getKey() {
- finalKey = key;
+ Serializable finalKey = key;
if ( key instanceof DelayedPostInsertIdentifier ) {
// need to look it up from the persistence-context
finalKey = session.getPersistenceContext().getEntry( collection.getOwner() ).getId();
@@ -114,25 +126,6 @@
return session;
}
- public final void beforeExecutions() throws CacheException {
- // we need to obtain the lock before any actions are
- // executed, since this may be an inverse="true"
- // bidirectional association and it is one of the
- // earlier entity actions which actually updates
- // the database (this action is resposible for
- // second-level cache invalidation only)
- if ( persister.hasCache() ) {
- final CacheKey ck = new CacheKey(
- key,
- persister.getKeyType(),
- persister.getRole(),
- session.getEntityMode(),
- session.getFactory()
- );
- lock = persister.getCacheAccessStrategy().lockItem( ck, null );
- }
- }
-
protected final void evict() throws CacheException {
if ( persister.hasCache() ) {
CacheKey ck = new CacheKey(
@@ -164,6 +157,29 @@
.compare( key, action.key, session.getEntityMode() );
}
}
+
+ private static class CacheCleanupProcess implements AfterTransactionCompletionProcess {
+ private final Serializable key;
+ private final CollectionPersister persister;
+ private final SoftLock lock;
+
+ private CacheCleanupProcess(Serializable key, CollectionPersister persister, SoftLock lock) {
+ this.key = key;
+ this.persister = persister;
+ this.lock = lock;
+ }
+
+ public void doAfterTransactionCompletion(boolean success, SessionImplementor session) {
+ final CacheKey ck = new CacheKey(
+ key,
+ persister.getKeyType(),
+ persister.getRole(),
+ session.getEntityMode(),
+ session.getFactory()
+ );
+ persister.getCacheAccessStrategy().unlockItem( ck, lock );
+ }
+ }
}
Modified: core/trunk/core/src/main/java/org/hibernate/action/EntityAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/EntityAction.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/action/EntityAction.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -40,7 +40,8 @@
*
* @author Gavin King
*/
-public abstract class EntityAction implements Executable, Serializable, Comparable {
+public abstract class EntityAction
+ implements Executable, Serializable, Comparable, AfterTransactionCompletionProcess {
private final String entityName;
private final Serializable id;
@@ -65,8 +66,22 @@
this.persister = persister;
}
+ public BeforeTransactionCompletionProcess getBeforeTransactionCompletionProcess() {
+ return null;
+ }
+
+ public AfterTransactionCompletionProcess getAfterTransactionCompletionProcess() {
+ return needsAfterTransactionCompletion()
+ ? this
+ : null;
+ }
+
protected abstract boolean hasPostCommitEventListeners();
+ public boolean needsAfterTransactionCompletion() {
+ return persister.hasCache() || hasPostCommitEventListeners();
+ }
+
/**
* entity name accessor
*
@@ -123,10 +138,6 @@
throw new AssertionFailure( "beforeExecutions() called for non-collection action" );
}
- public boolean hasAfterTransactionCompletion() {
- return persister.hasCache() || hasPostCommitEventListeners();
- }
-
public String toString() {
return StringHelper.unqualify( getClass().getName() ) + MessageHelper.infoString( entityName, id );
}
Modified: core/trunk/core/src/main/java/org/hibernate/action/EntityDeleteAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/EntityDeleteAction.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/action/EntityDeleteAction.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -42,12 +42,12 @@
import org.hibernate.persister.entity.EntityPersister;
public final class EntityDeleteAction extends EntityAction {
-
private final Object version;
- private SoftLock lock;
private final boolean isCascadeDeleteEnabled;
private final Object[] state;
+ private SoftLock lock;
+
public EntityDeleteAction(
final Serializable id,
final Object[] state,
@@ -86,7 +86,7 @@
persister.getRootEntityName(),
session.getEntityMode(),
session.getFactory()
- );
+ );
lock = persister.getCacheAccessStrategy().lockItem( ck, version );
}
else {
@@ -112,19 +112,19 @@
persistenceContext.removeEntity(key);
persistenceContext.removeProxy(key);
- if ( persister.hasCache() ) persister.getCacheAccessStrategy().remove( ck );
+ if ( persister.hasCache() ) {
+ persister.getCacheAccessStrategy().remove( ck );
+ }
postDelete();
if ( getSession().getFactory().getStatistics().isStatisticsEnabled() && !veto ) {
- getSession().getFactory().getStatisticsImplementor()
- .deleteEntity( getPersister().getEntityName() );
+ getSession().getFactory().getStatisticsImplementor().deleteEntity( getPersister().getEntityName() );
}
}
private boolean preDelete() {
- PreDeleteEventListener[] preListeners = getSession().getListeners()
- .getPreDeleteEventListeners();
+ PreDeleteEventListener[] preListeners = getSession().getListeners().getPreDeleteEventListeners();
boolean veto = false;
if (preListeners.length>0) {
PreDeleteEvent preEvent = new PreDeleteEvent( getInstance(), getId(), state, getPersister() ,(EventSource) getSession() );
@@ -169,29 +169,21 @@
}
}
- public void afterTransactionCompletion(boolean success) throws HibernateException {
+ public void doAfterTransactionCompletion(boolean success, SessionImplementor session) throws HibernateException {
if ( getPersister().hasCache() ) {
- final CacheKey ck = new CacheKey(
- getId(),
- getPersister().getIdentifierType(),
+ final CacheKey ck = new CacheKey(
+ getId(),
+ getPersister().getIdentifierType(),
getPersister().getRootEntityName(),
- getSession().getEntityMode(),
+ getSession().getEntityMode(),
getSession().getFactory()
- );
+ );
getPersister().getCacheAccessStrategy().unlockItem( ck, lock );
}
postCommitDelete();
}
protected boolean hasPostCommitEventListeners() {
- return getSession().getListeners().getPostCommitDeleteEventListeners().length>0;
+ return getSession().getListeners().getPostCommitDeleteEventListeners().length > 0;
}
-
}
-
-
-
-
-
-
-
Modified: core/trunk/core/src/main/java/org/hibernate/action/EntityIdentityInsertAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/EntityIdentityInsertAction.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/action/EntityIdentityInsertAction.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -37,7 +37,8 @@
import org.hibernate.event.EventSource;
import org.hibernate.persister.entity.EntityPersister;
-public final class EntityIdentityInsertAction extends EntityAction {
+public final class EntityIdentityInsertAction extends EntityAction {
+
private final Object[] state;
private final boolean isDelayed;
private final EntityKey delayedEntityKey;
@@ -53,11 +54,10 @@
super( session, null, instance, persister );
this.state = state;
this.isDelayed = isDelayed;
- delayedEntityKey = isDelayed ? generateDelayedEntityKey() : null;
+ this.delayedEntityKey = isDelayed ? generateDelayedEntityKey() : null;
}
public void execute() throws HibernateException {
-
final EntityPersister persister = getPersister();
final SessionImplementor session = getSession();
final Object instance = getInstance();
@@ -89,12 +89,29 @@
postInsert();
if ( session.getFactory().getStatistics().isStatisticsEnabled() && !veto ) {
- session.getFactory().getStatisticsImplementor()
- .insertEntity( getPersister().getEntityName() );
+ session.getFactory().getStatisticsImplementor().insertEntity( getPersister().getEntityName() );
}
}
+ public boolean needsAfterTransactionCompletion() {
+ //TODO: simply remove this override if we fix the above todos
+ return hasPostCommitEventListeners();
+ }
+
+ protected boolean hasPostCommitEventListeners() {
+ return getSession().getListeners().getPostCommitInsertEventListeners().length>0;
+ }
+
+ public void doAfterTransactionCompletion(boolean success, SessionImplementor session) {
+ //TODO: reenable if we also fix the above todo
+ /*EntityPersister persister = getEntityPersister();
+ if ( success && persister.hasCache() && !persister.isCacheInvalidationRequired() ) {
+ persister.getCache().afterInsert( getGeneratedId(), cacheEntry );
+ }*/
+ postCommitInsert();
+ }
+
private void postInsert() {
if ( isDelayed ) {
getSession().getPersistenceContext().replaceDelayedEntityIdentityInsertKeys( delayedEntityKey, generatedId );
@@ -145,26 +162,6 @@
return veto;
}
- //Make 100% certain that this is called before any subsequent ScheduledUpdate.afterTransactionCompletion()!!
- public void afterTransactionCompletion(boolean success) throws HibernateException {
- //TODO: reenable if we also fix the above todo
- /*EntityPersister persister = getEntityPersister();
- if ( success && persister.hasCache() && !persister.isCacheInvalidationRequired() ) {
- persister.getCache().afterInsert( getGeneratedId(), cacheEntry );
- }*/
- postCommitInsert();
- }
-
- public boolean hasAfterTransactionCompletion() {
- //TODO: simply remove this override
- // if we fix the above todos
- return hasPostCommitEventListeners();
- }
-
- protected boolean hasPostCommitEventListeners() {
- return getSession().getListeners().getPostCommitInsertEventListeners().length>0;
- }
-
public final Serializable getGeneratedId() {
return generatedId;
}
Modified: core/trunk/core/src/main/java/org/hibernate/action/EntityInsertAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/EntityInsertAction.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/action/EntityInsertAction.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -116,7 +116,6 @@
session.getEntityMode(),
session.getFactory()
);
-// boolean put = persister.getCache().insert(ck, cacheEntry);
boolean put = persister.getCacheAccessStrategy().insert( ck, cacheEntry, version );
if ( put && factory.getStatistics().isStatisticsEnabled() ) {
@@ -181,8 +180,10 @@
return veto;
}
- //Make 100% certain that this is called before any subsequent ScheduledUpdate.afterTransactionCompletion()!!
- public void afterTransactionCompletion(boolean success) throws HibernateException {
+ /**
+ * {@inheritDoc}
+ */
+ public void doAfterTransactionCompletion(boolean success, SessionImplementor session) throws HibernateException {
EntityPersister persister = getPersister();
if ( success && isCachePutEnabled( persister, getSession() ) ) {
final CacheKey ck = new CacheKey(
@@ -191,7 +192,7 @@
persister.getRootEntityName(),
getSession().getEntityMode(),
getSession().getFactory()
- );
+ );
boolean put = persister.getCacheAccessStrategy().afterInsert( ck, cacheEntry, version );
if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
@@ -207,16 +208,9 @@
}
private boolean isCachePutEnabled(EntityPersister persister, SessionImplementor session) {
- return persister.hasCache() &&
- !persister.isCacheInvalidationRequired() &&
- session.getCacheMode().isPutEnabled();
+ return persister.hasCache()
+ && !persister.isCacheInvalidationRequired()
+ && session.getCacheMode().isPutEnabled();
}
}
-
-
-
-
-
-
-
Modified: core/trunk/core/src/main/java/org/hibernate/action/EntityUpdateAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/EntityUpdateAction.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/action/EntityUpdateAction.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -46,14 +46,13 @@
import org.hibernate.type.TypeFactory;
public final class EntityUpdateAction extends EntityAction {
-
private final Object[] state;
private final Object[] previousState;
private final Object previousVersion;
- private Object nextVersion;
private final int[] dirtyFields;
private final boolean hasDirtyCollection;
private final Object rowId;
+ private Object nextVersion;
private Object cacheEntry;
private SoftLock lock;
@@ -149,7 +148,7 @@
nextVersion = Versioning.getVersion( state, persister );
}
}
- // have the entity entry perform post-update processing, passing it the
+ // have the entity entry doAfterTransactionCompletion post-update processing, passing it the
// update state and the new version (if one).
entry.postUpdate( instance, state, nextVersion );
}
@@ -240,7 +239,11 @@
return veto;
}
- public void afterTransactionCompletion(boolean success) throws CacheException {
+ protected boolean hasPostCommitEventListeners() {
+ return getSession().getListeners().getPostCommitUpdateEventListeners().length>0;
+ }
+
+ public void doAfterTransactionCompletion(boolean success, SessionImplementor session) throws CacheException {
EntityPersister persister = getPersister();
if ( persister.hasCache() ) {
@@ -266,10 +269,6 @@
postCommitUpdate();
}
- protected boolean hasPostCommitEventListeners() {
- return getSession().getListeners().getPostCommitUpdateEventListeners().length>0;
- }
-
}
Modified: core/trunk/core/src/main/java/org/hibernate/action/Executable.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/Executable.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/action/Executable.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -34,29 +34,43 @@
* together with required second-level cache management.
*
* @author Gavin King
+ * @author Steve Ebersole
*/
public interface Executable {
/**
- * Called before executing any actions
+ * What spaces (tables) are affected by this action?
+ *
+ * @return The spaces affected by this action.
*/
+ public Serializable[] getPropertySpaces();
+
+ /**
+ * Called before executing any actions. Gives actions a chance to perform any preparation.
+ *
+ * @throws HibernateException Indicates a problem during preparation.
+ */
public void beforeExecutions() throws HibernateException;
+
/**
* Execute this action
+ *
+ * @throws HibernateException Indicates a problem during execution.
*/
public void execute() throws HibernateException;
+
/**
- * Do we need to retain this instance until after the
- * transaction completes?
- * @return false if this class defines a no-op
- * <tt>hasAfterTransactionCompletion()</tt>
+ * Get the after-transaction-completion process, if any, for this action.
+ *
+ * @return The after-transaction-completion process, or null if we have no
+ * after-transaction-completion process
*/
- public boolean hasAfterTransactionCompletion();
+ public AfterTransactionCompletionProcess getAfterTransactionCompletionProcess();
+
/**
- * Called after the transaction completes
+ * Get the before-transaction-completion process, if any, for this action.
+ *
+ * @return The before-transaction-completion process, or null if we have no
+ * before-transaction-completion process
*/
- public void afterTransactionCompletion(boolean success) throws HibernateException;
- /**
- * What spaces (tables) are affected by this action?
- */
- public Serializable[] getPropertySpaces();
+ public BeforeTransactionCompletionProcess getBeforeTransactionCompletionProcess();
}
Modified: core/trunk/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -319,7 +319,7 @@
// method call to pass through since the real session
// will complain by throwing an appropriate exception;
// NOTE that allowing close() above has the same basic effect,
- // but we capture that there simply to perform the unbind...
+ // but we capture that there simply to doAfterTransactionCompletion the unbind...
}
else if ( !realSession.getTransaction().isActive() ) {
// limit the methods available if no transaction is active
Modified: core/trunk/core/src/main/java/org/hibernate/dialect/MySQLDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/MySQLDialect.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/dialect/MySQLDialect.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -287,7 +287,7 @@
public Boolean performTemporaryTableDDLInIsolation() {
// because we [drop *temporary* table...] we do not
- // have to perform these in isolation.
+ // have to doAfterTransactionCompletion these in isolation.
return Boolean.FALSE;
}
Modified: core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -34,6 +34,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
+import java.util.HashSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,6 +50,8 @@
import org.hibernate.action.EntityInsertAction;
import org.hibernate.action.EntityUpdateAction;
import org.hibernate.action.Executable;
+import org.hibernate.action.AfterTransactionCompletionProcess;
+import org.hibernate.action.BeforeTransactionCompletionProcess;
import org.hibernate.cache.CacheException;
import org.hibernate.type.Type;
@@ -82,7 +85,8 @@
private ArrayList collectionUpdates;
private ArrayList collectionRemovals;
- private ArrayList executions;
+ private AfterTransactionCompletionProcessQueue afterTransactionProcesses;
+ private BeforeTransactionCompletionProcessQueue beforeTransactionProcesses;
/**
* Constructs an action queue bound to the given session.
@@ -103,7 +107,8 @@
collectionRemovals = new ArrayList( INIT_QUEUE_LIST_SIZE );
collectionUpdates = new ArrayList( INIT_QUEUE_LIST_SIZE );
- executions = new ArrayList( INIT_QUEUE_LIST_SIZE * 3 );
+ afterTransactionProcesses = new AfterTransactionCompletionProcessQueue( session );
+ beforeTransactionProcesses = new BeforeTransactionCompletionProcessQueue( session );
}
public void clear() {
@@ -145,10 +150,17 @@
}
public void addAction(BulkOperationCleanupAction cleanupAction) {
- // Add these directly to the executions queue
- executions.add( cleanupAction );
+ registerProcess( cleanupAction.getAfterTransactionCompletionProcess() );
}
+ public void registerProcess(AfterTransactionCompletionProcess process) {
+ afterTransactionProcesses.register( process );
+ }
+
+ public void registerProcess(BeforeTransactionCompletionProcess process) {
+ beforeTransactionProcesses.register( process );
+ }
+
/**
* Perform all currently queued entity-insertion actions.
*
@@ -189,32 +201,17 @@
* @param success Was the transaction successful.
*/
public void afterTransactionCompletion(boolean success) {
- int size = executions.size();
- final boolean invalidateQueryCache = session.getFactory().getSettings().isQueryCacheEnabled();
- for ( int i = 0; i < size; i++ ) {
- try {
- Executable exec = ( Executable ) executions.get( i );
- try {
- exec.afterTransactionCompletion( success );
- }
- finally {
- if ( invalidateQueryCache ) {
- session.getFactory().getUpdateTimestampsCache().invalidate( exec.getPropertySpaces() );
- }
- }
- }
- catch ( CacheException ce ) {
- log.error( "could not release a cache lock", ce );
- // continue loop
- }
- catch ( Exception e ) {
- throw new AssertionFailure( "Exception releasing cache locks", e );
- }
- }
- executions.clear();
+ afterTransactionProcesses.afterTransactionCompletion( success );
}
/**
+ * Execute any registered {@link BeforeTransactionCompletionProcess}
+ */
+ public void beforeTransactionCompletion() {
+ beforeTransactionProcesses.beforeTransactionCompletion();
+ }
+
+ /**
* Check whether the given tables/query-spaces are to be executed against
* given the currently queued actions.
*
@@ -267,16 +264,18 @@
}
public void execute(Executable executable) {
- final boolean lockQueryCache = session.getFactory().getSettings().isQueryCacheEnabled();
- if ( executable.hasAfterTransactionCompletion() || lockQueryCache ) {
- executions.add( executable );
+ try {
+ executable.execute();
}
- if ( lockQueryCache ) {
- session.getFactory()
- .getUpdateTimestampsCache()
- .preinvalidate( executable.getPropertySpaces() );
+ finally {
+ beforeTransactionProcesses.register( executable.getBeforeTransactionCompletionProcess() );
+ if ( session.getFactory().getSettings().isQueryCacheEnabled() ) {
+ final String[] spaces = (String[]) executable.getPropertySpaces();
+ afterTransactionProcesses.addSpacesToInvalidate( spaces );
+ session.getFactory().getUpdateTimestampsCache().preinvalidate( executable.getPropertySpaces() );
+ }
+ afterTransactionProcesses.register( executable.getAfterTransactionCompletionProcess() );
}
- executable.execute();
}
private void prepareActions(List queue) throws HibernateException {
@@ -376,7 +375,8 @@
}
public boolean hasAfterTransactionActions() {
- return executions.size() > 0;
+ // todo : method is not used anywhere; why is it here?
+ return afterTransactionProcesses.processes.size() > 0;
}
public boolean hasAnyQueuedActions() {
@@ -394,7 +394,7 @@
*
* @param oos The stream to which the action queue should get written
*
- * @throws IOException
+ * @throws IOException Indicates an error writing to the stream
*/
public void serialize(ObjectOutputStream oos) throws IOException {
log.trace( "serializing action-queue" );
@@ -447,8 +447,12 @@
* action queue
*
* @param ois The stream from which to read the action queue
+ * @param session The session to which the action queue belongs
*
- * @throws IOException
+ * @return The deserialized action queue
+ *
+ * @throws IOException indicates a problem reading from the stream
+ * @throws ClassNotFoundException Generally means we were unable to locate user classes.
*/
public static ActionQueue deserialize(
ObjectInputStream ois,
@@ -500,14 +504,100 @@
return rtn;
}
+ private static class BeforeTransactionCompletionProcessQueue {
+ private SessionImplementor session;
+ private List processes = new ArrayList();
+ private BeforeTransactionCompletionProcessQueue(SessionImplementor session) {
+ this.session = session;
+ }
+
+ public void register(BeforeTransactionCompletionProcess process) {
+ if ( process == null ) {
+ return;
+ }
+ processes.add( process );
+ }
+
+ public void beforeTransactionCompletion() {
+ final int size = processes.size();
+ for ( int i = 0; i < size; i++ ) {
+ try {
+ BeforeTransactionCompletionProcess process = ( BeforeTransactionCompletionProcess ) processes.get( i );
+ process.doBeforeTransactionCompletion( session );
+ }
+ catch ( HibernateException he ) {
+ throw he;
+ }
+ catch ( Exception e ) {
+ throw new AssertionFailure( "Unable to perform beforeTransactionCompletion callback", e );
+ }
+ }
+ processes.clear();
+ }
+ }
+
+ private static class AfterTransactionCompletionProcessQueue {
+ private SessionImplementor session;
+ private Set querySpacesToInvalidate = new HashSet();
+ private List processes = new ArrayList( INIT_QUEUE_LIST_SIZE * 3 );
+
+ private AfterTransactionCompletionProcessQueue(SessionImplementor session) {
+ this.session = session;
+ }
+
+ public void addSpacesToInvalidate(String[] spaces) {
+ if ( spaces == null ) {
+ return;
+ }
+ for ( int i = 0, max = spaces.length; i < max; i++ ) {
+ addSpaceToInvalidate( spaces[i] );
+ }
+ }
+
+ public void addSpaceToInvalidate(String space) {
+ querySpacesToInvalidate.add( space );
+ }
+
+ public void register(AfterTransactionCompletionProcess process) {
+ if ( process == null ) {
+ return;
+ }
+ processes.add( process );
+ }
+
+ public void afterTransactionCompletion(boolean success) {
+ final int size = processes.size();
+ for ( int i = 0; i < size; i++ ) {
+ try {
+ AfterTransactionCompletionProcess process = ( AfterTransactionCompletionProcess ) processes.get( i );
+ process.doAfterTransactionCompletion( success, session );
+ }
+ catch ( CacheException ce ) {
+ log.error( "could not release a cache lock", ce );
+ // continue loop
+ }
+ catch ( Exception e ) {
+ throw new AssertionFailure( "Exception releasing cache locks", e );
+ }
+ }
+ processes.clear();
+
+ if ( session.getFactory().getSettings().isQueryCacheEnabled() ) {
+ session.getFactory().getUpdateTimestampsCache().invalidate(
+ ( String[] ) querySpacesToInvalidate.toArray( new String[ querySpacesToInvalidate.size()] )
+ );
+ }
+ querySpacesToInvalidate.clear();
+ }
+ }
+
/**
* Sorts the insert actions using more hashes.
*
* @author Jay Erb
*/
private class InsertActionSorter {
-
// the mapping of entity names to their latest batch numbers.
private HashMap latestBatches = new HashMap();
private HashMap entityBatchNumber;
@@ -567,10 +657,16 @@
}
/**
- * Finds an acceptable batch for this entity to be a member.
+ * Finds an acceptable batch for this entity to be a member as part of the {@link InsertActionSorter}
+ *
+ * @param action The action being sorted
+ * @param entityName The name of the entity affected by the action
+ *
+ * @return An appropriate batch number; todo document this process better
*/
- private Integer findBatchNumber(EntityInsertAction action,
- String entityName) {
+ private Integer findBatchNumber(
+ EntityInsertAction action,
+ String entityName) {
// loop through all the associated entities and make sure they have been
// processed before the latest
// batch associated with this entity type.
Modified: core/trunk/core/src/main/java/org/hibernate/engine/query/NativeSQLQueryPlan.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/NativeSQLQueryPlan.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/engine/query/NativeSQLQueryPlan.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -179,7 +179,7 @@
( ( EventSource ) session ).getActionQueue().addAction( action );
}
else {
- action.afterTransactionCompletion( true );
+ action.getAfterTransactionCompletionProcess().doAfterTransactionCompletion( true, session );
}
}
Modified: core/trunk/core/src/main/java/org/hibernate/engine/transaction/Isolater.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/transaction/Isolater.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/engine/transaction/Isolater.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -126,7 +126,7 @@
connection = session.getBatcher().openConnection();
- // perform the actual work
+ // doAfterTransactionCompletion the actual work
work.doWork( connection );
// if everything went ok, commit the transaction and close the obtained
Modified: core/trunk/core/src/main/java/org/hibernate/event/def/DefaultFlushEntityEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/def/DefaultFlushEntityEventListener.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/event/def/DefaultFlushEntityEventListener.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -287,7 +287,7 @@
dirtyProperties = ArrayHelper.EMPTY_INT_ARRAY;
}
- // check nullability but do not perform command execute
+ // check nullability but do not doAfterTransactionCompletion command execute
// we'll use scheduled updates for that.
new Nullability(session).checkNullability( values, persister, true );
Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/QueryTranslatorImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/hql/ast/QueryTranslatorImpl.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/hql/ast/QueryTranslatorImpl.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -547,7 +547,7 @@
if ( persister.isMultiTable() ) {
// even here, if only properties mapped to the "base table" are referenced
// in the set and where clauses, this could be handled by the BasicDelegate.
- // TODO : decide if it is better performance-wise to perform that check, or to simply use the MultiTableUpdateDelegate
+ // TODO : decide if it is better performance-wise to doAfterTransactionCompletion that check, or to simply use the MultiTableUpdateDelegate
return new MultiTableUpdateExecutor( walker );
}
else {
Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/AbstractStatementExecutor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/AbstractStatementExecutor.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/AbstractStatementExecutor.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -245,7 +245,7 @@
( ( EventSource ) session ).getActionQueue().addAction( action );
}
else {
- action.afterTransactionCompletion( true );
+ action.getAfterTransactionCompletionProcess().doAfterTransactionCompletion( true, session );
}
}
Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableDeleteExecutor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableDeleteExecutor.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableDeleteExecutor.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -59,7 +59,7 @@
super( walker, log );
if ( !walker.getSessionFactoryHelper().getFactory().getDialect().supportsTemporaryTables() ) {
- throw new HibernateException( "cannot perform multi-table deletes using dialect not supporting temp tables" );
+ throw new HibernateException( "cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables" );
}
DeleteStatement deleteStatement = ( DeleteStatement ) walker.getAST();
Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableUpdateExecutor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableUpdateExecutor.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableUpdateExecutor.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -63,7 +63,7 @@
super( walker, log );
if ( !walker.getSessionFactoryHelper().getFactory().getDialect().supportsTemporaryTables() ) {
- throw new HibernateException( "cannot perform multi-table updates using dialect not supporting temp tables" );
+ throw new HibernateException( "cannot doAfterTransactionCompletion multi-table updates using dialect not supporting temp tables" );
}
UpdateStatement updateStatement = ( UpdateStatement ) walker.getAST();
Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/FromClause.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/FromClause.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/FromClause.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -333,7 +333,7 @@
// the subquery has already been performed (meaning that for
// theta-join dialects, the join conditions have already been moved
// over to the where clause). A "simple" solution here might to
- // perform "join post processing" once for the entire query (including
+ // doAfterTransactionCompletion "join post processing" once for the entire query (including
// any subqueries) at one fell swoop
}
Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/IntoClause.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/IntoClause.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/IntoClause.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -220,7 +220,7 @@
return true;
}
- // otherwise, perform a "deep equivalence" check...
+ // otherwise, doAfterTransactionCompletion a "deep equivalence" check...
if ( !target.getReturnedClass().isAssignableFrom( source.getReturnedClass() ) ) {
return false;
Modified: core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -423,6 +423,7 @@
public void beforeTransactionCompletion(Transaction tx) {
log.trace( "before transaction completion" );
+ actionQueue.beforeTransactionCompletion();
if ( rootSession == null ) {
try {
interceptor.beforeTransactionCompletion(tx);
@@ -1185,7 +1186,7 @@
errorIfClosed();
checkTransactionSynchStatus();
if ( query == null ) {
- throw new IllegalArgumentException("attempt to perform delete-by-query with null query");
+ throw new IllegalArgumentException("attempt to doAfterTransactionCompletion delete-by-query with null query");
}
if ( log.isTraceEnabled() ) {
Modified: core/trunk/core/src/main/java/org/hibernate/jdbc/Expectations.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/jdbc/Expectations.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/jdbc/Expectations.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -161,7 +161,7 @@
public static final Expectation NONE = new Expectation() {
public void verifyOutcome(int rowCount, PreparedStatement statement, int batchPosition) {
- // explicitly perform no checking...
+ // explicitly doAfterTransactionCompletion no checking...
}
public int prepare(PreparedStatement statement) {
Modified: core/trunk/core/src/main/java/org/hibernate/loader/Loader.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/Loader.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/loader/Loader.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -352,7 +352,7 @@
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
sqle,
- "could not perform sequential read of results (forward)",
+ "could not doAfterTransactionCompletion sequential read of results (forward)",
getSQLString()
);
}
@@ -400,7 +400,7 @@
}
// We call getKeyFromResultSet() here so that we can know the
- // key value upon which to perform the breaking logic. However,
+ // key value upon which to doAfterTransactionCompletion the breaking logic. However,
// it is also then called from getRowFromResultSet() which is certainly
// not the most efficient. But the call here is needed, and there
// currently is no other way without refactoring of the doQuery()/getRowFromResultSet()
@@ -419,7 +419,7 @@
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
sqle,
- "could not perform sequential read of results (forward)",
+ "could not doAfterTransactionCompletion sequential read of results (forward)",
getSQLString()
);
}
@@ -538,14 +538,14 @@
// at the first physical row we are interested in loading
resultSet.next();
- // and perform the load
+ // and doAfterTransactionCompletion the load
return sequentialLoad( resultSet, session, queryParameters, returnProxies, keyToRead );
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
sqle,
- "could not perform sequential read of results (forward)",
+ "could not doAfterTransactionCompletion sequential read of results (forward)",
getSQLString()
);
}
Modified: core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -2794,7 +2794,7 @@
// need to treat this as if it where optimistic-lock="all" (dirty does *not* make sense);
// first we need to locate the "loaded" state
//
- // Note, it potentially could be a proxy, so perform the location the safe way...
+ // Note, it potentially could be a proxy, so doAfterTransactionCompletion the location the safe way...
EntityKey key = new EntityKey( id, this, session.getEntityMode() );
Object entity = session.getPersistenceContext().getEntity( key );
if ( entity != null ) {
Modified: core/trunk/core/src/main/java/org/hibernate/type/CollectionType.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/type/CollectionType.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/core/src/main/java/org/hibernate/type/CollectionType.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -120,7 +120,7 @@
}
public int getHashCode(Object x, EntityMode entityMode) {
- throw new UnsupportedOperationException( "cannot perform lookups on collections" );
+ throw new UnsupportedOperationException( "cannot doAfterTransactionCompletion lookups on collections" );
}
/**
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/cid/CompositeIdWithGeneratorTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/cid/CompositeIdWithGeneratorTest.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/cid/CompositeIdWithGeneratorTest.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -494,7 +494,7 @@
s = openSession();
t = s.beginTransaction();
- // perform a find to show that it will wire together fine
+ // doAfterTransactionCompletion a find to show that it will wire together fine
PurchaseRecord foundRecord = (PurchaseRecord) s.get(PurchaseRecord.class,
new PurchaseRecord.Id(foundPurchaseNumber, foundPurchaseSequence)
);
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -527,14 +527,14 @@
assertEquals( 1, types.length );
assertTrue( types[0] instanceof ComponentType );
- // Test the ability to perform comparisions between component values
+ // Test the ability to doAfterTransactionCompletion comparisions between component values
s.createQuery( "from Human h where h.name = h.name" ).list();
s.createQuery( "from Human h where h.name = :name" ).setParameter( "name", new Name() ).list();
s.createQuery( "from Human where name = :name" ).setParameter( "name", new Name() ).list();
s.createQuery( "from Human h where :name = h.name" ).setParameter( "name", new Name() ).list();
s.createQuery( "from Human h where :name <> h.name" ).setParameter( "name", new Name() ).list();
- // Test the ability to perform comparisions between a component and an explicit row-value
+ // Test the ability to doAfterTransactionCompletion comparisions between a component and an explicit row-value
s.createQuery( "from Human h where h.name = ('John', 'X', 'Doe')" ).list();
s.createQuery( "from Human h where ('John', 'X', 'Doe') = h.name" ).list();
s.createQuery( "from Human h where ('John', 'X', 'Doe') <> h.name" ).list();
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/jpa/lock/JPALockTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/jpa/lock/JPALockTest.java 2009-11-04 18:40:13 UTC (rev 17912)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/jpa/lock/JPALockTest.java 2009-11-04 21:19:21 UTC (rev 17913)
@@ -74,7 +74,7 @@
Long itemId = item.getId();
- // perform the isolated update
+ // doAfterTransactionCompletion the isolated update
s1 = getSessions().openSession();
t1 = s1.beginTransaction();
item = (Item) s1.get( Item.class, itemId );
15 years, 1 month
Hibernate SVN: r17912 - in core/trunk/envers/src/main/java/org: hibernate/envers/exception and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: adamw
Date: 2009-11-04 13:40:13 -0500 (Wed, 04 Nov 2009)
New Revision: 17912
Removed:
core/trunk/envers/src/main/java/org/jboss/envers/
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/reader/AnnotationsMetadataReader.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/reader/AuditedPropertiesReader.java
core/trunk/envers/src/main/java/org/hibernate/envers/exception/AuditException.java
core/trunk/envers/src/main/java/org/hibernate/envers/exception/NotAuditedException.java
core/trunk/envers/src/main/java/org/hibernate/envers/exception/RevisionDoesNotExistException.java
core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImpl.java
core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImplementor.java
Log:
Removing the org.jboss compatibility classes
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/reader/AnnotationsMetadataReader.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/reader/AnnotationsMetadataReader.java 2009-11-04 16:24:28 UTC (rev 17911)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/reader/AnnotationsMetadataReader.java 2009-11-04 18:40:13 UTC (rev 17912)
@@ -36,7 +36,6 @@
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
-import org.jboss.envers.*;
/**
* A helper class to read versioning meta-data from annotations on a persistent class.
@@ -69,12 +68,7 @@
if (defaultAudited != null) {
return defaultAudited.modStore();
} else {
- Versioned defaultVersioned = clazz.getAnnotation(Versioned.class);
- if (defaultVersioned != null) {
- return ModificationStore.FULL;
- } else {
- return null;
- }
+ return null;
}
}
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/reader/AuditedPropertiesReader.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/reader/AuditedPropertiesReader.java 2009-11-04 16:24:28 UTC (rev 17911)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/reader/AuditedPropertiesReader.java 2009-11-04 18:40:13 UTC (rev 17912)
@@ -26,7 +26,6 @@
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Value;
import org.hibernate.MappingException;
-import org.jboss.envers.Versioned;
/**
* Reads persistent properties form a
@@ -157,12 +156,9 @@
// Checking if this property is explicitly audited or if all properties are.
Audited aud = property.getAnnotation(Audited.class);
- Versioned ver = property.getAnnotation(Versioned.class);
if (aud != null) {
propertyData.setStore(aud.modStore());
propertyData.setRelationTargetAuditMode(aud.targetAuditMode());
- } else if (ver != null) {
- propertyData.setStore(ModificationStore.FULL);
} else {
if (defaultStore != null) {
propertyData.setStore(defaultStore);
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/exception/AuditException.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/exception/AuditException.java 2009-11-04 16:24:28 UTC (rev 17911)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/exception/AuditException.java 2009-11-04 18:40:13 UTC (rev 17912)
@@ -23,13 +23,15 @@
*/
package org.hibernate.envers.exception;
-import org.jboss.envers.exception.VersionsException;
+import org.hibernate.HibernateException;
/**
* @author Adam Warski (adam at warski dot org)
*/
-public class AuditException extends VersionsException {
- public AuditException(String message) {
+public class AuditException extends HibernateException {
+ private static final long serialVersionUID = 4306480965630972168L;
+
+ public AuditException(String message) {
super(message);
}
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/exception/NotAuditedException.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/exception/NotAuditedException.java 2009-11-04 16:24:28 UTC (rev 17911)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/exception/NotAuditedException.java 2009-11-04 18:40:13 UTC (rev 17912)
@@ -23,13 +23,20 @@
*/
package org.hibernate.envers.exception;
-import org.jboss.envers.exception.NotVersionedException;
-
/**
* @author Adam Warski (adam at warski dot org)
*/
-public class NotAuditedException extends NotVersionedException {
- public NotAuditedException(String entityName, String message) {
- super(entityName, message);
+public class NotAuditedException extends AuditException {
+ private static final long serialVersionUID = 4809674577449455510L;
+
+ private final String entityName;
+
+ public NotAuditedException(String entityName, String message) {
+ super(message);
+ this.entityName = entityName;
}
+
+ public String getEntityName() {
+ return entityName;
+ }
}
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/exception/RevisionDoesNotExistException.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/exception/RevisionDoesNotExistException.java 2009-11-04 16:24:28 UTC (rev 17911)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/exception/RevisionDoesNotExistException.java 2009-11-04 18:40:13 UTC (rev 17912)
@@ -28,12 +28,27 @@
/**
* @author Adam Warski (adam at warski dot org)
*/
-public class RevisionDoesNotExistException extends org.jboss.envers.exception.RevisionDoesNotExistException {
- public RevisionDoesNotExistException(Number revision) {
- super(revision);
+public class RevisionDoesNotExistException extends AuditException {
+ private static final long serialVersionUID = -6417768274074962282L;
+
+ private Number revision;
+ private Date date;
+
+ public RevisionDoesNotExistException(Number revision) {
+ super("Revision " + revision + " does not exist.");
+ this.revision = revision;
}
public RevisionDoesNotExistException(Date date) {
- super(date);
+ super("There is no revision before or at " + date + ".");
+ this.date = date;
}
+
+ public Number getRevision() {
+ return revision;
+ }
+
+ public Date getDate() {
+ return date;
+ }
}
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImpl.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImpl.java 2009-11-04 16:24:28 UTC (rev 17911)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImpl.java 2009-11-04 18:40:13 UTC (rev 17912)
@@ -32,6 +32,7 @@
import org.hibernate.envers.exception.RevisionDoesNotExistException;
import org.hibernate.envers.exception.AuditException;
import org.hibernate.envers.query.AuditEntity;
+import org.hibernate.envers.query.AuditQueryCreator;
import static org.hibernate.envers.tools.ArgumentsTools.checkNotNull;
import static org.hibernate.envers.tools.ArgumentsTools.checkPositive;
import org.hibernate.envers.synchronization.AuditSync;
@@ -41,7 +42,6 @@
import org.hibernate.Session;
import org.hibernate.event.EventSource;
import org.hibernate.engine.SessionImplementor;
-import org.jboss.envers.query.VersionsQueryCreator;
/**
* @author Adam Warski (adam at warski dot org)
@@ -205,7 +205,7 @@
return (T) auditSync.getCurrentRevisionData(session, persist);
}
- public VersionsQueryCreator createQuery() {
- return new VersionsQueryCreator(verCfg, this);
+ public AuditQueryCreator createQuery() {
+ return new AuditQueryCreator(verCfg, this);
}
}
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImplementor.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImplementor.java 2009-11-04 16:24:28 UTC (rev 17911)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImplementor.java 2009-11-04 18:40:13 UTC (rev 17912)
@@ -27,13 +27,12 @@
import org.hibernate.Session;
import org.hibernate.engine.SessionImplementor;
-import org.jboss.envers.VersionsReader;
/**
* An interface exposed by a VersionsReader to library-facing classes.
* @author Adam Warski (adam at warski dot org)
*/
-public interface AuditReaderImplementor extends AuditReader, VersionsReader {
+public interface AuditReaderImplementor extends AuditReader {
SessionImplementor getSessionImplementor();
Session getSession();
FirstLevelCache getFirstLevelCache();
15 years, 1 month
Hibernate SVN: r17911 - in validator/trunk/hibernate-validator/src/test: java/org/hibernate/validator/xml and 6 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-11-04 11:24:28 -0500 (Wed, 04 Nov 2009)
New Revision: 17911
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/ICompetition.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/IFixture.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/InheritanceMappingsTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/Competition.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/Fixture.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/Game.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/GameDetail.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/PersonCompetition.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/TeamCompetition.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/Competition.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/Fixture.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/Game.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/GameDetail.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/PersonCompetition.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/TeamCompetition.java
validator/trunk/hibernate-validator/src/test/resources/org/hibernate/validator/xml/mixedconfiguration/
validator/trunk/hibernate-validator/src/test/resources/org/hibernate/validator/xml/mixedconfiguration/annotation-mappings.xml
validator/trunk/hibernate-validator/src/test/resources/org/hibernate/validator/xml/mixedconfiguration/xml-mappings.xml
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/util/TestUtil.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/XmlMappingTest.java
validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml
Log:
HV-265 Added tests
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/util/TestUtil.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/util/TestUtil.java 2009-11-04 16:01:22 UTC (rev 17910)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/util/TestUtil.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -23,6 +23,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import javax.validation.Configuration;
import javax.validation.ConstraintViolation;
import javax.validation.Path;
import javax.validation.Validation;
@@ -55,14 +56,16 @@
public static Validator getValidator() {
if ( hibernateValidator == null ) {
- HibernateValidatorConfiguration configuration = Validation
- .byProvider( HibernateValidator.class )
- .configure();
+ Configuration configuration = getConfiguration();
hibernateValidator = configuration.buildValidatorFactory().getValidator();
}
return hibernateValidator;
}
+ public static Configuration<?> getConfiguration() {
+ return Validation.byProvider( HibernateValidator.class ).configure();
+ }
+
/**
* @param path The path to the xml file which should server as <code>validation.xml</code> for the returned
* <code>Validator</code>.
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/XmlMappingTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/XmlMappingTest.java 2009-11-04 16:01:22 UTC (rev 17910)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/XmlMappingTest.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -22,7 +22,6 @@
import java.util.Set;
import javax.validation.Configuration;
import javax.validation.ConstraintViolation;
-import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import javax.validation.groups.Default;
@@ -30,6 +29,8 @@
import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;
+import org.hibernate.validator.util.TestUtil;
+
/**
* @author Hardy Ferentschik
*/
@@ -41,7 +42,7 @@
*/
public void testConstraintInheritanceWithXmlConfiguration() {
- final Configuration<?> configuration = Validation.byDefaultProvider().configure();
+ final Configuration<?> configuration = TestUtil.getConfiguration();
configuration.addMapping( XmlMappingTest.class.getResourceAsStream( "mapping.xml" ) );
final ValidatorFactory validatorFactory = configuration.buildValidatorFactory();
@@ -58,7 +59,7 @@
*/
public void testListOfString() {
- final Configuration<?> configuration = Validation.byDefaultProvider().configure();
+ final Configuration<?> configuration = TestUtil.getConfiguration();
configuration.addMapping( XmlMappingTest.class.getResourceAsStream( "properties-mapping.xml" ) );
final ValidatorFactory validatorFactory = configuration.buildValidatorFactory();
@@ -82,14 +83,14 @@
*/
public void testInterfaceConfiguration() {
- final Configuration<?> configuration = Validation.byDefaultProvider().configure();
+ final Configuration<?> configuration = TestUtil.getConfiguration();
configuration.addMapping( XmlMappingTest.class.getResourceAsStream( "my-interface-mapping.xml" ) );
final ValidatorFactory validatorFactory = configuration.buildValidatorFactory();
final Validator validator = validatorFactory.getValidator();
- final Set<ConstraintViolation<MyInterfaceImpl>> violations = validator.validate( new MyInterfaceImpl());
+ final Set<ConstraintViolation<MyInterfaceImpl>> violations = validator.validate( new MyInterfaceImpl() );
- assertEquals( violations.size(), 1);
+ assertEquals( violations.size(), 1 );
}
@Test
@@ -98,29 +99,29 @@
*/
public void testInterfaceImplementationConfiguration() {
- final Configuration<?> configuration = Validation.byDefaultProvider().configure();
+ final Configuration<?> configuration = TestUtil.getConfiguration();
configuration.addMapping( XmlMappingTest.class.getResourceAsStream( "my-interface-impl-mapping.xml" ) );
final ValidatorFactory validatorFactory = configuration.buildValidatorFactory();
final Validator validator = validatorFactory.getValidator();
- final Set<ConstraintViolation<MyInterfaceImpl>> violations = validator.validate( new MyInterfaceImpl());
+ final Set<ConstraintViolation<MyInterfaceImpl>> violations = validator.validate( new MyInterfaceImpl() );
- assertEquals( violations.size(), 1);
+ assertEquals( violations.size(), 1 );
}
-
+
@Test
/**
* HV-263
*/
public void testEmptyInterfaceConfiguration() {
- final Configuration<?> configuration = Validation.byDefaultProvider().configure();
+ final Configuration<?> configuration = TestUtil.getConfiguration();
configuration.addMapping( XmlMappingTest.class.getResourceAsStream( "empty-my-interface-mapping.xml" ) );
final ValidatorFactory validatorFactory = configuration.buildValidatorFactory();
final Validator validator = validatorFactory.getValidator();
- final Set<ConstraintViolation<MyInterfaceImpl>> violations = validator.validate( new MyInterfaceImpl());
+ final Set<ConstraintViolation<MyInterfaceImpl>> violations = validator.validate( new MyInterfaceImpl() );
- assertEquals( violations.size(), 0);
- }
+ assertEquals( violations.size(), 0 );
+ }
}
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/ICompetition.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/ICompetition.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/ICompetition.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,20 @@
+// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.xml.mixedconfiguration;
+
+public interface ICompetition {}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/ICompetition.java
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/IFixture.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/IFixture.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/IFixture.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,22 @@
+// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.xml.mixedconfiguration;
+
+public interface IFixture {
+ ICompetition getCompetition();
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/IFixture.java
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/InheritanceMappingsTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/InheritanceMappingsTest.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/InheritanceMappingsTest.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,130 @@
+// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.xml.mixedconfiguration;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+import javax.validation.Configuration;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+import javax.validation.constraints.NotNull;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.FileAssert.fail;
+import org.testng.annotations.Test;
+
+import org.hibernate.validator.util.TestUtil;
+
+
+/**
+ * See HV-265
+ *
+ * @author Hardy Ferentschik
+ */
+public class InheritanceMappingsTest {
+
+ @Test
+ public void defaultConfigurationNoExplicitAnnotationDefinition1() {
+ validateAnnotatedFixture(
+ new org.hibernate.validator.xml.mixedconfiguration.annotation.PersonCompetition(),
+ configure()
+ );
+ }
+
+ @Test
+ public void defaultConfigurationNoExplicitAnnotationDefinition2() {
+ validateAnnotatedFixture(
+ new org.hibernate.validator.xml.mixedconfiguration.annotation.TeamCompetition(),
+ configure()
+ );
+ }
+
+ @Test
+ public void customConfigurationNoExplicitAnnotationDefinition1() {
+ validateAnnotatedFixture(
+ new org.hibernate.validator.xml.mixedconfiguration.annotation.PersonCompetition(),
+ configure( "annotation-mappings.xml" )
+ );
+ }
+
+ @Test
+ public void customConfigurationNoExplicitAnnotationDefinition2() {
+ validateAnnotatedFixture(
+ new org.hibernate.validator.xml.mixedconfiguration.annotation.TeamCompetition(),
+ configure( "annotation-mappings.xml" )
+ );
+ }
+
+ @Test
+ public void customConfigurationExplicitXmlDefinition() {
+ validateXmlDefinedFixture(
+ new org.hibernate.validator.xml.mixedconfiguration.xml.PersonCompetition(),
+ configure( "xml-mappings.xml" )
+ );
+ }
+
+ @Test
+ public void customConfigurationNoExplicitXmlDefinition() {
+ validateXmlDefinedFixture(
+ new org.hibernate.validator.xml.mixedconfiguration.xml.TeamCompetition(),
+ configure( "xml-mappings.xml" )
+ );
+ }
+
+ private Validator configure() {
+ return TestUtil.getValidator();
+ }
+
+ private Validator configure(String mappingsUrl) {
+ Configuration<?> configuration = TestUtil.getConfiguration();
+ configuration.addMapping( InheritanceMappingsTest.class.getResourceAsStream( mappingsUrl ) );
+
+ ValidatorFactory validatorFactory = configuration.buildValidatorFactory();
+ return validatorFactory.getValidator();
+ }
+
+ private void validateFixture(IFixture fixture, Validator validator) {
+ Set<ConstraintViolation<IFixture>> violations = validator.validate( fixture );
+
+ for ( ConstraintViolation<IFixture> violation : violations ) {
+ if ( violation.getLeafBean() instanceof ICompetition
+ && "detail.competition.name".equals( violation.getPropertyPath().toString() ) ) {
+ assertEquals( violation.getLeafBean(), fixture.getCompetition() );
+ Annotation annotation = ( ( Annotation ) violation.getConstraintDescriptor().getAnnotation() );
+ assertEquals( annotation.annotationType(), NotNull.class );
+ return;
+ }
+ }
+ fail( "@NotNull constraint violation for 'detail.competition.name' not detected" );
+ }
+
+ private void validateAnnotatedFixture(org.hibernate.validator.xml.mixedconfiguration.annotation.Competition competition,
+ Validator validator) {
+ org.hibernate.validator.xml.mixedconfiguration.annotation.Fixture fixture = new org.hibernate.validator.xml.mixedconfiguration.annotation.Fixture();
+ fixture.setCompetition( competition );
+ validateFixture( fixture, validator );
+ }
+
+ private void validateXmlDefinedFixture(org.hibernate.validator.xml.mixedconfiguration.xml.Competition competition,
+ Validator validator) {
+ org.hibernate.validator.xml.mixedconfiguration.xml.Fixture fixture = new org.hibernate.validator.xml.mixedconfiguration.xml.Fixture();
+ fixture.setCompetition( competition );
+ validateFixture( fixture, validator );
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/InheritanceMappingsTest.java
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/Competition.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/Competition.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/Competition.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,46 @@
+// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.xml.mixedconfiguration.annotation;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+import org.hibernate.validator.xml.mixedconfiguration.ICompetition;
+
+public abstract class Competition implements ICompetition {
+
+ @NotNull
+ @Size(min = 1)
+ private String name;
+
+ public Competition() {
+ super();
+ }
+
+ public Competition(String name) {
+ setName( name );
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/Competition.java
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/Fixture.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/Fixture.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/Fixture.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,31 @@
+// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.xml.mixedconfiguration.annotation;
+
+import org.hibernate.validator.xml.mixedconfiguration.IFixture;
+
+public class Fixture extends Game implements IFixture {
+
+ public Fixture() {
+ super();
+ }
+
+ public Fixture(Competition competition) {
+ super( competition );
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/Fixture.java
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/Game.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/Game.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/Game.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,48 @@
+// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.xml.mixedconfiguration.annotation;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+
+public abstract class Game {
+
+ @NotNull
+ @Valid
+ private GameDetail detail;
+
+ private Game(GameDetail detail) {
+ this.detail = detail;
+ }
+
+ public Game() {
+ this( new GameDetail() );
+ }
+
+ public Game(Competition competition) {
+ this( new GameDetail( competition ) );
+ }
+
+ public Competition getCompetition() {
+ return detail.getCompetition();
+ }
+
+ public void setCompetition(Competition competition) {
+ detail.setCompetition( competition );
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/Game.java
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/GameDetail.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/GameDetail.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/GameDetail.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,44 @@
+// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.xml.mixedconfiguration.annotation;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+
+public class GameDetail {
+
+ @NotNull
+ @Valid
+ private Competition competition;
+
+ public GameDetail() {
+ super();
+ }
+
+ public GameDetail(Competition competition) {
+ setCompetition( competition );
+ }
+
+ public Competition getCompetition() {
+ return competition;
+ }
+
+ public void setCompetition(Competition competition) {
+ this.competition = competition;
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/GameDetail.java
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/PersonCompetition.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/PersonCompetition.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/PersonCompetition.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,29 @@
+// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.xml.mixedconfiguration.annotation;
+
+public class PersonCompetition extends Competition {
+
+ public PersonCompetition() {
+ super();
+ }
+
+ public PersonCompetition(String name) {
+ super( name );
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/PersonCompetition.java
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/TeamCompetition.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/TeamCompetition.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/TeamCompetition.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,28 @@
+// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.xml.mixedconfiguration.annotation;
+
+public class TeamCompetition extends Competition {
+ public TeamCompetition() {
+ super();
+ }
+
+ public TeamCompetition(String name) {
+ super( name );
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/annotation/TeamCompetition.java
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/Competition.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/Competition.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/Competition.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,41 @@
+// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.xml.mixedconfiguration.xml;
+
+import org.hibernate.validator.xml.mixedconfiguration.ICompetition;
+
+public abstract class Competition implements ICompetition {
+
+ private String name;
+
+ public Competition() {
+ super();
+ }
+
+ public Competition(String name) {
+ setName( name );
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/Competition.java
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/Fixture.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/Fixture.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/Fixture.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,36 @@
+// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.xml.mixedconfiguration.xml;
+
+import org.hibernate.validator.xml.mixedconfiguration.IFixture;
+
+public class Fixture extends Game implements IFixture {
+
+ public Fixture() {
+ super();
+ }
+
+ public Fixture(Competition competition) {
+ super( competition );
+ }
+
+ @Override
+ public void setCompetition(Competition competition) {
+ super.setCompetition( competition );
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/Fixture.java
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/Game.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/Game.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/Game.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,43 @@
+// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.xml.mixedconfiguration.xml;
+
+public abstract class Game {
+
+ private GameDetail detail;
+
+ private Game(GameDetail detail) {
+ this.detail = detail;
+ }
+
+ public Game() {
+ this( new GameDetail() );
+ }
+
+ public Game(Competition competition) {
+ this( new GameDetail( competition ) );
+ }
+
+ public Competition getCompetition() {
+ return detail.getCompetition();
+ }
+
+ public void setCompetition(Competition competition) {
+ detail.setCompetition( competition );
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/Game.java
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/GameDetail.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/GameDetail.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/GameDetail.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,39 @@
+// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.xml.mixedconfiguration.xml;
+
+public class GameDetail {
+
+ private Competition competition;
+
+ public GameDetail() {
+ super();
+ }
+
+ public GameDetail(Competition competition) {
+ setCompetition( competition );
+ }
+
+ public Competition getCompetition() {
+ return competition;
+ }
+
+ public void setCompetition(Competition competition) {
+ this.competition = competition;
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/GameDetail.java
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/PersonCompetition.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/PersonCompetition.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/PersonCompetition.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,29 @@
+// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.xml.mixedconfiguration.xml;
+
+public class PersonCompetition extends Competition {
+
+ public PersonCompetition() {
+ super();
+ }
+
+ public PersonCompetition(String name) {
+ super( name );
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/PersonCompetition.java
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/TeamCompetition.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/TeamCompetition.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/TeamCompetition.java 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,29 @@
+// $Id: AnnotationFactoryTest.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.xml.mixedconfiguration.xml;
+
+public class TeamCompetition extends Competition {
+
+ public TeamCompetition() {
+ super();
+ }
+
+ public TeamCompetition(String name) {
+ super( name );
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/xml/TeamCompetition.java
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/resources/org/hibernate/validator/xml/mixedconfiguration/annotation-mappings.xml
===================================================================
--- validator/trunk/hibernate-validator/src/test/resources/org/hibernate/validator/xml/mixedconfiguration/annotation-mappings.xml (rev 0)
+++ validator/trunk/hibernate-validator/src/test/resources/org/hibernate/validator/xml/mixedconfiguration/annotation-mappings.xml 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<constraint-mappings
+ xmlns="http://jboss.org/xml/ns/javax/validation/mapping"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://jboss.org/xml/ns/javax/validation/mapping
+ validation-mapping-1.0.xsd">
+
+</constraint-mappings>
Property changes on: validator/trunk/hibernate-validator/src/test/resources/org/hibernate/validator/xml/mixedconfiguration/annotation-mappings.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: validator/trunk/hibernate-validator/src/test/resources/org/hibernate/validator/xml/mixedconfiguration/xml-mappings.xml
===================================================================
--- validator/trunk/hibernate-validator/src/test/resources/org/hibernate/validator/xml/mixedconfiguration/xml-mappings.xml (rev 0)
+++ validator/trunk/hibernate-validator/src/test/resources/org/hibernate/validator/xml/mixedconfiguration/xml-mappings.xml 2009-11-04 16:24:28 UTC (rev 17911)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<constraint-mappings
+ xmlns="http://jboss.org/xml/ns/javax/validation/mapping"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://jboss.org/xml/ns/javax/validation/mapping
+ validation-mapping-1.0.xsd">
+
+ <default-package>org.hibernate.validator.xml.mixedconfiguration.xml</default-package>
+
+ <bean class="Competition" ignore-annotations="true">
+ <field name="name">
+ <constraint annotation="javax.validation.constraints.NotNull"/>
+ <constraint annotation="javax.validation.constraints.Size">
+ <element name="min">1</element>
+ </constraint>
+ </field>
+ </bean>
+ <bean class="PersonCompetition" ignore-annotations="true"/>
+ <!--bean class="TeamCompetition"/-->
+
+ <bean class="Game" ignore-annotations="true">
+ <field name="detail">
+ <valid/>
+ <constraint annotation="javax.validation.constraints.NotNull"/>
+ </field>
+ </bean>
+
+ <bean class="GameDetail" ignore-annotations="true">
+ <field name="competition">
+ <valid/>
+ <constraint annotation="javax.validation.constraints.NotNull"/>
+ </field>
+ </bean>
+ <bean class="Fixture"/>
+
+</constraint-mappings>
Property changes on: validator/trunk/hibernate-validator/src/test/resources/org/hibernate/validator/xml/mixedconfiguration/xml-mappings.xml
___________________________________________________________________
Name: svn:executable
+ *
Modified: validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml
===================================================================
--- validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml 2009-11-04 16:01:22 UTC (rev 17910)
+++ validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml 2009-11-04 16:24:28 UTC (rev 17911)
@@ -16,6 +16,7 @@
<package name="org.hibernate.validator.util"/>
<package name="org.hibernate.validator.util.annotationfactory"/>
<package name="org.hibernate.validator.xml"/>
+ <package name="org.hibernate.validator.xml.mixedconfiguration"/>
</packages>
</test>
</suite>
\ No newline at end of file
15 years, 1 month
Hibernate SVN: r17910 - in jpamodelgen/trunk/src: main/java/org/hibernate/jpamodelgen/annotation and 5 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-11-04 11:01:22 -0500 (Wed, 04 Nov 2009)
New Revision: 17910
Added:
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype/
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype/ArrayTest.java
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype/Image.java
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype/TemperatureSamples.java
Removed:
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Image.java
Modified:
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.java
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstype/AccessTypeTest.java
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/TestUtil.java
jpamodelgen/trunk/src/test/suite/unit-tests.xml
Log:
METAGEN-2
Added support for arrays. Arrays are now added to the metamodel as SingularAttribute.
We don't, however, cover the case yet where there is a @*ToMany annotation on the array
Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.java 2009-11-04 15:59:20 UTC (rev 17909)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.java 2009-11-04 16:01:22 UTC (rev 17910)
@@ -17,26 +17,26 @@
*/
package org.hibernate.jpamodelgen;
+import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
-import java.io.IOException;
import java.io.StringWriter;
import java.util.List;
-import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.FilerException;
-import javax.tools.FileObject;
-import javax.tools.Diagnostic;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.DeclaredType;
+import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.TypeKind;
+import javax.lang.model.type.TypeMirror;
+import javax.tools.Diagnostic;
+import javax.tools.FileObject;
/**
* @author Emmanuel Bernard
*/
public class ClassWriter {
-
+
public static void writeFile(MetaEntity entity, ProcessingEnvironment processingEnv, Context context) {
try {
String metaModelPackage = entity.getPackageName();
@@ -89,21 +89,13 @@
StringWriter sw = new StringWriter();
PrintWriter pw = null;
try {
-
pw = new PrintWriter( sw );
-
+ // we cannot use add @Generated into the metamodel class since this would not work in a JDK 5 environment
//pw.println( "@" + entity.importType( Generated.class.getName() ) + "(\"JPA MetaModel for " + entity.getQualifiedName() + "\")" );
-
pw.println( "@" + entity.importType( "javax.persistence.metamodel.StaticMetamodel" ) + "(" + entity.getSimpleName() + ".class)" );
-
-
-
printClassDeclaration( entity, pw, context );
-
pw.println();
-
List<MetaAttribute> members = entity.getMembers();
-
for ( MetaAttribute metaMember : members ) {
pw.println( " " + metaMember.getDeclarationString() );
}
@@ -124,16 +116,15 @@
final TypeMirror superClass = entity.getTypeElement().getSuperclass();
//superclass of Object is of NoType which returns some other kind
String superclassDeclaration = "";
- if (superClass.getKind() == TypeKind.DECLARED ) {
+ if ( superClass.getKind() == TypeKind.DECLARED ) {
//F..king Ch...t Have those people used their horrible APIs even once?
final Element superClassElement = ( ( DeclaredType ) superClass ).asElement();
String superClassName = ( ( TypeElement ) superClassElement ).getQualifiedName().toString();
if ( context.getMetaEntitiesToProcess().containsKey( superClassName )
|| context.getMetaSuperclassAndEmbeddableToProcess().containsKey( superClassName ) ) {
- pw.print( " extends " + superClassName + "_" );
+ pw.print( " extends " + superClassName + "_" );
}
}
-
pw.println( " {" );
}
}
Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java 2009-11-04 15:59:20 UTC (rev 17909)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java 2009-11-04 16:01:22 UTC (rev 17910)
@@ -25,38 +25,37 @@
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.Modifier;
import javax.lang.model.element.Name;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.Modifier;
+import javax.lang.model.type.ArrayType;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.ExecutableType;
import javax.lang.model.type.PrimitiveType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
import javax.lang.model.util.SimpleTypeVisitor6;
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.ElementCollection;
+import javax.persistence.Embeddable;
+import javax.persistence.Embedded;
import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
import javax.persistence.Id;
-import javax.persistence.AccessType;
-import javax.persistence.Entity;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
-import javax.persistence.Embedded;
-import javax.persistence.Embeddable;
-import javax.persistence.Access;
-import javax.persistence.ElementCollection;
-import javax.tools.Diagnostic.Kind;
import javax.tools.Diagnostic;
-import org.hibernate.jpamodelgen.MetaEntity;
-import org.hibernate.jpamodelgen.MetaAttribute;
+import org.hibernate.jpamodelgen.Context;
import org.hibernate.jpamodelgen.ImportContext;
import org.hibernate.jpamodelgen.ImportContextImpl;
+import org.hibernate.jpamodelgen.MetaAttribute;
+import org.hibernate.jpamodelgen.MetaEntity;
import org.hibernate.jpamodelgen.TypeUtils;
-import org.hibernate.jpamodelgen.Context;
/**
- *
* @author Max Andersen
* @author Hardy Ferentschik
* @author Emmanuel Bernard
@@ -80,7 +79,7 @@
}
public AnnotationMetaEntity(ProcessingEnvironment pe, TypeElement element, Context context, AccessType accessType) {
- this(pe, element, context);
+ this( pe, element, context );
this.defaultAccessTypeForHierarchy = accessType;
}
@@ -88,10 +87,6 @@
return element.getSimpleName().toString();
}
- public Element getOriginalElement() {
- return element;
- }
-
public String getQualifiedName() {
return element.getQualifiedName().toString();
}
@@ -112,9 +107,9 @@
addPersistentMembers( membersFound, elementAccessType, methodsOfClass, AccessType.PROPERTY );
//process superclasses
- for(TypeElement superclass = TypeUtils.getSuperclass(element) ;
- superclass != null ;
- superclass = TypeUtils.getSuperclass( superclass ) ) {
+ for ( TypeElement superclass = TypeUtils.getSuperclass( element );
+ superclass != null;
+ superclass = TypeUtils.getSuperclass( superclass ) ) {
if ( superclass.getAnnotation( Entity.class ) != null ) {
break; //will be handled or has been handled already
}
@@ -123,11 +118,6 @@
context.processElement( superclass, defaultAccessTypeForHierarchy );
}
}
-
- //this is valid to not have properties (ie subentities)
-// if ( membersFound.size() == 0 ) {
-// pe.getMessager().printMessage( Kind.WARNING, "No properties found on " + element, element );
-// }
return membersFound;
}
@@ -136,10 +126,8 @@
AccessType elementAccessType,
List<? extends Element> membersOfClass,
AccessType membersKind) {
- pe.getMessager()
- .printMessage( Kind.NOTE, "Scanning " + membersOfClass.size() + " " + membersKind + " for " + element.toString() );
AccessType explicitAccessType;
- if (elementAccessType == membersKind) {
+ if ( elementAccessType == membersKind ) {
//all membersKind considered
explicitAccessType = null;
}
@@ -149,27 +137,22 @@
}
for ( Element memberOfClass : membersOfClass ) {
- AnnotationMetaAttribute result = memberOfClass.asType().accept( new TypeVisitor( this, explicitAccessType ),
- memberOfClass
- );
+ TypeVisitor visitor = new TypeVisitor( this, explicitAccessType );
+ AnnotationMetaAttribute result = memberOfClass.asType().accept( visitor, memberOfClass );
if ( result != null ) {
membersFound.add( result );
}
-//EBE not sure why?
-// else {
-// pe.getMessager().printMessage( Kind.WARNING, "Could not find valid info for JPA property", mymember );
-// }
}
}
private AccessType getAccessTypeForElement() {
//get local strategy
- AccessType accessType = getAccessTypeForClass(element);
- if (accessType == null) {
+ AccessType accessType = getAccessTypeForClass( element );
+ if ( accessType == null ) {
accessType = this.defaultAccessTypeForHierarchy;
}
- if (accessType == null) {
+ if ( accessType == null ) {
//we dont' know
//if an enity go up
//
@@ -179,13 +162,13 @@
TypeElement superClass = element;
do {
superClass = TypeUtils.getSuperclass( superClass );
- if (superClass != null) {
+ if ( superClass != null ) {
if ( superClass.getAnnotation( Entity.class ) != null
|| superClass.getAnnotation( MappedSuperclass.class ) != null ) {
//FIXME make it work for XML
- AccessType superClassAccessType = getAccessTypeForClass(superClass);
+ AccessType superClassAccessType = getAccessTypeForClass( superClass );
//we've reach the root entity and resolved Ids
- if ( superClassAccessType != null && defaultAccessTypeForHierarchy != null) {
+ if ( superClassAccessType != null && defaultAccessTypeForHierarchy != null ) {
break; //we've found it
}
}
@@ -212,11 +195,12 @@
pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "check class" + searchedElement );
AccessType accessType = context.getAccessType( searchedElement );
- if (defaultAccessTypeForHierarchy == null) {
+ if ( defaultAccessTypeForHierarchy == null ) {
this.defaultAccessTypeForHierarchy = context.getDefaultAccessTypeForHerarchy( searchedElement );
}
if ( accessType != null ) {
- pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "Found in cache" + searchedElement + ":" + accessType );
+ pe.getMessager()
+ .printMessage( Diagnostic.Kind.NOTE, "Found in cache" + searchedElement + ":" + accessType );
return accessType;
}
@@ -226,14 +210,15 @@
*/
final Access accessAnn = searchedElement.getAnnotation( Access.class );
AccessType forcedAccessType = accessAnn != null ? accessAnn.value() : null;
- if ( forcedAccessType != null) {
- pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "access type " + searchedElement + ":" + forcedAccessType );
+ if ( forcedAccessType != null ) {
+ pe.getMessager()
+ .printMessage( Diagnostic.Kind.NOTE, "access type " + searchedElement + ":" + forcedAccessType );
context.addAccessType( searchedElement, forcedAccessType );
}
//continue nevertheless to check if we are root and if defaultAccessTypeForHierarchy
//should be overridden
- if ( forcedAccessType == null || defaultAccessTypeForHierarchy == null) {
+ if ( forcedAccessType == null || defaultAccessTypeForHierarchy == null ) {
List<? extends Element> myMembers = searchedElement.getEnclosedElements();
for ( Element subElement : myMembers ) {
List<? extends AnnotationMirror> entityAnnotations =
@@ -252,8 +237,10 @@
if ( kind == ElementKind.FIELD || kind == ElementKind.METHOD ) {
accessType = kind == ElementKind.FIELD ? AccessType.FIELD : AccessType.PROPERTY;
//FIXME enlever in niveau
- if (defaultAccessTypeForHierarchy == null) {
- this.defaultAccessTypeForHierarchy = context.getDefaultAccessTypeForHerarchy( searchedElement );
+ if ( defaultAccessTypeForHierarchy == null ) {
+ this.defaultAccessTypeForHierarchy = context.getDefaultAccessTypeForHerarchy(
+ searchedElement
+ );
//we've discovered the class hierarchy, let's cache it
if ( defaultAccessTypeForHierarchy == null ) {
this.defaultAccessTypeForHierarchy = accessType;
@@ -262,9 +249,11 @@
//context.addAccessTypeForHierarchy( element, defaultAccessTypeForHierarchy );
}
}
- if ( forcedAccessType == null) {
+ if ( forcedAccessType == null ) {
context.addAccessType( searchedElement, accessType );
- pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "access type " + searchedElement + ":" + accessType );
+ pe.getMessager().printMessage(
+ Diagnostic.Kind.NOTE, "access type " + searchedElement + ":" + accessType
+ );
return accessType;
}
else {
@@ -323,10 +312,20 @@
}
}
+ @Override
+ public AnnotationMetaAttribute visitArray(ArrayType t, Element element) {
+ if ( isPersistent( element ) ) {
+ return new AnnotationMetaSingleAttribute( parent, element, TypeUtils.toTypeString( t ) );
+ }
+ else {
+ return null;
+ }
+ }
+
private boolean isPersistent(Element element) {
//FIXME consider XML
boolean correctAccessType = false;
- if (this.explicitAccessType == null) {
+ if ( this.explicitAccessType == null ) {
correctAccessType = true;
}
else {
@@ -342,7 +341,6 @@
}
-
@Override
public AnnotationMetaAttribute visitDeclared(DeclaredType t, Element element) {
//FIXME consider XML
@@ -354,12 +352,17 @@
//collection of element
if ( element.getAnnotation( ElementCollection.class ) != null ) {
final TypeMirror collectionType = t.getTypeArguments().get( 0 );
- final TypeElement collectionElement = ( TypeElement ) pe.getTypeUtils().asElement( collectionType );
- this.parent.context.processElement( collectionElement,
- this.parent.defaultAccessTypeForElement );
+ final TypeElement collectionElement = ( TypeElement ) pe.getTypeUtils()
+ .asElement( collectionType );
+ this.parent.context.processElement(
+ collectionElement,
+ this.parent.defaultAccessTypeForElement
+ );
}
if ( collection.equals( "javax.persistence.metamodel.MapAttribute" ) ) {
- return new AnnotationMetaMap( parent, element, collection, getKeyType( t ), getElementType( t ) );
+ return new AnnotationMetaMap(
+ parent, element, collection, getKeyType( t ), getElementType( t )
+ );
}
else {
return new AnnotationMetaCollection( parent, element, collection, getElementType( t ) );
@@ -369,10 +372,14 @@
//FIXME Consider XML
if ( element.getAnnotation( Embedded.class ) != null
|| returnedElement.getAnnotation( Embeddable.class ) != null ) {
- this.parent.context.processElement( returnedElement,
- this.parent.defaultAccessTypeForElement );
+ this.parent.context.processElement(
+ returnedElement,
+ this.parent.defaultAccessTypeForElement
+ );
}
- return new AnnotationMetaSingleAttribute( parent, element, returnedElement.getQualifiedName().toString() );
+ return new AnnotationMetaSingleAttribute(
+ parent, element, returnedElement.getQualifiedName().toString()
+ );
}
}
else {
@@ -380,7 +387,6 @@
}
}
-
@Override
public AnnotationMetaAttribute visitExecutable(ExecutableType t, Element p) {
String string = p.getSimpleName().toString();
@@ -421,7 +427,6 @@
return t.getTypeArguments().get( 0 ).toString();
}
-
private String getElementType(DeclaredType declaredType) {
if ( declaredType.getTypeArguments().size() == 1 ) {
return declaredType.getTypeArguments().get( 0 ).toString();
Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java 2009-11-04 15:59:20 UTC (rev 17909)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java 2009-11-04 16:01:22 UTC (rev 17910)
@@ -17,12 +17,11 @@
*/
package org.hibernate.jpamodelgen.annotation;
-import org.hibernate.jpamodelgen.MetaSingleAttribute;
-
import javax.lang.model.element.Element;
+import org.hibernate.jpamodelgen.MetaSingleAttribute;
+
/**
- *
* @author Max Andersen
* @author Hardy Ferentschik
* @author Emmanuel Bernard
@@ -30,12 +29,11 @@
public class AnnotationMetaSingleAttribute extends AnnotationMetaAttribute implements MetaSingleAttribute {
public AnnotationMetaSingleAttribute(AnnotationMetaEntity parent, Element element, String type) {
- super(parent, element, type);
+ super( parent, element, type );
}
@Override
public String getMetaType() {
return "javax.persistence.metamodel.SingularAttribute";
}
-
}
Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstype/AccessTypeTest.java
===================================================================
--- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstype/AccessTypeTest.java 2009-11-04 15:59:20 UTC (rev 17909)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstype/AccessTypeTest.java 2009-11-04 16:01:22 UTC (rev 17910)
@@ -21,6 +21,7 @@
import org.hibernate.jpamodelgen.test.util.CompilationTest;
import static org.hibernate.jpamodelgen.test.util.TestUtil.assertAbsenceOfField;
+import static org.hibernate.jpamodelgen.test.util.TestUtil.assertFieldType;
import static org.hibernate.jpamodelgen.test.util.TestUtil.assertPresenceOfField;
/**
@@ -81,6 +82,7 @@
@Test
public void testMemberAccessType() throws Exception {
assertPresenceOfField( Customer.class.getName() + "_", "goodPayer", "access type overriding" );
+ assertFieldType( Customer.class.getName() + "_", "goodPayer", Boolean.class, "access type overriding" );
}
@Override
Deleted: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Image.java
===================================================================
--- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Image.java 2009-11-04 15:59:20 UTC (rev 17909)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Image.java 2009-11-04 16:01:22 UTC (rev 17910)
@@ -1,46 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.jpamodelgen.test.accesstype;
-
-import javax.persistence.Entity;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-public class Image {
- private String name;
-
- private byte[] data;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public byte[] getData() {
- return data;
- }
-
- public void setData(byte[] data) {
- this.data = data;
- }
-}
\ No newline at end of file
Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype/ArrayTest.java (from rev 17903, jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance/InheritanceTest.java)
===================================================================
--- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype/ArrayTest.java (rev 0)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype/ArrayTest.java 2009-11-04 16:01:22 UTC (rev 17910)
@@ -0,0 +1,51 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.arraytype;
+
+import org.testng.annotations.Test;
+
+import org.hibernate.jpamodelgen.test.util.CompilationTest;
+import static org.hibernate.jpamodelgen.test.util.TestUtil.assertFieldType;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class ArrayTest extends CompilationTest {
+ /**
+ * METAGEN-2
+ */
+ @Test
+ public void testPrimitiveArray() throws Exception {
+ assertFieldType( Image.class.getName() + "_", "data", byte[].class, "Wrong type for field." );
+ }
+
+ /**
+ * METAGEN-2
+ */
+ @Test
+ public void testIntegerArray() throws Exception {
+ assertFieldType(
+ TemperatureSamples.class.getName() + "_", "samples", Integer[].class, "Wrong type for field."
+ );
+ }
+
+ @Override
+ protected String getTestPackage() {
+ return Image.class.getPackage().getName();
+ }
+}
\ No newline at end of file
Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype/Image.java (from rev 17903, jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Image.java)
===================================================================
--- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype/Image.java (rev 0)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype/Image.java 2009-11-04 16:01:22 UTC (rev 17910)
@@ -0,0 +1,46 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.arraytype;
+
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Image {
+ private String name;
+
+ private byte[] data;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public byte[] getData() {
+ return data;
+ }
+
+ public void setData(byte[] data) {
+ this.data = data;
+ }
+}
\ No newline at end of file
Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype/Image.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype/TemperatureSamples.java
===================================================================
--- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype/TemperatureSamples.java (rev 0)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/arraytype/TemperatureSamples.java 2009-11-04 16:01:22 UTC (rev 17910)
@@ -0,0 +1,36 @@
+// $Id: Image.java 17903 2009-11-04 13:22:37Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.arraytype;
+
+import javax.persistence.Entity;
+
+/**
+ * @author Hardy Feretnschik
+ */
+@Entity
+public class TemperatureSamples {
+ private Integer[] samples;
+
+ public Integer[] getSamples() {
+ return samples;
+ }
+
+ public void setSamples(Integer[] samples) {
+ this.samples = samples;
+ }
+}
\ No newline at end of file
Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/TestUtil.java
===================================================================
--- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/TestUtil.java 2009-11-04 15:59:20 UTC (rev 17909)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/TestUtil.java 2009-11-04 16:01:22 UTC (rev 17910)
@@ -17,7 +17,13 @@
*/
package org.hibernate.jpamodelgen.test.util;
+import java.lang.reflect.Field;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
import org.testng.Assert;
+import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.FileAssert.fail;
@@ -52,6 +58,19 @@
Assert.assertTrue( isFieldHere( className, fieldName ), errorString );
}
+ public static void assertFieldType(String className, String fieldName, Class expectedType, String errorString)
+ throws ClassNotFoundException {
+ Field field = getField( className, fieldName );
+ assertNotNull( field );
+ ParameterizedType type = ( ParameterizedType ) field.getGenericType();
+ Type actualType = type.getActualTypeArguments()[1];
+ if ( expectedType.isArray() ) {
+ expectedType = expectedType.getComponentType();
+ actualType = ( ( GenericArrayType ) actualType ).getGenericComponentType();
+ }
+ assertEquals( actualType, expectedType, errorString );
+ }
+
public static void assertSuperClass(String className, String superClassName) {
Class<?> clazz;
Class<?> superClazz;
@@ -69,13 +88,16 @@
}
private static boolean isFieldHere(String className, String fieldName) throws ClassNotFoundException {
+ return getField( className, fieldName ) != null;
+ }
+
+ private static Field getField(String className, String fieldName) throws ClassNotFoundException {
Class<?> clazz = Class.forName( className );
try {
- clazz.getField( fieldName );
- return true;
+ return clazz.getField( fieldName );
}
catch ( NoSuchFieldException e ) {
- return false;
+ return null;
}
}
}
Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/util/TestUtil.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jpamodelgen/trunk/src/test/suite/unit-tests.xml
===================================================================
--- jpamodelgen/trunk/src/test/suite/unit-tests.xml 2009-11-04 15:59:20 UTC (rev 17909)
+++ jpamodelgen/trunk/src/test/suite/unit-tests.xml 2009-11-04 16:01:22 UTC (rev 17910)
@@ -4,6 +4,7 @@
<test name="Unit tests">
<packages>
<package name="org.hibernate.jpamodelgen.test.accesstype"/>
+ <package name="org.hibernate.jpamodelgen.test.arraytype"/>
<package name="org.hibernate.jpamodelgen.test.inheritance"/>
<package name="org.hibernate.jpamodelgen.test.xmlmapped"/>
</packages>
15 years, 1 month