Hibernate SVN: r19849 - core/branches/Branch_3_5/core/src/main/java/org/hibernate/stat.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-06-29 03:01:11 -0400 (Tue, 29 Jun 2010)
New Revision: 19849
Modified:
core/branches/Branch_3_5/core/src/main/java/org/hibernate/stat/StatisticsImpl.java
Log:
HHH-3659 statistics: Execution time of a query
Modified: core/branches/Branch_3_5/core/src/main/java/org/hibernate/stat/StatisticsImpl.java
===================================================================
--- core/branches/Branch_3_5/core/src/main/java/org/hibernate/stat/StatisticsImpl.java 2010-06-29 06:52:24 UTC (rev 19848)
+++ core/branches/Branch_3_5/core/src/main/java/org/hibernate/stat/StatisticsImpl.java 2010-06-29 07:01:11 UTC (rev 19849)
@@ -293,6 +293,7 @@
if (hql!=null) {
QueryStatisticsImpl qs = (QueryStatisticsImpl) getQueryStatistics(hql);
qs.executed(rows, time);
+ log.info("HQL: {}, time: {}ms, rows: {}", new Object[]{hql, new Long(time), new Long(rows)});
}
}
14 years, 4 months
Hibernate SVN: r19848 - core/trunk/core/src/main/java/org/hibernate/stat.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-06-29 02:52:24 -0400 (Tue, 29 Jun 2010)
New Revision: 19848
Modified:
core/trunk/core/src/main/java/org/hibernate/stat/QueryStatisticsImpl.java
Log:
correct typo in the javadoc
Modified: core/trunk/core/src/main/java/org/hibernate/stat/QueryStatisticsImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/stat/QueryStatisticsImpl.java 2010-06-29 06:51:14 UTC (rev 19847)
+++ core/trunk/core/src/main/java/org/hibernate/stat/QueryStatisticsImpl.java 2010-06-29 06:52:24 UTC (rev 19848)
@@ -85,21 +85,21 @@
}
/**
- * average time in ms taken by the excution of this query onto the DB
+ * average time in ms taken by the execution of this query onto the DB
*/
public long getExecutionAvgTime() {
return executionAvgTime;
}
/**
- * max time in ms taken by the excution of this query onto the DB
+ * max time in ms taken by the execution of this query onto the DB
*/
public long getExecutionMaxTime() {
return executionMaxTime;
}
/**
- * min time in ms taken by the excution of this query onto the DB
+ * min time in ms taken by the execution of this query onto the DB
*/
public long getExecutionMinTime() {
return executionMinTime;
14 years, 4 months
Hibernate SVN: r19847 - core/trunk/core/src/main/java/org/hibernate/stat.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-06-29 02:51:14 -0400 (Tue, 29 Jun 2010)
New Revision: 19847
Modified:
core/trunk/core/src/main/java/org/hibernate/stat/StatisticsImpl.java
Log:
HHH-3659 statistics: Execution time of a query
Modified: core/trunk/core/src/main/java/org/hibernate/stat/StatisticsImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/stat/StatisticsImpl.java 2010-06-28 19:44:32 UTC (rev 19846)
+++ core/trunk/core/src/main/java/org/hibernate/stat/StatisticsImpl.java 2010-06-29 06:51:14 UTC (rev 19847)
@@ -293,6 +293,7 @@
if (hql!=null) {
QueryStatisticsImpl qs = (QueryStatisticsImpl) getQueryStatistics(hql);
qs.executed(rows, time);
+ log.info( "HQL: {}, time: {}ms, rows: {}", new Object[]{hql, new Long( time ), new Long( rows )} );
}
}
14 years, 4 months
Hibernate SVN: r19846 - core/branches/gradle2/databases/h2.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-06-28 15:44:32 -0400 (Mon, 28 Jun 2010)
New Revision: 19846
Added:
core/branches/gradle2/databases/h2/matrix.gradle
Log:
allow matrix.gradle file to define database testing dependencies
Added: core/branches/gradle2/databases/h2/matrix.gradle
===================================================================
--- core/branches/gradle2/databases/h2/matrix.gradle (rev 0)
+++ core/branches/gradle2/databases/h2/matrix.gradle 2010-06-28 19:44:32 UTC (rev 19846)
@@ -0,0 +1 @@
+jdbcDependency "com.h2database:h2:1.2.134"
\ No newline at end of file
14 years, 4 months
Hibernate SVN: r19845 - core/branches/gradle2/buildSrc/src/main/java/org/hibernate/gradle/testing/database.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-06-28 15:43:57 -0400 (Mon, 28 Jun 2010)
New Revision: 19845
Added:
core/branches/gradle2/buildSrc/src/main/java/org/hibernate/gradle/testing/database/IvyXmlDependency.java
Modified:
core/branches/gradle2/buildSrc/src/main/java/org/hibernate/gradle/testing/database/DatabaseMatrixPlugin.java
Log:
allow matrix.gradle file to define database testing dependencies
Modified: core/branches/gradle2/buildSrc/src/main/java/org/hibernate/gradle/testing/database/DatabaseMatrixPlugin.java
===================================================================
--- core/branches/gradle2/buildSrc/src/main/java/org/hibernate/gradle/testing/database/DatabaseMatrixPlugin.java 2010-06-28 18:47:57 UTC (rev 19844)
+++ core/branches/gradle2/buildSrc/src/main/java/org/hibernate/gradle/testing/database/DatabaseMatrixPlugin.java 2010-06-28 19:43:57 UTC (rev 19845)
@@ -2,12 +2,13 @@
import java.io.File;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import groovy.lang.Closure;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
-import org.gradle.api.file.FileCollection;
import org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,10 +48,57 @@
}
}
+ private static final String MATRIX_NODE_CONVENTION_KEY = "matrixNode";
+ private static final String MATRIX_BUILD_FILE = "matrix.gradle";
+ private static final String IVY_XML_FILE = "ivy.xml";
+
private void applyPossibleDatabaseDirectory(final File databaseDir) {
final String databaseName = databaseDir.getName();
log.debug( "Checking potential database directory : {}", databaseName );
+ MatrixNode node = null;
+
+ // 3 types of support here:
+ // 1) directory contains a file named 'matrix.gradle'
+ // 2) directory contains a file named 'ivy.xml'
+ // 3) directory contains a sub-directory named 'jdbc' containing the driver artifacts
+
+ final File matrixFile = new File( databaseDir, MATRIX_BUILD_FILE );
+ if ( matrixFile.exists() && matrixFile.isFile() ) {
+ // (1) we found the 'matrix.gradle' file
+ node = prepareFromGradleFile( matrixFile );
+ }
+ else {
+ final File ivyXmlFile = new File( databaseDir, IVY_XML_FILE );
+ if ( ivyXmlFile.exists() && ivyXmlFile.isFile() ) {
+ // (2) we found the 'ivy.xml' file
+ node = prepareFromIvyXmlFile( ivyXmlFile );
+ }
+ else {
+ final File jdbcDir = new File( databaseDir, "jdbc" );
+ if ( jdbcDir.exists() && jdbcDir.isDirectory() ) {
+ node = prepareFromJdbcDir( jdbcDir );
+ }
+ }
+ }
+
+ if ( node == null ) {
+ log.info( "" );
+ return;
+ }
+
+ final File resourcesDir = new File( matrixFile.getParentFile(), "resources" );
+ if ( resourcesDir.isDirectory() && resourcesDir.exists() ) {
+ node.getTestingRuntimeConfiguration().addDependency(
+ new DefaultSelfResolvingDependency( project.files( resourcesDir ) )
+ );
+ }
+
+ matrixNodes.add( node );
+
+
+
+
final Configuration configuration = prepareJdbcDependencies( databaseDir );
if ( configuration == null ) {
return;
@@ -58,28 +106,128 @@
configuration.setVisible( true );
configuration.setDescription( "The [" + databaseName + "] JDBC dependency configuration" );
- final File resourcesDir = new File( databaseDir, "resources" );
- if ( resourcesDir.isDirectory() && resourcesDir.exists() ) {
- configuration.addDependency(
- new DefaultSelfResolvingDependency( project.files( resourcesDir ) )
+
+ }
+
+ private MatrixNode prepareFromGradleFile(File matrixFile) {
+ MatrixDotGradleMatrixNodeImpl matrixNode = new MatrixDotGradleMatrixNodeImpl( matrixFile.getParentFile().getName() );
+ MatrixDotGradleMatrixNodeConvention convention = new MatrixDotGradleMatrixNodeConvention( matrixNode );
+ project.getConvention().getPlugins().put( MATRIX_NODE_CONVENTION_KEY, convention );
+ try {
+ project.apply( Collections.singletonMap( "from", matrixFile ) );
+ }
+ finally {
+ project.getConvention().getPlugins().remove( MATRIX_NODE_CONVENTION_KEY );
+ }
+ return matrixNode;
+ }
+
+ /**
+ * {@link MatrixNode} implementation for handling 'matrix.gradle' files
+ */
+ private class MatrixDotGradleMatrixNodeImpl implements MatrixNode {
+ private final String name;
+ private final Configuration jdbcDependencies;
+ private Jdk jdk;
+
+ public MatrixDotGradleMatrixNodeImpl(String name) {
+ this.name = name;
+ this.jdbcDependencies = prepareConfiguration( name );
+ this.jdk = getDefaultJdk();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Configuration getTestingRuntimeConfiguration() {
+ return jdbcDependencies;
+ }
+
+ public Jdk getTestingRuntimeJdk() {
+ return jdk;
+ }
+ }
+
+ /**
+ * Provides simplified convention object to the database-specific script for convenient configuration.
+ */
+ private class MatrixDotGradleMatrixNodeConvention {
+ private final MatrixDotGradleMatrixNodeImpl matrixNode;
+
+ private MatrixDotGradleMatrixNodeConvention(MatrixDotGradleMatrixNodeImpl matrixNode) {
+ this.matrixNode = matrixNode;
+ }
+
+ public void jdbcDependency(Object dependencyNotation, Closure closure) {
+ project.getDependencies().add( matrixNode.jdbcDependencies.getName(), dependencyNotation, closure );
+ }
+
+ public void jdbcDependency(Object dependencyNotation) {
+ project.getDependencies().add( matrixNode.jdbcDependencies.getName(), dependencyNotation );
+ }
+
+ public void jdk(Jdk jdk) {
+ matrixNode.jdk = jdk;
+ }
+ }
+
+ private MatrixNode prepareFromIvyXmlFile(File ivyXmlFile) {
+ return new IvyXmlMatrixNode( ivyXmlFile );
+ }
+
+ private class IvyXmlMatrixNode implements MatrixNode {
+ private final String name;
+ private final Configuration jdbcDependencies;
+ private final Jdk jdk = getDefaultJdk();
+
+ private IvyXmlMatrixNode(File ivyXmlFile) {
+ name = ivyXmlFile.getParentFile().getName();
+ jdbcDependencies = getOrCreateConfiguration( name );
+ jdbcDependencies.addDependency( new IvyXmlDependency( project, ivyXmlFile ) );
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Configuration getTestingRuntimeConfiguration() {
+ return jdbcDependencies;
+ }
+
+ public Jdk getTestingRuntimeJdk() {
+ return jdk;
+ }
+ }
+
+ private MatrixNode prepareFromJdbcDir(File jdbcDir) {
+ return new LocalMatrixNode( jdbcDir );
+ }
+
+ private class LocalMatrixNode implements MatrixNode {
+ private final String name;
+ private final Configuration jdbcDependencies;
+ private final Jdk jdk = getDefaultJdk();
+
+ private LocalMatrixNode(File jdbcDir) {
+ name = jdbcDir.getParentFile().getName();
+ jdbcDependencies = getOrCreateConfiguration( name );
+ jdbcDependencies.addDependency(
+ new DefaultSelfResolvingDependency( project.files( (File[]) jdbcDir.listFiles() ) )
);
}
- matrixNodes.add(
- new MatrixNode() {
- public String getName() {
- return databaseName;
- }
+ public String getName() {
+ return name;
+ }
- public Configuration getTestingRuntimeConfiguration() {
- return configuration;
- }
+ public Configuration getTestingRuntimeConfiguration() {
+ return jdbcDependencies;
+ }
- public Jdk getTestingRuntimeJdk() {
- return null;
- }
- }
- );
+ public Jdk getTestingRuntimeJdk() {
+ return jdk;
+ }
}
private Configuration prepareJdbcDependencies(File databaseDir) {
@@ -125,4 +273,23 @@
public List<MatrixNode> getMatrixNodes() {
return matrixNodes;
}
+
+ private Configuration prepareConfiguration(String name) {
+ Configuration configuration = getOrCreateConfiguration( name );
+ configuration.setVisible( true );
+ configuration.setDescription( "The [" + name + "] JDBC dependency configuration" );
+ return configuration;
+ }
+
+ private Configuration getOrCreateConfiguration(String configurationName) {
+ Configuration configuration = project.getConfigurations().findByName( configurationName );
+ if ( configuration == null ) {
+ configuration = project.getConfigurations().add( configurationName );
+ }
+ return configuration;
+ }
+
+ private Jdk getDefaultJdk() {
+ return (Jdk) project.getProperties().get( "java5Home" );
+ }
}
Added: core/branches/gradle2/buildSrc/src/main/java/org/hibernate/gradle/testing/database/IvyXmlDependency.java
===================================================================
--- core/branches/gradle2/buildSrc/src/main/java/org/hibernate/gradle/testing/database/IvyXmlDependency.java (rev 0)
+++ core/branches/gradle2/buildSrc/src/main/java/org/hibernate/gradle/testing/database/IvyXmlDependency.java 2010-06-28 19:43:57 UTC (rev 19845)
@@ -0,0 +1,194 @@
+package org.hibernate.gradle.testing.database;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ivy.Ivy;
+import org.apache.ivy.core.cache.DefaultRepositoryCacheManager;
+import org.apache.ivy.core.cache.RepositoryCacheManager;
+import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.ResolveReport;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.resolver.DependencyResolver;
+import org.gradle.api.Project;
+import org.gradle.api.artifacts.repositories.InternalRepository;
+import org.gradle.api.internal.artifacts.IvyService;
+import org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer;
+import org.gradle.api.internal.artifacts.configurations.ResolverProvider;
+import org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency;
+import org.gradle.api.internal.artifacts.ivyservice.DefaultIvyService;
+import org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingIvyService;
+import org.gradle.api.internal.artifacts.ivyservice.IvyFactory;
+import org.gradle.api.internal.artifacts.ivyservice.SettingsConverter;
+import org.gradle.api.internal.artifacts.ivyservice.ShortcircuitEmptyConfigsIvyService;
+import org.gradle.api.internal.file.AbstractFileCollection;
+import org.gradle.invocation.DefaultGradle;
+
+import org.hibernate.gradle.util.BuildException;
+import org.hibernate.gradle.util.ResolutionException;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class IvyXmlDependency extends DefaultSelfResolvingDependency {
+ private final String name;
+
+ public IvyXmlDependency(Project project, File ivyXmlFile) {
+ super( new IvyXmlDependencyFileCollection( project, ivyXmlFile ) );
+ this.name = ivyXmlFile.getParentFile().getName() + '/' + ivyXmlFile.getName();
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public IvyXmlDependencyFileCollection getSource() {
+ return (IvyXmlDependencyFileCollection) super.getSource();
+ }
+
+ private static class IvyXmlDependencyFileCollection extends AbstractFileCollection {
+ private final Project project;
+ private final File ivyXmlFile;
+ private Set<File> resolvedDependencyFiles;
+
+ private IvyXmlDependencyFileCollection(Project project, File ivyXmlFile) {
+ this.project = project;
+ this.ivyXmlFile = ivyXmlFile;
+ }
+
+ public File getIvyXmlFile() {
+ return ivyXmlFile;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return ivyXmlFile.getAbsolutePath();
+ }
+
+ public Set<File> getFiles() {
+ if ( resolvedDependencyFiles == null ) {
+ resolvedDependencyFiles = resolveDependencyFiles();
+ }
+ return resolvedDependencyFiles;
+ }
+
+ private Set<File> resolveDependencyFiles() {
+ DefaultIvyService ivyService = unwrap(
+ ( (DefaultConfigurationContainer) project.getConfigurations() ).getIvyService()
+ );
+
+ final ModuleDescriptor moduleDescriptor = resolveIvyXml( ivyService );
+
+ DefaultRepositoryCacheManager repositoryCacheManager = null;
+ final ResolverProvider resolverProvider = ivyService.getResolverProvider();
+ for ( DependencyResolver resolver : resolverProvider.getResolvers() ) {
+ RepositoryCacheManager potentialRepositoryCacheManager = resolver.getRepositoryCacheManager();
+ if ( DefaultRepositoryCacheManager.class.isInstance( potentialRepositoryCacheManager ) ) {
+ repositoryCacheManager = (DefaultRepositoryCacheManager) potentialRepositoryCacheManager;
+ }
+ }
+ if ( repositoryCacheManager == null ) {
+ throw buildResolutionException( moduleDescriptor.getModuleRevisionId(), "Unable to locate proper dependency cache manager" );
+ }
+
+ HashSet<File> dependencyFiles = new HashSet<File>();
+ for ( DependencyDescriptor dependencyDescriptor : moduleDescriptor.getDependencies() ) {
+ final ModuleRevisionId info = dependencyDescriptor.getDynamicConstraintDependencyRevisionId();
+
+ dependencyFiles.add( repositoryCacheManager.getIvyFileInCache( info ) );
+ }
+
+ return dependencyFiles;
+ }
+
+ private DefaultIvyService unwrap(IvyService ivyService) {
+ if ( DefaultIvyService.class.isInstance( ivyService ) ) {
+ return (DefaultIvyService) ivyService;
+ }
+
+ if ( ErrorHandlingIvyService.class.isInstance( ivyService ) ) {
+ return unwrap( ( (ErrorHandlingIvyService) ivyService ).getIvyService() );
+ }
+
+ if ( ShortcircuitEmptyConfigsIvyService.class.isInstance( ivyService ) ) {
+ return unwrap( ( (ShortcircuitEmptyConfigsIvyService) ivyService ).getIvyService() );
+ }
+
+ throw new BuildException( "Do not know how to extract needed ivy config from ivy service of type " + ivyService.getClass().getName() );
+ }
+
+ private ModuleDescriptor resolveIvyXml(DefaultIvyService ivyService) {
+ Ivy ivy = locateIvyService( ivyService );
+ ResolveReport resolveReport = performResolve( ivy, ivyXmlFile );
+ return resolveReport.getModuleDescriptor();
+ }
+
+ @SuppressWarnings({ "unchecked" })
+ private ResolveReport performResolve(Ivy ivy, File ivyXmlFile) {
+ try {
+ ResolveReport resolveReport = ivy.resolve( ivyXmlFile );
+ if ( resolveReport.hasError() ) {
+ throw buildResolutionException(
+ resolveReport.getModuleDescriptor().getModuleRevisionId(),
+ resolveReport.getAllProblemMessages()
+ );
+ }
+ return resolveReport;
+ }
+ catch ( ParseException e ) {
+ throw new BuildException( "Malformed ivy dependency file [" + ivyXmlFile.getName() + "]", e );
+ }
+ catch ( IOException e ) {
+ throw new BuildException( "Problem reading ivy dependency file [" + ivyXmlFile.getName() + "]", e );
+ }
+ }
+
+ private Ivy locateIvyService(DefaultIvyService ivyService) {
+ final IvyFactory ivyFactory = ivyService.getIvyFactory();
+ final SettingsConverter settingsConverter = ivyService.getSettingsConverter();
+ final ResolverProvider resolverProvider = ivyService.getResolverProvider();
+
+ // Ugh, can absolutely find no way to access this other than a bunch of recursive reflection calls to
+ // locate the build's org.gradle.api.internal.project.TopLevelBuildServiceRegistry and access its
+ // private org.gradle.api.internal.project.TopLevelBuildServiceRegistry.clientModuleRegistry field.
+ //
+ // Not sure if it is critical to reuse that map instance or not. seems to work without, but i have no
+ // idea about the ramifications.
+ Map<String, ModuleDescriptor> clientModuleRegistry = new HashMap<String, ModuleDescriptor>();
+
+ // this part is mainly DefaultIvyService#ivyForResolve
+ IvySettings ivySettings = settingsConverter.convertForResolve(
+ resolverProvider.getResolvers(),
+ project.getGradle().getGradleUserHomeDir(),
+ getGradeService( InternalRepository.class ),
+ clientModuleRegistry
+ );
+ return ivyFactory.createIvy( ivySettings );
+ }
+
+ protected <T> T getGradeService(Class<T> type) {
+ return ( (DefaultGradle) project.getGradle() ).getServiceRegistryFactory().get( type );
+ }
+ }
+
+ private static ResolutionException buildResolutionException(ModuleRevisionId descriptor, List<String> messages) {
+ return new ResolutionException( descriptor.toString(), messages );
+ }
+
+ private static ResolutionException buildResolutionException(ModuleRevisionId descriptor, String... messages) {
+ return buildResolutionException( descriptor, Arrays.asList( messages ) );
+ }
+}
14 years, 4 months
Hibernate SVN: r19844 - in search/trunk/hibernate-search/src: test/java/org/hibernate/search/test/configuration and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-06-28 14:47:57 -0400 (Mon, 28 Jun 2010)
New Revision: 19844
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/TransactionalWorker.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/configuration/ProgrammaticSearchMappingFactory.java
Log:
HSEARCH-552 Raise an exception when the object passed to the worker is not of an unindexed or contained type
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2010-06-28 18:46:57 UTC (rev 19843)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2010-06-28 18:47:57 UTC (rev 19844)
@@ -37,6 +37,7 @@
import org.hibernate.annotations.common.AssertionFailure;
import org.hibernate.search.Environment;
+import org.hibernate.search.SearchException;
import org.hibernate.search.spi.WorkerBuildContext;
import org.hibernate.search.backend.AddLuceneWork;
import org.hibernate.search.backend.BackendQueueProcessorFactory;
@@ -268,7 +269,10 @@
containedInBuilder.addWorkToQueue(
entityClass, work.getEntity(), work.getId(), work.getType(), luceneQueue, searchFactoryImplementor
);
+ return;
}
+ //should never happen but better be safe than sorry
+ throw new SearchException( "Unable to perform work. Entity Class is not @Indexed nor hosts @ContainedIn: " + entityClass);
}
public void performWorks(WorkQueue workQueue) {
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/TransactionalWorker.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/TransactionalWorker.java 2010-06-28 18:46:57 UTC (rev 19843)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/TransactionalWorker.java 2010-06-28 18:47:57 UTC (rev 19844)
@@ -29,12 +29,15 @@
import org.slf4j.Logger;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.engine.SearchFactoryImplementor;
import org.hibernate.search.spi.WorkerBuildContext;
import org.hibernate.search.backend.QueueingProcessor;
import org.hibernate.search.backend.TransactionContext;
import org.hibernate.search.backend.Work;
import org.hibernate.search.backend.WorkQueue;
import org.hibernate.search.backend.Worker;
+import org.hibernate.search.util.HibernateHelper;
import org.hibernate.search.util.LoggerFactory;
import org.hibernate.search.util.WeakIdentityHashMap;
@@ -57,8 +60,14 @@
//synchronized map since for a given transaction, we have not concurrent access
protected final WeakIdentityHashMap<Object, Synchronization> synchronizationPerTransaction = new WeakIdentityHashMap<Object, Synchronization>();
private QueueingProcessor queueingProcessor;
+ private SearchFactoryImplementor factory;
- public void performWork(Work work, TransactionContext transactionContext) {
+ public void performWork(Work<?> work, TransactionContext transactionContext) {
+ final Class<?> entityType = HibernateHelper.getClassFromWork( work );
+ if ( factory.getDocumentBuilderIndexedEntity( entityType ) == null
+ && factory.getDocumentBuilderContainedEntity( entityType ) == null ) {
+ throw new SearchException( "Unable to perform work. Entity Class is not @Indexed nor hosts @ContainedIn: " + entityType);
+ }
if ( transactionContext.isTransactionInProgress() ) {
Object transactionIdentifier = transactionContext.getTransactionIdentifier();
PostTransactionWorkQueueSynchronization txSync = ( PostTransactionWorkQueueSynchronization )
@@ -86,6 +95,7 @@
public void initialize(Properties props, WorkerBuildContext context) {
this.queueingProcessor = new BatchedQueueingProcessor( context, props );
+ this.factory = context.getUninitializedSearchFactory();
}
public void close() {
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/configuration/ProgrammaticSearchMappingFactory.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/configuration/ProgrammaticSearchMappingFactory.java 2010-06-28 18:46:57 UTC (rev 19843)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/configuration/ProgrammaticSearchMappingFactory.java 2010-06-28 18:47:57 UTC (rev 19844)
@@ -99,6 +99,7 @@
.property("items", ElementType.FIELD)
.indexEmbedded()
.entity(Item.class)
+ .indexed()
.property("description", ElementType.FIELD)
.field().name("description").analyzer("en").index(Index.TOKENIZED).store(Store.YES)
.property("productCatalog", ElementType.FIELD)
14 years, 4 months
Hibernate SVN: r19843 - in search/trunk/hibernate-search/src/main/java/org/hibernate/search: util and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-06-28 14:46:57 -0400 (Mon, 28 Jun 2010)
New Revision: 19843
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/util/HibernateHelper.java
Log:
HSEARCH-553 Mutualize class extraction logic from a Work object
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2010-06-28 18:46:13 UTC (rev 19842)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2010-06-28 18:46:57 UTC (rev 19843)
@@ -253,9 +253,7 @@
}
private <T> void addWorkToBuilderQueue(List<LuceneWork> luceneQueue, Work<T> work) {
- Class<T> entityClass = work.getEntityClass() != null ?
- work.getEntityClass() :
- HibernateHelper.getClass( work.getEntity() );
+ Class<T> entityClass = HibernateHelper.getClassFromWork( work );
DocumentBuilderIndexedEntity<T> entityBuilder = searchFactoryImplementor.getDocumentBuilderIndexedEntity( entityClass );
if ( entityBuilder != null ) {
entityBuilder.addWorkToQueue(
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/util/HibernateHelper.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/util/HibernateHelper.java 2010-06-28 18:46:13 UTC (rev 19842)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/util/HibernateHelper.java 2010-06-28 18:46:57 UTC (rev 19843)
@@ -1,6 +1,7 @@
package org.hibernate.search.util;
import org.hibernate.Hibernate;
+import org.hibernate.search.backend.Work;
/**
* @author Emmanuel Bernard
@@ -25,4 +26,10 @@
public static boolean isInitialized(Object entity) {
return Hibernate.isInitialized( entity );
}
+
+ public static <T> Class<T> getClassFromWork(Work<T> work) {
+ return work.getEntityClass() != null ?
+ work.getEntityClass() :
+ getClass( work.getEntity() );
+ }
}
14 years, 4 months
Hibernate SVN: r19842 - search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-06-28 14:46:13 -0400 (Mon, 28 Jun 2010)
New Revision: 19842
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/PolymorphicIndexHierarchy.java
Log:
Add FIXME comment on immutability work
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/PolymorphicIndexHierarchy.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/PolymorphicIndexHierarchy.java 2010-06-28 18:45:33 UTC (rev 19841)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/PolymorphicIndexHierarchy.java 2010-06-28 18:46:13 UTC (rev 19842)
@@ -13,6 +13,7 @@
/**
* Helper class which keeps track of all super classes and interfaces of the indexed entities.
*/
+//FIXME make it immutable (builder pattern)
class PolymorphicIndexHierarchy {
private static final Logger log = LoggerFactory.make();
14 years, 4 months
Hibernate SVN: r19841 - search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-06-28 14:45:33 -0400 (Mon, 28 Jun 2010)
New Revision: 19841
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/PolymorphicIndexHierarchy.java
Log:
Fix typo
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/PolymorphicIndexHierarchy.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/PolymorphicIndexHierarchy.java 2010-06-28 18:44:49 UTC (rev 19840)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/PolymorphicIndexHierarchy.java 2010-06-28 18:45:33 UTC (rev 19841)
@@ -44,18 +44,18 @@
}
Set<Class<?>> getIndexedClasses(Class<?>[] classes) {
- Set<Class<?>> idexedClasses = new HashSet<Class<?>>();
+ Set<Class<?>> indexedClasses = new HashSet<Class<?>>();
for ( Class<?> clazz : classes ) {
Set<Class<?>> set = classToIndexedClass.get( clazz );
if ( set != null ) {
// at this point we don't have to care about including indexed subclasses of a indexed class
// MultiClassesQueryLoader will take care of this later and optimise the queries
- idexedClasses.addAll( set );
+ indexedClasses.addAll( set );
}
}
if ( log.isTraceEnabled() ) {
- log.trace( "Targeted indexed classes for {}: {}", Arrays.toString( classes ), idexedClasses );
+ log.trace( "Targeted indexed classes for {}: {}", Arrays.toString( classes ), indexedClasses );
}
- return idexedClasses;
+ return indexedClasses;
}
}
14 years, 4 months
Hibernate SVN: r19840 - in search/trunk/hibernate-search/src/main/java/org/hibernate/search: impl and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-06-28 14:44:49 -0400 (Mon, 28 Jun 2010)
New Revision: 19840
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/Worker.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/PolymorphicIndexHierarchy.java
Log:
Fix improper raw generics type use
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/Worker.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/Worker.java 2010-06-28 18:44:09 UTC (rev 19839)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/Worker.java 2010-06-28 18:44:49 UTC (rev 19840)
@@ -39,7 +39,7 @@
* @param work
* @param transactionContext
*/
- void performWork(Work work, TransactionContext transactionContext);
+ void performWork(Work<?> work, TransactionContext transactionContext);
void initialize(Properties props, WorkerBuildContext context);
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/PolymorphicIndexHierarchy.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/PolymorphicIndexHierarchy.java 2010-06-28 18:44:09 UTC (rev 19839)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/PolymorphicIndexHierarchy.java 2010-06-28 18:44:49 UTC (rev 19840)
@@ -22,19 +22,19 @@
classToIndexedClass = new HashMap<Class<?>, Set<Class<?>>>();
}
- void addIndexedClass(Class indexedClass) {
+ void addIndexedClass(Class<?> indexedClass) {
addClass( indexedClass, indexedClass );
- Class superClass = indexedClass.getSuperclass();
+ Class<?> superClass = indexedClass.getSuperclass();
while ( superClass != null ) {
addClass( superClass, indexedClass );
superClass = superClass.getSuperclass();
}
- for ( Class clazz : indexedClass.getInterfaces() ) {
+ for ( Class<?> clazz : indexedClass.getInterfaces() ) {
addClass( clazz, indexedClass );
}
}
- private void addClass(Class superclass, Class indexedClass) {
+ private void addClass(Class<?> superclass, Class<?> indexedClass) {
Set<Class<?>> classesSet = classToIndexedClass.get( superclass );
if ( classesSet == null ) {
classesSet = new HashSet<Class<?>>();
@@ -45,7 +45,7 @@
Set<Class<?>> getIndexedClasses(Class<?>[] classes) {
Set<Class<?>> idexedClasses = new HashSet<Class<?>>();
- for ( Class clazz : classes ) {
+ for ( Class<?> clazz : classes ) {
Set<Class<?>> set = classToIndexedClass.get( clazz );
if ( set != null ) {
// at this point we don't have to care about including indexed subclasses of a indexed class
14 years, 4 months