Hibernate SVN: r20296 - in core/trunk/core/src/main/java/org/hibernate: impl and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-31 15:07:03 -0400 (Tue, 31 Aug 2010)
New Revision: 20296
Modified:
core/trunk/core/src/main/java/org/hibernate/id/UUIDGenerator.java
core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java
core/trunk/core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java
Log:
HHH-5517 - Switch uuid generation in SessionFactory to org.hibernate.id.UUIDGenerator instead
Modified: core/trunk/core/src/main/java/org/hibernate/id/UUIDGenerator.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/id/UUIDGenerator.java 2010-08-31 18:57:54 UTC (rev 20295)
+++ core/trunk/core/src/main/java/org/hibernate/id/UUIDGenerator.java 2010-08-31 19:07:03 UTC (rev 20296)
@@ -65,6 +65,13 @@
private UUIDGenerationStrategy strategy;
private UUIDTypeDescriptor.ValueTransformer valueTransformer;
+ public static UUIDGenerator buildSessionFactoryUniqueIdentifierGenerator() {
+ final UUIDGenerator generator = new UUIDGenerator();
+ generator.strategy = StandardRandomStrategy.INSTANCE;
+ generator.valueTransformer = UUIDTypeDescriptor.ToStringTransformer.INSTANCE;
+ return generator;
+ }
+
public void configure(Type type, Properties params, Dialect d) throws MappingException {
// check first for the strategy instance
strategy = (UUIDGenerationStrategy) params.get( UUID_GEN_STRATEGY );
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-31 18:57:54 UTC (rev 20295)
+++ core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java 2010-08-31 19:07:03 UTC (rev 20296)
@@ -95,7 +95,7 @@
import org.hibernate.event.EventListeners;
import org.hibernate.exception.SQLExceptionConverter;
import org.hibernate.id.IdentifierGenerator;
-import org.hibernate.id.UUIDHexGenerator;
+import org.hibernate.id.UUIDGenerator;
import org.hibernate.id.factory.IdentifierGeneratorFactory;
import org.hibernate.jdbc.BatcherFactory;
import org.hibernate.mapping.Collection;
@@ -128,7 +128,7 @@
/**
* Concrete implementation of the <tt>SessionFactory</tt> interface. Has the following
- * responsibilites
+ * responsibilities
* <ul>
* <li>caches configuration settings (immutably)
* <li>caches "compiled" mappings ie. <tt>EntityPersister</tt>s and
@@ -152,7 +152,7 @@
public final class SessionFactoryImpl implements SessionFactory, SessionFactoryImplementor {
private static final Logger log = LoggerFactory.getLogger(SessionFactoryImpl.class);
- private static final IdentifierGenerator UUID_GENERATOR = new UUIDHexGenerator();
+ private static final IdentifierGenerator UUID_GENERATOR = UUIDGenerator.buildSessionFactoryUniqueIdentifierGenerator();
private final String name;
private final String uuid;
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-31 18:57:54 UTC (rev 20295)
+++ core/trunk/core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java 2010-08-31 19:07:03 UTC (rev 20296)
@@ -1,4 +1,26 @@
-//$Id: SessionFactoryStub.java 8754 2005-12-05 23:36:59Z steveebersole $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * 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 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.jmx;
import java.io.InvalidObjectException;
@@ -23,7 +45,7 @@
import org.hibernate.TypeHelper;
import org.hibernate.engine.FilterDefinition;
import org.hibernate.id.IdentifierGenerator;
-import org.hibernate.id.UUIDHexGenerator;
+import org.hibernate.id.UUIDGenerator;
import org.hibernate.impl.SessionFactoryObjectFactory;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metadata.CollectionMetadata;
@@ -37,11 +59,9 @@
* @author Gavin King
*/
public class SessionFactoryStub implements SessionFactory {
+ private static final IdentifierGenerator UUID_GENERATOR = UUIDGenerator.buildSessionFactoryUniqueIdentifierGenerator();
+ private static final Logger log = LoggerFactory.getLogger( SessionFactoryStub.class );
- private static final Logger log = LoggerFactory.getLogger(SessionFactoryStub.class);
-
- private static final IdentifierGenerator UUID_GENERATOR = new UUIDHexGenerator();
-
private transient SessionFactory impl;
private transient HibernateService service;
private String uuid;
14 years, 2 months
Hibernate SVN: r20295 - core/trunk/core/src/main/java/org/hibernate/cfg.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-31 14:57:54 -0400 (Tue, 31 Aug 2010)
New Revision: 20295
Modified:
core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
Log:
HHH-5520 - Per org.hibernate.cache.RegionFactory javadocs, implementors should be allowed to use no-arg constructor
Modified: core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java 2010-08-31 18:44:56 UTC (rev 20294)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java 2010-08-31 18:57:54 UTC (rev 20295)
@@ -24,6 +24,7 @@
package org.hibernate.cfg;
import java.io.Serializable;
+import java.lang.reflect.Constructor;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
@@ -368,8 +369,8 @@
return new org.hibernate.bytecode.cglib.BytecodeProviderImpl();
}
else {
- log.debug( "using cglib as bytecode provider by default" );
- return new org.hibernate.bytecode.cglib.BytecodeProviderImpl();
+ log.debug( "using javassist as bytecode provider by default" );
+ return new org.hibernate.bytecode.javassist.BytecodeProviderImpl();
}
}
@@ -404,9 +405,19 @@
}
log.info( "Cache region factory : " + regionFactoryClassName );
try {
- return ( RegionFactory ) ReflectHelper.classForName( regionFactoryClassName )
- .getConstructor( new Class[] { Properties.class } )
- .newInstance( new Object[] { properties } );
+ try {
+ return (RegionFactory) ReflectHelper.classForName( regionFactoryClassName )
+ .getConstructor( Properties.class )
+ .newInstance( properties );
+ }
+ catch ( NoSuchMethodException nsme ) {
+ // no constructor accepting Properties found, try no arg constructor
+ log.debug(
+ regionFactoryClassName + " did not provide constructor accepting java.util.Properties; " +
+ "attempting no-arg constructor."
+ );
+ return (RegionFactory) ReflectHelper.classForName( regionFactoryClassName ).newInstance();
+ }
}
catch ( Exception e ) {
throw new HibernateException( "could not instantiate RegionFactory [" + regionFactoryClassName + "]", e );
@@ -429,9 +440,9 @@
protected BatcherFactory createBatcherFactory(Properties properties, int batchSize) {
String batcherClass = properties.getProperty(Environment.BATCH_STRATEGY);
if (batcherClass==null) {
- return batchSize==0 ?
- (BatcherFactory) new NonBatchingBatcherFactory() :
- (BatcherFactory) new BatchingBatcherFactory();
+ return batchSize == 0
+ ? new NonBatchingBatcherFactory()
+ : new BatchingBatcherFactory();
}
else {
log.info("Batcher factory: " + batcherClass);
14 years, 2 months
Hibernate SVN: r20294 - core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-31 14:44:56 -0400 (Tue, 31 Aug 2010)
New Revision: 20294
Modified:
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/JBossCacheRegionFactory.java
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/JndiMultiplexedJBossCacheRegionFactory.java
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/JndiSharedJBossCacheRegionFactory.java
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/MultiplexedJBossCacheRegionFactory.java
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/SharedJBossCacheRegionFactory.java
Log:
HHH-5489 - Deprecate jbosscache as a second level cache provider, in favor of infinispan
Modified: core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/JBossCacheRegionFactory.java
===================================================================
--- core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/JBossCacheRegionFactory.java 2010-08-31 18:19:55 UTC (rev 20293)
+++ core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/JBossCacheRegionFactory.java 2010-08-31 18:44:56 UTC (rev 20294)
@@ -43,6 +43,8 @@
import org.hibernate.cfg.Settings;
import org.hibernate.util.PropertiesHelper;
import org.jboss.cache.DefaultCacheFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* {@link RegionFactory} that uses one or more JBoss Cache instances for
@@ -62,11 +64,15 @@
* Also exposes an overloaded constructor that allows injection of different
* <code>CacheInstanceManager</code> implementations.
* </p>
+ *
+ * @deprecated Favor Infinispan integration; see HHH-5489 for details.
*
* @author Steve Ebersole
* @author Brian Stansberry
*/
+@Deprecated
public class JBossCacheRegionFactory implements RegionFactory {
+ private static final Logger log = LoggerFactory.getLogger( JBossCacheRegionFactory.class );
private CacheInstanceManager cacheInstanceManager;
/**
@@ -83,6 +89,7 @@
* Create a new JBossCacheRegionFactory.
*/
public JBossCacheRegionFactory() {
+ log.warn( "Integration with JBossCache is deprecated in favor of Infinispan" );
}
/**
@@ -93,6 +100,7 @@
*/
public JBossCacheRegionFactory(CacheInstanceManager cacheInstanceManager) {
this.cacheInstanceManager = cacheInstanceManager;
+ log.warn( "Integration with JBossCache is deprecated in favor of Infinispan" );
}
public CacheInstanceManager getCacheInstanceManager() {
Modified: core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/JndiMultiplexedJBossCacheRegionFactory.java
===================================================================
--- core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/JndiMultiplexedJBossCacheRegionFactory.java 2010-08-31 18:19:55 UTC (rev 20293)
+++ core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/JndiMultiplexedJBossCacheRegionFactory.java 2010-08-31 18:44:56 UTC (rev 20294)
@@ -25,6 +25,9 @@
import java.util.Properties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.hibernate.cache.jbc.builder.JndiMultiplexingCacheInstanceManager;
/**
@@ -41,10 +44,13 @@
* This version finds the factory in JNDI. See
* {@link JndiMultiplexingCacheInstanceManager} for configuration details.
* </p>
- *
+ *
+ * @deprecated Favor Infinispan integration; see HHH-5489 for details.
+ *
* @author Brian Stansberry
* @version $Revision$
*/
+@Deprecated
public class JndiMultiplexedJBossCacheRegionFactory extends JBossCacheRegionFactory {
/**
Modified: core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/JndiSharedJBossCacheRegionFactory.java
===================================================================
--- core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/JndiSharedJBossCacheRegionFactory.java 2010-08-31 18:19:55 UTC (rev 20293)
+++ core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/JndiSharedJBossCacheRegionFactory.java 2010-08-31 18:44:56 UTC (rev 20294)
@@ -37,10 +37,13 @@
* using the value of the {@link JndiSharedCacheInstanceManager#CACHE_RESOURCE_PROP}
* configuration property as the name to look up.
* </p>
+ *
+ * @deprecated Favor Infinispan integration; see HHH-5489 for details.
*
* @author Brian Stansberry
* @version $Revision$
*/
+@Deprecated
public class JndiSharedJBossCacheRegionFactory extends JBossCacheRegionFactory {
/**
Modified: core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/MultiplexedJBossCacheRegionFactory.java
===================================================================
--- core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/MultiplexedJBossCacheRegionFactory.java 2010-08-31 18:19:55 UTC (rev 20293)
+++ core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/MultiplexedJBossCacheRegionFactory.java 2010-08-31 18:44:56 UTC (rev 20294)
@@ -41,10 +41,13 @@
* This version instantiates the factory itself. See
* {@link MultiplexingCacheInstanceManager} for configuration details.
* </p>
- *
+ *
+ * @deprecated Favor Infinispan integration; see HHH-5489 for details.
+ *
* @author Brian Stansberry
* @version $Revision$
*/
+@Deprecated
public class MultiplexedJBossCacheRegionFactory extends JBossCacheRegionFactory {
/**
Modified: core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/SharedJBossCacheRegionFactory.java
===================================================================
--- core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/SharedJBossCacheRegionFactory.java 2010-08-31 18:19:55 UTC (rev 20293)
+++ core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/SharedJBossCacheRegionFactory.java 2010-08-31 18:44:56 UTC (rev 20294)
@@ -28,6 +28,8 @@
import org.hibernate.cache.jbc.builder.JndiSharedCacheInstanceManager;
import org.hibernate.cache.jbc.builder.SharedCacheInstanceManager;
import org.jboss.cache.DefaultCacheFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* {@link JBossCacheRegionFactory} that uses
@@ -40,10 +42,13 @@
* {@link JndiSharedCacheInstanceManager#CACHE_RESOURCE_PROP}
* configuration property.
* </p>
- *
+ *
+ * @deprecated Favor Infinispan integration; see HHH-5489 for details.
+ *
* @author Brian Stansberry
* @version $Revision$
*/
+@Deprecated
public class SharedJBossCacheRegionFactory extends JBossCacheRegionFactory {
/**
14 years, 2 months
Hibernate SVN: r20293 - in core/trunk/documentation/quickstart/tutorials: basic/src/test/resources and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-31 14:19:55 -0400 (Tue, 31 Aug 2010)
New Revision: 20293
Modified:
core/trunk/documentation/quickstart/tutorials/annotations/src/test/resources/hibernate.cfg.xml
core/trunk/documentation/quickstart/tutorials/basic/src/test/resources/hibernate.cfg.xml
core/trunk/documentation/quickstart/tutorials/entitymanager/src/test/resources/META-INF/persistence.xml
Log:
HHH-5441 - Create "Getting Started Guide"
Modified: core/trunk/documentation/quickstart/tutorials/annotations/src/test/resources/hibernate.cfg.xml
===================================================================
--- core/trunk/documentation/quickstart/tutorials/annotations/src/test/resources/hibernate.cfg.xml 2010-08-31 17:59:31 UTC (rev 20292)
+++ core/trunk/documentation/quickstart/tutorials/annotations/src/test/resources/hibernate.cfg.xml 2010-08-31 18:19:55 UTC (rev 20293)
@@ -49,7 +49,7 @@
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
- <property name="hbm2ddl.auto">update</property>
+ <property name="hbm2ddl.auto">create</property>
<!-- Names the annotated entity class -->
<mapping class="org.hibernate.tutorial.annotations.Event"/>
Modified: core/trunk/documentation/quickstart/tutorials/basic/src/test/resources/hibernate.cfg.xml
===================================================================
--- core/trunk/documentation/quickstart/tutorials/basic/src/test/resources/hibernate.cfg.xml 2010-08-31 17:59:31 UTC (rev 20292)
+++ core/trunk/documentation/quickstart/tutorials/basic/src/test/resources/hibernate.cfg.xml 2010-08-31 18:19:55 UTC (rev 20293)
@@ -49,7 +49,7 @@
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
- <property name="hbm2ddl.auto">update</property>
+ <property name="hbm2ddl.auto">create</property>
<mapping resource="org/hibernate/tutorial/hbm/Event.hbm.xml"/>
Modified: core/trunk/documentation/quickstart/tutorials/entitymanager/src/test/resources/META-INF/persistence.xml
===================================================================
--- core/trunk/documentation/quickstart/tutorials/entitymanager/src/test/resources/META-INF/persistence.xml 2010-08-31 17:59:31 UTC (rev 20292)
+++ core/trunk/documentation/quickstart/tutorials/entitymanager/src/test/resources/META-INF/persistence.xml 2010-08-31 18:19:55 UTC (rev 20293)
@@ -40,8 +40,7 @@
<property name="javax.persistence.jdbc.password" value="" />
<property name="hibernate.show_sql" value="true" />
- <property name="hibernate.hbm2ddl.auto" value="update" />
-
+ <property name="hibernate.hbm2ddl.auto" value="create" />
</properties>
</persistence-unit>
14 years, 2 months
Hibernate SVN: r20292 - in core/trunk/documentation/quickstart: src/main/docbook/en-US/content and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-31 13:59:31 -0400 (Tue, 31 Aug 2010)
New Revision: 20292
Added:
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_jpa.xml
Modified:
core/trunk/documentation/quickstart/src/main/docbook/en-US/Hibernate_Getting_Started_Guide.xml
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_annotations.xml
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml
core/trunk/documentation/quickstart/tutorials/entitymanager/src/test/java/org/hibernate/tutorial/em/EntityManagerIllustrationTest.java
core/trunk/documentation/quickstart/tutorials/entitymanager/src/test/resources/META-INF/persistence.xml
Log:
HHH-5445 - Write a jpa/entitymanager tutorial guide
Modified: core/trunk/documentation/quickstart/src/main/docbook/en-US/Hibernate_Getting_Started_Guide.xml
===================================================================
--- core/trunk/documentation/quickstart/src/main/docbook/en-US/Hibernate_Getting_Started_Guide.xml 2010-08-31 16:05:27 UTC (rev 20291)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/Hibernate_Getting_Started_Guide.xml 2010-08-31 17:59:31 UTC (rev 20292)
@@ -31,6 +31,7 @@
</partintro>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="content/tutorial_native.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="content/tutorial_annotations.xml" />
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="content/tutorial_jpa.xml" />
</part>
</book>
\ No newline at end of file
Modified: core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_annotations.xml
===================================================================
--- core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_annotations.xml 2010-08-31 16:05:27 UTC (rev 20291)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_annotations.xml 2010-08-31 17:59:31 UTC (rev 20292)
@@ -30,7 +30,7 @@
</para>
</section>
- <section id="hibernate-gsg-tutorial-basic-entity">
+ <section id="hibernate-gsg-tutorial-annotations-entity">
<title>The annotated entity Java class</title>
<para>
The entity class in this tutorial is <classname>org.hibernate.tutorial.annotations.Event</classname>
@@ -39,7 +39,7 @@
annotations to provide the metadata instead of a separate <filename>hbm.xml</filename> file.
</para>
- <example id="hibernate-gsg-tutorial-basic-entity-entity">
+ <example id="hibernate-gsg-tutorial-annotations-entity-entity">
<title>Identifying the class as an entity</title>
<programlisting role="JAVA">@Entity
@Table( name = "EVENTS" )
@@ -57,7 +57,7 @@
<database class="table">EVENT</database>).
</para>
- <example id="hibernate-gsg-tutorial-basic-entity-id">
+ <example id="hibernate-gsg-tutorial-annotations-entity-id">
<title>Identifying the identifier property</title>
<programlisting role="JAVA">@Id
@GeneratedValue(generator="increment")
@@ -75,7 +75,7 @@
strategy for this entity's identifier values.
</para>
- <example id="hibernate-gsg-tutorial-basic-entity-properties">
+ <example id="hibernate-gsg-tutorial-annotations-entity-properties">
<title>Identifying basic properties</title>
<programlisting role="JAVA">public String getTitle() {
return title;
@@ -112,14 +112,15 @@
<itemizedlist>
<listitem>
<para>
- With help of the Developer Guide, add an association to the <classname>Event</classname>
- entity to model a message thread.
+ With help of the <citetitle pubwork="book">Developer Guide</citetitle>, add an association to
+ the <classname>Event</classname> entity to model a message thread.
</para>
</listitem>
<listitem>
<para>
- With help of the Developer Guide, add a callback to receive notifications when an
- <classname>Event</classname> is created, updated or deleted. Try the same with an event listener.
+ With help of the <citetitle pubwork="book">Developer Guide</citetitle>, add a callback to
+ receive notifications when an <classname>Event</classname> is created, updated or deleted. Try
+ the same with an event listener.
</para>
</listitem>
</itemizedlist>
Added: core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_jpa.xml
===================================================================
--- core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_jpa.xml (rev 0)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_jpa.xml 2010-08-31 17:59:31 UTC (rev 20292)
@@ -0,0 +1,128 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+
+<chapter id="hibernate-gsg-tutorial-jpa">
+ <title>Tutorial Using the <firstterm><phrase>Java Persistence API (JPA)</phrase></firstterm></title>
+
+ <para>
+ This tutorial is located within the download bundle under <filename>entitymanager</filename> and illustrates
+ <itemizedlist>
+ <listitem>
+ <para>
+ using annotations to provide mapping information
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ using <phrase>JPA</phrase>
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+
+ <section id="hibernate-gsg-tutorial-jpa-config">
+ <title><filename>persistence.xml</filename></title>
+
+ <para>
+ The previous tutorials used the Hibernate-specific
+ <filename><replaceable>hibernate.cfg.xml</replaceable></filename> configuration file. <phrase>JPA</phrase>,
+ however, defines a different <phrase>bootstrap</phrase> process that uses its own configuration file
+ named <filename>persistence.xml</filename>. How this <phrase>bootstrapping</phrase> works is defined
+ by the <phrase>JPA</phrase> specification. In <trademark>Java</trademark> SE environments the
+ persistence provider (Hibernate in this case) is required to locate all <phrase>JPA</phrase>
+ configuration files by classpath lookup of the <filename>META-INF/persistence.xml</filename> resource
+ name.
+ </para>
+
+ <example id="hibernate-gsg-tutorial-jpa-config-pu">
+ <title><filename>persistence.xml</filename></title>
+ <programlisting role="XML"><![CDATA[<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
+ <persistence-unit name="org.hibernate.tutorial.jpa">
+ ...
+ </persistence-unit>
+</persistence>]]></programlisting>
+ </example>
+
+ <para>
+ <filename>persistence.xml</filename> files should provide a unique name for each
+ <phrase>persistence unit</phrase>. This name is how applications reference the configuration
+ while obtaining an <interfacename>javax.persistence.EntityManagerFactory</interfacename> reference.
+ </para>
+
+ <para>
+ The settings defined in the <literal>properties</literal> element were already discussed in
+ <xref linkend="hibernate-gsg-tutorial-basic-config"/>. Here the <literal>javax.persistence</literal>-prefixed
+ varieties are used when possible. For the remaining Hibernate-specific configuration setting names notice
+ that they are now prefixed with <literal>hibernate.</literal>.
+ </para>
+
+ <para>
+ Additionally, the <literal>class</literal> element functions the same as discussed in
+ <xref linkend="hibernate-gsg-tutorial-annotations-config"/>.
+ </para>
+ </section>
+
+ <section id="hibernate-gsg-tutorial-jpa-entity">
+ <title>The annotated entity Java class</title>
+ <para>
+ The entity is exactly the same as that from the annotations tutorial. See
+ <xref linkend="hibernate-gsg-tutorial-annotations-entity"/>
+ </para>
+ </section>
+
+ <section id="hibernate-gsg-tutorial-jpa-test">
+ <title>Example code</title>
+ <para>
+ The previous tutorials used the Hibernate APIs. This tutorial uses the <phrase>JPA</phrase> APIs.
+ </para>
+
+ <example id="hibernate-gsg-tutorial-jpa-test-setUp">
+ <title>Obtaining the <interfacename>javax.persistence.EntityManagerFactory</interfacename></title>
+ <programlisting role="JAVA">protected void setUp() throws Exception {
+ entityManagerFactory = Persistence.createEntityManagerFactory( "org.hibernate.tutorial.jpa" );
+}</programlisting>
+ </example>
+
+ <para>
+ Notice again the use of <literal>org.hibernate.tutorial.jpa</literal> as the
+ <phrase>persistence unit</phrase> name, which matches from <xref linkend="hibernate-gsg-tutorial-jpa-config-pu"/>
+ </para>
+
+ <example id="hibernate-gsg-tutorial-jpa-test-saving">
+ <title>Saving (persisting) entities</title>
+ <programlisting role="JAVA">EntityManager entityManager = entityManagerFactory.createEntityManager();
+entityManager.getTransaction().begin();
+entityManager.persist( new Event( "Our very first event!", new Date() ) );
+entityManager.persist( new Event( "A follow up event", new Date() ) );
+entityManager.getTransaction().commit();
+entityManager.close();</programlisting>
+ </example>
+
+ <para>
+ The code is pretty similar to <xref linkend="hibernate-gsg-tutorial-basic-test-saving"/>. Here
+ we use an <interfacename>javax.persistence.EntityManager</interfacename> as opposed to a
+ <interfacename>org.hibernate.Session</interfacename>. <phrase>JPA</phrase> calls this operation
+ <literal>persist</literal> instead of <literal>save</literal>.
+ </para>
+
+ <example id="hibernate-gsg-tutorial-jpa-test-list">
+ <title>Obtaining a list of entities</title>
+ <programlisting role="JAVA"><![CDATA[entityManager = entityManagerFactory.createEntityManager();
+entityManager.getTransaction().begin();
+List<Event> result = entityManager.createQuery( "from Event", Event.class ).getResultList();
+for ( Event event : result ) {
+ System.out.println( "Event (" + event.getDate() + ") : " + event.getTitle() );
+}
+entityManager.getTransaction().commit();
+entityManager.close();]]></programlisting>
+ </example>
+
+ <para>
+ Again, the code is pretty similar to <xref linkend="hibernate-gsg-tutorial-basic-test-list"/>.
+ </para>
+ </section>
+
+</chapter>
\ 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-31 16:05:27 UTC (rev 20291)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml 2010-08-31 17:59:31 UTC (rev 20292)
@@ -320,8 +320,8 @@
</listitem>
<listitem>
<para>
- With help of the Developer Guide, add an association to the <classname>Event</classname>
- entity to model a message thread.
+ With help of the <citetitle pubwork="book">Developer Guide</citetitle>, add an association to
+ the <classname>Event</classname> entity to model a message thread.
</para>
</listitem>
</itemizedlist>
Modified: core/trunk/documentation/quickstart/tutorials/entitymanager/src/test/java/org/hibernate/tutorial/em/EntityManagerIllustrationTest.java
===================================================================
--- core/trunk/documentation/quickstart/tutorials/entitymanager/src/test/java/org/hibernate/tutorial/em/EntityManagerIllustrationTest.java 2010-08-31 16:05:27 UTC (rev 20291)
+++ core/trunk/documentation/quickstart/tutorials/entitymanager/src/test/java/org/hibernate/tutorial/em/EntityManagerIllustrationTest.java 2010-08-31 17:59:31 UTC (rev 20292)
@@ -42,7 +42,8 @@
@Override
protected void setUp() throws Exception {
// like discussed with regards to SessionFactory, an EntityManagerFactory is set up once for an application
- entityManagerFactory = Persistence.createEntityManagerFactory( "hibernate-jpa-tutorial" );
+ // IMPORTANT: notice how the name here matches the name we gave the persistence-unit in persistence.xml!
+ entityManagerFactory = Persistence.createEntityManagerFactory( "org.hibernate.tutorial.jpa" );
}
@Override
Modified: core/trunk/documentation/quickstart/tutorials/entitymanager/src/test/resources/META-INF/persistence.xml
===================================================================
--- core/trunk/documentation/quickstart/tutorials/entitymanager/src/test/resources/META-INF/persistence.xml 2010-08-31 16:05:27 UTC (rev 20291)
+++ core/trunk/documentation/quickstart/tutorials/entitymanager/src/test/resources/META-INF/persistence.xml 2010-08-31 17:59:31 UTC (rev 20292)
@@ -26,7 +26,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
- <persistence-unit name="hibernate-jpa-tutorial">
+ <persistence-unit name="org.hibernate.tutorial.jpa">
<description>
Persistence unit for the JPA tutorial of the Hibernate Getting Started Guide
</description>
14 years, 2 months
Hibernate SVN: r20291 - core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional.
by hibernate-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2010-08-31 12:05:27 -0400 (Tue, 31 Aug 2010)
New Revision: 20291
Modified:
core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java
Log:
[HHH-5519] (VersionedItem should not extend Item, otherwise query cache results are confusing) Fixed.
Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java
===================================================================
--- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java 2010-08-31 16:05:14 UTC (rev 20290)
+++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java 2010-08-31 16:05:27 UTC (rev 20291)
@@ -1,9 +1,8 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
+/* * Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2007, Red Hat, Inc. and/or it's affiliates or third-party contributors as
* indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
+ * statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat, Inc. and/or it's affiliates.
*
* This copyrighted material is made available to anyone wishing to use, modify,
@@ -26,14 +25,42 @@
/**
* @author Steve Ebersole
*/
-public class VersionedItem extends Item {
- private Long version;
+public class VersionedItem {
+ private Long id;
+ private Long version;
+ private String name;
+ private String description;
- public Long getVersion() {
- return version;
- }
+ public Long getId() {
+ return id;
+ }
- public void setVersion(Long version) {
- this.version = version;
- }
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(Long version) {
+ this.version = version;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
}
14 years, 2 months
Hibernate SVN: r20290 - core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional.
by hibernate-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2010-08-31 12:05:14 -0400 (Tue, 31 Aug 2010)
New Revision: 20290
Modified:
core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java
Log:
[HHH-5519] (VersionedItem should not extend Item, otherwise query cache results are confusing) Fixed.
Modified: core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java
===================================================================
--- core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java 2010-08-31 15:15:25 UTC (rev 20289)
+++ core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java 2010-08-31 16:05:14 UTC (rev 20290)
@@ -1,9 +1,8 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
+/* * Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2007, Red Hat, Inc. and/or it's affiliates or third-party contributors as
* indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
+ * statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat, Inc. and/or it's affiliates.
*
* This copyrighted material is made available to anyone wishing to use, modify,
@@ -26,14 +25,42 @@
/**
* @author Steve Ebersole
*/
-public class VersionedItem extends Item {
- private Long version;
+public class VersionedItem {
+ private Long id;
+ private Long version;
+ private String name;
+ private String description;
- public Long getVersion() {
- return version;
- }
+ public Long getId() {
+ return id;
+ }
- public void setVersion(Long version) {
- this.version = version;
- }
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(Long version) {
+ this.version = version;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
}
14 years, 2 months
Hibernate SVN: r20289 - in core/branches/Branch_3_5/cache-infinispan/src: main/java/org/hibernate/cache/infinispan/impl and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2010-08-31 11:15:25 -0400 (Tue, 31 Aug 2010)
New Revision: 20289
Modified:
core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/JndiInfinispanRegionFactory.java
core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java
core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapter.java
core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapterImpl.java
core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java
core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractEntityRegionAccessStrategyTestCase.java
Log:
[HHH-5511] (Infinispan Region.destroy() impl should call cache.stop()) Fixed.
[HHH-5512] (JndiInfinispanRegionFactory shouldn't try to stop CacheManager) Fixed.
Modified: core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/JndiInfinispanRegionFactory.java
===================================================================
--- core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/JndiInfinispanRegionFactory.java 2010-08-31 15:09:48 UTC (rev 20288)
+++ core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/JndiInfinispanRegionFactory.java 2010-08-31 15:15:25 UTC (rev 20289)
@@ -86,6 +86,10 @@
}
}
}
- }
+ }
+ @Override
+ public void stop() {
+ // Do not attempt to stop a cache manager because it wasn't created by this region factory.
+ }
}
Modified: core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java
===================================================================
--- core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java 2010-08-31 15:09:48 UTC (rev 20288)
+++ core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java 2010-08-31 15:15:25 UTC (rev 20289)
@@ -150,7 +150,8 @@
public void destroy() throws CacheException {
try {
- cacheAdapter.clear();
+ cacheAdapter.stop();
+// cacheAdapter.clear();
} finally {
cacheAdapter.removeListener(this);
}
@@ -294,4 +295,4 @@
}
}
-}
\ No newline at end of file
+}
Modified: core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapter.java
===================================================================
--- core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapter.java 2010-08-31 15:09:48 UTC (rev 20288)
+++ core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapter.java 2010-08-31 15:15:25 UTC (rev 20289)
@@ -157,6 +157,11 @@
void clear() throws CacheException;
/**
+ * Stops the cache.
+ */
+ void stop();
+
+ /**
* Add listener to this cache.
*
* @param listener to be added to cache.
Modified: core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapterImpl.java
===================================================================
--- core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapterImpl.java 2010-08-31 15:09:48 UTC (rev 20288)
+++ core/branches/Branch_3_5/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapterImpl.java 2010-08-31 15:15:25 UTC (rev 20289)
@@ -32,6 +32,8 @@
import org.infinispan.context.Flag;
import org.infinispan.remoting.rpc.RpcManager;
import org.infinispan.util.concurrent.TimeoutException;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
/**
* CacheAdapterImpl.
@@ -40,6 +42,7 @@
* @since 3.5
*/
public class CacheAdapterImpl implements CacheAdapter {
+ private static final Log log = LogFactory.getLog(CacheAdapterImpl.class);
private final Cache cache;
@@ -142,6 +145,12 @@
}
}
+ public void stop() {
+ if (log.isTraceEnabled())
+ log.trace("Stop " + cache);
+ cache.stop();
+ }
+
private static boolean isClusteredInvalidation(Configuration.CacheMode cacheMode) {
return cacheMode == Configuration.CacheMode.INVALIDATION_ASYNC
|| cacheMode == Configuration.CacheMode.INVALIDATION_SYNC;
Modified: core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java
===================================================================
--- core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java 2010-08-31 15:09:48 UTC (rev 20288)
+++ core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java 2010-08-31 15:15:25 UTC (rev 20289)
@@ -151,11 +151,6 @@
super.tearDown();
- if (localCollectionRegion != null)
- localCollectionRegion.destroy();
- if (remoteCollectionRegion != null)
- remoteCollectionRegion.destroy();
-
try {
localCache.withFlags(FlagAdapter.CACHE_MODE_LOCAL).clear();
} catch (Exception e) {
Modified: core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractEntityRegionAccessStrategyTestCase.java
===================================================================
--- core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractEntityRegionAccessStrategyTestCase.java 2010-08-31 15:09:48 UTC (rev 20288)
+++ core/branches/Branch_3_5/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractEntityRegionAccessStrategyTestCase.java 2010-08-31 15:15:25 UTC (rev 20289)
@@ -138,11 +138,6 @@
super.tearDown();
- if (localEntityRegion != null)
- localEntityRegion.destroy();
- if (remoteEntityRegion != null)
- remoteEntityRegion.destroy();
-
try {
localCache.withFlags(FlagAdapter.CACHE_MODE_LOCAL).clear();
} catch (Exception e) {
14 years, 2 months
Hibernate SVN: r20288 - in core/trunk/cache-infinispan/src: main/java/org/hibernate/cache/infinispan/impl and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2010-08-31 11:09:48 -0400 (Tue, 31 Aug 2010)
New Revision: 20288
Modified:
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/JndiInfinispanRegionFactory.java
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapter.java
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapterImpl.java
core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java
core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractEntityRegionAccessStrategyTestCase.java
Log:
[HHH-5511] (Infinispan Region.destroy() impl should call cache.stop()) Fixed.
[HHH-5512] (JndiInfinispanRegionFactory shouldn't try to stop CacheManager) Fixed.
Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/JndiInfinispanRegionFactory.java
===================================================================
--- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/JndiInfinispanRegionFactory.java 2010-08-31 13:03:19 UTC (rev 20287)
+++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/JndiInfinispanRegionFactory.java 2010-08-31 15:09:48 UTC (rev 20288)
@@ -86,6 +86,10 @@
}
}
}
- }
+ }
+ @Override
+ public void stop() {
+ // Do not attempt to stop a cache manager because it wasn't created by this region factory.
+ }
}
Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java
===================================================================
--- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java 2010-08-31 13:03:19 UTC (rev 20287)
+++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java 2010-08-31 15:09:48 UTC (rev 20288)
@@ -150,7 +150,8 @@
public void destroy() throws CacheException {
try {
- cacheAdapter.clear();
+ cacheAdapter.stop();
+// cacheAdapter.clear();
} finally {
cacheAdapter.removeListener(this);
}
Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapter.java
===================================================================
--- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapter.java 2010-08-31 13:03:19 UTC (rev 20287)
+++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapter.java 2010-08-31 15:09:48 UTC (rev 20288)
@@ -157,6 +157,11 @@
void clear() throws CacheException;
/**
+ * Stops the cache.
+ */
+ void stop();
+
+ /**
* Add listener to this cache.
*
* @param listener to be added to cache.
Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapterImpl.java
===================================================================
--- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapterImpl.java 2010-08-31 13:03:19 UTC (rev 20287)
+++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheAdapterImpl.java 2010-08-31 15:09:48 UTC (rev 20288)
@@ -32,6 +32,8 @@
import org.infinispan.context.Flag;
import org.infinispan.remoting.rpc.RpcManager;
import org.infinispan.util.concurrent.TimeoutException;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
/**
* CacheAdapterImpl.
@@ -40,6 +42,7 @@
* @since 3.5
*/
public class CacheAdapterImpl implements CacheAdapter {
+ private static final Log log = LogFactory.getLog(CacheAdapterImpl.class);
private final Cache cache;
@@ -142,6 +145,12 @@
}
}
+ public void stop() {
+ if (log.isTraceEnabled())
+ log.trace("Stop " + cache);
+ cache.stop();
+ }
+
private static boolean isClusteredInvalidation(Configuration.CacheMode cacheMode) {
return cacheMode == Configuration.CacheMode.INVALIDATION_ASYNC
|| cacheMode == Configuration.CacheMode.INVALIDATION_SYNC;
Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java
===================================================================
--- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java 2010-08-31 13:03:19 UTC (rev 20287)
+++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java 2010-08-31 15:09:48 UTC (rev 20288)
@@ -151,11 +151,6 @@
super.tearDown();
- if (localCollectionRegion != null)
- localCollectionRegion.destroy();
- if (remoteCollectionRegion != null)
- remoteCollectionRegion.destroy();
-
try {
localCache.withFlags(FlagAdapter.CACHE_MODE_LOCAL).clear();
} catch (Exception e) {
Modified: core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractEntityRegionAccessStrategyTestCase.java
===================================================================
--- core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractEntityRegionAccessStrategyTestCase.java 2010-08-31 13:03:19 UTC (rev 20287)
+++ core/trunk/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractEntityRegionAccessStrategyTestCase.java 2010-08-31 15:09:48 UTC (rev 20288)
@@ -138,11 +138,6 @@
super.tearDown();
- if (localEntityRegion != null)
- localEntityRegion.destroy();
- if (remoteEntityRegion != null)
- remoteEntityRegion.destroy();
-
try {
localCache.withFlags(FlagAdapter.CACHE_MODE_LOCAL).clear();
} catch (Exception e) {
14 years, 2 months
Hibernate SVN: r20287 - core/trunk/documentation/quickstart/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-31 09:03:19 -0400 (Tue, 31 Aug 2010)
New Revision: 20287
Modified:
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_annotations.xml
Log:
HHH-5444 - Write annotations tutorial chapter
Modified: core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_annotations.xml
===================================================================
--- core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_annotations.xml 2010-08-31 12:43:29 UTC (rev 20286)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_annotations.xml 2010-08-31 13:03:19 UTC (rev 20287)
@@ -34,44 +34,65 @@
<title>The annotated entity Java class</title>
<para>
The entity class in this tutorial is <classname>org.hibernate.tutorial.annotations.Event</classname>
- <itemizedlist>
- <title>Notes About the Entity</title>
- <listitem>
- <para>
- The entity class is still using JavaBean conventions. In fact the class itself is exactly
- the same as we saw in <xref linkend="hibernate-gsg-tutorial-basic-entity"/>, the only
- difference being the use of annotations to provide the metadata instead of a separate
- <filename>hbm.xml</filename> file.
- </para>
- </listitem>
- <listitem>
- <para>
- The <interfacename>@javax.persistence.Entity</interfacename> annotation is used to mark a
- class as an entity. It's function is essentially the same as the <literal>class</literal>
- mapping element discussed in <xref linkend="hibernate-gsg-tutorial-basic-mapping"/>.
- Additionally the <interfacename>@javax.persistence.Table</interfacename> annotation is
- used to explicitly specify the table name (the default table name would have been
- <database class="table">EVENT</database>).
- </para>
- </listitem>
- <listitem>
- <para>
- <interfacename>@javax.persistence.Id</interfacename> marks the property defining the
- entity's identifier. <interfacename>@javax.persistence.GeneratedValue</interfacename> and
- <interfacename>@org.hibernate.annotations.GenericGenerator</interfacename> work in tandem
- to indicate that Hibernate should use Hibernate's <literal>increment</literal> generation
- strategy for this entity's identifier values.
- </para>
- </listitem>
- <listitem>
- <para>
- Just as discussed in <xref linkend="hibernate-gsg-tutorial-basic-mapping"/>, the
- <literal>date</literal> property needs special handling to account for its special naming
- and its SQL type.
- </para>
- </listitem>
- </itemizedlist>
+ which is still following JavaBean conventions. In fact the class itself is exactly the same as we saw
+ in <xref linkend="hibernate-gsg-tutorial-basic-entity"/>, the only difference being the use of
+ annotations to provide the metadata instead of a separate <filename>hbm.xml</filename> file.
</para>
+
+ <example id="hibernate-gsg-tutorial-basic-entity-entity">
+ <title>Identifying the class as an entity</title>
+ <programlisting role="JAVA">@Entity
+@Table( name = "EVENTS" )
+public class Event {
+ ...
+}</programlisting>
+ </example>
+
+ <para>
+ The <interfacename>@javax.persistence.Entity</interfacename> annotation is used to mark a
+ class as an entity. It's function is essentially the same as the <literal>class</literal>
+ mapping element discussed in <xref linkend="hibernate-gsg-tutorial-basic-mapping"/>.
+ Additionally the <interfacename>@javax.persistence.Table</interfacename> annotation is
+ used to explicitly specify the table name (the default table name would have been
+ <database class="table">EVENT</database>).
+ </para>
+
+ <example id="hibernate-gsg-tutorial-basic-entity-id">
+ <title>Identifying the identifier property</title>
+ <programlisting role="JAVA">@Id
+@GeneratedValue(generator="increment")
+@GenericGenerator(name="increment", strategy = "increment")
+public Long getId() {
+ return id;
+}</programlisting>
+ </example>
+
+ <para>
+ <interfacename>@javax.persistence.Id</interfacename> marks the property defining the
+ entity's identifier. <interfacename>@javax.persistence.GeneratedValue</interfacename> and
+ <interfacename>@org.hibernate.annotations.GenericGenerator</interfacename> work in tandem
+ to indicate that Hibernate should use Hibernate's <literal>increment</literal> generation
+ strategy for this entity's identifier values.
+ </para>
+
+ <example id="hibernate-gsg-tutorial-basic-entity-properties">
+ <title>Identifying basic properties</title>
+ <programlisting role="JAVA">public String getTitle() {
+ return title;
+}
+
+(a)Temporal(TemporalType.TIMESTAMP)
+@Column(name = "EVENT_DATE")
+public Date getDate() {
+ return date;
+}</programlisting>
+ </example>
+
+ <para>
+ Just as discussed in <xref linkend="hibernate-gsg-tutorial-basic-mapping"/>, the
+ <literal>date</literal> property needs special handling to account for its special naming
+ and its SQL type.
+ </para>
</section>
<section id="hibernate-gsg-tutorial-annotations-test">
14 years, 2 months