Hibernate SVN: r15338 - core/trunk/core/src/main/java/org/hibernate/cfg.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2008-10-13 10:13:15 -0400 (Mon, 13 Oct 2008)
New Revision: 15338
Modified:
core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java
core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
Log:
HHH-3525 : JDK 1.4 isolation reflection
Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java 2008-10-13 14:12:43 UTC (rev 15337)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java 2008-10-13 14:13:15 UTC (rev 15338)
@@ -237,7 +237,7 @@
public static final String SESSION_FACTORY_NAME = "hibernate.session_factory_name";
/**
- * Hibernate SQL <tt>Dialect</tt> class
+ * Hibernate SQL {@link org.hibernate.dialect.Dialect} class
*/
public static final String DIALECT ="hibernate.dialect";
/**
@@ -516,7 +516,9 @@
private static final Logger log = LoggerFactory.getLogger(Environment.class);
/**
- * Issues warnings to the user when any obsolete property names are used.
+ * Issues warnings to the user when any obsolete or renamed property names are used.
+ *
+ * @param props The specified properties.
*/
public static void verifyProperties(Properties props) {
Iterator iter = props.keySet().iterator();
@@ -605,7 +607,9 @@
getGeneratedKeysSupport = false;
}
JVM_SUPPORTS_GET_GENERATED_KEYS = getGeneratedKeysSupport;
- if (!JVM_SUPPORTS_GET_GENERATED_KEYS) log.info("JVM does not support Statement.getGeneratedKeys()");
+ if (!JVM_SUPPORTS_GET_GENERATED_KEYS) {
+ log.info("JVM does not support Statement.getGeneratedKeys()");
+ }
boolean linkedHashSupport;
try {
@@ -616,10 +620,16 @@
linkedHashSupport = false;
}
JVM_SUPPORTS_LINKED_HASH_COLLECTIONS = linkedHashSupport;
- if (!JVM_SUPPORTS_LINKED_HASH_COLLECTIONS) log.info("JVM does not support LinkedHasMap, LinkedHashSet - ordered maps and sets disabled");
+ if (!JVM_SUPPORTS_LINKED_HASH_COLLECTIONS) {
+ log.info("JVM does not support LinkedHasMap, LinkedHashSet - ordered maps and sets disabled");
+ }
- JVM_HAS_TIMESTAMP_BUG = new Timestamp(123456789).getTime() != 123456789;
- if (JVM_HAS_TIMESTAMP_BUG) log.info("using workaround for JVM bug in java.sql.Timestamp");
+ long x = 123456789;
+ JVM_HAS_TIMESTAMP_BUG = new Timestamp(x).getTime() != x;
+ if (JVM_HAS_TIMESTAMP_BUG) {
+ log.info("using workaround for JVM bug in java.sql.Timestamp");
+ }
+
Timestamp t = new Timestamp(0);
t.setNanos(5 * 1000000);
JVM_HAS_JDK14_TIMESTAMP = t.getTime() == 5;
@@ -636,21 +646,37 @@
}
/**
- * Does this JVM have the IBM JDK 1.3.1. The bug is <tt>new Timestamp(x).getTime()!=x</tt>.
+ * Does this JVM's implementation of {@link java.sql.Timestamp} have a bug in which the following is true:<code>
+ * new java.sql.Timestamp( x ).getTime() != x
+ * </code>
+ * <p/>
+ * NOTE : IBM JDK 1.3.1 the only known JVM to exhibit this behavior.
+ *
+ * @return True if the JVM's {@link Timestamp} implementa
*/
public static boolean jvmHasTimestampBug() {
return JVM_HAS_TIMESTAMP_BUG;
}
/**
- * Does this JVM handle <tt>Timestamp</tt> in the JDK 1.4 compliant way?
+ * Does this JVM handle {@link java.sql.Timestamp} in the JDK 1.4 compliant way wrt to nano rolling>
+ *
+ * @return True if the JDK 1.4 (JDBC3) specification for {@link java.sql.Timestamp} nano rolling is adhered to.
+ *
+ * @deprecated Starting with 3.3 Hibernate requires JDK 1.4 or higher
*/
public static boolean jvmHasJDK14Timestamp() {
return JVM_HAS_JDK14_TIMESTAMP;
}
/**
- * Does this JVM support <tt>LinkedHashSet</tt>, <tt>LinkedHashMap</tt>.
+ * Does this JVM support {@link java.util.LinkedHashSet} and {@link java.util.LinkedHashMap}?
+ * <p/>
+ * Note, this is true for JDK 1.4 and above; hence the deprecation.
+ *
+ * @return True if {@link java.util.LinkedHashSet} and {@link java.util.LinkedHashMap} are available.
+ *
+ * @deprecated Starting with 3.3 Hibernate requires JDK 1.4 or higher
* @see java.util.LinkedHashSet
* @see java.util.LinkedHashMap
*/
@@ -658,29 +684,50 @@
return JVM_SUPPORTS_LINKED_HASH_COLLECTIONS;
}
+ /**
+ * Does this JDK/JVM define the JDBC {@link Statement} interface with a 'getGeneratedKeys' method?
+ * <p/>
+ * Note, this is true for JDK 1.4 and above; hence the deprecation.
+ *
+ * @return True if generated keys can be retrieved via Statement; false otherwise.
+ *
+ * @see Statement
+ * @deprecated Starting with 3.3 Hibernate requires JDK 1.4 or higher
+ */
public static boolean jvmSupportsGetGeneratedKeys() {
return JVM_SUPPORTS_GET_GENERATED_KEYS;
}
/**
- * Should we use streams to bind binary types to JDBC IN parameters.
- * Property <tt>hibernate.jdbc.use_streams_for_binary</tt>.
- * @see Environment#USE_STREAMS_FOR_BINARY
+ * Should we use streams to bind binary types to JDBC IN parameters?
+ *
+ * @return True if streams should be used for binary data handling; false otherwise.
+ *
+ * @see #USE_STREAMS_FOR_BINARY
*/
public static boolean useStreamsForBinary() {
return ENABLE_BINARY_STREAMS;
}
/**
- * Should we use CGLIB reflection optimizer.
- * Property <tt>hibernate.jdbc.use_refection_optimizer</tt>.
- * @see Environment#USE_REFLECTION_OPTIMIZER
+ * Should we use reflection optimization?
+ *
+ * @return True if reflection optimization should be used; false otherwise.
+ *
+ * @see #USE_REFLECTION_OPTIMIZER
+ * @see #getBytecodeProvider()
+ * @see BytecodeProvider#getReflectionOptimizer
*/
public static boolean useReflectionOptimizer() {
return ENABLE_REFLECTION_OPTIMIZER;
}
- private Environment() { throw new UnsupportedOperationException(); }
+ /**
+ * Disallow instantiation
+ */
+ private Environment() {
+ throw new UnsupportedOperationException();
+ }
/**
* Return <tt>System</tt> properties, extended by any properties specified
Modified: core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java 2008-10-13 14:12:43 UTC (rev 15337)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java 2008-10-13 14:13:15 UTC (rev 15338)
@@ -120,28 +120,17 @@
metaSupportsBatchUpdates = meta.supportsBatchUpdates();
metaReportsDDLCausesTxnCommit = meta.dataDefinitionCausesTransactionCommit();
metaReportsDDLInTxnSupported = !meta.dataDefinitionIgnoredInTransactions();
-
- if ( Environment.jvmSupportsGetGeneratedKeys() ) {
- try {
- Boolean result = (Boolean) DatabaseMetaData.class.getMethod("supportsGetGeneratedKeys", null)
- .invoke(meta, null);
- metaSupportsGetGeneratedKeys = result.booleanValue();
- }
- catch (AbstractMethodError ame) {
- metaSupportsGetGeneratedKeys = false;
- }
- catch (Exception e) {
- metaSupportsGetGeneratedKeys = false;
- }
- }
-
+ metaSupportsGetGeneratedKeys = meta.supportsGetGeneratedKeys();
}
+ catch (SQLException sqle) {
+ log.warn("Could not obtain connection metadata", sqle);
+ }
finally {
connections.closeConnection(conn);
}
}
catch (SQLException sqle) {
- log.warn("Could not obtain connection metadata", sqle);
+ log.warn("Could not obtain connection to query metadata", sqle);
}
catch (UnsupportedOperationException uoe) {
// user supplied JDBC connections
15 years, 7 months
Hibernate SVN: r15337 - core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2008-10-13 10:12:43 -0400 (Mon, 13 Oct 2008)
New Revision: 15337
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Environment.java
core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
Log:
HHH-3525 : JDK 1.4 isolation reflection
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Environment.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Environment.java 2008-10-13 11:04:49 UTC (rev 15336)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Environment.java 2008-10-13 14:12:43 UTC (rev 15337)
@@ -237,7 +237,7 @@
public static final String SESSION_FACTORY_NAME = "hibernate.session_factory_name";
/**
- * Hibernate SQL <tt>Dialect</tt> class
+ * Hibernate SQL {@link org.hibernate.dialect.Dialect} class
*/
public static final String DIALECT ="hibernate.dialect";
/**
@@ -516,7 +516,9 @@
private static final Logger log = LoggerFactory.getLogger(Environment.class);
/**
- * Issues warnings to the user when any obsolete property names are used.
+ * Issues warnings to the user when any obsolete or renamed property names are used.
+ *
+ * @param props The specified properties.
*/
public static void verifyProperties(Properties props) {
Iterator iter = props.keySet().iterator();
@@ -605,7 +607,9 @@
getGeneratedKeysSupport = false;
}
JVM_SUPPORTS_GET_GENERATED_KEYS = getGeneratedKeysSupport;
- if (!JVM_SUPPORTS_GET_GENERATED_KEYS) log.info("JVM does not support Statement.getGeneratedKeys()");
+ if (!JVM_SUPPORTS_GET_GENERATED_KEYS) {
+ log.info("JVM does not support Statement.getGeneratedKeys()");
+ }
boolean linkedHashSupport;
try {
@@ -616,10 +620,16 @@
linkedHashSupport = false;
}
JVM_SUPPORTS_LINKED_HASH_COLLECTIONS = linkedHashSupport;
- if (!JVM_SUPPORTS_LINKED_HASH_COLLECTIONS) log.info("JVM does not support LinkedHasMap, LinkedHashSet - ordered maps and sets disabled");
+ if (!JVM_SUPPORTS_LINKED_HASH_COLLECTIONS) {
+ log.info("JVM does not support LinkedHasMap, LinkedHashSet - ordered maps and sets disabled");
+ }
- JVM_HAS_TIMESTAMP_BUG = new Timestamp(123456789).getTime() != 123456789;
- if (JVM_HAS_TIMESTAMP_BUG) log.info("using workaround for JVM bug in java.sql.Timestamp");
+ long x = 123456789;
+ JVM_HAS_TIMESTAMP_BUG = new Timestamp(x).getTime() != x;
+ if (JVM_HAS_TIMESTAMP_BUG) {
+ log.info("using workaround for JVM bug in java.sql.Timestamp");
+ }
+
Timestamp t = new Timestamp(0);
t.setNanos(5 * 1000000);
JVM_HAS_JDK14_TIMESTAMP = t.getTime() == 5;
@@ -636,21 +646,37 @@
}
/**
- * Does this JVM have the IBM JDK 1.3.1. The bug is <tt>new Timestamp(x).getTime()!=x</tt>.
+ * Does this JVM's implementation of {@link java.sql.Timestamp} have a bug in which the following is true:<code>
+ * new java.sql.Timestamp( x ).getTime() != x
+ * </code>
+ * <p/>
+ * NOTE : IBM JDK 1.3.1 the only known JVM to exhibit this behavior.
+ *
+ * @return True if the JVM's {@link Timestamp} implementa
*/
public static boolean jvmHasTimestampBug() {
return JVM_HAS_TIMESTAMP_BUG;
}
/**
- * Does this JVM handle <tt>Timestamp</tt> in the JDK 1.4 compliant way?
+ * Does this JVM handle {@link java.sql.Timestamp} in the JDK 1.4 compliant way wrt to nano rolling>
+ *
+ * @return True if the JDK 1.4 (JDBC3) specification for {@link java.sql.Timestamp} nano rolling is adhered to.
+ *
+ * @deprecated Starting with 3.3 Hibernate requires JDK 1.4 or higher
*/
public static boolean jvmHasJDK14Timestamp() {
return JVM_HAS_JDK14_TIMESTAMP;
}
/**
- * Does this JVM support <tt>LinkedHashSet</tt>, <tt>LinkedHashMap</tt>.
+ * Does this JVM support {@link java.util.LinkedHashSet} and {@link java.util.LinkedHashMap}?
+ * <p/>
+ * Note, this is true for JDK 1.4 and above; hence the deprecation.
+ *
+ * @return True if {@link java.util.LinkedHashSet} and {@link java.util.LinkedHashMap} are available.
+ *
+ * @deprecated Starting with 3.3 Hibernate requires JDK 1.4 or higher
* @see java.util.LinkedHashSet
* @see java.util.LinkedHashMap
*/
@@ -658,29 +684,50 @@
return JVM_SUPPORTS_LINKED_HASH_COLLECTIONS;
}
+ /**
+ * Does this JDK/JVM define the JDBC {@link Statement} interface with a 'getGeneratedKeys' method?
+ * <p/>
+ * Note, this is true for JDK 1.4 and above; hence the deprecation.
+ *
+ * @return True if generated keys can be retrieved via Statement; false otherwise.
+ *
+ * @see Statement
+ * @deprecated Starting with 3.3 Hibernate requires JDK 1.4 or higher
+ */
public static boolean jvmSupportsGetGeneratedKeys() {
return JVM_SUPPORTS_GET_GENERATED_KEYS;
}
/**
- * Should we use streams to bind binary types to JDBC IN parameters.
- * Property <tt>hibernate.jdbc.use_streams_for_binary</tt>.
- * @see Environment#USE_STREAMS_FOR_BINARY
+ * Should we use streams to bind binary types to JDBC IN parameters?
+ *
+ * @return True if streams should be used for binary data handling; false otherwise.
+ *
+ * @see #USE_STREAMS_FOR_BINARY
*/
public static boolean useStreamsForBinary() {
return ENABLE_BINARY_STREAMS;
}
/**
- * Should we use CGLIB reflection optimizer.
- * Property <tt>hibernate.jdbc.use_refection_optimizer</tt>.
- * @see Environment#USE_REFLECTION_OPTIMIZER
+ * Should we use reflection optimization?
+ *
+ * @return True if reflection optimization should be used; false otherwise.
+ *
+ * @see #USE_REFLECTION_OPTIMIZER
+ * @see #getBytecodeProvider()
+ * @see BytecodeProvider#getReflectionOptimizer
*/
public static boolean useReflectionOptimizer() {
return ENABLE_REFLECTION_OPTIMIZER;
}
- private Environment() { throw new UnsupportedOperationException(); }
+ /**
+ * Disallow instantiation
+ */
+ private Environment() {
+ throw new UnsupportedOperationException();
+ }
/**
* Return <tt>System</tt> properties, extended by any properties specified
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/SettingsFactory.java 2008-10-13 11:04:49 UTC (rev 15336)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/SettingsFactory.java 2008-10-13 14:12:43 UTC (rev 15337)
@@ -120,28 +120,17 @@
metaSupportsBatchUpdates = meta.supportsBatchUpdates();
metaReportsDDLCausesTxnCommit = meta.dataDefinitionCausesTransactionCommit();
metaReportsDDLInTxnSupported = !meta.dataDefinitionIgnoredInTransactions();
-
- if ( Environment.jvmSupportsGetGeneratedKeys() ) {
- try {
- Boolean result = (Boolean) DatabaseMetaData.class.getMethod("supportsGetGeneratedKeys", null)
- .invoke(meta, null);
- metaSupportsGetGeneratedKeys = result.booleanValue();
- }
- catch (AbstractMethodError ame) {
- metaSupportsGetGeneratedKeys = false;
- }
- catch (Exception e) {
- metaSupportsGetGeneratedKeys = false;
- }
- }
-
+ metaSupportsGetGeneratedKeys = meta.supportsGetGeneratedKeys();
}
+ catch (SQLException sqle) {
+ log.warn("Could not obtain connection metadata", sqle);
+ }
finally {
connections.closeConnection(conn);
}
}
catch (SQLException sqle) {
- log.warn("Could not obtain connection metadata", sqle);
+ log.warn("Could not obtain connection to query metadata", sqle);
}
catch (UnsupportedOperationException uoe) {
// user supplied JDBC connections
15 years, 7 months
Hibernate SVN: r15336 - in search/trunk: src/test/org/hibernate/search/test/analyzer/solr and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-10-13 07:04:49 -0400 (Mon, 13 Oct 2008)
New Revision: 15336
Modified:
search/trunk/ivy.xml
search/trunk/pom.xml
search/trunk/src/test/org/hibernate/search/test/analyzer/solr/SolrAnalyzerTest.java
search/trunk/src/test/org/hibernate/search/test/analyzer/solr/Team.java
Log:
HSEARCH-232
* Added testcase for snowball analzyer.
Modified: search/trunk/ivy.xml
===================================================================
--- search/trunk/ivy.xml 2008-10-13 09:51:41 UTC (rev 15335)
+++ search/trunk/ivy.xml 2008-10-13 11:04:49 UTC (rev 15336)
@@ -24,6 +24,7 @@
<dependency org="javax.annotation" name="jsr250-api" rev="1.0" conf="default->default"/> <!-- optional -->
<dependency org="org.apache.solr" name="solr-core" rev="1.3.0" conf="default->default"/>
<dependency org="org.apache.solr" name="solr-common" rev="1.3.0" conf="default->default"/>
+ <dependency org="org.apache.solr" name="solr-lucene-snowball" rev="1.3.0" conf="default->default"/>
<!--dependency org="org.hibernate.apache.lucene.solr" name="apache-solr-analyzer" rev="1.3.0" conf="default->default"/-->
<!-- transitive dependencies -->
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2008-10-13 09:51:41 UTC (rev 15335)
+++ search/trunk/pom.xml 2008-10-13 11:04:49 UTC (rev 15336)
@@ -63,6 +63,12 @@
<version>1.3.0</version>
<optional>true</optional>
</dependency>
+ <dependency>
+ <groupId>org.apache.solr</groupId>
+ <artifactId>solr-lucene-snowball</artifactId>
+ <version>1.3.0</version>
+ <optional>true</optional>
+ </dependency>
<dependency>
Modified: search/trunk/src/test/org/hibernate/search/test/analyzer/solr/SolrAnalyzerTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/analyzer/solr/SolrAnalyzerTest.java 2008-10-13 09:51:41 UTC (rev 15335)
+++ search/trunk/src/test/org/hibernate/search/test/analyzer/solr/SolrAnalyzerTest.java 2008-10-13 11:04:49 UTC (rev 15336)
@@ -1,34 +1,62 @@
// $Id$
package org.hibernate.search.test.analyzer.solr;
-import org.hibernate.search.test.SearchTestCase;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.TermQuery;
+
+import org.hibernate.Transaction;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
-import org.hibernate.Transaction;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.index.Term;
+import org.hibernate.search.test.SearchTestCase;
/**
+ * Tests the Solr analyzer creation framework.
+ *
* @author Emmanuel Bernard
+ * @author Hardy Ferentschik
*/
public class SolrAnalyzerTest extends SearchTestCase {
+
+ /**
+ * Tests that the token filters applied to <code>Team</code> are successfully created and used. Refer to
+ * <code>Team</code> to see the exat definitions.
+ *
+ * @throws Exception in case the test fails
+ */
public void testAnalyzerDef() throws Exception {
+ // create the test instance
Team team = new Team();
- team.setDescription( "This is a D\u00E0scription" );
+ team.setDescription( "This is a D\u00E0scription" ); // \u00E0 == � - ISOLatin1AccentFilterFactory should strip of diacritic
team.setLocation( "Atlanta" );
team.setName( "ATL team" );
+
+ // persist and index the test object
FullTextSession fts = Search.getFullTextSession( openSession() );
Transaction tx = fts.beginTransaction();
fts.persist( team );
tx.commit();
fts.clear();
+
+ // execute several search to show that the right tokenizers were applies
tx = fts.beginTransaction();
- TermQuery query = new TermQuery( new Term("description", "D\u00E0scription") );
- assertEquals( "iso latin filter should work", 0, fts.createFullTextQuery( query ).list().size() );
- query = new TermQuery( new Term("description", "is") );
- assertEquals( "stop word filter should work", 0, fts.createFullTextQuery( query ).list().size() );
- query = new TermQuery( new Term("description", "dascription") );
- assertEquals( 1, fts.createFullTextQuery( query ).list().size() );
+ TermQuery query = new TermQuery( new Term( "description", "D\u00E0scription" ) );
+ assertEquals(
+ "iso latin filter should work. � should be a now", 0, fts.createFullTextQuery( query ).list().size()
+ );
+
+ query = new TermQuery( new Term( "description", "is" ) );
+ assertEquals(
+ "stop word filter should work. is should be removed", 0, fts.createFullTextQuery( query ).list().size()
+ );
+
+ query = new TermQuery( new Term( "description", "dascript" ) );
+ assertEquals(
+ "snowball stemmer should work. 'dascription' should be stemmed to 'dascript'",
+ 1,
+ fts.createFullTextQuery( query ).list().size()
+ );
+
+ // cleanup
fts.delete( fts.createFullTextQuery( query ).list().get( 0 ) );
tx.commit();
fts.close();
Modified: search/trunk/src/test/org/hibernate/search/test/analyzer/solr/Team.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/analyzer/solr/Team.java 2008-10-13 09:51:41 UTC (rev 15335)
+++ search/trunk/src/test/org/hibernate/search/test/analyzer/solr/Team.java 2008-10-13 11:04:49 UTC (rev 15336)
@@ -2,37 +2,43 @@
package org.hibernate.search.test.analyzer.solr;
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.AnalyzerDef;
-import org.hibernate.search.annotations.TokenizerDef;
-import org.hibernate.search.annotations.TokenFilterDef;
-import org.hibernate.search.annotations.Parameter;
-import org.hibernate.search.annotations.Analyzer;
-import org.apache.solr.analysis.StandardTokenizerFactory;
import org.apache.solr.analysis.ISOLatin1AccentFilterFactory;
import org.apache.solr.analysis.LowerCaseFilterFactory;
+import org.apache.solr.analysis.SnowballPorterFilterFactory;
+import org.apache.solr.analysis.StandardTokenizerFactory;
import org.apache.solr.analysis.StopFilterFactory;
+import org.hibernate.search.annotations.Analyzer;
+import org.hibernate.search.annotations.AnalyzerDef;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Parameter;
+import org.hibernate.search.annotations.TokenFilterDef;
+import org.hibernate.search.annotations.TokenizerDef;
+
/**
* @author Emmanuel Bernard
*/
@Entity
@Indexed
-@AnalyzerDef(name="customanalyzer",
+@AnalyzerDef(name = "customanalyzer",
tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
filters = {
@TokenFilterDef(factory = ISOLatin1AccentFilterFactory.class),
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(factory = StopFilterFactory.class, params = {
- @Parameter(name="words", value= "org/hibernate/search/test/analyzer/solr/stoplist.properties" ),
- @Parameter(name="ignoreCase", value="true")
+ @Parameter(name = "words",
+ value = "org/hibernate/search/test/analyzer/solr/stoplist.properties"),
+ @Parameter(name = "ignoreCase", value = "true")
+ }),
+ @TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {
+ @Parameter(name = "language", value = "English")
})
-})
+ })
public class Team {
@Id
@DocumentId
@@ -45,7 +51,8 @@
@Field
private String location;
- @Field @Analyzer(definition = "customanalyzer")
+ @Field
+ @Analyzer(definition = "customanalyzer")
private String description;
public Integer getId() {
15 years, 7 months
Hibernate SVN: r15335 - in search/trunk: src/java/org/hibernate/search/impl and 9 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-10-13 05:51:41 -0400 (Mon, 13 Oct 2008)
New Revision: 15335
Added:
search/trunk/src/java/org/hibernate/search/util/HibernateSearchResourceLoader.java
search/trunk/src/test-resources/org/
search/trunk/src/test-resources/org/hibernate/
search/trunk/src/test-resources/org/hibernate/search/
search/trunk/src/test-resources/org/hibernate/search/test/
search/trunk/src/test-resources/org/hibernate/search/test/analyzer/
search/trunk/src/test-resources/org/hibernate/search/test/analyzer/solr/
search/trunk/src/test-resources/org/hibernate/search/test/analyzer/solr/stoplist.properties
Removed:
search/trunk/src/test/org/hibernate/search/test/analyzer/solr/stoplist.properties
Modified:
search/trunk/ivy.xml
search/trunk/pom.xml
search/trunk/src/java/org/hibernate/search/impl/SolrAnalyzerBuilder.java
Log:
HSEARCH-254
* Upgraded to Lucene 2.4.0
* Upgraded to Solr 1.3.0
* Updated analyzer builder
* moved the properties file stoplist.properties into test-resources
Modified: search/trunk/ivy.xml
===================================================================
--- search/trunk/ivy.xml 2008-10-13 09:24:31 UTC (rev 15334)
+++ search/trunk/ivy.xml 2008-10-13 09:51:41 UTC (rev 15335)
@@ -19,10 +19,12 @@
<dependency org="org.slf4j" name="slf4j-api" rev="1.4.2" conf="default->default"/>
<dependency org="org.hibernate" name="hibernate-core" rev="3.3.0.CR2" conf="default->default"/>
<dependency org="javax.transaction" name="jta" rev="1.1" conf="default->default"/>
- <dependency org="org.apache.lucene" name="lucene-core" rev="2.3.2" conf="default->default"/>
+ <dependency org="org.apache.lucene" name="lucene-core" rev="2.4.0" conf="default->default"/>
<dependency org="javax.jms" name="jms" rev="1.1" conf="default->default"/> <!-- optional -->
<dependency org="javax.annotation" name="jsr250-api" rev="1.0" conf="default->default"/> <!-- optional -->
- <dependency org="org.hibernate.apache.lucene.solr" name="apache-solr-analyzer" rev="1.2.0" conf="default->default"/> <!-- optional -->
+ <dependency org="org.apache.solr" name="solr-core" rev="1.3.0" conf="default->default"/>
+ <dependency org="org.apache.solr" name="solr-common" rev="1.3.0" conf="default->default"/>
+ <!--dependency org="org.hibernate.apache.lucene.solr" name="apache-solr-analyzer" rev="1.3.0" conf="default->default"/-->
<!-- transitive dependencies -->
<dependency org="antlr" name="antlr" rev="2.7.6" conf="test->default"/>
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2008-10-13 09:24:31 UTC (rev 15334)
+++ search/trunk/pom.xml 2008-10-13 09:51:41 UTC (rev 15335)
@@ -25,7 +25,7 @@
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
- <version>2.3.2</version>
+ <version>2.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@@ -52,11 +52,17 @@
<optional>true</optional>
</dependency>
<dependency>
- <groupId>org.hibernate.apache.lucene.solr</groupId>
- <artifactId>apache-solr-analyzer</artifactId>
- <version>1.2.0</version>
+ <groupId>org.apache.solr</groupId>
+ <artifactId>solr-common</artifactId>
+ <version>1.3.0</version>
<optional>true</optional>
</dependency>
+ <dependency>
+ <groupId>org.apache.solr</groupId>
+ <artifactId>solr-core</artifactId>
+ <version>1.3.0</version>
+ <optional>true</optional>
+ </dependency>
<dependency>
Modified: search/trunk/src/java/org/hibernate/search/impl/SolrAnalyzerBuilder.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/impl/SolrAnalyzerBuilder.java 2008-10-13 09:24:31 UTC (rev 15334)
+++ search/trunk/src/java/org/hibernate/search/impl/SolrAnalyzerBuilder.java 2008-10-13 09:51:41 UTC (rev 15335)
@@ -8,21 +8,33 @@
import org.apache.solr.analysis.TokenizerChain;
import org.apache.solr.analysis.TokenFilterFactory;
import org.apache.solr.analysis.TokenizerFactory;
+import org.apache.solr.util.plugin.ResourceLoaderAware;
+import org.apache.solr.common.ResourceLoader;
import org.hibernate.search.annotations.AnalyzerDef;
import org.hibernate.search.annotations.TokenizerDef;
import org.hibernate.search.annotations.TokenFilterDef;
import org.hibernate.search.annotations.Parameter;
import org.hibernate.search.SearchException;
+import org.hibernate.search.util.HibernateSearchResourceLoader;
/**
- * This class has a direct dependency on Solr classes
+ * Instances of this class are used to build Lucene analyzers which are defined using the solr <code>TokenFilterFactory</code>.
+ * To make the dependency to the solr framework optional only this class has direct dependecies to solr. Solr dependencies
+ * are not supposed to be used anywhere else (except the actual configuration of the analzers in the domain model).
*
* @author Emmanuel Bernard
+ * @author Hardy Ferentschik
*/
class SolrAnalyzerBuilder {
private SolrAnalyzerBuilder() {}
+ /**
+ * Builds a Lucene <code>Analyzer</code> from the specified <code>AnalyzerDef</code> annotation.
+ *
+ * @param analyzerDef The <code>AnalyzerDef</code> annotation as found in the annotated domain class.
+ * @return a Lucene <code>Analyzer</code>
+ */
public static Analyzer buildAnalyzer(AnalyzerDef analyzerDef) {
TokenizerDef token = analyzerDef.tokenizer();
TokenizerFactory tokenFactory = ( TokenizerFactory ) instantiate( token.factory() );
@@ -30,10 +42,14 @@
final int length = analyzerDef.filters().length;
TokenFilterFactory[] filters = new TokenFilterFactory[length];
+ ResourceLoader resourceLoader = new HibernateSearchResourceLoader();
for ( int index = 0 ; index < length ; index++ ) {
TokenFilterDef filterDef = analyzerDef.filters()[index];
filters[index] = (TokenFilterFactory) instantiate( filterDef.factory() );
filters[index].init( getMapOfParameters( filterDef.params() ) );
+ if ( filters[index] instanceof ResourceLoaderAware ) {
+ ((ResourceLoaderAware)filters[index]).inform( resourceLoader );
+ }
}
return new TokenizerChain(tokenFactory, filters);
}
Added: search/trunk/src/java/org/hibernate/search/util/HibernateSearchResourceLoader.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/util/HibernateSearchResourceLoader.java (rev 0)
+++ search/trunk/src/java/org/hibernate/search/util/HibernateSearchResourceLoader.java 2008-10-13 09:51:41 UTC (rev 15335)
@@ -0,0 +1,76 @@
+package org.hibernate.search.util;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.BufferedReader;
+import java.io.Reader;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+
+import org.apache.solr.common.ResourceLoader;
+import org.apache.solr.util.plugin.ResourceLoaderAware;
+
+import org.hibernate.annotations.common.util.ReflectHelper;
+import org.hibernate.search.SearchException;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class HibernateSearchResourceLoader implements ResourceLoader {
+ public InputStream openResource(String resource) throws IOException {
+ return Thread.currentThread().getContextClassLoader().getResourceAsStream( resource );
+ }
+
+ public List<String> getLines(String resource) throws IOException {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader( new InputStreamReader( openResource( resource ) ) );
+ List<String> results = new ArrayList<String>();
+ String line = reader.readLine();
+ while ( line != null ) {
+ //comment or empty line
+ if ( line.length() != 0 && !line.startsWith( "#" ) ) {
+ results.add( line );
+ }
+ line = reader.readLine();
+ }
+ return Collections.unmodifiableList( results );
+ }
+ finally {
+ try {
+ if (reader != null) reader.close();
+ }
+ catch ( Exception e ) {
+ //we don't really care if we can't close
+ }
+ }
+ }
+
+ public Object newInstance(String cname, String... subpackages) {
+ if (subpackages != null && subpackages.length > 0)
+ throw new UnsupportedOperationException( "newInstance(classname, packages) not implemented" );
+
+ final Class<?> clazz;
+ try {
+ clazz = ReflectHelper.classForName( cname );
+ }
+ catch ( ClassNotFoundException e ) {
+ throw new SearchException("Unable to find class " + cname, e);
+ }
+ try {
+ final Object instance = clazz.newInstance();
+ if (instance instanceof ResourceLoaderAware) {
+ ( ( ResourceLoaderAware) instance ).inform( this );
+ }
+ return instance;
+ }
+ catch ( InstantiationException e ) {
+ throw new SearchException("Unable to instanciate class with no-arg constructor: " + cname, e);
+ }
+ catch ( IllegalAccessException e ) {
+ throw new SearchException("Unable to instanciate class with no-arg constructor: " + cname, e);
+ }
+ }
+}
Deleted: search/trunk/src/test/org/hibernate/search/test/analyzer/solr/stoplist.properties
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/analyzer/solr/stoplist.properties 2008-10-13 09:24:31 UTC (rev 15334)
+++ search/trunk/src/test/org/hibernate/search/test/analyzer/solr/stoplist.properties 2008-10-13 09:51:41 UTC (rev 15335)
@@ -1,33 +0,0 @@
-a
-an
-and
-are
-as
-at
-be
-but
-by
-for
-if
-in
-into
-is
-it
-no
-not
-of
-on
-or
-such
-that
-the
-their
-then
-there
-these
-they
-this
-to
-was
-will
-with
\ No newline at end of file
Added: search/trunk/src/test-resources/org/hibernate/search/test/analyzer/solr/stoplist.properties
===================================================================
--- search/trunk/src/test-resources/org/hibernate/search/test/analyzer/solr/stoplist.properties (rev 0)
+++ search/trunk/src/test-resources/org/hibernate/search/test/analyzer/solr/stoplist.properties 2008-10-13 09:51:41 UTC (rev 15335)
@@ -0,0 +1,33 @@
+a
+an
+and
+are
+as
+at
+be
+but
+by
+for
+if
+in
+into
+is
+it
+no
+not
+of
+on
+or
+such
+that
+the
+their
+then
+there
+these
+they
+this
+to
+was
+will
+with
\ No newline at end of file
15 years, 7 months
Hibernate SVN: r15334 - core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2.
by hibernate-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-13 05:24:31 -0400 (Mon, 13 Oct 2008)
New Revision: 15334
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractRegionImplTestCase.java
Log:
Upgraded to use a non-deprecated factory constructor
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractRegionImplTestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractRegionImplTestCase.java 2008-10-13 09:17:58 UTC (rev 15333)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractRegionImplTestCase.java 2008-10-13 09:24:31 UTC (rev 15334)
@@ -67,7 +67,7 @@
public void testActivationDeactivation() throws Exception {
// Set up a cache to monitor affects of starting the region
- Cache remoteCache = DefaultCacheFactory.getInstance().createCache(SharedCacheInstanceManager.DEFAULT_CACHE_RESOURCE, false);
+ Cache remoteCache = new DefaultCacheFactory().createCache(SharedCacheInstanceManager.DEFAULT_CACHE_RESOURCE, false);
// This test assumes replication; verify that's correct
assertEquals("Cache is REPL_SYNC", "REPL_SYNC", remoteCache.getConfiguration().getCacheModeString());
15 years, 7 months
Hibernate SVN: r15333 - core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder.
by hibernate-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-13 05:17:58 -0400 (Mon, 13 Oct 2008)
New Revision: 15333
Modified:
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/SharedCacheInstanceManager.java
Log:
Upgraded to use a non-deprecated factory constructor
Modified: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/SharedCacheInstanceManager.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/SharedCacheInstanceManager.java 2008-10-13 09:14:12 UTC (rev 15332)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/SharedCacheInstanceManager.java 2008-10-13 09:17:58 UTC (rev 15333)
@@ -190,7 +190,7 @@
protected Cache createSharedCache(Settings settings, Properties properties)
{
String configResource = PropertiesHelper.getString(CACHE_RESOURCE_PROP, properties, DEFAULT_CACHE_RESOURCE);
- return DefaultCacheFactory.getInstance().createCache(configResource, false);
+ return new DefaultCacheFactory().createCache(configResource, false);
}
/**
15 years, 7 months
Hibernate SVN: r15332 - search/trunk/src/filters.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-10-13 05:14:12 -0400 (Mon, 13 Oct 2008)
New Revision: 15332
Added:
search/trunk/src/filters/postgresql.filter
Log:
Added a filter for postgres. Trying to run all test against postgres. One test is still failing.
Added: search/trunk/src/filters/postgresql.filter
===================================================================
--- search/trunk/src/filters/postgresql.filter (rev 0)
+++ search/trunk/src/filters/postgresql.filter 2008-10-13 09:14:12 UTC (rev 15332)
@@ -0,0 +1,9 @@
+## PostgreSQL
+
+hibernate.dialect org.hibernate.dialect.PostgreSQLDialect
+hibernate.connection.driver_class org.postgresql.Driver
+hibernate.connection.username hibernate
+hibernate.connection.password hibernate
+hibernate.connection.url jdbc:postgresql://localhost:5432/hibernate
+
+
15 years, 7 months
Hibernate SVN: r15331 - search/trunk/src/test/org/hibernate/search/test/reader.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-10-13 05:13:18 -0400 (Mon, 13 Oct 2008)
New Revision: 15331
Modified:
search/trunk/src/test/org/hibernate/search/test/reader/Suspect.java
Log:
Set the field lenght for suspect charge to 500 in order to let test pass on mysql (or any other db which honours the field lenght). The default is 256, but in the test more characters are used.
Modified: search/trunk/src/test/org/hibernate/search/test/reader/Suspect.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/reader/Suspect.java 2008-10-12 23:22:31 UTC (rev 15330)
+++ search/trunk/src/test/org/hibernate/search/test/reader/Suspect.java 2008-10-13 09:13:18 UTC (rev 15331)
@@ -4,6 +4,7 @@
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
+import javax.persistence.Column;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
@@ -25,6 +26,7 @@
@Field(index = Index.TOKENIZED)
private String physicalDescription;
@Field(index = Index.TOKENIZED)
+ @Column(length = 500)
private String suspectCharge;
15 years, 7 months
Hibernate SVN: r15330 - in core/branches/Branch_3_2/src/org/hibernate: loader and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: dstephan
Date: 2008-10-12 19:22:31 -0400 (Sun, 12 Oct 2008)
New Revision: 15330
Modified:
core/branches/Branch_3_2/src/org/hibernate/dialect/Dialect.java
core/branches/Branch_3_2/src/org/hibernate/loader/Loader.java
Log:
JBPAPP-1205 - Added forceLimitUsage, Backport of HHH-2592
Modified: core/branches/Branch_3_2/src/org/hibernate/dialect/Dialect.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/dialect/Dialect.java 2008-10-12 23:19:57 UTC (rev 15329)
+++ core/branches/Branch_3_2/src/org/hibernate/dialect/Dialect.java 2008-10-12 23:22:31 UTC (rev 15330)
@@ -804,7 +804,18 @@
return false;
}
+
/**
+ * Generally, if there is no limit applied to a Hibernate query we do not apply any limits
+ * to the SQL query. This option forces that the limit be written to the SQL query.
+ *
+ * @return True to force limit into SQL query even if none specified in Hibernate query; false otherwise.
+ */
+ public boolean forceLimitUsage() {
+ return false;
+ }
+
+ /**
* Given a limit and an offset, apply the limit clause to the query.
*
* @param query The query to which to apply the limit.
@@ -813,7 +824,7 @@
* @return The modified query statement with the limit applied.
*/
public String getLimitString(String query, int offset, int limit) {
- return getLimitString( query, offset > 0 );
+ return getLimitString( query, ( offset > 0 || forceLimitUsage() ) );
}
/**
Modified: core/branches/Branch_3_2/src/org/hibernate/loader/Loader.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/loader/Loader.java 2008-10-12 23:19:57 UTC (rev 15329)
+++ core/branches/Branch_3_2/src/org/hibernate/loader/Loader.java 2008-10-12 23:22:31 UTC (rev 15330)
@@ -1638,7 +1638,7 @@
}
int firstRow = getFirstRow( selection );
int lastRow = getMaxOrLimit( selection, dialect );
- boolean hasFirstRow = firstRow > 0 && dialect.supportsLimitOffset();
+ boolean hasFirstRow = dialect.supportsLimitOffset() && ( firstRow > 0 || dialect.forceLimitUsage() );
boolean reverse = dialect.bindLimitParametersInReverseOrder();
if ( hasFirstRow ) {
statement.setInt( index + ( reverse ? 1 : 0 ), firstRow );
15 years, 7 months
Hibernate SVN: r15329 - core/tags.
by hibernate-commits@lists.jboss.org
Author: dstephan
Date: 2008-10-12 19:19:57 -0400 (Sun, 12 Oct 2008)
New Revision: 15329
Removed:
core/tags/JBOSS_EAP_3_2_4_SP1_CP05/
Log:
Deleted to avoid confusion with EAP release. See JBOSS_EAP_3_2_4_SP1_CP06 for EAP 4.3.0_CP03/EAP 4.2.0_CP05.
15 years, 7 months