Hibernate SVN: r20210 - in core/trunk: testsuite/src/test/java/org/hibernate/test/cascade and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2010-08-20 13:18:44 -0400 (Fri, 20 Aug 2010)
New Revision: 20210
Modified:
core/trunk/core/src/main/java/org/hibernate/event/def/AbstractSaveEventListener.java
core/trunk/testsuite/src/test/java/org/hibernate/test/cascade/CascadeTestWithAssignedParentIdTest.java
Log:
HHH-3334 : Cascade-save breaks if parent ID is assigned (delays insert) and child has identity ID (early insert) (Wallace Wadge)
Modified: core/trunk/core/src/main/java/org/hibernate/event/def/AbstractSaveEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/def/AbstractSaveEventListener.java 2010-08-20 13:34:56 UTC (rev 20209)
+++ core/trunk/core/src/main/java/org/hibernate/event/def/AbstractSaveEventListener.java 2010-08-20 17:18:44 UTC (rev 20210)
@@ -262,11 +262,6 @@
boolean inTxn = source.getJDBCContext().isTransactionInProgress();
boolean shouldDelayIdentityInserts = !inTxn && !requiresImmediateIdAccess;
- if ( useIdentityColumn && !shouldDelayIdentityInserts ) {
- log.trace( "executing insertions" );
- source.getActionQueue().executeInserts();
- }
-
// Put a placeholder in entries, so we don't recurse back and try to save() the
// same object again. QUESTION: should this be done before onSave() is called?
// likewise, should it be done before onUpdate()?
@@ -286,6 +281,11 @@
cascadeBeforeSave( source, persister, entity, anything );
+ if ( useIdentityColumn && !shouldDelayIdentityInserts ) {
+ log.trace( "executing insertions" );
+ source.getActionQueue().executeInserts();
+ }
+
Object[] values = persister.getPropertyValuesToInsert( entity, getMergeMap( anything ), source );
Type[] types = persister.getPropertyTypes();
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/cascade/CascadeTestWithAssignedParentIdTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/cascade/CascadeTestWithAssignedParentIdTest.java 2010-08-20 13:34:56 UTC (rev 20209)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/cascade/CascadeTestWithAssignedParentIdTest.java 2010-08-20 17:18:44 UTC (rev 20210)
@@ -59,44 +59,7 @@
return new FunctionalTestClassTestSuite( CascadeTestWithAssignedParentIdTest.class );
}
-
- /**
- * Saves the child object with the parent when both the one-to-many and
- * many-to-one associations use cascade="all"
- */
- public void testSaveChildWithParentFailureExpected() {
- if ( ! IdentityGenerator.class.isAssignableFrom( getDialect().getNativeIdentifierGeneratorClass() ) ) {
- reportSkip( "FailureExpected test passes when native id generator is not IdentityGenerator",
- "parent insert is assigned (delayed) when child is identity (early insert)" );
- fail( "test is expected to fail" );
- return;
- }
- Session session = openSession();
- Transaction txn = session.beginTransaction();
- Parent parent = new Parent();
- Child child = new Child();
- child.setParent( parent );
- parent.setChildren( Collections.singleton( child ) );
- parent.setId(new Long(123L));
- // this should figure out that the parent needs saving first since id is assigned.
- session.save( child );
- txn.commit();
- session.close();
-
- session = openSession();
- txn = session.beginTransaction();
- parent = ( Parent ) session.get( Parent.class, parent.getId() );
- assertEquals( 1, parent.getChildren().size() );
- txn.commit();
- session.close();
- }
-
public void testSaveChildWithParent() {
- if ( IdentityGenerator.class.isAssignableFrom( getDialect().getNativeIdentifierGeneratorClass() ) ) {
- reportSkip( "test is known to fail when native id generator is IdentityGenerator",
- "parent insert is assigned (delayed) when child has identity (early insert)" );
- return;
- }
Session session = openSession();
Transaction txn = session.beginTransaction();
Parent parent = new Parent();
13 years, 8 months
Hibernate SVN: r20209 - in search/trunk/hibernate-search/src/main: docbook/en-US/modules and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-08-20 09:34:56 -0400 (Fri, 20 Aug 2010)
New Revision: 20209
Added:
search/trunk/hibernate-search/src/main/docbook/en-US/modules/jmx.xml
Modified:
search/trunk/hibernate-search/src/main/docbook/en-US/master.xml
search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java
Log:
HSEARCH-278 added docs
Modified: search/trunk/hibernate-search/src/main/docbook/en-US/master.xml
===================================================================
--- search/trunk/hibernate-search/src/main/docbook/en-US/master.xml 2010-08-20 13:31:48 UTC (rev 20208)
+++ search/trunk/hibernate-search/src/main/docbook/en-US/master.xml 2010-08-20 13:34:56 UTC (rev 20209)
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- $Id$ -->
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
@@ -93,6 +92,9 @@
<xi:include href="modules/optimize.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="modules/jmx.xml"
+ xmlns:xi="http://www.w3.org/2001/XInclude" />
+
<xi:include href="modules/lucene-native.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
</book>
Added: search/trunk/hibernate-search/src/main/docbook/en-US/modules/jmx.xml
===================================================================
--- search/trunk/hibernate-search/src/main/docbook/en-US/modules/jmx.xml (rev 0)
+++ search/trunk/hibernate-search/src/main/docbook/en-US/modules/jmx.xml 2010-08-20 13:34:56 UTC (rev 20209)
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC 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.
+ ~
+ ~ 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
+ -->
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter id="search-jmx">
+ <title>JMX integration</title>
+
+ <para>Hibernate Search offers, similar to Hibernate Core, the ability to
+ manage several aspects of Search via JMX. In order to use this functionality
+ you have to set the <literal>hibernate.search.jmx_enabled</literal> property
+ in your configuration. Setting this property will give you access to the
+ Mbeans <classname>StatisticsInfoMBean</classname>,
+ <classname>IndexControlMBean</classname> and
+ <classname>IndexingProgressMonitorMBean</classname>. Depending on the
+ configuration and state of Search not all beans are available at all times.
+ Lets have a closer look at the different MBeans.</para>
+
+ <section>
+ <title>StatisticsInfoMBean</title>
+
+ <para>This MBean gives you access to information like the total number of
+ indexed entities as well as total and average Lucene query and object
+ loading times. Setting the property
+ <literal>hibernate.search.jmx_enabled</literal> will automatically
+ register the MBean, however query and object loading timings will not be
+ taken unless you also specify
+ <literal>hibernate.search.generate_statistics</literal> in your
+ configuration. The statistics offered by
+ <classname>StatisticsInfoMBean</classname> are also available
+ programmatically via <code>SearchFactory.getStatistics()</code>.</para>
+ </section>
+
+ <section>
+ <title>IndexControlMBean</title>
+
+ <para>This MBean allows to build, optimize and purge the index for a given
+ entity. Indexing occurs via the mass indexing API (see <xref
+ linkend="search-batchindex-massindexer" />). A requirement for this bean
+ to be registered in JMX is, that the Hibernate
+ <classname>SessionFactory</classname> is bound to JNDI via the
+ <literal>hibernate.session_factory_name</literal> property. Refer to the
+ Hibernate Core manual for more information on how to configure JNDI. The
+ <classname>IndexControlMBean</classname> and its API have to be considered
+ experimental.</para>
+ </section>
+
+ <section>
+ <title>IndexingProgressMonitorMBean</title>
+
+ <para>This MBean is an implementation
+ <classname>MassIndexerProgressMonitor</classname> interface. If
+ <literal>hibernate.search.jmx_enabled</literal> is enabled and the mass
+ indexer API is used the indexing progress can be followed via this bean.
+ The bean will only be bound to JMX while indexing is in progress. Once
+ indexing is completed the MBean is not longer available.</para>
+ </section>
+</chapter>
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java 2010-08-20 13:31:48 UTC (rev 20208)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java 2010-08-20 13:34:56 UTC (rev 20209)
@@ -23,7 +23,6 @@
*/
package org.hibernate.search.stat;
-import java.util.List;
import java.util.Map;
import java.util.Set;
13 years, 8 months
Hibernate SVN: r20208 - search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-08-20 09:31:48 -0400 (Fri, 20 Aug 2010)
New Revision: 20208
Added:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/MutableSearchFactoryAndJMXTest.java
Log:
HSEARCH-278 This the SearchFactory is mutable we have to be a more devensive when registring an MBean and check first whether a bean is registered.
Added: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/MutableSearchFactoryAndJMXTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/MutableSearchFactoryAndJMXTest.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/MutableSearchFactoryAndJMXTest.java 2010-08-20 13:31:48 UTC (rev 20208)
@@ -0,0 +1,60 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its 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
+ * 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.search.test.jmx;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.hibernate.search.Environment;
+import org.hibernate.search.impl.SearchFactoryBuilder;
+import org.hibernate.search.store.RAMDirectoryProvider;
+import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.test.util.ManualConfiguration;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class MutableSearchFactoryAndJMXTest extends TestCase {
+ public void testRebuildFactory() throws Exception {
+ File targetDir = SearchTestCase.getTargetDir();
+ File simpleJndiDir = new File( targetDir, "simpleJndi" );
+ simpleJndiDir.mkdir();
+
+ ManualConfiguration configuration = new ManualConfiguration()
+ .addProperty( "hibernate.search.default.directory_provider", RAMDirectoryProvider.class.getName() )
+ .addProperty( "hibernate.session_factory_name", "java:comp/SessionFactory" )
+ .addProperty( "hibernate.jndi.class", "org.osjava.sj.SimpleContextFactory" )
+ .addProperty( "hibernate.jndi.org.osjava.sj.root", simpleJndiDir.getAbsolutePath() )
+ .addProperty( "hibernate.jndi.org.osjava.sj.jndi.shared", "true" )
+ .addProperty( Environment.JMX_ENABLED, "true" );
+
+ new SearchFactoryBuilder().configuration( configuration ).buildSearchFactory();
+
+ // if there are problems with the JMX registration there will be an exception when the new factory is build
+ new SearchFactoryBuilder().configuration( configuration ).buildSearchFactory();
+ }
+}
+
+
13 years, 8 months
Hibernate SVN: r20207 - in search/trunk/hibernate-search/src: main/java/org/hibernate/search/jmx and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-08-20 09:31:16 -0400 (Fri, 20 Aug 2010)
New Revision: 20207
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/ImmutableSearchFactory.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SearchFactoryBuilder.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexingProgressMonitor.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/JMXRegistrar.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/SearchTestCase.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/configuration/mutablefactory/MutableFactoryTest.java
Log:
HSEARCH-278 This the SearchFactory is mutable we have to be a more devensive when registring an MBean and check first whether a bean is registered.
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/ImmutableSearchFactory.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/ImmutableSearchFactory.java 2010-08-20 11:01:35 UTC (rev 20206)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/ImmutableSearchFactory.java 2010-08-20 13:31:16 UTC (rev 20207)
@@ -133,6 +133,10 @@
}
if ( isJMXEnabled() ) {
+ // since the SearchFactory is mutable we might have an already existing MBean which we have to unregister first
+ if(JMXRegistrar.isNameRegistered( StatisticsInfoMBean.STATISTICS_MBEAN_OBJECT_NAME)) {
+ JMXRegistrar.unRegisterMBean( StatisticsInfoMBean.STATISTICS_MBEAN_OBJECT_NAME );
+ }
JMXRegistrar.registerMBean(
new StatisticsInfo( statistics ), StatisticsInfoMBean.STATISTICS_MBEAN_OBJECT_NAME
);
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SearchFactoryBuilder.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SearchFactoryBuilder.java 2010-08-20 11:01:35 UTC (rev 20206)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SearchFactoryBuilder.java 2010-08-20 13:31:16 UTC (rev 20207)
@@ -156,21 +156,31 @@
String enableJMX = configurationProperties.getProperty( Environment.JMX_ENABLED );
if ( "true".equalsIgnoreCase( enableJMX ) ) {
- enableIndexCrtlBean( searchFactoryImplementor );
+ enableIndexControlBean( searchFactoryImplementor );
}
return searchFactoryImplementor;
}
- private void enableIndexCrtlBean(SearchFactoryImplementor searchFactoryImplementor) {
+ private void enableIndexControlBean(SearchFactoryImplementor searchFactoryImplementor) {
if ( !searchFactoryImplementor.isJMXEnabled() ) {
return;
}
- // if we have a JNDI bound SessionFactory we can also enable the index control bean
- if ( StringHelper.isNotEmpty( configurationProperties.getProperty( "hibernate.session_factory_name" ) ) ) {
- IndexControl indexCtrlBean = new IndexControl( configurationProperties );
- JMXRegistrar.registerMBean( indexCtrlBean, IndexControl.INDEX_CTRL_MBEAN_OBJECT_NAME );
+ // if we don't have a JNDI bound SessionFactory we cannot enable the index control bean
+ if ( StringHelper.isEmpty( configurationProperties.getProperty( "hibernate.session_factory_name" ) ) ) {
+ log.debug(
+ "In order to bind the IndexControlMBean the Hibernate SessionFactory has to be available via JNDI"
+ );
+ return;
}
+
+ // since the SearchFactory is mutable we might have an already existing MBean which we have to unregister first
+ if ( JMXRegistrar.isNameRegistered( IndexControl.INDEX_CTRL_MBEAN_OBJECT_NAME ) ) {
+ JMXRegistrar.unRegisterMBean( IndexControl.INDEX_CTRL_MBEAN_OBJECT_NAME );
+ }
+
+ IndexControl indexCtrlBean = new IndexControl( configurationProperties );
+ JMXRegistrar.registerMBean( indexCtrlBean, IndexControl.INDEX_CTRL_MBEAN_OBJECT_NAME );
}
private SearchFactoryImplementor buildIncrementalSearchFactory() {
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexingProgressMonitor.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexingProgressMonitor.java 2010-08-20 11:01:35 UTC (rev 20206)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexingProgressMonitor.java 2010-08-20 13:31:16 UTC (rev 20207)
@@ -24,7 +24,6 @@
package org.hibernate.search.jmx;
import java.util.concurrent.atomic.AtomicLong;
-import javax.management.ObjectName;
import org.slf4j.Logger;
@@ -44,7 +43,7 @@
private final AtomicLong totalCounter = new AtomicLong();
private final AtomicLong entitiesLoadedCounter = new AtomicLong();
- private final ObjectName registeredName;
+ private final String registeredName;
public IndexingProgressMonitor() {
String name = IndexingProgressMonitorMBean.INDEXING_PROGRESS_MONITOR_MBEAN_OBJECT_NAME;
@@ -54,36 +53,36 @@
registeredName = JMXRegistrar.registerMBean( this, name );
}
- public void documentsAdded(long increment) {
+ public final void documentsAdded(long increment) {
documentsDoneCounter.addAndGet( increment );
}
- public void documentsBuilt(int number) {
+ public final void documentsBuilt(int number) {
documentsBuiltCounter.addAndGet( number );
}
- public void entitiesLoaded(int size) {
+ public final void entitiesLoaded(int size) {
entitiesLoadedCounter.addAndGet( size );
}
- public void addToTotalCount(long count) {
+ public final void addToTotalCount(long count) {
totalCounter.addAndGet( count );
}
- public void indexingCompleted() {
+ public final void indexingCompleted() {
log.info( "Indexing completed. Reindexed {} entities. Unregistering MBean from server", totalCounter.get() );
JMXRegistrar.unRegisterMBean( registeredName );
}
- public long getLoadedEntitiesCount() {
+ public final long getLoadedEntitiesCount() {
return entitiesLoadedCounter.get();
}
- public long getDocumentsAddedCount() {
+ public final long getDocumentsAddedCount() {
return documentsDoneCounter.get();
}
- public long getNumberOfEntitiesToIndex() {
+ public final long getNumberOfEntitiesToIndex() {
return totalCounter.get();
}
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/JMXRegistrar.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/JMXRegistrar.java 2010-08-20 11:01:35 UTC (rev 20206)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/JMXRegistrar.java 2010-08-20 13:31:16 UTC (rev 20207)
@@ -52,7 +52,7 @@
*
* @return The registered object name
*/
- public static ObjectName registerMBean(Object object, String name) {
+ public static String registerMBean(Object object, String name) {
ObjectName objectName = createObjectName( name );
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
try {
@@ -61,24 +61,25 @@
catch ( Exception e ) {
throw new SearchException( "Unable to enable MBean for Hibernate Search", e );
}
- return objectName;
+ return objectName.toString();
}
/**
* Unregister the MBean with the specified name.
*
- * @param name The object name of the bean to unregister. The {@code name} cannot be {@code null}
+ * @param name The name of the bean to unregister. The {@code name} cannot be {@code null}
*
* @throws IllegalArgumentException In case the object name is {@code null}
*/
- public static void unRegisterMBean(ObjectName name) {
+ public static void unRegisterMBean(String name) {
if ( name == null ) {
throw new IllegalArgumentException( "The object name cannot be null" );
}
+ ObjectName objectName = createObjectName( name );
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- if ( mbs.isRegistered( name ) ) {
+ if ( mbs.isRegistered( objectName ) ) {
try {
- mbs.unregisterMBean( name );
+ mbs.unregisterMBean( objectName );
}
catch ( Exception e ) {
log.warn( "Unable to un-register existing MBean: " + name, e );
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/SearchTestCase.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/SearchTestCase.java 2010-08-20 11:01:35 UTC (rev 20206)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/SearchTestCase.java 2010-08-20 13:31:16 UTC (rev 20207)
@@ -258,7 +258,7 @@
*
* @return the target directory of the build
*/
- public File getTargetDir() {
+ public static File getTargetDir() {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
// get a URL reference to something we now is part of the classpath (us)
URL myUrl = contextClassLoader.getResource( SearchTestCase.class.getName().replace( '.', '/' ) + ".class" );
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/configuration/mutablefactory/MutableFactoryTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/configuration/mutablefactory/MutableFactoryTest.java 2010-08-20 11:01:35 UTC (rev 20206)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/configuration/mutablefactory/MutableFactoryTest.java 2010-08-20 13:31:16 UTC (rev 20207)
@@ -1,3 +1,26 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its 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
+ * 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.search.test.configuration.mutablefactory;
import java.io.File;
13 years, 8 months
Hibernate SVN: r20206 - search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-08-20 07:01:35 -0400 (Fri, 20 Aug 2010)
New Revision: 20206
Removed:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ObjectLoader.java
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ProjectionLoader.java
Log:
HSEARCH-278 Made sure that ProjectionLoader does not skew object loading times
Deleted: search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ObjectLoader.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ObjectLoader.java 2010-08-20 11:01:03 UTC (rev 20205)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ObjectLoader.java 2010-08-20 11:01:35 UTC (rev 20206)
@@ -1,93 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2010, Red Hat, Inc. and/or its 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
- * 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.search.engine;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.slf4j.Logger;
-
-import org.hibernate.Session;
-import org.hibernate.search.util.HibernateHelper;
-import org.hibernate.search.util.LoggerFactory;
-
-/**
- * @author Emmanuel Bernard
- */
-public class ObjectLoader extends AbstractLoader {
- private static final Logger log = LoggerFactory.make();
- private Session session;
-
- public void init(Session session, SearchFactoryImplementor searchFactoryImplementor) {
- super.init( session, searchFactoryImplementor );
- this.session = session;
- }
-
- public final Object executeLoad(EntityInfo entityInfo) {
- return ObjectLoaderHelper.load( entityInfo, session );
- }
-
- public final List executeLoad(EntityInfo... entityInfos) {
- if ( entityInfos.length == 0 ) {
- return Collections.EMPTY_LIST;
- }
- if ( entityInfos.length == 1 ) {
- final Object entity = load( entityInfos[0] );
- if ( entity == null ) {
- return Collections.EMPTY_LIST;
- }
- else {
- final List<Object> list = new ArrayList<Object>( 1 );
- list.add( entity );
- return list;
- }
- }
- //use load to benefit from the batch-size
- //we don't face proxy casting issues since the exact class is extracted from the index
- for ( EntityInfo entityInfo : entityInfos ) {
- session.load( entityInfo.clazz, entityInfo.id );
- }
- List result = new ArrayList( entityInfos.length );
- for ( EntityInfo entityInfo : entityInfos ) {
- try {
- Object entity = session.load( entityInfo.clazz, entityInfo.id );
- HibernateHelper.initialize( entity );
- result.add( entity );
- }
- catch ( RuntimeException e ) {
- if ( LoaderHelper.isObjectNotFoundException( e ) ) {
- log.debug(
- "Object found in Search index but not in database: {} with id {}",
- entityInfo.clazz, entityInfo.id
- );
- }
- else {
- throw e;
- }
- }
- }
- return result;
- }
-}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ProjectionLoader.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ProjectionLoader.java 2010-08-20 11:01:03 UTC (rev 20205)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ProjectionLoader.java 2010-08-20 11:01:35 UTC (rev 20206)
@@ -1,26 +1,25 @@
-/* $Id$
- *
+/*
* Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat, Inc. and/or its 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
- * 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
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its 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
+ * 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.search.engine;
@@ -32,7 +31,7 @@
import org.hibernate.transform.ResultTransformer;
/**
- * Implementation of the <code>Loader</code> interface used for loading entities which are projected via
+ * Implementation of the {@code Loader} interface used for loading entities which are projected via
* {@link org.hibernate.search.ProjectionConstants#THIS}.
*
* @author Emmanuel Bernard
@@ -41,7 +40,7 @@
public class ProjectionLoader implements Loader {
private SearchFactoryImplementor searchFactoryImplementor;
private Session session;
- private Loader objectLoader;
+ private MultiClassesQueryLoader objectLoader;
private Boolean projectThis;
private ResultTransformer transformer;
private String[] aliases;
@@ -101,7 +100,8 @@
for ( EntityInfo entityInfo : entityInfos ) {
for ( int index : entityInfo.indexesOfThis ) {
// set one by one to avoid loosing null objects (skipped in the objectLoader.load( EntityInfo[] ))
- entityInfo.projection[index] = objectLoader.load( entityInfo );
+ // use objectLoader.executeLoad to prevent measuring load time again (see AbstractLoader)
+ entityInfo.projection[index] = objectLoader.executeLoad( entityInfo );
}
}
}
13 years, 8 months
Hibernate SVN: r20205 - in search/trunk/hibernate-search/src/main/java/org/hibernate/search: engine and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-08-20 07:01:03 -0400 (Fri, 20 Aug 2010)
New Revision: 20205
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/Environment.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/AbstractLoader.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/StatisticsImplementor.java
Log:
HSEARCH-278 Switched to nano second resolution for timings
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/Environment.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/Environment.java 2010-08-20 11:00:24 UTC (rev 20204)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/Environment.java 2010-08-20 11:01:03 UTC (rev 20205)
@@ -1,26 +1,25 @@
-/* $Id$
- *
+/*
* Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat, Inc. and/or its 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
- * 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
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its 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
+ * 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.search;
@@ -29,6 +28,10 @@
* @author Hardy Ferentschik
*/
public final class Environment {
+
+ private Environment() {
+ }
+
/**
* Enable listeners auto registration in Hibernate Annotations and EntityManager. Default to true.
*/
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/AbstractLoader.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/AbstractLoader.java 2010-08-20 11:00:24 UTC (rev 20204)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/AbstractLoader.java 2010-08-20 11:01:03 UTC (rev 20205)
@@ -46,11 +46,11 @@
public final Object load(EntityInfo entityInfo) {
long startTime = 0;
if ( takeTimings ) {
- startTime = System.currentTimeMillis();
+ startTime = System.nanoTime();
}
Object loadedObject = executeLoad( entityInfo );
if ( takeTimings ) {
- statisticsImplementor.objectLoadExecuted( 1, System.currentTimeMillis() - startTime );
+ statisticsImplementor.objectLoadExecuted( 1, System.nanoTime() - startTime );
}
return loadedObject;
}
@@ -60,11 +60,11 @@
public List load(EntityInfo... entityInfos) {
long startTime = 0;
if ( takeTimings ) {
- startTime = System.currentTimeMillis();
+ startTime = System.nanoTime();
}
List loadedObjects = executeLoad( entityInfos );
if ( takeTimings ) {
- statisticsImplementor.objectLoadExecuted( loadedObjects.size(), System.currentTimeMillis() - startTime );
+ statisticsImplementor.objectLoadExecuted( loadedObjects.size(), System.nanoTime() - startTime );
}
return loadedObjects;
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java 2010-08-20 11:00:24 UTC (rev 20204)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java 2010-08-20 11:01:03 UTC (rev 20205)
@@ -402,7 +402,7 @@
boolean stats = searchFactoryImplementor.getStatistics().isStatisticsEnabled();
long startTime = 0;
if ( stats ) {
- startTime = System.currentTimeMillis();
+ startTime = System.nanoTime();
}
if ( n == null ) { // try to make sure that we get the right amount of top docs
@@ -414,7 +414,7 @@
resultSize = queryHits.totalHits;
if ( stats ) {
- searchFactoryImplementor.getStatisticsImplementor().searchExecuted( query.toString(), System.currentTimeMillis() - startTime );
+ searchFactoryImplementor.getStatisticsImplementor().searchExecuted( query.toString(), System.nanoTime() - startTime );
}
return queryHits;
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java 2010-08-20 11:00:24 UTC (rev 20204)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java 2010-08-20 11:01:03 UTC (rev 20205)
@@ -47,17 +47,17 @@
long getSearchQueryExecutionCount();
/**
- * Get the total search time in milliseconds.
+ * Get the total search time in nanoseconds.
*/
long getSearchQueryTotalTime();
/**
- * Get the time in milliseconds of the slowest search.
+ * Get the time in nanoseconds of the slowest search.
*/
long getSearchQueryExecutionMaxTime();
/**
- * Get the average search time in milliseconds.
+ * Get the average search time in nanoseconds.
*/
long getSearchQueryExecutionAvgTime();
@@ -67,17 +67,17 @@
String getSearchQueryExecutionMaxTimeQueryString();
/**
- * Get the total object loading in milliseconds.
+ * Get the total object loading in nanoseconds.
*/
long getObjectLoadingTotalTime();
/**
- * Get the time in milliseconds for the slowest object load.
+ * Get the time in nanoseconds for the slowest object load.
*/
long getObjectLoadingExecutionMaxTime();
/**
- * Get the average object loading time in milliseconds.
+ * Get the average object loading time in nanoseconds.
*/
long getObjectLoadingExecutionAvgTime();
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/StatisticsImplementor.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/StatisticsImplementor.java 2010-08-20 11:00:24 UTC (rev 20204)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/StatisticsImplementor.java 2010-08-20 11:01:03 UTC (rev 20205)
@@ -26,10 +26,24 @@
package org.hibernate.search.stat;
/**
+ * Statistics SPI for the Search. This is essentially the "statistic collector" API.
+ *
* @author Hardy Ferentschik
*/
public interface StatisticsImplementor {
+ /**
+ * Callback for number of object loaded from the db.
+ *
+ * @param numberOfObjectsLoaded Number of objects loaded
+ * @param time time in nanoseconds to load the objects
+ */
void objectLoadExecuted(long numberOfObjectsLoaded, long time);
+ /**
+ * Callback for an executed Lucene search.
+ *
+ * @param searchString executed query string
+ * @param time time in nanoseconds to execute the search
+ */
void searchExecuted(String searchString, long time);
}
13 years, 8 months
Hibernate SVN: r20204 - in search/trunk/hibernate-search/src/main/java/org/hibernate/search: stat and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-08-20 07:00:24 -0400 (Fri, 20 Aug 2010)
New Revision: 20204
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/StatisticsInfo.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/StatisticsImpl.java
Log:
HSEARCH-278 Removed getIndexingParameters to avoid that string representation of the parameters will become public API
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/StatisticsInfo.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/StatisticsInfo.java 2010-08-20 10:59:44 UTC (rev 20203)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/StatisticsInfo.java 2010-08-20 11:00:24 UTC (rev 20204)
@@ -25,7 +25,6 @@
// $Id:$
package org.hibernate.search.jmx;
-import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -101,10 +100,6 @@
return delegate.getNumberOfIndexedEntities( entity );
}
- public List<String> getIndexingParameters(String entity) {
- return delegate.getIndexingParameters( entity );
- }
-
public Map<String, Integer> indexedEntitiesCount() {
return delegate.indexedEntitiesCount();
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java 2010-08-20 10:59:44 UTC (rev 20203)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/Statistics.java 2010-08-20 11:00:24 UTC (rev 20204)
@@ -122,18 +122,6 @@
int getNumberOfIndexedEntities(String entity);
/**
- * A list of string representations of the indexing parameters for each directory of the specified entity.
- * Defaults are not displayed, but only parameters which are explicitly set via the configuration.
- *
- * @param entity the fqc of the entity
- *
- * @return A list of string representations of the indexing parameters for each directory of the specified entity
- *
- * @throws IllegalArgumentException in case the entity name is not valid
- */
- List<String> getIndexingParameters(String entity);
-
- /**
* Returns a map of all indexed entities and their document count in the index.
*
* @return a map of all indexed entities and their document count. The map key is the fqc of the entity and
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/StatisticsImpl.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/StatisticsImpl.java 2010-08-20 10:59:44 UTC (rev 20203)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/stat/StatisticsImpl.java 2010-08-20 11:00:24 UTC (rev 20204)
@@ -24,10 +24,8 @@
package org.hibernate.search.stat;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
@@ -52,6 +50,8 @@
import org.hibernate.util.ReflectHelper;
/**
+ * A concurrent implementation of the {@code Statistics} interface.
+ *
* @author Hardy Ferentschik
*/
public class StatisticsImpl implements Statistics, StatisticsImplementor {
@@ -238,15 +238,6 @@
return countPerEntity;
}
- public List<String> getIndexingParameters(String entity) {
- Class<?> clazz = getEntityClass( entity );
- List<String> indexingParameters = new ArrayList<String>();
- for ( DirectoryProvider directoryProvider : searchFactoryImplementor.getDirectoryProviders( clazz ) ) {
- indexingParameters.add( searchFactoryImplementor.getIndexingParameters( directoryProvider ).toString() );
- }
- return indexingParameters;
- }
-
private Class<?> getEntityClass(String entity) {
Class<?> clazz;
try {
13 years, 8 months
Hibernate SVN: r20203 - in search/trunk/hibernate-search: src/main/java/org/hibernate/search and 6 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-08-20 06:59:44 -0400 (Fri, 20 Aug 2010)
New Revision: 20203
Added:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexControl.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexControlMBean.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/IndexControlMBeanTest.java
Removed:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrl.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrlMBean.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/IndexCtrlMBeanTest.java
Modified:
search/trunk/hibernate-search/pom.xml
search/trunk/hibernate-search/src/main/java/org/hibernate/search/ProjectionConstants.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/UpdatableBackendQueueProcessorFactory.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/batchlucene/LuceneBatchBackend.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SearchFactoryBuilder.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/spi/SearchFactoryIntegrator.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/NoMBeansEnabledTest.java
Log:
HSEARCH-278 Renamed IndexCtrl to IndexControl and marked IndexControlMBean as experimental. Introduced @experimental in order to have a more formal way to mark something as such
Modified: search/trunk/hibernate-search/pom.xml
===================================================================
--- search/trunk/hibernate-search/pom.xml 2010-08-20 05:23:28 UTC (rev 20202)
+++ search/trunk/hibernate-search/pom.xml 2010-08-20 10:59:44 UTC (rev 20203)
@@ -226,6 +226,13 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
+ <tags>
+ <tag>
+ <name>experimental</name>
+ <placement>a</placement>
+ <head>Experimental</head>
+ </tag>
+ </tags>
<docfilessubdirs>true</docfilessubdirs>
<stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css</stylesheetfile>
<links>
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/ProjectionConstants.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/ProjectionConstants.java 2010-08-20 05:23:28 UTC (rev 20202)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/ProjectionConstants.java 2010-08-20 10:59:44 UTC (rev 20203)
@@ -1,26 +1,25 @@
-/* $Id$
- *
+/*
* Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat, Inc. and/or its 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
- * 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
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its 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
+ * 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.search;
@@ -58,10 +57,11 @@
public String ID = "__HSearch_id";
/**
- * Lucene Document id
- * Experimental: If you use this feature, please speak up in the forum
+ * Lucene Document id.
* <p/>
* Expert: Lucene document id can change overtime between 2 different IndexReader opening.
+ *
+ * @experimental If you use this constant/feature, please speak up in the forum
*/
public String DOCUMENT_ID = "__HSearch_DocumentId";
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/UpdatableBackendQueueProcessorFactory.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/UpdatableBackendQueueProcessorFactory.java 2010-08-20 05:23:28 UTC (rev 20202)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/UpdatableBackendQueueProcessorFactory.java 2010-08-20 10:59:44 UTC (rev 20203)
@@ -1,3 +1,26 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its 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
+ * 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.search.backend;
import java.util.Set;
@@ -6,10 +29,10 @@
import org.hibernate.search.store.DirectoryProvider;
/**
- * Experimental
- * Allow a BackendQueueProcessorFactory to be notified of DiurectoryProvider changes
+ * Allow a BackendQueueProcessorFactory to be notified of {@code DirectoryProvider} changes.
*
* @author Emmanuel Bernard
+ * @experimental This API is experimental
*/
public interface UpdatableBackendQueueProcessorFactory extends BackendQueueProcessorFactory {
/**
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/batchlucene/LuceneBatchBackend.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/batchlucene/LuceneBatchBackend.java 2010-08-20 05:23:28 UTC (rev 20202)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/batchlucene/LuceneBatchBackend.java 2010-08-20 10:59:44 UTC (rev 20203)
@@ -43,11 +43,12 @@
import org.hibernate.search.store.IndexShardingStrategy;
/**
- * First EXPERIMENTAL BatchBackend; this is not meant to be used as a regular
+ * This is not meant to be used as a regular
* backend, only to apply batch changes to the index. Several threads
* are used to make changes to each index, so order of Work processing is not guaranteed.
*
* @author Sanne Grinovero
+ * @experimental First {@code BatchBackend}
*/
public class LuceneBatchBackend implements BatchBackend {
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SearchFactoryBuilder.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SearchFactoryBuilder.java 2010-08-20 05:23:28 UTC (rev 20202)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SearchFactoryBuilder.java 2010-08-20 10:59:44 UTC (rev 20203)
@@ -74,7 +74,7 @@
import org.hibernate.search.filter.FilterCachingStrategy;
import org.hibernate.search.filter.MRUFilterCachingStrategy;
import org.hibernate.search.filter.ShardSensitiveOnlyFilter;
-import org.hibernate.search.jmx.IndexCtrl;
+import org.hibernate.search.jmx.IndexControl;
import org.hibernate.search.jmx.JMXRegistrar;
import org.hibernate.search.reader.ReaderProvider;
import org.hibernate.search.reader.ReaderProviderFactory;
@@ -168,8 +168,8 @@
// if we have a JNDI bound SessionFactory we can also enable the index control bean
if ( StringHelper.isNotEmpty( configurationProperties.getProperty( "hibernate.session_factory_name" ) ) ) {
- IndexCtrl indexCtrlBean = new IndexCtrl( configurationProperties );
- JMXRegistrar.registerMBean( indexCtrlBean, IndexCtrl.INDEX_CTRL_MBEAN_OBJECT_NAME );
+ IndexControl indexCtrlBean = new IndexControl( configurationProperties );
+ JMXRegistrar.registerMBean( indexCtrlBean, IndexControl.INDEX_CTRL_MBEAN_OBJECT_NAME );
}
}
Copied: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexControl.java (from rev 20181, search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrl.java)
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexControl.java (rev 0)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexControl.java 2010-08-20 10:59:44 UTC (rev 20203)
@@ -0,0 +1,155 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its 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
+ * 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.search.jmx;
+
+import java.util.Properties;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.hibernate.CacheMode;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.util.JNDIHelper;
+import org.hibernate.util.ReflectHelper;
+
+
+/**
+ * Implementation of the {@code IndexControlMBean} JMX attributes and operations.
+ *
+ * @author Hardy Ferentschik
+ */
+public class IndexControl implements IndexControlMBean {
+ private static final String HIBERNATE_JNDI_PREFIX = "hibernate.jndi.";
+
+ private final Properties jndiProperties;
+ private final String sessionFactoryJndiName;
+
+ private int batchSize = 25;
+ private int numberOfObjectLoadingThreads = 2;
+ private int numberOfFetchingThreads = 4;
+
+ public IndexControl(Properties props) {
+ this.sessionFactoryJndiName = props.getProperty( "hibernate.session_factory_name" );
+ this.jndiProperties = JNDIHelper.getJndiProperties( props, HIBERNATE_JNDI_PREFIX );
+ }
+
+ public void setBatchSize(int batchSize) {
+ this.batchSize = batchSize;
+ }
+
+ public int getBatchSize() {
+ return batchSize;
+ }
+
+ public void setNumberOfObjectLoadingThreads(int numberOfThreads) {
+ this.numberOfObjectLoadingThreads = numberOfThreads;
+ }
+
+ public int getNumberOfObjectLoadingThreads() {
+ return numberOfObjectLoadingThreads;
+ }
+
+ public void setNumberOfFetchingThreads(int numberOfThreads) {
+ this.numberOfFetchingThreads = numberOfThreads;
+ }
+
+ public int getNumberOfFetchingThreads() {
+ return numberOfFetchingThreads;
+ }
+
+ public void index(String entity) {
+ Class<?> clazz = getEntityClass( entity );
+
+ SessionFactory factory = getSessionFactory();
+ Session session = factory.openSession();
+ FullTextSession fulltextSession = Search.getFullTextSession( session );
+ try {
+ fulltextSession.createIndexer( clazz )
+ .batchSizeToLoadObjects( batchSize )
+ .cacheMode( CacheMode.NORMAL )
+ .threadsToLoadObjects( numberOfObjectLoadingThreads )
+ .threadsForSubsequentFetching( numberOfFetchingThreads )
+ .startAndWait();
+ }
+ catch ( InterruptedException e ) {
+ throw new RuntimeException( "Unable to complete indexing" );
+ }
+ session.close();
+ }
+
+ public void optimize(String entity) {
+ Class<?> clazz = getEntityClass( entity );
+
+ SessionFactory factory = getSessionFactory();
+ Session session = factory.openSession();
+ FullTextSession fullTextSession = Search.getFullTextSession( session );
+ fullTextSession.beginTransaction();
+ fullTextSession.getSearchFactory().optimize( clazz );
+ fullTextSession.getTransaction().commit();
+ session.close();
+ }
+
+ public void purge(String entity) {
+ Class<?> clazz = getEntityClass( entity );
+
+ SessionFactory factory = getSessionFactory();
+ Session session = factory.openSession();
+ FullTextSession fullTextSession = Search.getFullTextSession( session );
+ fullTextSession.beginTransaction();
+ fullTextSession.purgeAll( clazz );
+ fullTextSession.getTransaction().commit();
+ session.close();
+ }
+
+ private Class<?> getEntityClass(String entity) {
+ Class<?> clazz;
+ try {
+ clazz = ReflectHelper.classForName( entity, IndexControl.class );
+ }
+ catch ( ClassNotFoundException e ) {
+ throw new IllegalArgumentException( entity + "not a indexed entity" );
+ }
+ return clazz;
+ }
+
+ private SessionFactory getSessionFactory() {
+ try {
+ Context initialContext;
+ if ( jndiProperties.isEmpty() ) {
+ initialContext = new InitialContext();
+ }
+ else {
+ initialContext = new InitialContext( jndiProperties );
+ }
+ return ( SessionFactory ) initialContext.lookup( sessionFactoryJndiName );
+ }
+ catch ( Exception e ) {
+ throw new UnsupportedOperationException(
+ "In order for this operation to work the SessionFactory must be bound to JNDI"
+ );
+ }
+ }
+}
\ No newline at end of file
Copied: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexControlMBean.java (from rev 20181, search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrlMBean.java)
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexControlMBean.java (rev 0)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexControlMBean.java 2010-08-20 10:59:44 UTC (rev 20203)
@@ -0,0 +1,109 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its 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
+ * 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.search.jmx;
+
+/**
+ * Defines the Hibernate Search exposed JMX attributes and operations for index creation and purging.
+ *
+ * @experimental This MBean is experimental
+ * @author Hardy Ferentschik
+ */
+public interface IndexControlMBean {
+
+ public static final String INDEX_CTRL_MBEAN_OBJECT_NAME = "org.hibernate.search.jmx:type=IndexControlMBean";
+
+ /**
+ * Sets the batch size for the mass indexer.
+ *
+ * @param batchSize the new batch size
+ */
+ void setBatchSize(int batchSize);
+
+ /**
+ * @return the current batch size for (mass) indexing
+ */
+ int getBatchSize();
+
+ /**
+ * @param numberOfThreads the number of threads used for object loading during mass indexing.
+ */
+ void setNumberOfObjectLoadingThreads(int numberOfThreads);
+
+ /**
+ * @return the current number of threads during mass indexing
+ */
+ int getNumberOfObjectLoadingThreads();
+
+ /**
+ * @param numberOfThreads the number of threads used for collections fetching during mass indexing
+ */
+ void setNumberOfFetchingThreads(int numberOfThreads);
+
+ /**
+ * @return the current number of threads used for collection fetching
+ */
+ int getNumberOfFetchingThreads();
+
+ /**
+ * Index the specified entity using the mass indexer.
+ * <p><b>Note:<br/>
+ * This method is only available if the Hibernate {@code SessionFactory}
+ * is available via JNDI.
+ * </p>
+ *
+ * @param entity The fqc of the entity to index
+ *
+ * @throws IllegalArgumentException in case the entity name is not valid
+ * @throws UnsupportedOperationException in case the Hibernate {@code SessionFactory} is not bound via JNDI.
+ */
+ void index(String entity);
+
+ /**
+ * Optimizes the index for the specified entity.
+ * <p><b>Note:<br/>
+ * This method is only available if the Hibernate {@code SessionFactory}
+ * is available via JNDI.
+ * </p>
+ *
+ * @param entity The fqc of the entity to index
+ *
+ * @throws IllegalArgumentException in case the entity name is not valid
+ * @throws UnsupportedOperationException in case the Hibernate {@code SessionFactory} is not bound via JNDI.
+ */
+ void optimize(String entity);
+
+ /**
+ * Purge the index of the specified entity.
+ * <p><b>Note:<br/>
+ * This method is only available if the Hibernate {@code SessionFactory}
+ * is available via JNDI.
+ * </p>
+ *
+ * @param entity The fqc of the entity to index
+ *
+ * @throws IllegalArgumentException in case the entity name is not valid
+ * @throws UnsupportedOperationException in case the Hibernate {@code SessionFactory} is not bound via JNDI.
+ */
+ void purge(String entity);
+}
\ No newline at end of file
Deleted: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrl.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrl.java 2010-08-20 05:23:28 UTC (rev 20202)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrl.java 2010-08-20 10:59:44 UTC (rev 20203)
@@ -1,155 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2010, Red Hat, Inc. and/or its 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
- * 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.search.jmx;
-
-import java.util.Properties;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.hibernate.CacheMode;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.search.util.JNDIHelper;
-import org.hibernate.util.ReflectHelper;
-
-
-/**
- * Implementation of the {@code IndexCtrlMBean} JMX attributes and operations.
- *
- * @author Hardy Ferentschik
- */
-public class IndexCtrl implements IndexCtrlMBean {
- private static final String HIBERNATE_JNDI_PREFIX = "hibernate.jndi.";
-
- private final Properties jndiProperties;
- private final String sessionFactoryJndiName;
-
- private int batchSize = 25;
- private int numberOfObjectLoadingThreads = 2;
- private int numberOfFetchingThreads = 4;
-
- public IndexCtrl(Properties props) {
- this.sessionFactoryJndiName = props.getProperty( "hibernate.session_factory_name" );
- this.jndiProperties = JNDIHelper.getJndiProperties( props, HIBERNATE_JNDI_PREFIX );
- }
-
- public void setBatchSize(int batchSize) {
- this.batchSize = batchSize;
- }
-
- public int getBatchSize() {
- return batchSize;
- }
-
- public void setNumberOfObjectLoadingThreads(int numberOfThreads) {
- this.numberOfObjectLoadingThreads = numberOfThreads;
- }
-
- public int getNumberOfObjectLoadingThreads() {
- return numberOfObjectLoadingThreads;
- }
-
- public void setNumberOfFetchingThreads(int numberOfThreads) {
- this.numberOfFetchingThreads = numberOfThreads;
- }
-
- public int getNumberOfFetchingThreads() {
- return numberOfFetchingThreads;
- }
-
- public void index(String entity) {
- Class<?> clazz = getEntityClass( entity );
-
- SessionFactory factory = getSessionFactory();
- Session session = factory.openSession();
- FullTextSession fulltextSession = Search.getFullTextSession( session );
- try {
- fulltextSession.createIndexer( clazz )
- .batchSizeToLoadObjects( batchSize )
- .cacheMode( CacheMode.NORMAL )
- .threadsToLoadObjects( numberOfObjectLoadingThreads )
- .threadsForSubsequentFetching( numberOfFetchingThreads )
- .startAndWait();
- }
- catch ( InterruptedException e ) {
- throw new RuntimeException( "Unable to complete indexing" );
- }
- session.close();
- }
-
- public void optimize(String entity) {
- Class<?> clazz = getEntityClass( entity );
-
- SessionFactory factory = getSessionFactory();
- Session session = factory.openSession();
- FullTextSession fullTextSession = Search.getFullTextSession( session );
- fullTextSession.beginTransaction();
- fullTextSession.getSearchFactory().optimize( clazz );
- fullTextSession.getTransaction().commit();
- session.close();
- }
-
- public void purge(String entity) {
- Class<?> clazz = getEntityClass( entity );
-
- SessionFactory factory = getSessionFactory();
- Session session = factory.openSession();
- FullTextSession fullTextSession = Search.getFullTextSession( session );
- fullTextSession.beginTransaction();
- fullTextSession.purgeAll( clazz );
- fullTextSession.getTransaction().commit();
- session.close();
- }
-
- private Class<?> getEntityClass(String entity) {
- Class<?> clazz;
- try {
- clazz = ReflectHelper.classForName( entity, IndexCtrl.class );
- }
- catch ( ClassNotFoundException e ) {
- throw new IllegalArgumentException( entity + "not a indexed entity" );
- }
- return clazz;
- }
-
- private SessionFactory getSessionFactory() {
- try {
- Context initialContext;
- if ( jndiProperties.isEmpty() ) {
- initialContext = new InitialContext();
- }
- else {
- initialContext = new InitialContext( jndiProperties );
- }
- return ( SessionFactory ) initialContext.lookup( sessionFactoryJndiName );
- }
- catch ( Exception e ) {
- throw new UnsupportedOperationException(
- "In order for this operation to work the SessionFactory must be bound to JNDI"
- );
- }
- }
-}
\ No newline at end of file
Deleted: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrlMBean.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrlMBean.java 2010-08-20 05:23:28 UTC (rev 20202)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrlMBean.java 2010-08-20 10:59:44 UTC (rev 20203)
@@ -1,108 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2010, Red Hat, Inc. and/or its 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
- * 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.search.jmx;
-
-/**
- * Defines the Hibernate Search exposed JMX attributes and operations for index creation and purging.
- *
- * @author Hardy Ferentschik
- */
-public interface IndexCtrlMBean {
-
- public static final String INDEX_CTRL_MBEAN_OBJECT_NAME = "org.hibernate.search.jmx:type=IndexCtrlMBean";
-
- /**
- * Sets the batch size for the mass indexer.
- *
- * @param batchSize the new batch size
- */
- void setBatchSize(int batchSize);
-
- /**
- * @return the current batch size for (mass) indexing
- */
- int getBatchSize();
-
- /**
- * @param numberOfThreads the number of threads used for object loading during mass indexing.
- */
- void setNumberOfObjectLoadingThreads(int numberOfThreads);
-
- /**
- * @return the current number of threads during mass indexing
- */
- int getNumberOfObjectLoadingThreads();
-
- /**
- * @param numberOfThreads the number of threads used for collections fetching during mass indexing
- */
- void setNumberOfFetchingThreads(int numberOfThreads);
-
- /**
- * @return the current number of threads used for collection fetching
- */
- int getNumberOfFetchingThreads();
-
- /**
- * Index the specified entity using the mass indexer.
- * <p><b>Note:<br/>
- * This method is only available if the Hibernate {@code SessionFactory}
- * is available via JNDI.
- * </p>
- *
- * @param entity The fqc of the entity to index
- *
- * @throws IllegalArgumentException in case the entity name is not valid
- * @throws UnsupportedOperationException in case the Hibernate {@code SessionFactory} is not bound via JNDI.
- */
- void index(String entity);
-
- /**
- * Optimizes the index for the specified entity.
- * <p><b>Note:<br/>
- * This method is only available if the Hibernate {@code SessionFactory}
- * is available via JNDI.
- * </p>
- *
- * @param entity The fqc of the entity to index
- *
- * @throws IllegalArgumentException in case the entity name is not valid
- * @throws UnsupportedOperationException in case the Hibernate {@code SessionFactory} is not bound via JNDI.
- */
- void optimize(String entity);
-
- /**
- * Purge the index of the specified entity.
- * <p><b>Note:<br/>
- * This method is only available if the Hibernate {@code SessionFactory}
- * is available via JNDI.
- * </p>
- *
- * @param entity The fqc of the entity to index
- *
- * @throws IllegalArgumentException in case the entity name is not valid
- * @throws UnsupportedOperationException in case the Hibernate {@code SessionFactory} is not bound via JNDI.
- */
- void purge(String entity);
-}
\ No newline at end of file
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/spi/SearchFactoryIntegrator.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/spi/SearchFactoryIntegrator.java 2010-08-20 05:23:28 UTC (rev 20202)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/spi/SearchFactoryIntegrator.java 2010-08-20 10:59:44 UTC (rev 20203)
@@ -1,3 +1,26 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its 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
+ * 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.search.spi;
import org.hibernate.search.SearchFactory;
@@ -14,6 +37,7 @@
* It also allows modification of some of the search factory internals:
* - today allow addition of new indexed classes.
*
+ * @experimental
* @author Emmanuel Bernard
*/
public interface SearchFactoryIntegrator extends SearchFactory {
Copied: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/IndexControlMBeanTest.java (from rev 20181, search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/IndexCtrlMBeanTest.java)
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/IndexControlMBeanTest.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/IndexControlMBeanTest.java 2010-08-20 10:59:44 UTC (rev 20203)
@@ -0,0 +1,165 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its 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
+ * 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.search.test.jmx;
+
+import java.io.File;
+import java.lang.management.ManagementFactory;
+import java.util.HashSet;
+import java.util.Set;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.search.Environment;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.jmx.IndexControlMBean;
+import org.hibernate.search.jmx.StatisticsInfoMBean;
+import org.hibernate.search.test.SearchTestCase;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class IndexControlMBeanTest extends SearchTestCase {
+ MBeanServer mbeanServer;
+ ObjectName statisticsBeanObjectName;
+ ObjectName indexBeanObjectName;
+
+ public void testIndexCtrlMBeanRegistered() throws Exception {
+ assertTrue(
+ "With the right property set the Search MBean should be registered",
+ mbeanServer.isRegistered( indexBeanObjectName )
+ );
+ }
+
+ public void testAttributesAndOperations() throws Exception {
+ MBeanInfo info = mbeanServer.getMBeanInfo( indexBeanObjectName );
+ MBeanAttributeInfo[] attributes = info.getAttributes();
+ assertEquals( "Wrong number of attributes", 3, attributes.length );
+ Set<String> attributeNames = new HashSet<String>();
+ attributeNames.add( "NumberOfObjectLoadingThreads" );
+ attributeNames.add( "NumberOfFetchingThreads" );
+ attributeNames.add( "BatchSize" );
+ for ( MBeanAttributeInfo attribute : attributes ) {
+ assertTrue( attributeNames.contains( attribute.getName() ) );
+ }
+
+ MBeanOperationInfo[] operations = info.getOperations();
+ assertEquals( "Wrong number of operations", 3, operations.length );
+ Set<String> operationNames = new HashSet<String>();
+ operationNames.add( "index" );
+ operationNames.add( "purge" );
+ operationNames.add( "optimize" );
+ for ( MBeanOperationInfo operation : operations ) {
+ assertTrue( operationNames.contains( operation.getName() ) );
+ }
+ }
+
+ public void testIndexAndPurge() throws Exception {
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ Counter counter = new Counter();
+ s.save( counter );
+ tx.commit();
+ s.close();
+
+ assertNumberOfIndexedEntities( Counter.class.getName(), 0 ); // manual indexing!
+
+ mbeanServer.invoke(
+ indexBeanObjectName,
+ "index",
+ new String[] { Counter.class.getName() },
+ new String[] { String.class.getName() }
+ );
+
+ assertNumberOfIndexedEntities( Counter.class.getName(), 1 );
+
+ mbeanServer.invoke(
+ indexBeanObjectName,
+ "purge",
+ new String[] { Counter.class.getName() },
+ new String[] { String.class.getName() }
+ );
+
+ assertNumberOfIndexedEntities( Counter.class.getName(), 0 );
+ }
+
+ protected void setUp() throws Exception {
+ setCfg( null ); // force a rebuild of the configuration
+ super.setUp();
+ mbeanServer = ManagementFactory.getPlatformMBeanServer();
+ statisticsBeanObjectName = new ObjectName( StatisticsInfoMBean.STATISTICS_MBEAN_OBJECT_NAME );
+ indexBeanObjectName = new ObjectName( IndexControlMBean.INDEX_CTRL_MBEAN_OBJECT_NAME );
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ if ( mbeanServer.isRegistered( statisticsBeanObjectName ) ) {
+ mbeanServer.unregisterMBean( statisticsBeanObjectName );
+ }
+ if ( mbeanServer.isRegistered( indexBeanObjectName ) ) {
+ mbeanServer.unregisterMBean( indexBeanObjectName );
+ }
+ }
+
+ protected void configure(Configuration cfg) {
+ super.configure( cfg );
+ File targetDir = getTargetDir();
+ File simpleJndiDir = new File( targetDir, "simpleJndi" );
+ simpleJndiDir.mkdir();
+
+ cfg.setProperty( "hibernate.session_factory_name", "java:comp/SessionFactory" );
+ cfg.setProperty( "hibernate.jndi.class", "org.osjava.sj.SimpleContextFactory" );
+ cfg.setProperty( "hibernate.jndi.org.osjava.sj.root", simpleJndiDir.getAbsolutePath() );
+ cfg.setProperty( "hibernate.jndi.org.osjava.sj.jndi.shared", "true" );
+
+ cfg.setProperty( "hibernate.search.indexing_strategy", "manual" );
+ cfg.setProperty( Environment.JMX_ENABLED, "true" );
+ }
+
+ @Override
+ protected Class<?>[] getAnnotatedClasses() {
+ return new Class<?>[] { Counter.class };
+ }
+
+ private void assertNumberOfIndexedEntities(String entity, int count)
+ throws InstanceNotFoundException, MBeanException, ReflectionException {
+ assertEquals(
+ "wrong number of indexed entities", count,
+ mbeanServer.invoke(
+ statisticsBeanObjectName,
+ "getNumberOfIndexedEntities",
+ new String[] { entity },
+ new String[] { String.class.getName() }
+ )
+ );
+ }
+}
\ No newline at end of file
Deleted: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/IndexCtrlMBeanTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/IndexCtrlMBeanTest.java 2010-08-20 05:23:28 UTC (rev 20202)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/IndexCtrlMBeanTest.java 2010-08-20 10:59:44 UTC (rev 20203)
@@ -1,165 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2010, Red Hat, Inc. and/or its 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
- * 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.search.test.jmx;
-
-import java.io.File;
-import java.lang.management.ManagementFactory;
-import java.util.HashSet;
-import java.util.Set;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.search.Environment;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.search.jmx.IndexCtrlMBean;
-import org.hibernate.search.jmx.StatisticsInfoMBean;
-import org.hibernate.search.test.SearchTestCase;
-
-/**
- * @author Hardy Ferentschik
- */
-public class IndexCtrlMBeanTest extends SearchTestCase {
- MBeanServer mbeanServer;
- ObjectName statisticsBeanObjectName;
- ObjectName indexBeanObjectName;
-
- public void testIndexCtrlMBeanRegistered() throws Exception {
- assertTrue(
- "With the right property set the Search MBean should be registered",
- mbeanServer.isRegistered( indexBeanObjectName )
- );
- }
-
- public void testAttributesAndOperations() throws Exception {
- MBeanInfo info = mbeanServer.getMBeanInfo( indexBeanObjectName );
- MBeanAttributeInfo[] attributes = info.getAttributes();
- assertEquals( "Wrong number of attributes", 3, attributes.length );
- Set<String> attributeNames = new HashSet<String>();
- attributeNames.add( "NumberOfObjectLoadingThreads" );
- attributeNames.add( "NumberOfFetchingThreads" );
- attributeNames.add( "BatchSize" );
- for ( MBeanAttributeInfo attribute : attributes ) {
- assertTrue( attributeNames.contains( attribute.getName() ) );
- }
-
- MBeanOperationInfo[] operations = info.getOperations();
- assertEquals( "Wrong number of operations", 3, operations.length );
- Set<String> operationNames = new HashSet<String>();
- operationNames.add( "index" );
- operationNames.add( "purge" );
- operationNames.add( "optimize" );
- for ( MBeanOperationInfo operation : operations ) {
- assertTrue( operationNames.contains( operation.getName() ) );
- }
- }
-
- public void testIndexAndPurge() throws Exception {
- FullTextSession s = Search.getFullTextSession( openSession() );
- Transaction tx = s.beginTransaction();
- Counter counter = new Counter();
- s.save( counter );
- tx.commit();
- s.close();
-
- assertNumberOfIndexedEntities( Counter.class.getName(), 0 ); // manual indexing!
-
- mbeanServer.invoke(
- indexBeanObjectName,
- "index",
- new String[] { Counter.class.getName() },
- new String[] { String.class.getName() }
- );
-
- assertNumberOfIndexedEntities( Counter.class.getName(), 1 );
-
- mbeanServer.invoke(
- indexBeanObjectName,
- "purge",
- new String[] { Counter.class.getName() },
- new String[] { String.class.getName() }
- );
-
- assertNumberOfIndexedEntities( Counter.class.getName(), 0 );
- }
-
- protected void setUp() throws Exception {
- setCfg( null ); // force a rebuild of the configuration
- super.setUp();
- mbeanServer = ManagementFactory.getPlatformMBeanServer();
- statisticsBeanObjectName = new ObjectName( StatisticsInfoMBean.STATISTICS_MBEAN_OBJECT_NAME );
- indexBeanObjectName = new ObjectName( IndexCtrlMBean.INDEX_CTRL_MBEAN_OBJECT_NAME );
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- if ( mbeanServer.isRegistered( statisticsBeanObjectName ) ) {
- mbeanServer.unregisterMBean( statisticsBeanObjectName );
- }
- if ( mbeanServer.isRegistered( indexBeanObjectName ) ) {
- mbeanServer.unregisterMBean( indexBeanObjectName );
- }
- }
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- File targetDir = getTargetDir();
- File simpleJndiDir = new File( targetDir, "simpleJndi" );
- simpleJndiDir.mkdir();
-
- cfg.setProperty( "hibernate.session_factory_name", "java:comp/SessionFactory" );
- cfg.setProperty( "hibernate.jndi.class", "org.osjava.sj.SimpleContextFactory" );
- cfg.setProperty( "hibernate.jndi.org.osjava.sj.root", simpleJndiDir.getAbsolutePath() );
- cfg.setProperty( "hibernate.jndi.org.osjava.sj.jndi.shared", "true" );
-
- cfg.setProperty( "hibernate.search.indexing_strategy", "manual" );
- cfg.setProperty( Environment.JMX_ENABLED, "true" );
- }
-
- @Override
- protected Class<?>[] getAnnotatedClasses() {
- return new Class<?>[] { Counter.class };
- }
-
- private void assertNumberOfIndexedEntities(String entity, int count)
- throws InstanceNotFoundException, MBeanException, ReflectionException {
- assertEquals(
- "wrong number of indexed entities", count,
- mbeanServer.invoke(
- statisticsBeanObjectName,
- "getNumberOfIndexedEntities",
- new String[] { entity },
- new String[] { String.class.getName() }
- )
- );
- }
-}
\ No newline at end of file
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/NoMBeansEnabledTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/NoMBeansEnabledTest.java 2010-08-20 05:23:28 UTC (rev 20202)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/NoMBeansEnabledTest.java 2010-08-20 10:59:44 UTC (rev 20203)
@@ -30,7 +30,7 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.search.Environment;
-import org.hibernate.search.jmx.IndexCtrlMBean;
+import org.hibernate.search.jmx.IndexControlMBean;
import org.hibernate.search.jmx.StatisticsInfoMBean;
import org.hibernate.search.test.SearchTestCase;
@@ -49,7 +49,7 @@
mbeanServer.isRegistered( name )
);
- name = new ObjectName( IndexCtrlMBean.INDEX_CTRL_MBEAN_OBJECT_NAME );
+ name = new ObjectName( IndexControlMBean.INDEX_CTRL_MBEAN_OBJECT_NAME );
assertFalse(
"Without '" + Environment.JMX_ENABLED + "' set the index control MBean should not be registered",
mbeanServer.isRegistered( name )
@@ -77,7 +77,7 @@
if ( mbeanServer.isRegistered( statisticsBeanObjectName ) ) {
mbeanServer.unregisterMBean( statisticsBeanObjectName );
}
- ObjectName indexBeanObjectName = new ObjectName( IndexCtrlMBean.INDEX_CTRL_MBEAN_OBJECT_NAME );
+ ObjectName indexBeanObjectName = new ObjectName( IndexControlMBean.INDEX_CTRL_MBEAN_OBJECT_NAME );
if ( mbeanServer.isRegistered( indexBeanObjectName ) ) {
mbeanServer.unregisterMBean( indexBeanObjectName );
}
13 years, 8 months
Hibernate SVN: r20202 - core/trunk/documentation/quickstart/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: misty(a)redhat.com
Date: 2010-08-20 01:23:28 -0400 (Fri, 20 Aug 2010)
New Revision: 20202
Modified:
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml
Log:
Rolling back to the last version Steve worked on (20171)
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-20 02:07:25 UTC (rev 20201)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml 2010-08-20 05:23:28 UTC (rev 20202)
@@ -13,11 +13,9 @@
<tip>
<para>
- The tutorials in this guide use Maven, in order to leverage its
- transitive dependency management capabilities and its integration
- with many development environments (IDEs). <!--This sounds like
- marketing! -->You can use another build tool, adapting the examples
- to fit your needs.
+ The tutorials in this guide use Maven, in order to leverage its transitive dependency management
+ capabilities and its integration with many development environments (IDEs). You can use another build
+ tool, adapting the examples to fit your needs.
</para>
</tip>
@@ -42,11 +40,8 @@
<title>Create the entity Java class</title>
<para>
- Create a file named
- <filename>src/main/java/org/hibernate/tutorial/hbm/Event.java</filename>,
- containing the text in<xref
- linkend="hibernate-gsg-tutorial-native-entity-ex1"/>.<!-- Can we
- just include these files in an example.zip? -->
+ Create a file named<filename>src/main/java/org/hibernate/tutorial/hbm/Event.java</filename>,
+ containing the text in<xref linkend="hibernate-gsg-tutorial-native-entity-ex1"/>.
</para>
<example id="hibernate-gsg-tutorial-native-entity-ex1">
@@ -88,7 +83,7 @@
<title>Create the entity mapping file</title>
<para>
- Create a file named <filename>src/main/resources/org/hibernate/tutorial/native/Event.hbm.xml</filename>,
+ Create a file named<filename>src/main/resources/org/hibernate/tutorial/native/Event.hbm.xml</filename>,
with the contents in <xref linkend="hibernate-gsg-tutorial-native-hbm-xml-ex1"/>.
</para>
@@ -106,104 +101,79 @@
</para>
<orderedlist>
- <title>Functions of the <property>class</property> element</title>
+ <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.
+ 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.
+ The <literal>table</literal> attribute names the database table which contains the data for
+ this entity.
</para>
</listitem>
</orderedlist>
<para>
- Instances of the <classname>Event</classname> class are now
- mapped to rows in the <database class="table">EVENTS</database>
- table. Hibernate uses the <literal>id</literal> element to
- uniquely identify rows in the table.
+ 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>
<important>
<para>
- It is not strictly necessary for the <literal>id</literal>
- element to map to the table's actual primary key column(s),
- but this type of mapping is conventional. 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.
+ 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>
</important>
<para>
- The <literal>id</literal> element here identifies the <database
- class="field">EVENT_ID</database> column as the primary key of
- the <database class="table">EVENTS</database> table. It also
- identifies the <literal>id</literal> property of the
- <classname>Event</classname> class as the property containing
- 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>
- The <literal>generator</literal> element nested inside the
- <literal>id</literal> element informs Hibernate about which
- strategy is used to generated primary key values for this
- entity. In this example, a sequence-like value generation is
- used.
- </para>
<para>
- 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 includes the
- <literal>column</literal> attribute, but the
- <literal>title</literal> does not. In the absence 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
- different word for the column name.
+ 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 <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. <!-- We need to decide how we mark up XML tags (elements) and parameters (attributes). -->
+ 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 absence 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>
- In some cases this automatic detection might not choose 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.
+ 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>
- <info>
+ <tip>
<para>
- 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.
+ 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>
- </info
+ </tip>
</step>
<step id="hibernate-gsg-tutorial-native-config">
@@ -219,88 +189,38 @@
</example>
<para>
- The first few <property>property</property> tags define
- information about the JDBC connection. The
- <option>connection.url</option> contains information directing
- Hibernate to use the <firstterm>H2 in-memory
- database</firstterm>. The rest of the properties are explained
- in <xref linkend="tutorial-native-config-options-explained" />.
- </para>
-
- <!-- <mapping resource="org/hibernate/tutorial/hbm/Event.hbm.xml"/> -->
+ The first few <literal>property</literal> are defining JDBC connection information. These tutorials
+ utilize the H2 in-memory database. So these are all specific to running H2 in its in-memory mode.
+ The 'connection.pool_size' is used to configure Hibernate's built-in connection pool how many
+ connections
+ to pool.
+ </para>
- <table id="tutorial-native-config-options-explained">
- <title>Configuration Options Used In the Native Configuration Example</title>
- <tgroup cols="2">
- <thead>
- <row>
- <entry><p>Property Name</p></entry>
- <entry><p>Description</p></entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><p><option>connection.pool_size</option></p></entry>
- <entry>
- <p>
- configures Hibernate's built-in connection pool to
- contain the specified number of connections.
- </p>
- <p>
- <warning> <!-- We try to limit note levels to 'note', 'info', 'warning' -->
- <para>
- The built-in Hibernate connection pool is inappropriate for
- production use. It lacks several features found on any
- decent connection pool.
- <!-- What should be used instead? -->
- </para>
- </warning>
- </p>
- </entry>
- </row>
- <row>
- <entry><p><option>dialect</option></p></entry>
- <entry>
- <p>
- specifies the particular SQL variant Hibernate should
- generate.
- </p>
- <p> <!-- I hate doing this but Docbook has a silly rule about putting <note>s inside table entries -->
- <note>
- <para>
- In most cases, Hibernate can automatically determine which
- dialect to use. This capability is valuable for applications
- which target multiple databases.
- </para>
- </note>
- </p>
- </entry>
- </row>
- <row>
- <entry><p><option>cache.provider_class</option></p></entry>
- <entry><p></p></entry><!-- Explain me -->
- </row>
- <row>
- <entry><p>show_sql</p></entry>
- <entry><p></p></entry><!-- Explain me -->
- </row>
- <row>
- <entry><p>hbm2ddl.auto</p></entry>
- <entry>
- <p>
- enables automatic generation of database schemas directly
- into the database.
- </p>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
+ <caution>
+ <para>
+ The built-in Hibernate connection pool is in no way intended for production use. It
+ lacks several features found on any decent connection pool.
+ </para>
+ </caution>
+
<para>
- Finally, the mapping files provide persistent classes to the
- configuration.
+ The <literal>dialect</literal> option specifies the particular SQL variant Hibernate should generate.
</para>
+
+ <tip>
+ <para>
+ In most cases, Hibernate is able to properly determine which dialect to use which is invaluable if
+ your application targets multiple databases.
+ </para>
+ </tip>
+
+ <para>
+ The <literal>hbm2ddl.auto</literal> option turns on automatic generation of database schemas directly
+ into the database.
+ </para>
+ <para>
+ Finally, add the mapping file(s) for persistent classes to the configuration.
+ </para>
</step>
<step id="hibernate-gsg-tutorial-native-working">
13 years, 8 months
Hibernate SVN: r20201 - sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-19 22:07:25 -0400 (Thu, 19 Aug 2010)
New Revision: 20201
Added:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Identifier.java
Modified:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractValueContainer.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ObjectName.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ValueContainer.java
Log:
make column name an identifier as well
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractValueContainer.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractValueContainer.java 2010-08-20 01:01:03 UTC (rev 20200)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractValueContainer.java 2010-08-20 02:07:25 UTC (rev 20201)
@@ -42,7 +42,11 @@
}
public Column createColumn(String name) {
- final Column column = new Column( this, name );
+ return createColumn( Identifier.toIdentifier( name ) );
+ }
+
+ public Column createColumn(Identifier identifier) {
+ final Column column = new Column( this, identifier );
values.add( column );
return column;
}
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java 2010-08-20 01:01:03 UTC (rev 20200)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java 2010-08-20 02:07:25 UTC (rev 20201)
@@ -29,14 +29,14 @@
* @author Steve Ebersole
*/
public class Column extends AbstractColumn implements Value {
- private final String name;
+ private final Identifier name;
- protected Column(ValueContainer table, String name) {
+ protected Column(ValueContainer table, Identifier name) {
super( table );
this.name = name;
}
- public String getName() {
+ public Identifier getName() {
return name;
}
Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Identifier.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Identifier.java (rev 0)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Identifier.java 2010-08-20 02:07:25 UTC (rev 20201)
@@ -0,0 +1,87 @@
+/*
+ * 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.metadata.schema;
+
+import org.hibernate.util.StringHelper;
+
+/**
+ * Models an identifier (name).
+ *
+ * @author Steve Ebersole
+ */
+public class Identifier {
+ private final String name;
+ private final boolean isQuoted;
+
+ public static Identifier toIdentifier(String name) {
+ if ( name == null ) {
+ return null;
+ }
+ final String trimmedName = name.trim();
+ return new Identifier( trimmedName, trimmedName.startsWith( "`" ) && trimmedName.endsWith( "`" ) );
+ }
+
+ public Identifier(String name, boolean quoted) {
+ if ( StringHelper.isEmpty( name ) ) {
+ throw new IllegalNameException( "Identifier text/name cannot be null" );
+ }
+ this.name = name;
+ isQuoted = quoted;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean isQuoted() {
+ return isQuoted;
+ }
+
+ @Override
+ public String toString() {
+ return isQuoted
+ ? '`' + getName() + '`'
+ : getName();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+
+ Identifier that = (Identifier) o;
+
+ return isQuoted == that.isQuoted
+ && name.equals( that.name );
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+}
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ObjectName.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ObjectName.java 2010-08-20 01:01:03 UTC (rev 20200)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ObjectName.java 2010-08-20 02:07:25 UTC (rev 20201)
@@ -23,62 +23,12 @@
*/
package org.hibernate.metadata.schema;
-import org.hibernate.util.StringHelper;
-
/**
* Models the qualified name of a database object.
*
* @author Steve Ebersole
*/
public class ObjectName {
- public static class Identifier {
- private final String name;
- private final boolean isQuoted;
-
- public Identifier(String name, boolean quoted) {
- if ( StringHelper.isEmpty( name ) ) {
- throw new IllegalNameException( "Identifier text/name cannot be null" );
- }
- this.name = name;
- isQuoted = quoted;
- }
-
- public String getName() {
- return name;
- }
-
- public boolean isQuoted() {
- return isQuoted;
- }
-
- @Override
- public String toString() {
- return isQuoted
- ? '`' + getName() + '`'
- : getName();
- }
-
- @Override
- public boolean equals(Object o) {
- if ( this == o ) {
- return true;
- }
- if ( o == null || getClass() != o.getClass() ) {
- return false;
- }
-
- Identifier that = (Identifier) o;
-
- return isQuoted == that.isQuoted
- && name.equals( that.name );
- }
-
- @Override
- public int hashCode() {
- return name.hashCode();
- }
- }
-
private final Identifier schema;
private final Identifier catalog;
private final Identifier name;
@@ -91,17 +41,13 @@
}
public ObjectName(String schemaName, String catalogName, String name) {
- this( toIdentifier( schemaName ), toIdentifier( catalogName ), toIdentifier( name ) );
+ this(
+ Identifier.toIdentifier( schemaName ),
+ Identifier.toIdentifier( catalogName ),
+ Identifier.toIdentifier( name )
+ );
}
- public static Identifier toIdentifier(String name) {
- if ( name == null ) {
- return null;
- }
- final String trimmedName = name.trim();
- return new Identifier( trimmedName, trimmedName.startsWith( "`" ) && trimmedName.endsWith( "`" ) );
- }
-
/**
* Creates a qualified name reference.
*
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ValueContainer.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ValueContainer.java 2010-08-20 01:01:03 UTC (rev 20200)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ValueContainer.java 2010-08-20 02:07:25 UTC (rev 20201)
@@ -55,7 +55,7 @@
public String toLoggableString();
/**
- * Factory method for creating a {@link Column} associated with this container.
+ * Factory method for creating a {@link Column} associated with this container using its name
*
* @param name The column name
*
@@ -64,6 +64,15 @@
public Column createColumn(String name);
/**
+ * Factory method for creating a {@link Column} associated with this container using its identifier
+ *
+ * @param name The column identifier
+ *
+ * @return The generated column
+ */
+ public Column createColumn(Identifier name);
+
+ /**
* Factory method for creating a {@link DerivedValue} associated with this container.
*
* @param fragment The value expression
13 years, 8 months