Hibernate SVN: r20150 - core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras.
by hibernate-commits@lists.jboss.org
Author: misty(a)redhat.com
Date: 2010-08-16 02:43:06 -0400 (Mon, 16 Aug 2010)
New Revision: 20150
Added:
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm.xml
Removed:
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm
Log:
File naming error
Deleted: core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm
===================================================================
--- core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm 2010-08-16 06:39:11 UTC (rev 20149)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm 2010-08-16 06:43:06 UTC (rev 20150)
@@ -1,13 +0,0 @@
-<![CDATA[
-<hibernate-mapping package="org.hibernate.tutorial.native">
-
- <class name="Event" table="EVENTS">
- <id name="id" column="EVENT_ID">
- <generator class="enhanced-sequence"/>
- </id>
- <property name="date" type="timestamp" column="EVENT_DATE"/>
- <property name="title"/>
- </class>
-
-</hibernate-mapping>
-]]>
Copied: core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm.xml (from rev 20149, core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm)
===================================================================
--- core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm.xml (rev 0)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm.xml 2010-08-16 06:43:06 UTC (rev 20150)
@@ -0,0 +1,13 @@
+<![CDATA[
+<hibernate-mapping package="org.hibernate.tutorial.native">
+
+ <class name="Event" table="EVENTS">
+ <id name="id" column="EVENT_ID">
+ <generator class="enhanced-sequence"/>
+ </id>
+ <property name="date" type="timestamp" column="EVENT_DATE"/>
+ <property name="title"/>
+ </class>
+
+</hibernate-mapping>
+]]>
13 years, 7 months
Hibernate SVN: r20149 - core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras.
by hibernate-commits@lists.jboss.org
Author: misty(a)redhat.com
Date: 2010-08-16 02:39:11 -0400 (Mon, 16 Aug 2010)
New Revision: 20149
Modified:
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-pom.xml
Log:
Adding CDATA to the XML examples
Modified: core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm
===================================================================
--- core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm 2010-08-15 23:30:30 UTC (rev 20148)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm 2010-08-16 06:39:11 UTC (rev 20149)
@@ -1,3 +1,4 @@
+<![CDATA[
<hibernate-mapping package="org.hibernate.tutorial.native">
<class name="Event" table="EVENTS">
@@ -9,3 +10,4 @@
</class>
</hibernate-mapping>
+]]>
Modified: core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-pom.xml
===================================================================
--- core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-pom.xml 2010-08-15 23:30:30 UTC (rev 20148)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-pom.xml 2010-08-16 06:39:11 UTC (rev 20149)
@@ -1,3 +1,4 @@
+<![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">
@@ -45,4 +46,5 @@
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
+]]>
\ No newline at end of file
13 years, 7 months
Hibernate SVN: r20148 - core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras.
by hibernate-commits@lists.jboss.org
Author: misty(a)redhat.com
Date: 2010-08-15 19:30:30 -0400 (Sun, 15 Aug 2010)
New Revision: 20148
Added:
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-entity.java
Log:
Line edits regarding HHH-5441
Added: core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm
===================================================================
--- core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm (rev 0)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-Event.hbm 2010-08-15 23:30:30 UTC (rev 20148)
@@ -0,0 +1,11 @@
+<hibernate-mapping package="org.hibernate.tutorial.native">
+
+ <class name="Event" table="EVENTS">
+ <id name="id" column="EVENT_ID">
+ <generator class="enhanced-sequence"/>
+ </id>
+ <property name="date" type="timestamp" column="EVENT_DATE"/>
+ <property name="title"/>
+ </class>
+
+</hibernate-mapping>
Added: core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-entity.java
===================================================================
--- core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-entity.java (rev 0)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-entity.java 2010-08-15 23:30:30 UTC (rev 20148)
@@ -0,0 +1,36 @@
+package org.hibernate.tutorial.native;
+
+import java.util.Date;
+
+public class Event {
+ private Long id;
+
+ private String title;
+ private Date date;
+
+ public Event() {}
+
+ public Long getId() {
+ return id;
+ }
+
+ private void setId(Long id) {
+ this.id = id;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
\ No newline at end of file
13 years, 7 months
Hibernate SVN: r20147 - in core/trunk/documentation/quickstart/src/main/docbook/en-US/content: extras and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: misty(a)redhat.com
Date: 2010-08-15 19:30:03 -0400 (Sun, 15 Aug 2010)
New Revision: 20147
Added:
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-pom.xml
Modified:
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml
Log:
Line edits regarding HHH-5441
Added: core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-pom.xml
===================================================================
--- core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-pom.xml (rev 0)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/extras/example-pom.xml 2010-08-15 23:30:03 UTC (rev 20147)
@@ -0,0 +1,48 @@
+<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">
+
+<modelVersion>4.0.0</modelVersion>
+
+<groupId>org.hibernate.tutorials</groupId>
+<artifactId>hibernate-tutorial-native</artifactId>
+<version>1.0.0-SNAPSHOT</version>
+<name>Hibernate Native Tutorial</name>
+
+<build>
+ <!-- we dont want the version to be part of the generated war file name -->
+ <finalName>${artifactId}</finalName>
+</build>
+
+<dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ </dependency>
+
+ <!-- Because this is a web app, we also have a dependency on the servlet api. -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <!-- Hibernate uses slf4j for logging, for our purposes here use the simple backend -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </dependency>
+
+ <!-- Hibernate gives you a choice of bytecode providers between cglib and javassist -->
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </dependency>
+
+ <!-- The tutorial uses the H2 in-memory database -->
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
+</dependencies>
+
+</project>
\ No newline at end of file
Modified: core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml
===================================================================
--- core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml 2010-08-15 15:51:53 UTC (rev 20146)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml 2010-08-15 23:30:03 UTC (rev 20147)
@@ -6,18 +6,18 @@
<note>
<para>
- This tutorial will use the "standard layout" advocated by many build tools and best practices.
- <ulink url="http://maven.apache.org/guides/introduction/introduction-to-the-standard-..."/>
- provides a good description of the "standard layout" if you are unfamiliar.
+ This tutorial uses the <phrase>standard layout</phrase> described in
+ <ulink
+ url="http://maven.apache.org/guides/introduction/introduction-to-the-standard-..."/>.
</para>
</note>
<tip>
<para>
- The tutorials in this guide utilize Maven, taking advantage of its transitive dependency management
- capabilities as well as the ability of many IDEs to automatically set up a project based on the Maven
- descriptor. Just be aware that it is not a requirement to use Maven as your build tool in order to use
- Hibernate.
+ The tutorials in this guide use Maven, which includes superior
+ transitive dependency management capabilities and is easy to use
+ with many integrated development environments (IDEs). You can use
+ another build tool, adapting the examples to fit your needs.
</para>
</tip>
@@ -27,59 +27,13 @@
<step id="hibernate-gsg-tutorial-native-pom">
<title>Create the Maven POM file</title>
<para>
- Create a file named <filename>pom.xml</filename> in the root of your project directory with the
- following contents
+ Create a file named <filename>pom.xml</filename> in the root of
+ your project directory, containing the the text in <xref
+ linkend="hibernate-gsg-tutorial-native-pom-ex1" />.
</para>
<example id="hibernate-gsg-tutorial-native-pom-ex1">
<title><filename>pom.xml</filename></title>
- <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">
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.hibernate.tutorials</groupId>
- <artifactId>hibernate-tutorial-native</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <name>Hibernate Native Tutorial</name>
-
- <build>
- <!-- we dont want the version to be part of the generated war file name -->
- <finalName>${artifactId}</finalName>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
- </dependency>
-
- <!-- Because this is a web app, we also have a dependency on the servlet api. -->
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </dependency>
-
- <!-- Hibernate uses slf4j for logging, for our purposes here use the simple backend -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </dependency>
-
- <!-- Hibernate gives you a choice of bytecode providers between cglib and javassist -->
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- </dependency>
-
- <!-- The tutorial uses the H2 in-memory database -->
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- </dependency>
- </dependencies>
-
-</project>]]></programlisting>
+ <programlisting role="XML"><xi:include href="extras/example-pom.xml" xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" /></programlisting>
</example>
</step>
@@ -87,68 +41,36 @@
<title>Create the entity Java class</title>
<para>
- Create a file named <filename>src/main/java/org/hibernate/tutorial/native/Event.java</filename>
- with the following contents:
+ Create a file named <filename>src/main/java/org/hibernate/tutorial/native/Event.java</filename>, containing the text in <xref linkend="hibernate-gsg-tutorial-native-entity-ex1" />.
</para>
<example id="hibernate-gsg-tutorial-native-entity-ex1">
<title><filename>Entity.java</filename></title>
- <programlisting role="JAVA"><![CDATA[package org.hibernate.tutorial.native;
-
- import java.util.Date;
-
- public class Event {
- private Long id;
-
- private String title;
- private Date date;
-
- public Event() {}
-
- public Long getId() {
- return id;
- }
-
- private void setId(Long id) {
- this.id = id;
- }
-
- public Date getDate() {
- return date;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
- }]]></programlisting>
+ <programlisting role="JAVA"><xi:include href="extras/example-entity.java" xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" /></programlisting>
</example>
<para>
<!-- todo : what's the best way to refer to content in other books? -->
<!-- like here it would be nice to say something like: -->
<!-- "Entity class requirements are covered in detail in <x.y.z Some Developer Guide Chapter/Section>" -->
- A few things to notice about the entity
<itemizedlist>
+ <title>Notes About the Entity</title>
<listitem>
<para>
- This class uses standard JavaBean naming conventions for property getter and setter
- methods, as well as private visibility for the fields. Although this is the
- recommended design, it is not required.
+ This class uses standard JavaBean naming conventions
+ for property getter and setter methods, as well as
+ private visibility for the fields. Although this is
+ the recommended design, it is not required.
</para>
</listitem>
<listitem>
<para>
- The no-argument constructor (also a JavaBean convention) is a requirement for all
- persistent classes. Hibernate has to create objects for you, using Java Reflection. The
- constructor could be private, however package or public visibility is required for runtime
- proxy generation and efficient data retrieval without bytecode instrumentation.
+ The no-argument constructor, which is also a JavaBean
+ convention, is a requirement for all persistent
+ classes. Hibernate needs to create objects for you,
+ using Java Reflection. The constructor can be
+ private. However, package or public visibility is
+ required for runtime proxy generation and efficient
+ data retrieval without bytecode instrumentation.
</para>
</listitem>
</itemizedlist>
@@ -159,107 +81,118 @@
<title>Create the entity mapping file</title>
<para>
- Create a file named <filename>src/main/resources/org/hibernate/tutorial/native/Event.hbm.xml</filename>
- with the following contents:
+ Create a file named <filename>src/main/resources/org/hibernate/tutorial/native/Event.hbm.xml</filename>, with the contents in <xref linkend="example-Event.hbm.xml" />.
</para>
<example>
<title><filename>Event.hbm.xml</filename></title>
- <programlisting role="XML"><![CDATA[
-<hibernate-mapping package="org.hibernate.tutorial.native">
-
- <class name="Event" table="EVENTS">
- <id name="id" column="EVENT_ID">
- <generator class="enhanced-sequence"/>
- </id>
- <property name="date" type="timestamp" column="EVENT_DATE"/>
- <property name="title"/>
- </class>
-
-</hibernate-mapping>]]></programlisting>
+ <programlisting role="XML"><xi:include href="extras/example-Event.hbm.xml" xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" /></programlisting>
</example>
<para>
- Hibernate needs to know how to load and store objects of the persistent class. This is where the
- "mapping metadata" comes into play. The Hibernate mapping file is one choice for providing Hibernate
- with this metadata.
+ Hibernate uses the mapping metadata to find out how to load and
+ store objects of the persistent class. The Hibernate mapping
+ file is one choice for providing Hibernate with this metadata.
</para>
+ <orderedlist>
+ <title>Functions of the <literal>class</literal> element</title>
+ <listitem>
+ <para>
+ The <literal>class</literal> attribute, combined here with the
+ <literal>package</literal> attribute from the containing
+ <literal>hibernate-mapping</literal> element, names the FQN of
+ the class you want to define as an entity.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ The <literal>table</literal> attribute names the database
+ table which contains the data for this entity.
+ </para>
+ </listitem>
+ </orderedlist>
+
<para>
- The <literal>class</literal> element here is doing 2 things.
- <orderedlist>
- <listitem>
- <para>
- The <literal>class</literal> attribute (here combined with the <literal>package</literal>
- attribute from the containing <literal>hibernate-mapping</literal> element) names the FQN
- of the class we want to define as an entity.
- </para>
- </listitem>
- <listitem>
- <para>
- The <literal>table</literal> attribute names the database table which contains the data
- for this entity.
- </para>
- </listitem>
- </orderedlist>
+ Instances of <classname>Event</classname> are now mapped to rows
+ in the <literal>EVENTS</literal> table. Hibernate uses the
+ <literal>id</literal> element to uniquely identify rows in the
+ table.
</para>
- <para>
- Instances of <classname>Event</classname> are now "mapped" to rows in the <literal>EVENTS</literal> table.
- But an assumption there is that Hibernate knows how to uniquely identify rows in the table. This is the
- purpose of the <literal>id</literal> element. It names the column(s) which uniquely identify each row.
- </para>
- <note>
+ <important>
<para>
- It is not strictly necessary that the <literal>id</literal> element map to the table's
- actual primary key column(s); however that is the normal convention. Nor is it strictly
- necessary that tables mapped in Hibernate even define primary keys, the Hibernate team
- <emphasis>highly</emphasis> recommends all schemas define proper referential integrity.
- Therefore <literal>id</literal> and primary key are used interchangeably throughout Hibernate
- documentation.
+ It is not strictly necessary that the <literal>id</literal>
+ element map to the table's actual primary key column(s), but
+ it is the normal convention. Tables mapped in Hibernate do
+ not even need to define primary keys. However, the Hibernate
+ team <emphasis>strongly</emphasis> recommends that all
+ schemas define proper referential integrity. Therefore
+ <literal>id</literal> and <phrase>primary key</phrase> are
+ used interchangeably throughout Hibernate documentation.
</para>
- </note>
+ </important>
<para>
- The <literal>id</literal> element here identifies the <literal>EVENT_ID</literal> column as the primary
- key of the <literal>EVENTS</literal> table. Further, it names the <literal>id</literal> property of
- the <classname>Event</classname> class is the property to hold the identifier value.
+ The <literal>id</literal> element here identifies the
+ <literal>EVENT_ID</literal> column as the primary key of the
+ <literal>EVENTS</literal> table. It also identifies the
+ <literal>id</literal> property of the
+ <classname>Event</classname> class as the property to hold the
+ identifier value.
</para>
<para>
- In regards to the <literal>generator</literal> element nested inside the <literal>id</literal> element,
- for now just be aware that it tells Hibernate the strategy used to generated primary key values for
- this entity. Here we are telling it to use a sequence-like value generation.
+ The important thing to be aware of about the
+ <literal>generator</literal> element nested inside the
+ <literal>id</literal> element is that it informs Hibernate which
+ strategy is used to generated primary key values for this
+ entity. In this instance, it uses a sequence-like value
+ generation.
</para>
<para>
- The 2 <literal>property</literal> elements are declaring the remaining 2 properties of the
- <classname>Event</classname> class: <literal>date</literal> and <literal>title</literal>. Notice
- that the <literal>date</literal> property mapping include the <literal>column</literal>
- attribute, but the <literal>title</literal> does not. Without the <literal>column</literal>
- attribute, Hibernate by default uses the property name as the column name. This works for
- <literal>title</literal>, however, <literal>date</literal> is a reserved keyword in most databases
- so you will need to explicitly tell Hibernate the column name in this case.
+ The two <literal>property</literal> elements declare the
+ remaining two properties of the <classname>Event</classname>
+ class: <literal>date</literal> and <literal>title</literal>.
+ The <literal>date</literal> property mapping include the
+ <literal>column</literal> attribute, but the
+ <literal>title</literal> does not. In the absense of a
+ <literal>column</literal> attribute, Hibernate uses the property
+ name as the column name. This is appropriate for
+ <literal>title</literal>, but since <literal>date</literal> is a
+ reserved keyword in most databases, you need to specify a
+ non-reserved word for the column name.
</para>
<para>
- The <literal>title</literal> mapping also lacks a <literal>type</literal> attribute. The
- types declared and used in the mapping files are not Java data types; they are not SQL
- database types either. These types are called <emphasis>Hibernate mapping types</emphasis>,
- converters which can translate from Java to SQL data types and vice versa. Hibernate will try to
- determine the correct conversion and mapping type itself if the <literal>type</literal> attribute is not
- present in the mapping by using Java reflection to determine the Java type of the declared property
- and using a default mapping type for that Java type. In some cases this automatic detection might not
- have the default you expect or need. This is the case with the <literal>date</literal> property.
- Hibernate cannot know if the property, which is of type <classname>java.util.Date</classname>, should
- map to a SQL <literal>DATE</literal>, <literal>TIME</literal>, or <literal>TIMESTAMP</literal> datatype.
- Full date and time information is preserved by mapping the property with a <literal>timestamp</literal>
- converter.
+ The <literal>title</literal> mapping also lacks a
+ <literal>type</literal> attribute. The types declared and used
+ in the mapping files are neither Java data types nor SQL
+ database types. Instead, they are <firstterm><phrase>Hibernate
+ mapping types</phrase></firstterm>. Hibernate mapping types are
+ converters which translate between Java and SQL data types.
+ Hibernate attempts to determine the correct conversion and
+ mapping type autonomously if the <literal>type</literal>
+ attribute is not present in the mapping, by using Java
+ reflection to determine the Java type of the declared property
+ and using a default mapping type for that Java type.
+ </para>
+ <para>
+ In some cases this automatic detection might not have the
+ default you expect or need, as seen with the
+ <literal>date</literal> property. Hibernate cannot know if the
+ property, which is of type
+ <classname>java.util.Date</classname>, should map to a SQL
+ <literal>DATE</literal>, <literal>TIME</literal>, or
+ <literal>TIMESTAMP</literal> datatype. Full date and time
+ information is preserved by mapping the property to a
+ <literal>timestamp</literal> converter.
</para>
<tip>
<para>
- Hibernate makes this mapping type determination using reflection when the mapping files
- are processed. This can take time and resources, so if startup performance is important
- you should consider explicitly defining the type to use.
+ Hibernate makes this mapping type determination using
+ reflection when the mapping files are processed. This can
+ take time and resources. If startup performance is
+ important, consider explicitly defining the type to use.
</para>
</tip>
-
</step>
<step id="hibernate-gsg-tutorial-native-config">
13 years, 7 months
Hibernate SVN: r20146 - in core/trunk/documentation: quickstart and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-15 11:51:53 -0400 (Sun, 15 Aug 2010)
New Revision: 20146
Modified:
core/trunk/documentation/devguide/pom.xml
core/trunk/documentation/quickstart/pom.xml
Log:
HHH-5466 - Create "Developer Guide"
Modified: core/trunk/documentation/devguide/pom.xml
===================================================================
--- core/trunk/documentation/devguide/pom.xml 2010-08-15 15:45:21 UTC (rev 20145)
+++ core/trunk/documentation/devguide/pom.xml 2010-08-15 15:51:53 UTC (rev 20146)
@@ -38,6 +38,9 @@
<artifactId>devguide</artifactId>
<packaging>jdocbook</packaging>
+ <name>Hibernate Developer Guide</name>
+ <description>A guide for developers using Hibernate</description>
+
<properties>
<!-- Skip artifact deployment -->
<maven.deploy.skip>true</maven.deploy.skip>
@@ -64,16 +67,18 @@
</executions>
<configuration>
- <sourceDocumentName>Hibernate_Getting_Started_Guide.xml</sourceDocumentName>
+ <sourceDocumentName>Hibernate_Developer_Guide.xml</sourceDocumentName>
<masterTranslation>en-US</masterTranslation>
<translations>
+<!--
<translation>de-DE</translation>
<translation>es-ES</translation>
<translation>fr-FR</translation>
<translation>ja-JP</translation>
- <!-- <translation>ko-KR</translation> -->
+ <translation>ko-KR</translation>
<translation>pt-BR</translation>
<translation>zh-CN</translation>
+-->
</translations>
<imageResource>
<directory>${basedir}/src/main/docbook/en-US</directory>
Modified: core/trunk/documentation/quickstart/pom.xml
===================================================================
--- core/trunk/documentation/quickstart/pom.xml 2010-08-15 15:45:21 UTC (rev 20145)
+++ core/trunk/documentation/quickstart/pom.xml 2010-08-15 15:51:53 UTC (rev 20146)
@@ -38,8 +38,8 @@
<artifactId>hibernate-quickstart</artifactId>
<packaging>jdocbook</packaging>
- <name>Hibernate QuickStart Guide</name>
- <description>A QuickStart guide for getting up and started quickly using Hibernate</description>
+ <name>Hibernate Getting Started Guide</name>
+ <description>A guide for getting started using Hibernate</description>
<properties>
<!-- Skip artifact deployment -->
13 years, 7 months
Hibernate SVN: r20145 - core/trunk/parent.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-15 11:45:21 -0400 (Sun, 15 Aug 2010)
New Revision: 20145
Modified:
core/trunk/parent/pom.xml
Log:
HHH-5479 - Upgrade jDocBook plugin to 2.3.0
Modified: core/trunk/parent/pom.xml
===================================================================
--- core/trunk/parent/pom.xml 2010-08-15 15:36:50 UTC (rev 20144)
+++ core/trunk/parent/pom.xml 2010-08-15 15:45:21 UTC (rev 20145)
@@ -217,7 +217,7 @@
<plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jdocbook-plugin</artifactId>
- <version>2.2.3</version>
+ <version>2.3.0</version>
<extensions>true</extensions>
<dependencies>
<dependency>
@@ -226,6 +226,18 @@
<version>2.0.1</version>
<type>jdocbook-style</type>
</dependency>
+ <!-- Workaround http://jira.codehaus.org/browse/MNG-4761 -->
+ <dependency>
+ <groupId>saxon</groupId>
+ <artifactId>saxon</artifactId>
+ <version>6.5.3</version>
+ </dependency>
+ <dependency>
+ <groupId>xml-resolver</groupId>
+ <artifactId>xml-resolver</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <!-- (end of) Workaround http://jira.codehaus.org/browse/MNG-4761 -->
</dependencies>
<configuration>
<formats>
13 years, 7 months
Hibernate SVN: r20144 - core/trunk/documentation/quickstart.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-15 11:36:50 -0400 (Sun, 15 Aug 2010)
New Revision: 20144
Modified:
core/trunk/documentation/quickstart/pom.xml
Log:
HHH-5441 - Create "Getting Started Guide"
Modified: core/trunk/documentation/quickstart/pom.xml
===================================================================
--- core/trunk/documentation/quickstart/pom.xml 2010-08-13 22:29:41 UTC (rev 20143)
+++ core/trunk/documentation/quickstart/pom.xml 2010-08-15 15:36:50 UTC (rev 20144)
@@ -69,14 +69,39 @@
<configuration>
<sourceDocumentName>Hibernate_Getting_Started_Guide.xml</sourceDocumentName>
<masterTranslation>en-US</masterTranslation>
+ <!--
+ for now at least, do not render pdf as the xsl has errors apparently:
+
+Error at xsl:text on line 111 of jar:file:/home/steve/.m2/repository/net/sf/docbook/docbook/1.74.0/docbook-1.74.0.jar!/fo/docbook.xsl:
+ org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}block" is not a valid child of "fo:root"! (See position -1:-1)
+
+ Need to investigate this
+ -->
+
+ <formats>
+ <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml-single.xsl
+ </stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml.xsl
+ </stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ </formats>
<translations>
+<!--
<translation>de-DE</translation>
<translation>es-ES</translation>
<translation>fr-FR</translation>
<translation>ja-JP</translation>
- <!-- <translation>ko-KR</translation> -->
+ <translation>ko-KR</translation>
<translation>pt-BR</translation>
<translation>zh-CN</translation>
+-->
</translations>
<imageResource>
<directory>${basedir}/src/main/docbook/en-US</directory>
13 years, 7 months
Hibernate SVN: r20143 - in core/trunk: core/src/main/java/org/hibernate/action and 4 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-13 18:29:41 -0400 (Fri, 13 Aug 2010)
New Revision: 20143
Modified:
core/trunk/core/src/main/java/org/hibernate/SessionFactory.java
core/trunk/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java
core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java
core/trunk/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java
core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java
core/trunk/core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java
core/trunk/testsuite/src/test/java/org/hibernate/test/querycache/QueryCacheTest.java
Log:
HHH-5426 - HQL update/delete does not invalidate the query cache
Modified: core/trunk/core/src/main/java/org/hibernate/SessionFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/SessionFactory.java 2010-08-13 22:26:52 UTC (rev 20142)
+++ core/trunk/core/src/main/java/org/hibernate/SessionFactory.java 2010-08-13 22:29:41 UTC (rev 20143)
@@ -193,7 +193,7 @@
*
* @since 3.0 changed key from {@link Class} to {@link String}.
*/
- public Map getAllClassMetadata();
+ public Map<String,ClassMetadata> getAllClassMetadata();
/**
* Get the {@link CollectionMetadata} for all mapped collections
Modified: core/trunk/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java 2010-08-13 22:26:52 UTC (rev 20142)
+++ core/trunk/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java 2010-08-13 22:29:41 UTC (rev 20143)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * 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
@@ -20,28 +20,26 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.action;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
import org.hibernate.HibernateException;
-import org.hibernate.cache.access.SoftLock;
-import org.hibernate.cache.access.EntityRegionAccessStrategy;
import org.hibernate.cache.access.CollectionRegionAccessStrategy;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.persister.entity.Queryable;
-import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.cache.access.EntityRegionAccessStrategy;
+import org.hibernate.cache.access.SoftLock;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.persister.entity.Queryable;
-import java.io.Serializable;
-import java.util.Map;
-import java.util.Set;
-import java.util.Iterator;
-import java.util.HashSet;
-import java.util.ArrayList;
-import java.util.Arrays;
-
/**
* An {@link org.hibernate.engine.ActionQueue} {@link Executable} for ensuring
* shared cache cleanup in relation to performed bulk HQL queries.
@@ -57,8 +55,8 @@
public class BulkOperationCleanupAction implements Executable, Serializable {
private final Serializable[] affectedTableSpaces;
- private final Set entityCleanups = new HashSet();
- private final Set collectionCleanups = new HashSet();
+ private final Set<EntityCleanup> entityCleanups = new HashSet<EntityCleanup>();
+ private final Set<CollectionCleanup> collectionCleanups = new HashSet<CollectionCleanup>();
/**
* Constructs an action to cleanup "affected cache regions" based on the
@@ -72,17 +70,17 @@
*/
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() ) );
+ LinkedHashSet<String> spacesList = new LinkedHashSet<String>();
+ for ( Queryable persister : affectedQueryables ) {
+ spacesList.addAll( Arrays.asList( (String[]) persister.getQuerySpaces() ) );
+
+ if ( persister.hasCache() ) {
+ entityCleanups.add( new EntityCleanup( persister.getCacheAccessStrategy() ) );
}
- Set roles = factory.getCollectionRolesByEntityParticipant( affectedQueryables[i].getEntityName() );
+
+ Set<String> roles = factory.getCollectionRolesByEntityParticipant( persister.getEntityName() );
if ( roles != null ) {
- Iterator itr = roles.iterator();
- while ( itr.hasNext() ) {
- String role = ( String ) itr.next();
+ for ( String role : roles ) {
CollectionPersister collectionPersister = factory.getCollectionPersister( role );
if ( collectionPersister.hasCache() ) {
collectionCleanups.add( new CollectionCleanup( collectionPersister.getCacheAccessStrategy() ) );
@@ -91,14 +89,14 @@
}
}
- this.affectedTableSpaces = ( Serializable[] ) tmpSpaces.toArray( new Serializable[ tmpSpaces.size() ] );
+ this.affectedTableSpaces = spacesList.toArray( new String[ spacesList.size() ] );
}
/**
* Constructs an action to cleanup "affected cache regions" based on a
* set of affected table spaces. This differs from {@link #BulkOperationCleanupAction(SessionImplementor, Queryable[])}
* in that here we have the affected <strong>table names</strong>. From those
- * we deduce the entity persisters whcih are affected based on the defined
+ * we deduce the entity persisters which are affected based on the defined
* {@link EntityPersister#getQuerySpaces() table spaces}; and from there, we
* determine the affected collection regions based on any collections
* in which those entity persisters participate as elements/keys/etc.
@@ -106,26 +104,24 @@
* @param session The session to which this request is tied.
* @param tableSpaces The table spaces.
*/
+ @SuppressWarnings({ "unchecked" })
public BulkOperationCleanupAction(SessionImplementor session, Set tableSpaces) {
- Set tmpSpaces = new HashSet(tableSpaces);
- SessionFactoryImplementor factory = session.getFactory();
- Iterator iterator = factory.getAllClassMetadata().entrySet().iterator();
- while ( iterator.hasNext() ) {
- Map.Entry entry = (Map.Entry) iterator.next();
- String entityName = (String) entry.getKey();
- EntityPersister persister = factory.getEntityPersister( entityName );
- Serializable[] entitySpaces = persister.getQuerySpaces();
+ LinkedHashSet<String> spacesList = new LinkedHashSet<String>();
+ spacesList.addAll( tableSpaces );
+ SessionFactoryImplementor factory = session.getFactory();
+ for ( String entityName : factory.getAllClassMetadata().keySet() ) {
+ final EntityPersister persister = factory.getEntityPersister( entityName );
+ final String[] entitySpaces = (String[]) persister.getQuerySpaces();
if ( affectedEntity( tableSpaces, entitySpaces ) ) {
- tmpSpaces.addAll( Arrays.asList( entitySpaces ) );
+ spacesList.addAll( Arrays.asList( entitySpaces ) );
+
if ( persister.hasCache() ) {
entityCleanups.add( new EntityCleanup( persister.getCacheAccessStrategy() ) );
}
- Set roles = session.getFactory().getCollectionRolesByEntityParticipant( persister.getEntityName() );
+ Set<String> roles = session.getFactory().getCollectionRolesByEntityParticipant( persister.getEntityName() );
if ( roles != null ) {
- Iterator itr = roles.iterator();
- while ( itr.hasNext() ) {
- String role = ( String ) itr.next();
+ for ( String role : roles ) {
CollectionPersister collectionPersister = factory.getCollectionPersister( role );
if ( collectionPersister.hasCache() ) {
collectionCleanups.add(
@@ -137,7 +133,7 @@
}
}
- this.affectedTableSpaces = ( Serializable[] ) tmpSpaces.toArray( new Serializable[ tmpSpaces.size() ] );
+ this.affectedTableSpaces = spacesList.toArray( new String[ spacesList.size() ] );
}
@@ -158,8 +154,8 @@
return true;
}
- for ( int i = 0; i < checkTableSpaces.length; i++ ) {
- if ( affectedTableSpaces.contains( checkTableSpaces[i] ) ) {
+ for ( Serializable checkTableSpace : checkTableSpaces ) {
+ if ( affectedTableSpaces.contains( checkTableSpace ) ) {
return true;
}
}
Modified: core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java 2010-08-13 22:26:52 UTC (rev 20142)
+++ core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java 2010-08-13 22:29:41 UTC (rev 20143)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * 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
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.engine;
@@ -30,17 +29,18 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
-import java.util.HashSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
+import org.hibernate.action.AfterTransactionCompletionProcess;
+import org.hibernate.action.BeforeTransactionCompletionProcess;
import org.hibernate.action.BulkOperationCleanupAction;
import org.hibernate.action.CollectionRecreateAction;
import org.hibernate.action.CollectionRemoveAction;
@@ -50,8 +50,6 @@
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;
@@ -121,36 +119,43 @@
collectionUpdates.clear();
}
+ @SuppressWarnings({ "unchecked" })
public void addAction(EntityInsertAction action) {
insertions.add( action );
}
+ @SuppressWarnings({ "unchecked" })
public void addAction(EntityDeleteAction action) {
deletions.add( action );
}
+ @SuppressWarnings({ "unchecked" })
public void addAction(EntityUpdateAction action) {
updates.add( action );
}
+ @SuppressWarnings({ "unchecked" })
public void addAction(CollectionRecreateAction action) {
collectionCreations.add( action );
}
+ @SuppressWarnings({ "unchecked" })
public void addAction(CollectionRemoveAction action) {
collectionRemovals.add( action );
}
+ @SuppressWarnings({ "unchecked" })
public void addAction(CollectionUpdateAction action) {
collectionUpdates.add( action );
}
+ @SuppressWarnings({ "unchecked" })
public void addAction(EntityIdentityInsertAction insert) {
insertions.add( insert );
}
public void addAction(BulkOperationCleanupAction cleanupAction) {
- registerProcess( cleanupAction.getAfterTransactionCompletionProcess() );
+ registerCleanupActions( cleanupAction );
}
public void registerProcess(AfterTransactionCompletionProcess process) {
@@ -238,14 +243,14 @@
return ( insertions.size() > 0 || deletions.size() > 0 );
}
- private static boolean areTablesToUpdated(List executables, Set tablespaces) {
- int size = executables.size();
- for ( int j = 0; j < size; j++ ) {
- Serializable[] spaces = ( ( Executable ) executables.get( j ) ).getPropertySpaces();
- for ( int i = 0; i < spaces.length; i++ ) {
- if ( tablespaces.contains( spaces[i] ) ) {
+ @SuppressWarnings({ "unchecked" })
+ private static boolean areTablesToUpdated(List actions, Set tableSpaces) {
+ for ( Executable action : (List<Executable>) actions ) {
+ final Serializable[] spaces = action.getPropertySpaces();
+ for ( Serializable space : spaces ) {
+ if ( tableSpaces.contains( space ) ) {
if ( log.isDebugEnabled() ) {
- log.debug( "changes must be flushed to space: " + spaces[i] );
+ log.debug( "changes must be flushed to space: " + space );
}
return true;
}
@@ -268,20 +273,23 @@
executable.execute();
}
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() );
+ registerCleanupActions( executable );
}
}
+ private void registerCleanupActions(Executable executable) {
+ beforeTransactionProcesses.register( executable.getBeforeTransactionCompletionProcess() );
+ if ( session.getFactory().getSettings().isQueryCacheEnabled() ) {
+ final String[] spaces = (String[]) executable.getPropertySpaces();
+ afterTransactionProcesses.addSpacesToInvalidate( spaces );
+ session.getFactory().getUpdateTimestampsCache().preinvalidate( spaces );
+ }
+ afterTransactionProcesses.register( executable.getAfterTransactionCompletionProcess() );
+ }
+
+ @SuppressWarnings({ "unchecked" })
private void prepareActions(List queue) throws HibernateException {
- int size = queue.size();
- for ( int i = 0; i < size; i++ ) {
- Executable executable = ( Executable ) queue.get( i );
+ for ( Executable executable : (List<Executable>) queue ) {
executable.beforeExecutions();
}
}
@@ -327,6 +335,7 @@
return insertions.size();
}
+ @SuppressWarnings({ "unchecked" })
public void sortCollectionActions() {
if ( session.getFactory().getSettings().isOrderUpdatesEnabled() ) {
//sort the updates by fk
@@ -336,6 +345,7 @@
}
}
+ @SuppressWarnings({ "unchecked" })
public void sortActions() {
if ( session.getFactory().getSettings().isOrderUpdatesEnabled() ) {
//sort the updates by pk
@@ -359,6 +369,7 @@
new InsertActionSorter().sort();
}
+ @SuppressWarnings({ "UnusedDeclaration" })
public ArrayList cloneDeletions() {
return ( ArrayList ) deletions.clone();
}
@@ -374,6 +385,7 @@
}
}
+ @SuppressWarnings({ "UnusedDeclaration" })
public boolean hasAfterTransactionActions() {
return afterTransactionProcesses.processes.size() > 0;
}
@@ -457,6 +469,7 @@
* @throws IOException indicates a problem reading from the stream
* @throws ClassNotFoundException Generally means we were unable to locate user classes.
*/
+ @SuppressWarnings({ "unchecked" })
public static ActionQueue deserialize(
ObjectInputStream ois,
SessionImplementor session) throws IOException, ClassNotFoundException {
@@ -465,42 +478,42 @@
int queueSize = ois.readInt();
log.trace( "starting deserialization of [" + queueSize + "] insertions entries" );
- rtn.insertions = new ArrayList( queueSize );
+ rtn.insertions = new ArrayList<Executable>( queueSize );
for ( int i = 0; i < queueSize; i++ ) {
rtn.insertions.add( ois.readObject() );
}
queueSize = ois.readInt();
log.trace( "starting deserialization of [" + queueSize + "] deletions entries" );
- rtn.deletions = new ArrayList( queueSize );
+ rtn.deletions = new ArrayList<Executable>( queueSize );
for ( int i = 0; i < queueSize; i++ ) {
rtn.deletions.add( ois.readObject() );
}
queueSize = ois.readInt();
log.trace( "starting deserialization of [" + queueSize + "] updates entries" );
- rtn.updates = new ArrayList( queueSize );
+ rtn.updates = new ArrayList<Executable>( queueSize );
for ( int i = 0; i < queueSize; i++ ) {
rtn.updates.add( ois.readObject() );
}
queueSize = ois.readInt();
log.trace( "starting deserialization of [" + queueSize + "] collectionUpdates entries" );
- rtn.collectionUpdates = new ArrayList( queueSize );
+ rtn.collectionUpdates = new ArrayList<Executable>( queueSize );
for ( int i = 0; i < queueSize; i++ ) {
rtn.collectionUpdates.add( ois.readObject() );
}
queueSize = ois.readInt();
log.trace( "starting deserialization of [" + queueSize + "] collectionRemovals entries" );
- rtn.collectionRemovals = new ArrayList( queueSize );
+ rtn.collectionRemovals = new ArrayList<Executable>( queueSize );
for ( int i = 0; i < queueSize; i++ ) {
rtn.collectionRemovals.add( ois.readObject() );
}
queueSize = ois.readInt();
log.trace( "starting deserialization of [" + queueSize + "] collectionCreations entries" );
- rtn.collectionCreations = new ArrayList( queueSize );
+ rtn.collectionCreations = new ArrayList<Executable>( queueSize );
for ( int i = 0; i < queueSize; i++ ) {
rtn.collectionCreations.add( ois.readObject() );
}
@@ -509,7 +522,7 @@
private static class BeforeTransactionCompletionProcessQueue {
private SessionImplementor session;
- private List processes = new ArrayList();
+ private List<BeforeTransactionCompletionProcess> processes = new ArrayList<BeforeTransactionCompletionProcess>();
private BeforeTransactionCompletionProcessQueue(SessionImplementor session) {
this.session = session;
@@ -526,7 +539,7 @@
final int size = processes.size();
for ( int i = 0; i < size; i++ ) {
try {
- BeforeTransactionCompletionProcess process = ( BeforeTransactionCompletionProcess ) processes.get( i );
+ BeforeTransactionCompletionProcess process = processes.get( i );
process.doBeforeTransactionCompletion( session );
}
catch ( HibernateException he ) {
@@ -542,8 +555,9 @@
private static class AfterTransactionCompletionProcessQueue {
private SessionImplementor session;
- private Set querySpacesToInvalidate = new HashSet();
- private List processes = new ArrayList( INIT_QUEUE_LIST_SIZE * 3 );
+ private Set<String> querySpacesToInvalidate = new HashSet<String>();
+ private List<AfterTransactionCompletionProcess> processes
+ = new ArrayList<AfterTransactionCompletionProcess>( INIT_QUEUE_LIST_SIZE * 3 );
private AfterTransactionCompletionProcessQueue(SessionImplementor session) {
this.session = session;
@@ -573,7 +587,7 @@
final int size = processes.size();
for ( int i = 0; i < size; i++ ) {
try {
- AfterTransactionCompletionProcess process = ( AfterTransactionCompletionProcess ) processes.get( i );
+ AfterTransactionCompletionProcess process = processes.get( i );
process.doAfterTransactionCompletion( success, session );
}
catch ( CacheException ce ) {
@@ -588,7 +602,7 @@
if ( session.getFactory().getSettings().isQueryCacheEnabled() ) {
session.getFactory().getUpdateTimestampsCache().invalidate(
- ( String[] ) querySpacesToInvalidate.toArray( new String[ querySpacesToInvalidate.size()] )
+ querySpacesToInvalidate.toArray( new String[ querySpacesToInvalidate.size()] )
);
}
querySpacesToInvalidate.clear();
@@ -616,11 +630,10 @@
/**
* Sort the insert actions.
*/
+ @SuppressWarnings({ "unchecked", "UnnecessaryBoxing" })
public void sort() {
-
// the list of entity names that indicate the batch number
- for ( Iterator actionItr = insertions.iterator(); actionItr.hasNext(); ) {
- EntityInsertAction action = ( EntityInsertAction ) actionItr.next();
+ for ( EntityInsertAction action : (List<EntityInsertAction>) insertions ) {
// remove the current element from insertions. It will be added back later.
String entityName = action.getEntityName();
@@ -641,7 +654,7 @@
// doing the batch number before adding the name to the list is
// a faster way to get an accurate number.
- batchNumber = new Integer( actionBatches.size() );
+ batchNumber = Integer.valueOf( actionBatches.size() );
latestBatches.put( entityName, batchNumber );
}
entityBatchNumber.put( currentEntity, batchNumber );
@@ -652,8 +665,8 @@
// now rebuild the insertions list. There is a batch for each entry in the name list.
for ( int i = 0; i < actionBatches.size(); i++ ) {
List batch = ( List ) actionBatches.get( new Integer( i ) );
- for ( Iterator batchItr = batch.iterator(); batchItr.hasNext(); ) {
- EntityInsertAction action = ( EntityInsertAction ) batchItr.next();
+ for ( Object aBatch : batch ) {
+ EntityInsertAction action = (EntityInsertAction) aBatch;
insertions.add( action );
}
}
@@ -667,6 +680,7 @@
*
* @return An appropriate batch number; todo document this process better
*/
+ @SuppressWarnings({ "UnnecessaryBoxing", "unchecked" })
private Integer findBatchNumber(
EntityInsertAction action,
String entityName) {
@@ -691,7 +705,7 @@
Integer associationBatchNumber = ( Integer ) entityBatchNumber.get( value );
if ( associationBatchNumber != null && associationBatchNumber.compareTo( latestBatchNumberForType ) > 0 ) {
// create a new batch for this type. The batch number is the number of current batches.
- latestBatchNumberForType = new Integer( actionBatches.size() );
+ latestBatchNumberForType = Integer.valueOf( actionBatches.size() );
latestBatches.put( entityName, latestBatchNumberForType );
// since this entity will now be processed in the latest possible batch,
// we can be assured that it will come after all other associations,
@@ -703,6 +717,7 @@
return latestBatchNumberForType;
}
+ @SuppressWarnings({ "unchecked" })
private void addToBatch(Integer batchNumber, EntityInsertAction action) {
List actions = ( List ) actionBatches.get( batchNumber );
Modified: core/trunk/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java 2010-08-13 22:26:52 UTC (rev 20142)
+++ core/trunk/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java 2010-08-13 22:29:41 UTC (rev 20143)
@@ -230,7 +230,7 @@
* @param entityName The entity name for which to get the collection roles.
* @return set of all the collection roles in which the given entityName participates.
*/
- public Set getCollectionRolesByEntityParticipant(String entityName);
+ public Set<String> getCollectionRolesByEntityParticipant(String entityName);
public EntityNotFoundDelegate getEntityNotFoundDelegate();
Modified: core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java 2010-08-13 22:26:52 UTC (rev 20142)
+++ core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java 2010-08-13 22:29:41 UTC (rev 20143)
@@ -158,10 +158,10 @@
private final String uuid;
private final transient Map entityPersisters;
- private final transient Map classMetadata;
+ private final transient Map<String,ClassMetadata> classMetadata;
private final transient Map collectionPersisters;
private final transient Map collectionMetadata;
- private final transient Map collectionRolesByEntityParticipant;
+ private final transient Map<String,Set<String>> collectionRolesByEntityParticipant;
private final transient Map identifierGenerators;
private final transient Map namedQueries;
private final transient Map namedSqlQueries;
@@ -263,7 +263,7 @@
entityPersisters = new HashMap();
Map entityAccessStrategies = new HashMap();
- Map classMeta = new HashMap();
+ Map<String,ClassMetadata> classMeta = new HashMap<String,ClassMetadata>();
classes = cfg.getClassMappings();
while ( classes.hasNext() ) {
final PersistentClass model = (PersistentClass) classes.next();
@@ -285,9 +285,9 @@
entityPersisters.put( model.getEntityName(), cp );
classMeta.put( model.getEntityName(), cp.getClassMetadata() );
}
- classMetadata = Collections.unmodifiableMap(classMeta);
+ this.classMetadata = Collections.unmodifiableMap(classMeta);
- Map tmpEntityToCollectionRoleMap = new HashMap();
+ Map<String,Set<String>> tmpEntityToCollectionRoleMap = new HashMap<String,Set<String>>();
collectionPersisters = new HashMap();
Iterator collections = cfg.getCollectionMappings();
while ( collections.hasNext() ) {
@@ -726,8 +726,8 @@
return settings.getSQLExceptionConverter();
}
- public Set getCollectionRolesByEntityParticipant(String entityName) {
- return ( Set ) collectionRolesByEntityParticipant.get( entityName );
+ public Set<String> getCollectionRolesByEntityParticipant(String entityName) {
+ return collectionRolesByEntityParticipant.get( entityName );
}
// from javax.naming.Referenceable
@@ -884,7 +884,7 @@
}
}
- public Map getAllClassMetadata() throws HibernateException {
+ public Map<String,ClassMetadata> getAllClassMetadata() throws HibernateException {
return classMetadata;
}
Modified: core/trunk/core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java 2010-08-13 22:26:52 UTC (rev 20142)
+++ core/trunk/core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java 2010-08-13 22:29:41 UTC (rev 20143)
@@ -131,7 +131,7 @@
return getImpl().getCollectionMetadata(roleName);
}
- public Map getAllClassMetadata() throws HibernateException {
+ public Map<String,ClassMetadata> getAllClassMetadata() throws HibernateException {
return getImpl().getAllClassMetadata();
}
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/querycache/QueryCacheTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/querycache/QueryCacheTest.java 2010-08-13 22:26:52 UTC (rev 20142)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/querycache/QueryCacheTest.java 2010-08-13 22:29:41 UTC (rev 20143)
@@ -42,6 +42,51 @@
public static Test suite() {
return new FunctionalTestClassTestSuite( QueryCacheTest.class );
}
+
+ public void testInvalidationFromBulkHQL() {
+ // http://opensource.atlassian.com/projects/hibernate/browse/HHH-5426
+
+ getSessions().getCache().evictQueryRegions();
+ getSessions().getStatistics().clear();
+
+ Session s = openSession();
+ List list = new ArrayList();
+ s.beginTransaction();
+ for (int i = 0; i < 3; i++) {
+ Item a = new Item();
+ a.setName("a" + i);
+ a.setDescription("a" + i);
+ list.add(a);
+ s.persist(a);
+ }
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ String queryString = "select count(*) from Item";
+ // this query will hit the database and create the cache
+ Long result = (Long) s.createQuery(queryString).setCacheable(true).uniqueResult();
+ assertEquals(3, result.intValue());
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ String updateString = "delete from Item";
+ s.createQuery(updateString).executeUpdate();
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ // and this one SHOULD not be served by the cache
+ Number result2 = (Number) s.createQuery(queryString).setCacheable(true).uniqueResult();
+ assertEquals(0, result2.intValue());
+ s.getTransaction().commit();
+ s.close();
+ }
+
//https://jira.jboss.org/jira/browse/JBPAPP-4224
public void testHitCacheInSameSession() {
getSessions().evictQueries();
13 years, 7 months
Hibernate SVN: r20142 - in core/branches/Branch_3_5: core/src/main/java/org/hibernate/engine and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-13 18:26:52 -0400 (Fri, 13 Aug 2010)
New Revision: 20142
Modified:
core/branches/Branch_3_5/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java
core/branches/Branch_3_5/core/src/main/java/org/hibernate/engine/ActionQueue.java
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/querycache/QueryCacheTest.java
Log:
HHH-5426 - HQL update/delete does not invalidate the query cache
Modified: core/branches/Branch_3_5/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java
===================================================================
--- core/branches/Branch_3_5/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java 2010-08-13 20:21:07 UTC (rev 20141)
+++ core/branches/Branch_3_5/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java 2010-08-13 22:26:52 UTC (rev 20142)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * 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
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.action;
@@ -55,7 +54,7 @@
* @author Steve Ebersole
*/
public class BulkOperationCleanupAction implements Executable, Serializable {
- private final Serializable[] affectedTableSpaces;
+ private final String[] affectedTableSpaces;
private final Set entityCleanups = new HashSet();
private final Set collectionCleanups = new HashSet();
@@ -91,7 +90,7 @@
}
}
- this.affectedTableSpaces = ( Serializable[] ) tmpSpaces.toArray( new Serializable[ tmpSpaces.size() ] );
+ this.affectedTableSpaces = ( String[] ) tmpSpaces.toArray( new String[ tmpSpaces.size() ] );
}
/**
@@ -137,7 +136,7 @@
}
}
- this.affectedTableSpaces = ( Serializable[] ) tmpSpaces.toArray( new Serializable[ tmpSpaces.size() ] );
+ this.affectedTableSpaces = ( String[] ) tmpSpaces.toArray( new String[ tmpSpaces.size() ] );
}
Modified: core/branches/Branch_3_5/core/src/main/java/org/hibernate/engine/ActionQueue.java
===================================================================
--- core/branches/Branch_3_5/core/src/main/java/org/hibernate/engine/ActionQueue.java 2010-08-13 20:21:07 UTC (rev 20141)
+++ core/branches/Branch_3_5/core/src/main/java/org/hibernate/engine/ActionQueue.java 2010-08-13 22:26:52 UTC (rev 20142)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * 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
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.engine;
@@ -150,7 +149,7 @@
}
public void addAction(BulkOperationCleanupAction cleanupAction) {
- registerProcess( cleanupAction.getAfterTransactionCompletionProcess() );
+ registerCleanupActions( cleanupAction );
}
public void registerProcess(AfterTransactionCompletionProcess process) {
@@ -268,16 +267,20 @@
executable.execute();
}
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() );
+ registerCleanupActions( executable );
}
}
+ private void registerCleanupActions(Executable executable) {
+ beforeTransactionProcesses.register( executable.getBeforeTransactionCompletionProcess() );
+ if ( session.getFactory().getSettings().isQueryCacheEnabled() ) {
+ final String[] spaces = (String[]) executable.getPropertySpaces();
+ afterTransactionProcesses.addSpacesToInvalidate( spaces );
+ session.getFactory().getUpdateTimestampsCache().preinvalidate( spaces );
+ }
+ afterTransactionProcesses.register( executable.getAfterTransactionCompletionProcess() );
+ }
+
private void prepareActions(List queue) throws HibernateException {
int size = queue.size();
for ( int i = 0; i < size; i++ ) {
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/querycache/QueryCacheTest.java
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/querycache/QueryCacheTest.java 2010-08-13 20:21:07 UTC (rev 20141)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/querycache/QueryCacheTest.java 2010-08-13 22:26:52 UTC (rev 20142)
@@ -42,6 +42,51 @@
public static Test suite() {
return new FunctionalTestClassTestSuite( QueryCacheTest.class );
}
+
+ public void testInvalidationFromBulkHQL() {
+ // http://opensource.atlassian.com/projects/hibernate/browse/HHH-5426
+
+ getSessions().getCache().evictQueryRegions();
+ getSessions().getStatistics().clear();
+
+ Session s = openSession();
+ List list = new ArrayList();
+ s.beginTransaction();
+ for (int i = 0; i < 3; i++) {
+ Item a = new Item();
+ a.setName("a" + i);
+ a.setDescription("a" + i);
+ list.add(a);
+ s.persist(a);
+ }
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ String queryString = "select count(*) from Item";
+ // this query will hit the database and create the cache
+ Long result = (Long) s.createQuery(queryString).setCacheable(true).uniqueResult();
+ assertEquals(3, result.intValue());
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ String updateString = "delete from Item";
+ s.createQuery(updateString).executeUpdate();
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ // and this one SHOULD not be served by the cache
+ Number result2 = (Number) s.createQuery(queryString).setCacheable(true).uniqueResult();
+ assertEquals(0, result2.intValue());
+ s.getTransaction().commit();
+ s.close();
+ }
+
//https://jira.jboss.org/jira/browse/JBPAPP-4224
public void testHitCacheInSameSession() {
getSessions().evictQueries();
13 years, 7 months
Hibernate SVN: r20141 - core/trunk/testsuite/src/test/java/org/hibernate/test/queryplan.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-13 16:21:07 -0400 (Fri, 13 Aug 2010)
New Revision: 20141
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/queryplan/NativeSQLQueryPlanEqualsTest.java
Log:
HHH-5300 - Configurable QueryPlanCache reference counts (Manuel Dominguez Sarmiento)
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/queryplan/NativeSQLQueryPlanEqualsTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/queryplan/NativeSQLQueryPlanEqualsTest.java 2010-08-13 16:46:02 UTC (rev 20140)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/queryplan/NativeSQLQueryPlanEqualsTest.java 2010-08-13 20:21:07 UTC (rev 20141)
@@ -46,7 +46,7 @@
}
public void testNativeSQLQuerySpecEquals() {
- QueryPlanCache cache = new QueryPlanCache(null);
+ QueryPlanCache cache = new QueryPlanCache( sfi() );
NativeSQLQuerySpecification firstSpec = createSpec();
NativeSQLQuerySpecification secondSpec = createSpec();
13 years, 7 months