Hibernate SVN: r12855 - in trunk/HibernateExt/search/src/java/org/hibernate/search: jpa and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-30 20:04:27 -0400 (Mon, 30 Jul 2007)
New Revision: 12855
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/FullTextQuery.java
trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/FullTextQuery.java
trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java
Log:
HSEARCH-89
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/FullTextQuery.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/FullTextQuery.java 2007-07-31 00:03:48 UTC (rev 12854)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/FullTextQuery.java 2007-07-31 00:04:27 UTC (rev 12855)
@@ -69,6 +69,7 @@
FullTextQuery setProjection(String... fields);
/**
+ * Will be removed in the near future
* @deprecated Use #setProjection
*
*/
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/FullTextQuery.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/FullTextQuery.java 2007-07-31 00:03:48 UTC (rev 12854)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/FullTextQuery.java 2007-07-31 00:04:27 UTC (rev 12855)
@@ -4,8 +4,10 @@
import javax.persistence.Query;
import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.Filter;
import org.hibernate.Criteria;
import org.hibernate.search.ProjectionConstants;
+import org.hibernate.search.FullTextFilter;
/**
* The base interface for lucene powered searches.
@@ -29,6 +31,15 @@
FullTextQuery setSort(Sort sort);
/**
+ * Allows to use lucene filters.
+ * Semi-deprecated? a preferred way is to use the @FullTextFilterDef approach
+ *
+ * @param filter The lucene filter.
+ * @return this for method chaining
+ */
+ FullTextQuery setFilter(Filter filter);
+
+ /**
* Returns the number of hits for this search
*
* Caution:
@@ -60,4 +71,14 @@
*
*/
FullTextQuery setProjection(String... fields);
+
+ /**
+ * Enable a given filter by its name. Returns a FullTextFilter object that allows filter parameter injection
+ */
+ FullTextFilter enableFullTextFilter(String name);
+
+ /**
+ * Disable a given filter by its name
+ */
+ void disableFullTextFilter(String name);
}
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java 2007-07-31 00:03:48 UTC (rev 12854)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java 2007-07-31 00:04:27 UTC (rev 12855)
@@ -19,6 +19,7 @@
import org.hibernate.search.jpa.FullTextQuery;
import org.hibernate.search.SearchException;
+import org.hibernate.search.FullTextFilter;
import org.hibernate.Criteria;
import org.hibernate.TypeMismatchException;
import org.hibernate.HibernateException;
@@ -33,6 +34,7 @@
import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.hql.QueryExecutionRequestException;
import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.Filter;
/**
* @author Emmanuel Bernard
@@ -51,6 +53,11 @@
return this;
}
+ public FullTextQuery setFilter(Filter filter) {
+ query.setFilter( filter );
+ return this;
+ }
+
public int getResultSize() {
return query.getResultSize();
}
@@ -65,6 +72,14 @@
return this;
}
+ public FullTextFilter enableFullTextFilter(String name) {
+ return query.enableFullTextFilter( name );
+ }
+
+ public void disableFullTextFilter(String name) {
+ query.disableFullTextFilter( name );
+ }
+
public List getResultList() {
try {
return query.list();
17 years, 5 months
Hibernate SVN: r12854 - trunk/HibernateExt/search/src/java/org/hibernate/search/impl.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-30 20:03:48 -0400 (Mon, 30 Jul 2007)
New Revision: 12854
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/impl/SearchFactoryImpl.java
Log:
HSEARCH-58 refine the filtercaching strategy property names
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/impl/SearchFactoryImpl.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2007-07-30 22:48:45 UTC (rev 12853)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2007-07-31 00:03:48 UTC (rev 12854)
@@ -307,7 +307,7 @@
}
private void buildFilterCachingStrategy(Properties properties) {
- String impl = properties.getProperty( Environment.FILTER_CACHING_STRATEGY_IMPL );
+ String impl = properties.getProperty( Environment.FILTER_CACHING_STRATEGY );
if ( StringHelper.isEmpty( impl ) || "mru".equalsIgnoreCase( impl ) ) {
filterCachingStrategy = new MRUFilterCachingStrategy();
}
17 years, 5 months
Hibernate SVN: r12853 - in trunk/HibernateExt/search/src/java/org/hibernate/search: filter and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-30 18:48:45 -0400 (Mon, 30 Jul 2007)
New Revision: 12853
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/Environment.java
trunk/HibernateExt/search/src/java/org/hibernate/search/filter/MRUFilterCachingStrategy.java
Log:
HSEARCH-58 refine the filtercaching strategy property names
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/Environment.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/Environment.java 2007-07-30 21:59:45 UTC (rev 12852)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/Environment.java 2007-07-30 22:48:45 UTC (rev 12853)
@@ -52,11 +52,8 @@
*/
public static final String READER_STRATEGY = READER_PREFIX + "strategy";
/**
- * filter caching strategy
+ * filter caching strategy class (must have a no-arg constructor and implements FilterCachingStrategy)
*/
- public static final String FILTER_CACHING_STRATEGY_PREFIX = "hibernate.search.filter.cache_strategy.";
- /**
- * filter caching strategy class (must have a no-arg constructor and implements FilterCachingStrategy
- */
- public static final String FILTER_CACHING_STRATEGY_IMPL = "hibernate.search.filter.cache_strategy.impl";
+ public static final String FILTER_CACHING_STRATEGY = "hibernate.search.filter.cache_strategy";
+
}
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/filter/MRUFilterCachingStrategy.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/filter/MRUFilterCachingStrategy.java 2007-07-30 21:59:45 UTC (rev 12852)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/filter/MRUFilterCachingStrategy.java 2007-07-30 22:48:45 UTC (rev 12853)
@@ -18,18 +18,18 @@
public class MRUFilterCachingStrategy implements FilterCachingStrategy {
private static final String DEFAULT_SIZE = "128";
private SoftLimitMRUCache cache;
+ private static final String SIZE = Environment.FILTER_CACHING_STRATEGY + ".size";
public void initialize(Properties properties) {
int size;
try {
size = Integer.parseInt(
- properties.getProperty( Environment.FILTER_CACHING_STRATEGY_PREFIX + "size", DEFAULT_SIZE )
+ properties.getProperty( SIZE, DEFAULT_SIZE )
);
}
catch (NumberFormatException nfe) {
throw new SearchException(
- "Unable to parse " + Environment.FILTER_CACHING_STRATEGY_PREFIX + "size: "
- + properties.getProperty( Environment.FILTER_CACHING_STRATEGY_PREFIX + "size", DEFAULT_SIZE ), nfe
+ "Unable to parse " + SIZE + ": " + properties.getProperty( SIZE, DEFAULT_SIZE ), nfe
);
}
17 years, 5 months
Hibernate SVN: r12852 - in branches/Branch_3_2/HibernateExt/tools/src: test/org/hibernate/tool/ant and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-07-30 17:59:45 -0400 (Mon, 30 Jul 2007)
New Revision: 12852
Added:
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Properties.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/PropertiesTest.java
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntHibernateToolTest.java
Log:
HBX-267 hbm2java handle properties (old commit that got lost)
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java 2007-07-30 21:49:10 UTC (rev 12851)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java 2007-07-30 21:59:45 UTC (rev 12852)
@@ -138,8 +138,29 @@
}*/
}
+
+ // iterators.add( pc.getPropertyIterator() );
+ // Need to skip <properties> element which are defined via "embedded" components
+ // Best if we could return an intelligent iterator, but for now we just iterate explicitly.
+ Iterator pit = pc.getPropertyIterator();
+ while(pit.hasNext())
+ {
+ Property element = (Property) pit.next();
+ if ( element.getValue() instanceof Component
+ && element.getPropertyAccessorName().equals( "embedded" )) {
+ Component component = (Component) element.getValue();
+ // need to "explode" property to get proper sequence in java code.
+ Iterator embeddedProperty = component.getPropertyIterator();
+ while(embeddedProperty.hasNext()) {
+ properties.add(embeddedProperty.next());
+ }
+ } else {
+ properties.add(element);
+ }
+ }
+
iterators.add( properties.iterator() );
- iterators.add( pc.getPropertyIterator() );
+
Iterator[] it = (Iterator[]) iterators.toArray( new Iterator[iterators.size()] );
return new SkipBackRefPropertyIterator( new JoinedIterator( it ) );
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntHibernateToolTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntHibernateToolTest.java 2007-07-30 21:49:10 UTC (rev 12851)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntHibernateToolTest.java 2007-07-30 21:59:45 UTC (rev 12852)
@@ -94,7 +94,7 @@
fail("property overrides not accepted");
} catch (BuildException be) {
// should happen
- assertTrue(be.getMessage().indexOf("FAKEDialect")>0);
+ assertTrue(be.getMessage(), be.getMessage().indexOf("FAKEDialect")>0);
}
}
Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Properties.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Properties.hbm.xml (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Properties.hbm.xml 2007-07-30 21:59:45 UTC (rev 12852)
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ This mapping is a test mapping for hbm2java
+
+-->
+
+<hibernate-mapping package="properties">
+
+ <class name="PPerson">
+ <id name="id" type="string">
+ <generator class="native"/>
+ </id>
+
+ <property name="name" type="string" not-null="true"/>
+
+ <properties name="emergencyContact" unique="true">
+ <property name="contact" type="boolean" not-null="true"/>
+ <many-to-one name="company" class="PCompany"/>
+ </properties>
+ </class>
+
+ <class name="PCompany">
+ <id name="id" type="string">
+ <generator class="native"/>
+ </id>
+
+ <property name="brand" type="string" not-null="true"/>
+
+ <set name="employees" inverse="true">
+ <key>
+ <column name="company_id"/>
+ </key>
+ <one-to-many class="PPerson"/>
+ </set>
+
+<!-- <one-to-one name="emergencyContact" class="Person"
+ property-ref="emergencyContact">
+ <formula>'true'</formula>
+ <formula>id</formula>
+ </one-to-one> -->
+
+ </class>
+
+</hibernate-mapping>
+
+
Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/PropertiesTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/PropertiesTest.java (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/PropertiesTest.java 2007-07-30 21:59:45 UTC (rev 12852)
@@ -0,0 +1,83 @@
+/*
+ * Created on 2004-12-01
+ *
+ */
+package org.hibernate.tool.hbm2x;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.tool.NonReflectiveTestCase;
+import org.hibernate.tool.hbm2x.pojo.EntityPOJOClass;
+import org.hibernate.tool.hbm2x.pojo.POJOClass;
+import org.hibernate.tool.test.TestHelper;
+
+/**
+ * @author Josh Moore josh.moore(a)gmx.de
+ *
+ */
+public class PropertiesTest extends NonReflectiveTestCase {
+
+ private ArtifactCollector artifactCollector;
+
+ public PropertiesTest(String name) {
+ super( name, "hbm2javaoutput" );
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ artifactCollector = new ArtifactCollector();
+
+ Exporter exporter = new POJOExporter( getCfg(), getOutputDir() );
+ exporter.setArtifactCollector(artifactCollector);
+
+ Exporter hbmexporter = new HibernateMappingExporter(getCfg(), getOutputDir());
+ hbmexporter.setArtifactCollector(artifactCollector);
+
+ exporter.start();
+ hbmexporter.start();
+ }
+
+ public void testNoGenerationOfEmbeddedPropertiesComponent() {
+ assertEquals(2, artifactCollector.getFileCount("java"));
+ assertEquals(2, artifactCollector.getFileCount("hbm.xml"));
+ }
+
+ public void testGenerationOfEmbeddedProperties() {
+
+ // HACK: hbm.xml exporter actually does not support properties but whatever we do it should not remove emergencycontact from the list of properties being generated
+ assertNotNull(findFirstString("emergencyContact", new File(getOutputDir(), "properties/PPerson.hbm.xml" )));
+
+ assertNotNull(findFirstString("name", new File(getOutputDir(), "properties/PPerson.java" )));
+ assertEquals("Embedded component/properties should not show up in .java", null, findFirstString("emergencyContact", new File(getOutputDir(), "properties/PPerson.java" )));
+ }
+
+ public void testCompilable() {
+
+ File file = new File( "compilable" );
+ file.mkdir();
+
+ ArrayList list = new ArrayList();
+ list.add( new File( "src/testoutputdependent/properties/PropertiesUsage.java" )
+ .getAbsolutePath() );
+ TestHelper.compile( getOutputDir(), file, TestHelper.visitAllFiles(
+ getOutputDir(), list ) );
+
+ TestHelper.deleteDir( file );
+ }
+
+ protected String getBaseForMappings() {
+ return "org/hibernate/tool/hbm2x/";
+ }
+
+ protected String[] getMappings() {
+ return new String[] { "Properties.hbm.xml" };
+ }
+
+
+}
17 years, 5 months
Hibernate SVN: r12851 - in branches/Branch_3_2/HibernateExt/tools/src: java/org/hibernate/tool/hbm2x/visitor and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-07-30 17:49:10 -0400 (Mon, 30 Jul 2007)
New Revision: 12851
Added:
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DependentValue.hbm.xml
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/DefaultValueVisitor.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/EntityNameFromValueVisitor.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/JavaTypeFromValueVisitor.java
branches/Branch_3_2/HibernateExt/tools/src/templates/dot/entitygraph.dot.ftl
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java
Log:
HBX-953 java.lang.UnsupportedOperationException: accept on org.hibernate.mapping.DependantValue
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java 2007-07-30 19:29:48 UTC (rev 12850)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java 2007-07-30 21:49:10 UTC (rev 12851)
@@ -369,4 +369,9 @@
public String getHibernateTypeName(Property p) {
return (String) p.getValue().accept(new EntityNameFromValueVisitor());
}
+
+
+ public String getSafeHibernateTypeName(Property p) {
+ return (String) p.getValue().accept(new EntityNameFromValueVisitor(false));
+ }
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java 2007-07-30 19:29:48 UTC (rev 12850)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java 2007-07-30 21:49:10 UTC (rev 12851)
@@ -295,39 +295,7 @@
}
private String getJavaTypeName(Value value, boolean preferRawTypeNames) {
- if(true) return (String) value.accept( new JavaTypeFromValueVisitor() );
- if ( value instanceof Component) {
- // composite-element breaks without it.
- return ((Component)value).getComponentClassName();
- }
- if ( value instanceof ToOne ) {
- return ( (ToOne) value ).getReferencedEntityName(); // should get the cfg and lookup the persistenclass.
- }
-
- if(value instanceof OneToMany) {
- return ((OneToMany)value).getAssociatedClass().getClassName();
- }
-
- try {
- // have to attempt calling gettype to decide if its custom type.
- Type type = value.getType();
- if(type instanceof CustomType || type instanceof CompositeCustomType) {
- return toName( type.getReturnedClass() );
- }
- } catch(HibernateException he) {
- // ignore
- }
-
- if ( preferRawTypeNames && value.isSimpleValue() ) {
- // this logic make us use the raw typename if it is something else than an Hibernate type. So, if user wrote long we will use long...if he meant to have a Long then he should use the java.lang.Long version.
- String typename = ( (SimpleValue) value ).getTypeName();
- if ( !isNonPrimitiveTypeName( typename ) ) {
- String val = ( (SimpleValue) value ).getTypeName();
- if(val!=null) return val; // val can be null when type is any
- }
- }
-
- return toName( value.getType().getReturnedClass() );
+ return (String) value.accept( new JavaTypeFromValueVisitor() );
}
public String asParameterList(Iterator fields, boolean useGenerics, ImportContext ic) {
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/DefaultValueVisitor.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/DefaultValueVisitor.java 2007-07-30 19:29:48 UTC (rev 12850)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/DefaultValueVisitor.java 2007-07-30 21:49:10 UTC (rev 12851)
@@ -14,6 +14,7 @@
import org.hibernate.mapping.PrimitiveArray;
import org.hibernate.mapping.Set;
import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.Value;
import org.hibernate.mapping.ValueVisitor;
/**
@@ -35,8 +36,9 @@
this.throwException = throwException;
}
- protected Object handle(Object o) {
+ protected Object handle(Value o) {
if (throwException) {
+
throw new UnsupportedOperationException("accept on " + o);
}
else { return null; }
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/EntityNameFromValueVisitor.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/EntityNameFromValueVisitor.java 2007-07-30 19:29:48 UTC (rev 12850)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/EntityNameFromValueVisitor.java 2007-07-30 21:49:10 UTC (rev 12851)
@@ -21,6 +21,10 @@
super( true );
}
+ public EntityNameFromValueVisitor(boolean b) {
+ super(b);
+ }
+
public Object accept(OneToOne o) {
return acceptToOne(o);
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/JavaTypeFromValueVisitor.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/JavaTypeFromValueVisitor.java 2007-07-30 19:29:48 UTC (rev 12850)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/visitor/JavaTypeFromValueVisitor.java 2007-07-30 21:49:10 UTC (rev 12851)
@@ -55,7 +55,7 @@
}
}
- protected Object handle(Object o) {
+ protected Object handle(Value o) {
Value value = (Value) o;
try {
// have to attempt calling gettype to decide if its custom type.
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/dot/entitygraph.dot.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/dot/entitygraph.dot.ftl 2007-07-30 19:29:48 UTC (rev 12850)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/dot/entitygraph.dot.ftl 2007-07-30 21:49:10 UTC (rev 12851)
@@ -59,7 +59,7 @@
<#macro propertyEdges root properties>
/* Property edges/nodes for ${root} */
<#foreach property in properties>
- <#if c2h.getHibernateTypeName(property)?exists>
+ <#if c2h.getSafeHibernateTypeName(property)?exists>
${root} -> ${c2h.getHibernateTypeName(property)?replace(".","_dot_")} [
label="${property.name}"
<#if c2j.isComponent(property)>
Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DependentValue.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DependentValue.hbm.xml (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DependentValue.hbm.xml 2007-07-30 21:49:10 UTC (rev 12851)
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+<!-- Mapping for dependentValue bug - HBX-953 -->
+ <class name="Foo" table="foo">
+ <id name="id" type="java.lang.Integer" unsaved-value="null" >
+ <column name="foo_id" sql-type="int" not-null="true" />
+ <generator class="native"/>
+ </id>
+ <list name="bars"
+ table="bar"
+ lazy="false"
+ cascade="all">
+ <key column="foo_id" not-null="true"/>
+ <list-index column="ordering" />
+ <one-to-many class="Bar" />
+ </list>
+ </class>
+ <class name="Bar" table="bar">
+ <id name="id" type="java.lang.Integer" unsaved-value="null" >
+ <column name="bar_id" sql-type="int" not-null="true" />
+ <generator class="native"/>
+ </id>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java 2007-07-30 19:29:48 UTC (rev 12850)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java 2007-07-30 21:49:10 UTC (rev 12851)
@@ -23,7 +23,8 @@
"LineItem.hbm.xml",
"Product.hbm.xml",
"HelloWorld.hbm.xml",
- "UnionSubclass.hbm.xml"
+ "UnionSubclass.hbm.xml",
+ "DependentValue.hbm.xml"
};
}
17 years, 5 months
Hibernate SVN: r12850 - trunk/HibernateExt/annotations/doc/reference/en/modules.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-30 15:29:48 -0400 (Mon, 30 Jul 2007)
New Revision: 12850
Modified:
trunk/HibernateExt/annotations/doc/reference/en/modules/setup.xml
Log:
HSEARCH-105 Missing configure() in the documentation
Modified: trunk/HibernateExt/annotations/doc/reference/en/modules/setup.xml
===================================================================
--- trunk/HibernateExt/annotations/doc/reference/en/modules/setup.xml 2007-07-29 16:30:48 UTC (rev 12849)
+++ trunk/HibernateExt/annotations/doc/reference/en/modules/setup.xml 2007-07-30 19:29:48 UTC (rev 12850)
@@ -30,7 +30,7 @@
</itemizedlist>
</section>
- <section id="setup-configuration" revision="1">
+ <section id="setup-configuration" revision="2">
<title>Configuration</title>
<para>First, set up your classpath (after you have created a new project
@@ -75,7 +75,8 @@
static {
try {
- sessionFactory = new <emphasis role="bold">AnnotationConfiguration()</emphasis>.buildSessionFactory();
+ sessionFactory = new <emphasis role="bold">AnnotationConfiguration()</emphasis>
+ configure().buildSessionFactory();
} catch (Throwable ex) {
// Log exception!
throw new ExceptionInInitializerError(ex);
@@ -126,7 +127,7 @@
.addAnnotatedClass(Person.class)
.addAnnotatedClass(Dog.class)</emphasis>
<emphasis role="bold"> .addResource("test/animals/orm.xml")</emphasis>
- .buildSessionFactory();</programlisting>
+ configure()..buildSessionFactory();</programlisting>
<para>You can also use the Hibernate EntityManager which has its own
configuration mechanism. Please refer to this project documentation for
17 years, 5 months
Hibernate SVN: r12849 - in trunk/HibernateExt/search/src: test/org/hibernate/search/test/query and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-29 12:30:48 -0400 (Sun, 29 Jul 2007)
New Revision: 12849
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/query/FullTextQueryImpl.java
trunk/HibernateExt/search/src/java/org/hibernate/search/query/ScrollableResultsImpl.java
trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/LuceneQueryTest.java
Log:
HSEARCH-90 avoid lists with negative list capacity on setfirstresult
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/query/FullTextQueryImpl.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2007-07-29 15:59:13 UTC (rev 12848)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2007-07-29 16:30:48 UTC (rev 12849)
@@ -123,14 +123,15 @@
int max = max( first, hits );
Session sess = (Session) this.session;
- List<EntityInfo> entityInfos = new ArrayList<EntityInfo>( max - first + 1 );
+ int size = max - first + 1 < 0 ? 0 : max - first + 1;
+ List<EntityInfo> infos = new ArrayList<EntityInfo>( size );
DocumentExtractor extractor = new DocumentExtractor( searchFactoryImplementor, indexProjection );
for (int index = first; index <= max; index++) {
//TODO use indexSearcher.getIndexReader().document( hits.id(index), FieldSelector(indexProjection) );
- entityInfos.add( extractor.extract( hits, index ) );
+ infos.add( extractor.extract( hits, index ) );
}
Loader loader = getLoader( sess, searchFactoryImplementor );
- return new IteratorImpl( entityInfos, loader );
+ return new IteratorImpl( infos, loader );
}
catch (IOException e) {
throw new HibernateException( "Unable to query Lucene index", e );
@@ -231,7 +232,9 @@
int first = first();
int max = max( first, hits );
Session sess = (Session) this.session;
- List<EntityInfo> infos = new ArrayList<EntityInfo>( max - first + 1 );
+
+ int size = max - first + 1 < 0 ? 0 : max - first + 1;
+ List<EntityInfo> infos = new ArrayList<EntityInfo>( size );
DocumentExtractor extractor = new DocumentExtractor( searchFactoryImplementor, indexProjection );
for (int index = first; index <= max; index++) {
infos.add( extractor.extract( hits, index ) );
@@ -506,11 +509,17 @@
}
public FullTextQuery setFirstResult(int firstResult) {
+ if (firstResult < 0) {
+ throw new IllegalArgumentException("'first' pagination parameter less than 0");
+ }
this.firstResult = firstResult;
return this;
}
public FullTextQuery setMaxResults(int maxResults) {
+ if (maxResults < 0) {
+ throw new IllegalArgumentException("'max' pagination parameter less than 0");
+ }
this.maxResults = maxResults;
return this;
}
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/query/ScrollableResultsImpl.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/query/ScrollableResultsImpl.java 2007-07-29 15:59:13 UTC (rev 12848)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/query/ScrollableResultsImpl.java 2007-07-29 16:30:48 UTC (rev 12849)
@@ -59,8 +59,9 @@
this.current = first;
this.loader = loader;
this.documentExtractor = extractor;
- this.entityInfos = new EntityInfo[max - first + 1];
- this.resultContext = new HashMap<EntityInfo, Object[]>( max - first + 1 );
+ int size = max - first + 1 > 0 ? max - first + 1 : 0;
+ this.entityInfos = new EntityInfo[size];
+ this.resultContext = new HashMap<EntityInfo, Object[]>( size );
}
public boolean next() throws HibernateException {
@@ -121,14 +122,13 @@
if ( current < first || current > max ) return null;
EntityInfo info = entityInfos[current - first];
if ( info == null ) {
- Document document = null;
try {
info = documentExtractor.extract( hits, current );
}
catch (IOException e) {
throw new HibernateException( "Unable to read Lucene hits[" + current + "]", e );
}
- //FIXME should check that clazz match classes but this complexify a lot the firstResult/maxResult
+ //FIXME should check that clazz match classes but this complicates a lot the firstResult/maxResult
entityInfos[current - first] = info;
}
if ( !resultContext.containsKey( info ) ) {
Modified: trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/LuceneQueryTest.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/LuceneQueryTest.java 2007-07-29 15:59:13 UTC (rev 12848)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/LuceneQueryTest.java 2007-07-29 16:30:48 UTC (rev 12849)
@@ -1,21 +1,22 @@
//$Id$
package org.hibernate.search.test.query;
+import java.util.Iterator;
import java.util.List;
-import java.util.Iterator;
-import org.hibernate.search.test.SearchTestCase;
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+import org.hibernate.FetchMode;
+import org.hibernate.Hibernate;
+import org.hibernate.ScrollableResults;
+import org.hibernate.Transaction;
+import org.hibernate.search.FullTextQuery;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
-import org.hibernate.search.FullTextQuery;
-import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
-import org.hibernate.ScrollableResults;
-import org.hibernate.FetchMode;
+import org.hibernate.search.test.SearchTestCase;
import org.hibernate.stat.Statistics;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.analysis.StopAnalyzer;
/**
@@ -98,7 +99,7 @@
Statistics stats = s.getSessionFactory().getStatistics();
stats.clear();
boolean enabled = stats.isStatisticsEnabled();
- if (!enabled) stats.setStatisticsEnabled( true );
+ if ( !enabled ) stats.setStatisticsEnabled( true );
FullTextQuery hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
assertEquals( "Exection of getResultSize without actual results", 2, hibQuery.getResultSize() );
assertEquals( "No entity should be loaded", 0, stats.getEntityLoadCount() );
@@ -108,7 +109,7 @@
List result = hibQuery.list();
assertNotNull( result );
assertEquals( "2 entities should be loaded", 2, stats.getEntityLoadCount() );
- if (!enabled) stats.setStatisticsEnabled( false );
+ if ( !enabled ) stats.setStatisticsEnabled( false );
for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
tx.commit();
s.close();
@@ -311,9 +312,9 @@
Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
s.save( book );
Author emmanuel = new Author();
- emmanuel.setName("Emmanuel");
+ emmanuel.setName( "Emmanuel" );
s.save( emmanuel );
- book.getAuthors().add(emmanuel);
+ book.getAuthors().add( emmanuel );
tx.commit();
s.clear();
tx = s.beginTransaction();
@@ -324,16 +325,16 @@
List result = hibQuery.list();
assertNotNull( result );
assertEquals( "Query with no explicit criteria", 1, result.size() );
- book = (Book) result.get(0);
+ book = (Book) result.get( 0 );
assertFalse( "Association should not be inintialized", Hibernate.isInitialized( book.getAuthors() ) );
result = s.createFullTextQuery( query ).setCriteriaQuery(
s.createCriteria( Book.class ).setFetchMode( "authors", FetchMode.JOIN ) ).list();
assertNotNull( result );
assertEquals( "Query with explicit criteria", 1, result.size() );
- book = (Book) result.get(0);
+ book = (Book) result.get( 0 );
assertTrue( "Association should be inintialized", Hibernate.isInitialized( book.getAuthors() ) );
- assertEquals( 1, book.getAuthors().size() );
+ assertEquals( 1, book.getAuthors().size() );
//cleanup
Author author = book.getAuthors().iterator().next();
@@ -344,13 +345,107 @@
s.close();
}
+ public void testScrollEmptyHits() throws Exception {
+ FullTextSession s = Search.createFullTextSession( openSession() );
+ prepEmployeeIndex( s );
+ s.clear();
+ Transaction tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
+
+ Query query = parser.parse( "dept:XXX" );
+ org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
+
+ ScrollableResults projections = hibQuery.scroll();
+ projections.beforeFirst();
+ projections.next();
+ Object[] projection = projections.get();
+ assertNull( projection );
+
+ hibQuery = s.createFullTextQuery( query, Employee.class ).setFirstResult( 10 ).setMaxResults( 20 );
+
+ projections = hibQuery.scroll();
+ projections.beforeFirst();
+ projections.next();
+ projection = projections.get();
+ assertNull( projection );
+
+ //cleanup
+ for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testListEmptyHits() throws Exception {
+ FullTextSession s = Search.createFullTextSession( openSession() );
+ prepEmployeeIndex( s );
+
+ s.clear();
+ Transaction tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
+
+ Query query = parser.parse( "dept:XXX" );
+ org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
+ List result = hibQuery.list();
+ assertEquals( 0, result.size() );
+
+ hibQuery = s.createFullTextQuery( query, Employee.class ).setFirstResult( 10 ).setMaxResults( 20 );
+ result = hibQuery.list();
+ assertEquals( 0, result.size() );
+
+ //cleanup
+ for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ public void testIterateEmptyHits() throws Exception {
+ FullTextSession s = Search.createFullTextSession( openSession() );
+ prepEmployeeIndex( s );
+
+ s.clear();
+ Transaction tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
+
+ Query query = parser.parse( "dept:XXX" );
+ org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
+ Iterator iter = hibQuery.iterate();
+ assertFalse( iter.hasNext() );
+
+ hibQuery = s.createFullTextQuery( query, Employee.class ).setFirstResult( 10 ).setMaxResults( 20 );
+ iter = hibQuery.iterate();
+ assertFalse( iter.hasNext() );
+
+ //cleanup
+ for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
+ tx.commit();
+ s.close();
+ }
+
+ private void prepEmployeeIndex(FullTextSession s) {
+ Transaction tx = s.beginTransaction();
+ Employee e1 = new Employee( 1000, "Griffin", "ITech" );
+ s.save( e1 );
+ Employee e2 = new Employee( 1001, "Jackson", "Accounting" );
+ s.save( e2 );
+ Employee e3 = new Employee( 1002, "Jimenez", "ITech" );
+ s.save( e3 );
+ Employee e4 = new Employee( 1003, "Stejskal", "ITech" );
+ s.save( e4 );
+ Employee e5 = new Employee( 1004, "Whetbrook", "ITech" );
+ s.save( e5 );
+
+ tx.commit();
+ }
+
+
protected Class[] getMappings() {
return new Class[] {
Book.class,
AlternateBook.class,
Clock.class,
- Author.class
+ Author.class,
+ Employee.class
};
}
}
17 years, 5 months
Hibernate SVN: r12848 - trunk/HibernateExt/search/src/java/org/hibernate/search.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-29 11:59:13 -0400 (Sun, 29 Jul 2007)
New Revision: 12848
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/FullTextQuery.java
Log:
Allow method chaining for setFirstResult and setMaxResults
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/FullTextQuery.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/FullTextQuery.java 2007-07-29 15:35:48 UTC (rev 12847)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/FullTextQuery.java 2007-07-29 15:59:13 UTC (rev 12848)
@@ -84,4 +84,14 @@
*/
void disableFullTextFilter(String name);
+ /**
+ * {link:Query#setFirstResult}
+ */
+ FullTextQuery setFirstResult(int firstResult);
+
+ /**
+ * {link:Query#setMaxResults}
+ */
+ FullTextQuery setMaxResults(int maxResults);
+
}
17 years, 5 months
Hibernate SVN: r12847 - in trunk/HibernateExt/search/src/java/org/hibernate/search: engine and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-29 11:35:48 -0400 (Sun, 29 Jul 2007)
New Revision: 12847
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/annotations/FullTextFilterDef.java
trunk/HibernateExt/search/src/java/org/hibernate/search/engine/FilterDef.java
trunk/HibernateExt/search/src/java/org/hibernate/search/impl/SearchFactoryImpl.java
trunk/HibernateExt/search/src/java/org/hibernate/search/query/FullTextQueryImpl.java
Log:
HSEARCH-58 ability to disable cacheper filter def
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/annotations/FullTextFilterDef.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/annotations/FullTextFilterDef.java 2007-07-29 15:12:47 UTC (rev 12846)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/annotations/FullTextFilterDef.java 2007-07-29 15:35:48 UTC (rev 12847)
@@ -32,4 +32,9 @@
*
*/
Class impl();
+
+ /**
+ * Enable caching for this filter (default true).
+ */
+ boolean cache() default true;
}
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/engine/FilterDef.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/engine/FilterDef.java 2007-07-29 15:12:47 UTC (rev 12846)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/engine/FilterDef.java 2007-07-29 15:35:48 UTC (rev 12847)
@@ -17,6 +17,7 @@
private Method factoryMethod;
private Method keyMethod;
private Map<String, Method> setters = new HashMap<String, Method>();
+ private boolean cache;
public Class getImpl() {
return impl;
@@ -60,4 +61,12 @@
throw new SearchException( "Unable to set Filter parameter: " + parameterName + " on filter class: " + this.impl, e );
}
}
+
+ public void setCache(boolean cache) {
+ this.cache = cache;
+ }
+
+ public boolean isCache() {
+ return cache;
+ }
}
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/impl/SearchFactoryImpl.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2007-07-29 15:12:47 UTC (rev 12846)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2007-07-29 15:35:48 UTC (rev 12847)
@@ -123,6 +123,7 @@
}
FilterDef filterDef = new FilterDef();
filterDef.setImpl( defAnn.impl() );
+ filterDef.setCache( defAnn.cache() );
try {
filterDef.getImpl().newInstance();
}
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/query/FullTextQueryImpl.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2007-07-29 15:12:47 UTC (rev 12846)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2007-07-29 15:35:48 UTC (rev 12847)
@@ -288,42 +288,47 @@
for ( Map.Entry<String, Object> entry : filterDefinition.getParameters().entrySet() ) {
def.invoke( entry.getKey(), instance, entry.getValue() );
}
- if ( def.getKeyMethod() == null && filterDefinition.getParameters().size() > 0 ) {
+ if ( def.isCache() && def.getKeyMethod() == null && filterDefinition.getParameters().size() > 0 ) {
throw new SearchException("Filter with parameters and no @Key method: " + filterDefinition.getName() );
}
- FilterKey key;
- if ( def.getKeyMethod() == null ) {
- key = new FilterKey( ) {
- public int hashCode() {
- return getImpl().hashCode();
- }
+ FilterKey key = null;
+ if ( def.isCache() ) {
+ if ( def.getKeyMethod() == null ) {
+ key = new FilterKey( ) {
+ public int hashCode() {
+ return getImpl().hashCode();
+ }
- public boolean equals(Object obj) {
- if ( ! ( obj instanceof FilterKey ) ) return false;
- FilterKey that = (FilterKey) obj;
- return this.getImpl().equals( that.getImpl() );
+ public boolean equals(Object obj) {
+ if ( ! ( obj instanceof FilterKey ) ) return false;
+ FilterKey that = (FilterKey) obj;
+ return this.getImpl().equals( that.getImpl() );
+ }
+ };
+ }
+ else {
+ try {
+ key = (FilterKey) def.getKeyMethod().invoke( instance );
}
- };
- }
- else {
- try {
- key = (FilterKey) def.getKeyMethod().invoke( instance );
+ catch (IllegalAccessException e) {
+ throw new SearchException("Unable to access @Key method: "
+ + def.getImpl().getName() + "." + def.getKeyMethod().getName() );
+ }
+ catch (InvocationTargetException e) {
+ throw new SearchException("Unable to access @Key method: "
+ + def.getImpl().getName() + "." + def.getKeyMethod().getName() );
+ }
+ catch (ClassCastException e) {
+ throw new SearchException("@Key method does not return FilterKey: "
+ + def.getImpl().getName() + "." + def.getKeyMethod().getName() );
+ }
}
- catch (IllegalAccessException e) {
- throw new SearchException("Unable to access @Key method: "
- + def.getImpl().getName() + "." + def.getKeyMethod().getName() );
- }
- catch (InvocationTargetException e) {
- throw new SearchException("Unable to access @Key method: "
- + def.getImpl().getName() + "." + def.getKeyMethod().getName() );
- }
- catch (ClassCastException e) {
- throw new SearchException("@Key method does not return FilterKey: "
- + def.getImpl().getName() + "." + def.getKeyMethod().getName() );
- }
+ key.setImpl( def.getImpl() );
}
- key.setImpl( def.getImpl() );
- Filter filter = searchFactoryImplementor.getFilterCachingStrategy().getCachedFilter( key );
+
+ Filter filter = def.isCache() ?
+ searchFactoryImplementor.getFilterCachingStrategy().getCachedFilter( key ) :
+ null;
if (filter == null) {
if ( def.getFactoryMethod() != null ) {
try {
@@ -351,7 +356,7 @@
+ def.getImpl().getName() + "." + def.getFactoryMethod().getName() );
}
}
- searchFactoryImplementor.getFilterCachingStrategy().addCachedFilter( key, filter );
+ if ( def.isCache() ) searchFactoryImplementor.getFilterCachingStrategy().addCachedFilter( key, filter );
}
chainedFilter.addFilter( filter );
}
17 years, 5 months
Hibernate SVN: r12846 - trunk/HibernateExt/search/src/java/org/hibernate/search/annotations.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-29 11:12:47 -0400 (Sun, 29 Jul 2007)
New Revision: 12846
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/annotations/Field.java
Log:
HSEARCH-102 default @Field.index to TOKENIZED
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/annotations/Field.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/annotations/Field.java 2007-07-29 15:10:49 UTC (rev 12845)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/annotations/Field.java 2007-07-29 15:12:47 UTC (rev 12846)
@@ -27,13 +27,15 @@
/**
* Should the value be stored in the document
+ * defaults to no.
*/
Store store() default Store.NO;
/**
* Defines how the Field should be indexed
+ * defaults to tokenized
*/
- Index index();
+ Index index() default Index.TOKENIZED;
/**
* Define an analyzer for the field, default to
17 years, 5 months