Hibernate SVN: r12825 - trunk/HibernateExt/search/src/test/org/hibernate/search/test/query.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-26 12:41:36 -0400 (Thu, 26 Jul 2007)
New Revision: 12825
Modified:
trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/Book.java
trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java
Log:
more tests with Sort
Modified: trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/Book.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/Book.java 2007-07-26 16:33:54 UTC (rev 12824)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/Book.java 2007-07-26 16:41:36 UTC (rev 12825)
@@ -3,6 +3,7 @@
import java.util.Set;
import java.util.HashSet;
+import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
@@ -17,6 +18,8 @@
import org.hibernate.search.annotations.Store;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.Fields;
+import org.hibernate.search.annotations.Resolution;
+import org.hibernate.search.annotations.DateBridge;
/**
* @author Emmanuel Bernard
@@ -30,6 +33,7 @@
private String summary;
private Set<Author> authors = new HashSet<Author>();
private Author mainAuthor;
+ private Date publicationDate;
@IndexedEmbedded
@ManyToOne
@@ -89,4 +93,14 @@
public void setSummary(String summary) {
this.summary = summary;
}
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ @DateBridge(resolution=Resolution.SECOND)
+ public Date getPublicationDate() {
+ return publicationDate;
+ }
+
+ public void setPublicationDate(Date publicationDate) {
+ this.publicationDate = publicationDate;
+ }
}
Modified: trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java 2007-07-26 16:33:54 UTC (rev 12824)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java 2007-07-26 16:41:36 UTC (rev 12825)
@@ -2,6 +2,7 @@
package org.hibernate.search.test.query;
import java.util.List;
+import java.util.Calendar;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -86,6 +87,19 @@
assertEquals( "Wrong number of test results.", 4, result.size() );
assertEquals( "Hibernate & Lucene", result.get( 0 ).getSummary() );
+ // order by date backwards
+ query = parser.parse( "summary:lucene OR summary:action" );
+ hibQuery = s.createFullTextQuery( query, Book.class );
+ sort = new Sort( new SortField( "publicationDate", SortField.STRING, true ) ); //DESC
+ hibQuery.setSort( sort );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Wrong number of test results.", 4, result.size() );
+ for (Book book : result) {
+ System.out.println(book.getSummary() + " : " + book.getPublicationDate() );
+ }
+ assertEquals( "Groovy in Action", result.get( 0 ).getSummary() );
+
tx.commit();
deleteTestBooks(s);
@@ -101,13 +115,22 @@
*/
private void createTestBooks(FullTextSession s) {
Transaction tx = s.beginTransaction();
+ Calendar cal = Calendar.getInstance( );
+ cal.set( 2007, 07, 25, 11, 20, 30);
Book book = new Book(1, "Hibernate & Lucene", "This is a test book.");
+ book.setPublicationDate( cal.getTime() );
s.save(book);
+ cal.add( Calendar.SECOND, 1 );
book = new Book(2, "Hibernate & Lucene", "This is a test book.");
+ book.setPublicationDate( cal.getTime() );
s.save(book);
+ cal.add( Calendar.SECOND, 1 );
book = new Book(3, "Hibernate & Lucene", "This is a test book.");
+ book.setPublicationDate( cal.getTime() );
s.save(book);
+ cal.add( Calendar.SECOND, 1 );
book = new Book(4, "Groovy in Action", "The bible of Groovy");
+ book.setPublicationDate( cal.getTime() );
s.save(book);
tx.commit();
s.clear();
17 years, 5 months
Hibernate SVN: r12824 - core/branches/Branch_3_2.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-26 12:33:54 -0400 (Thu, 26 Jul 2007)
New Revision: 12824
Modified:
core/branches/Branch_3_2/build.xml
Log:
fork tests
Modified: core/branches/Branch_3_2/build.xml
===================================================================
--- core/branches/Branch_3_2/build.xml 2007-07-26 03:53:09 UTC (rev 12823)
+++ core/branches/Branch_3_2/build.xml 2007-07-26 16:33:54 UTC (rev 12824)
@@ -91,7 +91,6 @@
</path>
<!-- allows external definition of the JDBC classpath fragment -->
<property name="hibernate.test.jdbc.fs.importFile" value="doNotImport" />
- <import file="${hibernate.test.jdbc.fs.importFile}" optional="true" />
<!-- patternset for insturmentation-eligible resources -->
<patternset id="ps.instrument.domain">
@@ -99,6 +98,9 @@
<exclude name="**/*.hbm.xml" />
</patternset>
+ <!-- Define default test suite parameters -->
+ <property name="hibernate.junit.forkmode" value="perBatch"/>
+ <property name="hibernate.junit.timeout" value="2147483647"/>
<!-- ################################################################## -->
<!-- ############################# Tasks ############################## -->
@@ -283,7 +285,7 @@
<pathelement path="${dir.props}"/>
</path>
- <junit printsummary="yes" dir="${basedir}" maxmemory="256M" fork="yes" forkmode="perBatch">
+ <junit printsummary="yes" dir="${basedir}" maxmemory="256M" fork="yes" forkmode="${hibernate.junit.forkmode}" timeout="${hibernate.junit.timeout}">
<jvmarg value="-Dhibernate.test.validatefailureexpected=${hibernate.test.validatefailureexpected}"/>
<classpath>
<fileset refid="fs.lib" />
@@ -311,7 +313,7 @@
<target name="junit.instrument.cglib" depends="instrument.cglib">
<mkdir dir="${dir.out.junit}"/>
- <junit printsummary="yes" maxmemory="256M" fork="yes">
+ <junit printsummary="yes" maxmemory="256M" fork="yes" timeout="${hibernate.junit.timeout}">
<jvmarg value="-Dhibernate.test.validatefailureexpected=${hibernate.test.validatefailureexpected}"/>
<classpath>
<fileset refid="fs.lib" />
@@ -333,7 +335,7 @@
<target name="junit.instrument.javassist" depends="instrument.javassist">
<mkdir dir="${dir.out.junit}"/>
- <junit printsummary="yes" maxmemory="256M" fork="yes">
+ <junit printsummary="yes" maxmemory="256M" fork="yes" timeout="${hibernate.junit.timeout}">
<jvmarg value="-Dhibernate.test.validatefailureexpected=${hibernate.test.validatefailureexpected}"/>
<classpath>
<fileset refid="fs.lib" />
@@ -357,7 +359,7 @@
<target name="junitsingle" depends="cleantestdb,compiletest" description="Run a single test suite (requires testname and jar.driver properties)">
<delete dir="${dir.out.junit}"/>
<mkdir dir="${dir.out.junit}"/>
- <junit printsummary="yes" fork="yes" haltonfailure="yes" dir="${basedir}">
+ <junit printsummary="yes" fork="yes" haltonfailure="yes" dir="${basedir}" timeout="${hibernate.junit.timeout}">
<classpath>
<fileset refid="fs.lib" />
<path refid="path.jdbc" />
17 years, 5 months
Hibernate SVN: r12823 - in core/trunk: cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2 and 8 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-25 23:53:09 -0400 (Wed, 25 Jul 2007)
New Revision: 12823
Added:
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/TransactionalDataRegionAdapter.java
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/CollectionRegionImpl.java
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/ReadOnlyAccess.java
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/TransactionalAccess.java
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/TransactionalAccess.java
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/util/
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/util/CacheModeHelper.java
core/trunk/cache-jbosscache2/src/test/
core/trunk/cache-jbosscache2/src/test/java/
core/trunk/cache-jbosscache2/src/test/java/org/
core/trunk/cache-jbosscache2/src/test/resources/
Modified:
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/BasicRegionAdapter.java
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/JBossCacheRegionFactory.java
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/InvalidationCacheInstanceManager.java
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/MultiplexingCacheInstanceManager.java
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/EntityRegionImpl.java
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/ReadOnlyAccess.java
core/trunk/core/src/main/java/org/hibernate/cache/access/CollectionRegionAccessStrategy.java
core/trunk/core/src/main/java/org/hibernate/cache/access/EntityRegionAccessStrategy.java
core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java
Log:
jbosscache 2.x work
Modified: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/BasicRegionAdapter.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/BasicRegionAdapter.java 2007-07-26 02:12:05 UTC (rev 12822)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/BasicRegionAdapter.java 2007-07-26 03:53:09 UTC (rev 12823)
@@ -63,6 +63,14 @@
return regionName;
}
+ public Cache getCacheInstance() {
+ return jbcCache;
+ }
+
+ public Fqn getRegionFqn() {
+ return regionFqn;
+ }
+
public void destroy() throws CacheException {
try {
// NOTE : this is being used from the process of shutting down a
Modified: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/JBossCacheRegionFactory.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/JBossCacheRegionFactory.java 2007-07-26 02:12:05 UTC (rev 12822)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/JBossCacheRegionFactory.java 2007-07-26 03:53:09 UTC (rev 12823)
@@ -25,6 +25,7 @@
import org.hibernate.cache.RegionFactory;
import org.hibernate.cache.TimestampsRegion;
import org.hibernate.cache.jbc2.builder.InvalidationCacheInstanceManager;
+import org.hibernate.cache.jbc2.collection.CollectionRegionImpl;
import org.hibernate.cache.jbc2.entity.EntityRegionImpl;
import org.hibernate.cfg.Settings;
@@ -74,7 +75,7 @@
String regionName,
Properties properties,
CacheDataDescription metadata) throws CacheException {
- return null;
+ return new CollectionRegionImpl( cacheInstanceManager.getCollectionCacheInstance(), regionName, metadata );
}
public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException {
Added: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/TransactionalDataRegionAdapter.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/TransactionalDataRegionAdapter.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/TransactionalDataRegionAdapter.java 2007-07-26 03:53:09 UTC (rev 12823)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.cache.jbc2;
+
+import org.jboss.cache.Cache;
+
+import org.hibernate.cache.TransactionalDataRegion;
+import org.hibernate.cache.CacheDataDescription;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class TransactionalDataRegionAdapter extends BasicRegionAdapter implements TransactionalDataRegion {
+ protected final CacheDataDescription metadata;
+
+ public TransactionalDataRegionAdapter(Cache jbcCache, String regionName, CacheDataDescription metadata) {
+ super( jbcCache, regionName );
+ this.metadata = metadata;
+ }
+
+ /**
+ * Here, for JBossCache, we consider the cache to be transaction aware if the underlying
+ * cache instance has a refernece to the transaction manager.
+ */
+ public boolean isTransactionAware() {
+ return jbcCache.getConfiguration().getRuntimeConfig().getTransactionManager() != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public CacheDataDescription getCacheDataDescription() {
+ return metadata;
+ }
+}
Modified: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/InvalidationCacheInstanceManager.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/InvalidationCacheInstanceManager.java 2007-07-26 02:12:05 UTC (rev 12822)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/InvalidationCacheInstanceManager.java 2007-07-26 03:53:09 UTC (rev 12823)
@@ -16,22 +16,25 @@
package org.hibernate.cache.jbc2.builder;
import java.util.Properties;
-
import javax.transaction.TransactionManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
import org.jboss.cache.DefaultCacheFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.util.PropertiesHelper;
+import org.hibernate.cache.CacheException;
import org.hibernate.cache.jbc2.CacheInstanceManager;
+import org.hibernate.cache.jbc2.util.CacheModeHelper;
import org.hibernate.cfg.Settings;
+import org.hibernate.util.PropertiesHelper;
/**
- * A {@link org.hibernate.cache.jbc2.CacheInstanceManager} implementation where we use a single cache instance
+ * A {@link CacheInstanceManager} implementation where we use a single cache instance
* we assume to be configured for invalidation if operating on a cluster. Under that
* assumption, we can store all data into the same {@link Cache} instance.
+ * <p/>
+ * todo : this is built on the assumption that JBC clustered invalidation is changed to keep the "cache node" around on the other "cluster nodes"
*
* @author Steve Ebersole
*/
@@ -77,6 +80,9 @@
* {@inheritDoc}
*/
public Cache getQueryCacheInstance() {
+ if ( CacheModeHelper.isClusteredInvalidation( cache ) ) {
+ throw new CacheException( "Query cache not supported for clustered invalidation" );
+ }
return cache;
}
@@ -84,6 +90,9 @@
* {@inheritDoc}
*/
public Cache getTimestampsCacheInstance() {
+ if ( CacheModeHelper.isClusteredInvalidation( cache ) ) {
+ throw new CacheException( "Query cache not supported for clustered invalidation" );
+ }
return cache;
}
Modified: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/MultiplexingCacheInstanceManager.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/MultiplexingCacheInstanceManager.java 2007-07-26 02:12:05 UTC (rev 12822)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/MultiplexingCacheInstanceManager.java 2007-07-26 03:53:09 UTC (rev 12823)
@@ -30,9 +30,11 @@
/**
* Here we build separate {@link Cache} instances for each type of region, but
- * using the jgroups multiplexer under the covers to re-use the same group comm
- * stack.
- *
+ * using the jgroups multiplexer under the covers to re-use the same group
+ * communication stack.
+ * <p/>
+ * todo : this can get simplified once JBC implemants their "configuration factory" (the stuff akin to channel factory)
+ *
* @author Steve Ebersole
*/
public class MultiplexingCacheInstanceManager implements CacheInstanceManager {
Added: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/CollectionRegionImpl.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/CollectionRegionImpl.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/CollectionRegionImpl.java 2007-07-26 03:53:09 UTC (rev 12823)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.cache.jbc2.collection;
+
+import org.jboss.cache.Cache;
+
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CollectionRegion;
+import org.hibernate.cache.access.AccessType;
+import org.hibernate.cache.access.CollectionRegionAccessStrategy;
+import org.hibernate.cache.jbc2.TransactionalDataRegionAdapter;
+
+/**
+ * Defines the behavior of the collection cache regions for JBossCache.
+ *
+ * @author Steve Ebersole
+ */
+public class CollectionRegionImpl extends TransactionalDataRegionAdapter implements CollectionRegion {
+ public CollectionRegionImpl(Cache jbcCache, String regionName, CacheDataDescription metadata) {
+ super( jbcCache, regionName, metadata );
+ }
+
+ public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
+ if ( AccessType.READ_ONLY.equals( accessType ) ) {
+ return new ReadOnlyAccess( this );
+ }
+ if ( AccessType.TRANSACTIONAL.equals( accessType ) ) {
+ return new TransactionalAccess( this );
+ }
+
+ // todo : add support for READ_WRITE ( + NONSTRICT_READ_WRITE ??? )
+
+ throw new CacheException( "unsupported access type [" + accessType.getName() + "]" );
+ }
+}
Added: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/ReadOnlyAccess.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/ReadOnlyAccess.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/ReadOnlyAccess.java 2007-07-26 03:53:09 UTC (rev 12823)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.cache.jbc2.collection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.hibernate.cache.access.SoftLock;
+import org.hibernate.cache.CacheException;
+
+/**
+ * This defines the strategy for transactional access to enity data in JBossCache using its 2.x APIs
+ * <p/>
+ * read-only access to a JBossCache really is still transactional, just with
+ * the extra semantic or guarentee that we will not update data.
+ *
+ * @author Steve Ebersole
+ */
+public class ReadOnlyAccess extends TransactionalAccess {
+ private static final Log log = LogFactory.getLog( ReadOnlyAccess.class );
+
+ public ReadOnlyAccess(CollectionRegionImpl region) {
+ super( region );
+ }
+
+ public SoftLock lockItem(Object key, Object version) throws CacheException {
+ throw new UnsupportedOperationException( "Illegal attempt to edit read only item" );
+ }
+
+ public SoftLock lockRegion() throws CacheException {
+ throw new UnsupportedOperationException( "Illegal attempt to edit read only region" );
+ }
+
+ public void unlockItem(Object key, SoftLock lock) throws CacheException {
+ log.error( "Illegal attempt to edit read only item" );
+ }
+
+ public void unlockRegion(SoftLock lock) throws CacheException {
+ log.error( "Illegal attempt to edit read only region" );
+ }
+
+ public boolean update(
+ Object key,
+ Object value,
+ Object currentVersion,
+ Object previousVersion) throws CacheException {
+ throw new UnsupportedOperationException( "Illegal attempt to edit read only item" );
+ }
+
+ public boolean afterUpdate(
+ Object key,
+ Object value,
+ Object currentVersion,
+ Object previousVersion,
+ SoftLock lock) throws CacheException {
+ throw new UnsupportedOperationException( "Illegal attempt to edit read only item" );
+ }
+}
Added: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/TransactionalAccess.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/TransactionalAccess.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/TransactionalAccess.java 2007-07-26 03:53:09 UTC (rev 12823)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.cache.jbc2.collection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.hibernate.cache.access.CollectionRegionAccessStrategy;
+import org.hibernate.cache.access.SoftLock;
+import org.hibernate.cache.CollectionRegion;
+import org.hibernate.cache.CacheException;
+
+/**
+ * todo : implement
+ *
+ * @author Steve Ebersole
+ */
+public class TransactionalAccess implements CollectionRegionAccessStrategy {
+ private static final Log log = LogFactory.getLog( TransactionalAccess.class );
+
+ private final CollectionRegionImpl region;
+
+ public TransactionalAccess(CollectionRegionImpl region) {
+ this.region = region;
+ }
+
+ public CollectionRegion getRegion() {
+ return region;
+ }
+
+ public Object get(Object key, long txTimestamp) throws CacheException {
+ return null;
+ }
+
+ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException {
+ return false;
+ }
+
+ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride)
+ throws CacheException {
+ return false;
+ }
+
+ public SoftLock lockItem(Object key, Object version) throws CacheException {
+ return null;
+ }
+
+ public SoftLock lockRegion() throws CacheException {
+ return null;
+ }
+
+ public void unlockItem(Object key, SoftLock lock) throws CacheException {
+ }
+
+ public void unlockRegion(SoftLock lock) throws CacheException {
+ }
+
+ public void remove(Object key) throws CacheException {
+ }
+
+ public void removeAll() throws CacheException {
+ }
+
+ public void evict(Object key) throws CacheException {
+ }
+
+ public void evictAll() throws CacheException {
+ }
+}
Modified: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/EntityRegionImpl.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/EntityRegionImpl.java 2007-07-26 02:12:05 UTC (rev 12822)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/EntityRegionImpl.java 2007-07-26 03:53:09 UTC (rev 12823)
@@ -16,63 +16,38 @@
package org.hibernate.cache.jbc2.entity;
import org.jboss.cache.Cache;
-import org.jboss.cache.Fqn;
import org.hibernate.cache.CacheDataDescription;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.EntityRegion;
import org.hibernate.cache.access.AccessType;
import org.hibernate.cache.access.EntityRegionAccessStrategy;
-import org.hibernate.cache.jbc2.BasicRegionAdapter;
+import org.hibernate.cache.jbc2.TransactionalDataRegionAdapter;
-
/**
* Defines the behavior of the entity cache regions for JBossCache.
*
* @author Steve Ebersole
*/
-public class EntityRegionImpl extends BasicRegionAdapter implements EntityRegion {
- private final CacheDataDescription metadata;
+public class EntityRegionImpl extends TransactionalDataRegionAdapter implements EntityRegion {
public EntityRegionImpl(Cache jbcCache, String regionName, CacheDataDescription metadata) {
- super( jbcCache, regionName );
- this.metadata = metadata;
+ super( jbcCache, regionName, metadata );
}
/**
* {@inheritDoc}
*/
public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
- // todo : allow the other strategies, which will require a non-transactional cache instance
- if ( ! ( AccessType.READ_ONLY.equals( accessType ) || AccessType.TRANSACTIONAL.equals( accessType ) ) ) {
- throw new CacheException(
- "TreeCacheRegionFactory only supports " + AccessType.READ_ONLY.getName() + " or " +
- AccessType.TRANSACTIONAL + " access strategies [" + accessType.getName() + "]"
- );
+ if ( AccessType.READ_ONLY.equals( accessType ) ) {
+ return new ReadOnlyAccess( this );
}
- return null;
- }
+ if ( AccessType.TRANSACTIONAL.equals( accessType ) ) {
+ return new TransactionalAccess( this );
+ }
- /**
- * Here, for JBossCache, we consider the cache to be transaction aware if the underlying
- * cache instance has a refernece to the transaction manager.
- */
- public boolean isTransactionAware() {
- return jbcCache.getConfiguration().getRuntimeConfig().getTransactionManager() != null;
- }
+ // todo : add support for READ_WRITE ( + NONSTRICT_READ_WRITE ??? )
- /**
- * {@inheritDoc}
- */
- public CacheDataDescription getCacheDataDescription() {
- return metadata;
+ throw new CacheException( "unsupported access type [" + accessType.getName() + "]" );
}
-
- Cache getCacheInstance() {
- return jbcCache;
- }
-
- Fqn getRegionFqn() {
- return regionFqn;
- }
}
Modified: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/ReadOnlyAccess.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/ReadOnlyAccess.java 2007-07-26 02:12:05 UTC (rev 12822)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/ReadOnlyAccess.java 2007-07-26 03:53:09 UTC (rev 12823)
@@ -15,107 +15,49 @@
*/
package org.hibernate.cache.jbc2.entity;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.lock.TimeoutException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.cache.access.EntityRegionAccessStrategy;
import org.hibernate.cache.access.SoftLock;
-import org.hibernate.cache.EntityRegion;
import org.hibernate.cache.CacheException;
/**
- * {@inheritDoc}
+ * This defines the strategy for transactional access to enity data in JBossCache using its 2.x APIs
+ * <p/>
+ * read-only access to a JBossCache really is still transactional, just with
+ * the extra semantic or guarentee that we will not update data.
*
* @author Steve Ebersole
*/
-public class ReadOnlyAccess implements EntityRegionAccessStrategy {
+public class ReadOnlyAccess extends TransactionalAccess {
private static final Log log = LogFactory.getLog( ReadOnlyAccess.class );
- private final EntityRegionImpl region;
-
public ReadOnlyAccess(EntityRegionImpl region) {
- this.region = region;
+ super( region );
}
- public EntityRegion getRegion() {
- return region;
- }
-
- public Object get(Object key, long txTimestamp) throws CacheException {
- try {
- return region.getCacheInstance().get( region.getRegionFqn(), EntityRegionImpl.ITEM );
- }
- catch ( Exception e ) {
- throw new CacheException( e );
- }
- }
-
- public boolean putFromLoad(
- Object key,
- Object value,
- long txTimestamp,
- Object version) throws CacheException {
- try {
- region.getCacheInstance().putForExternalRead( region.getRegionFqn(), key, value );
- return true;
- }
- catch ( TimeoutException te) {
- //ignore!
- log.debug( "ignoring write lock acquisition failure" );
- return false;
- }
- catch ( Throwable t ) {
- throw new CacheException( t );
- }
- }
-
- public boolean putFromLoad(
- Object key,
- Object value,
- long txTimestamp,
- Object version,
- boolean minimalPutOverride) throws CacheException {
- return putFromLoad( key, value, txTimestamp, version );
- }
-
public SoftLock lockItem(Object key, Object version) throws CacheException {
- throw new UnsupportedOperationException( "Illegal attempt to lock (edit) read only item" );
+ throw new UnsupportedOperationException( "Illegal attempt to edit read only item" );
}
public SoftLock lockRegion() throws CacheException {
- throw new UnsupportedOperationException( "Illegal attempt to lock (edit) read only region" );
+ throw new UnsupportedOperationException( "Illegal attempt to edit read only region" );
}
public void unlockItem(Object key, SoftLock lock) throws CacheException {
- log.error( "Illegal attempt to lock (edit) read only item" );
+ log.error( "Illegal attempt to edit read only item" );
}
public void unlockRegion(SoftLock lock) throws CacheException {
- log.error( "Illegal attempt to lock (edit) read only region" );
+ log.error( "Illegal attempt to edit read only region" );
}
- public boolean insert(Object key, Object value, Object version) throws CacheException {
- try {
- region.getCacheInstance().put( new Fqn( region.getRegionFqn(), key ), EntityRegionImpl.ITEM, value );
- }
- catch (Exception e) {
- throw new CacheException(e);
- }
- return true;
- }
-
- public boolean afterInsert(Object key, Object value, Object version) throws CacheException {
- return false;
- }
-
public boolean update(
Object key,
Object value,
Object currentVersion,
Object previousVersion) throws CacheException {
- throw new UnsupportedOperationException( "Illegal attempt to lock (edit) read only item" );
+ throw new UnsupportedOperationException( "Illegal attempt to edit read only item" );
}
public boolean afterUpdate(
@@ -124,34 +66,6 @@
Object currentVersion,
Object previousVersion,
SoftLock lock) throws CacheException {
- throw new UnsupportedOperationException( "Illegal attempt to lock (edit) read only item" );
+ throw new UnsupportedOperationException( "Illegal attempt to edit read only item" );
}
-
- public void remove(Object key) throws CacheException {
- try {
- region.getCacheInstance().remove( region.getRegionFqn(), key );
- }
- catch ( Exception e ) {
- throw new CacheException( e );
- }
- }
-
- public void removeAll() throws CacheException {
- try {
- region.getCacheInstance().removeNode( region.getRegionFqn() );
- }
- catch ( Exception e ) {
- throw new CacheException( e );
- }
- }
-
- public void evict(Object key) throws CacheException {
- }
-
- public void evictAll() throws CacheException {
- }
-
- public void destroy() {
- region.destroy();
- }
}
Added: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/TransactionalAccess.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/TransactionalAccess.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/TransactionalAccess.java 2007-07-26 03:53:09 UTC (rev 12823)
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.cache.jbc2.entity;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.lock.TimeoutException;
+
+import org.hibernate.cache.access.EntityRegionAccessStrategy;
+import org.hibernate.cache.access.SoftLock;
+import org.hibernate.cache.EntityRegion;
+import org.hibernate.cache.CacheException;
+
+/**
+ * This defines the strategy for transactional access to enity data
+ * in JBossCache using its 2.x APIs
+ *
+ * @author Steve Ebersole
+ */
+public class TransactionalAccess implements EntityRegionAccessStrategy {
+ private static final Log log = LogFactory.getLog( TransactionalAccess.class );
+
+ private final EntityRegionImpl region;
+
+ public TransactionalAccess(EntityRegionImpl region) {
+ this.region = region;
+ }
+
+ public EntityRegion getRegion() {
+ return region;
+ }
+
+ public Object get(Object key, long txTimestamp) throws CacheException {
+ try {
+ return region.getCacheInstance().get( region.getRegionFqn(), EntityRegionImpl.ITEM );
+ }
+ catch ( Exception e ) {
+ throw new CacheException( e );
+ }
+ }
+
+ public boolean putFromLoad(
+ Object key,
+ Object value,
+ long txTimestamp,
+ Object version) throws CacheException {
+ try {
+ region.getCacheInstance().putForExternalRead( new Fqn( region.getRegionFqn(), key ), EntityRegionImpl.ITEM, value );
+ return true;
+ }
+ catch ( TimeoutException te) {
+ //ignore!
+ log.debug( "ignoring write lock acquisition failure" );
+ return false;
+ }
+ catch ( Throwable t ) {
+ throw new CacheException( t );
+ }
+ }
+
+ public boolean putFromLoad(
+ Object key,
+ Object value,
+ long txTimestamp,
+ Object version,
+ boolean minimalPutOverride) throws CacheException {
+ if ( minimalPutOverride && get( key, txTimestamp ) != null ) {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "item already cached: " + key );
+ }
+ return false;
+ }
+ return putFromLoad( key, value, txTimestamp, version );
+ }
+
+ public SoftLock lockItem(Object key, Object version) throws CacheException {
+ return null;
+ }
+
+ public SoftLock lockRegion() throws CacheException {
+ return null;
+ }
+
+ public void unlockItem(Object key, SoftLock lock) throws CacheException {
+ }
+
+ public void unlockRegion(SoftLock lock) throws CacheException {
+ }
+
+ public boolean insert(Object key, Object value, Object version) throws CacheException {
+ try {
+ region.getCacheInstance().put( new Fqn( region.getRegionFqn(), key ), EntityRegionImpl.ITEM, value );
+ }
+ catch ( Throwable t ) {
+ throw new CacheException( t );
+ }
+ return true;
+ }
+
+ public boolean afterInsert(Object key, Object value, Object version) throws CacheException {
+ return false;
+ }
+
+ public boolean update(Object key, Object value, Object currentVersion, Object previousVersion)
+ throws CacheException {
+ try {
+ region.getCacheInstance().put( new Fqn( region.getRegionFqn(), key ), EntityRegionImpl.ITEM, value );
+ }
+ catch ( Throwable t ) {
+ throw new CacheException( t );
+ }
+ return true;
+ }
+
+ public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock)
+ throws CacheException {
+ return false;
+ }
+
+ public void remove(Object key) throws CacheException {
+ try {
+ region.getCacheInstance().removeNode( new Fqn( region.getRegionFqn(), key ) );
+ }
+ catch ( Exception e ) {
+ throw new CacheException( e );
+ }
+ }
+
+ public void removeAll() throws CacheException {
+ try {
+ region.getCacheInstance().removeNode( region.getRegionFqn() );
+ }
+ catch ( Exception e ) {
+ throw new CacheException( e );
+ }
+ }
+
+ public void evict(Object key) throws CacheException {
+ remove( key );
+ }
+
+ public void evictAll() throws CacheException {
+ removeAll();
+ }
+}
Added: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/util/CacheModeHelper.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/util/CacheModeHelper.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/util/CacheModeHelper.java 2007-07-26 03:53:09 UTC (rev 12823)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.cache.jbc2.util;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.config.Configuration;
+
+/**
+ * Helper for dealing with JBossCache {@link Configuration.CacheMode}.
+ *
+ * @author Steve Ebersole
+ */
+public class CacheModeHelper {
+ /**
+ * Disallow external instantiation of CacheModeHelper.
+ */
+ private CacheModeHelper() {
+ }
+
+ /**
+ * Is this cache participating in a cluster with invalidation?
+ *
+ * @param cache The cache to check.
+ * @return True if the cache is configured for synchronous/asynchronous invalidation; false
+ * otherwise.
+ */
+ public static boolean isClusteredInvalidation(Cache cache) {
+ return isClusteredInvalidation( cache.getConfiguration().getCacheMode() );
+ }
+
+ /**
+ * Does this cache mode indicate clustered invalidation?
+ *
+ * @param cacheMode The cache to check
+ * @return True if the cache mode is confiogured for synchronous/asynchronous invalidation; false
+ * otherwise.
+ */
+ public static boolean isClusteredInvalidation(Configuration.CacheMode cacheMode) {
+ return cacheMode == Configuration.CacheMode.REPL_ASYNC || cacheMode == Configuration.CacheMode.REPL_SYNC;
+ }
+}
Modified: core/trunk/core/src/main/java/org/hibernate/cache/access/CollectionRegionAccessStrategy.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/access/CollectionRegionAccessStrategy.java 2007-07-26 02:12:05 UTC (rev 12822)
+++ core/trunk/core/src/main/java/org/hibernate/cache/access/CollectionRegionAccessStrategy.java 2007-07-26 03:53:09 UTC (rev 12823)
@@ -1,7 +1,5 @@
package org.hibernate.cache.access;
-import java.util.Comparator;
-
import org.hibernate.cache.CacheException;
import org.hibernate.cache.CollectionRegion;
@@ -148,9 +146,4 @@
* @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
*/
public void evictAll() throws CacheException;
-
- /**
- * Clean up all resources.
- */
- public void destroy();
}
Modified: core/trunk/core/src/main/java/org/hibernate/cache/access/EntityRegionAccessStrategy.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/access/EntityRegionAccessStrategy.java 2007-07-26 02:12:05 UTC (rev 12822)
+++ core/trunk/core/src/main/java/org/hibernate/cache/access/EntityRegionAccessStrategy.java 2007-07-26 03:53:09 UTC (rev 12823)
@@ -203,9 +203,4 @@
* @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
*/
public void evictAll() throws CacheException;
-
- /**
- * Clean up all resources.
- */
- public void destroy();
}
Modified: core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java 2007-07-26 02:12:05 UTC (rev 12822)
+++ core/trunk/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java 2007-07-26 03:53:09 UTC (rev 12823)
@@ -772,7 +772,7 @@
while ( iter.hasNext() ) {
EntityPersister p = (EntityPersister) iter.next();
if ( p.hasCache() ) {
- p.getCacheAccessStrategy().destroy();
+ p.getCacheAccessStrategy().getRegion().destroy();
}
}
@@ -780,7 +780,7 @@
while ( iter.hasNext() ) {
CollectionPersister p = (CollectionPersister) iter.next();
if ( p.hasCache() ) {
- p.getCacheAccessStrategy().destroy();
+ p.getCacheAccessStrategy().getRegion().destroy();
}
}
17 years, 5 months
Hibernate SVN: r12822 - in trunk/HibernateExt/annotations/src/java/org/hibernate: cfg and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: d.plentz
Date: 2007-07-25 22:12:05 -0400 (Wed, 25 Jul 2007)
New Revision: 12822
Modified:
trunk/HibernateExt/annotations/src/java/org/hibernate/annotations/SQLDeleteAll.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationConfiguration.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyHolderBuilder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/type/EnumType.java
Log:
Just some code cleanup.
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/annotations/SQLDeleteAll.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/annotations/SQLDeleteAll.java 2007-07-26 01:32:22 UTC (rev 12821)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/annotations/SQLDeleteAll.java 2007-07-26 02:12:05 UTC (rev 12822)
@@ -1,14 +1,14 @@
//$Id: $
package org.hibernate.annotations;
-import java.lang.annotation.Target;
-import java.lang.annotation.Retention;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.RetentionPolicy;
-import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
/**
* SqlDelete Annotation for overwriting Hibernate default DELETE ALL method
*
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java 2007-07-26 01:32:22 UTC (rev 12821)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java 2007-07-26 02:12:05 UTC (rev 12822)
@@ -475,7 +475,6 @@
}
if ( InheritanceType.SINGLE_TABLE.equals( inheritanceState.type ) ) {
- javax.persistence.Inheritance inhAnn = annotatedClass.getAnnotation( javax.persistence.Inheritance.class );
javax.persistence.DiscriminatorColumn discAnn = annotatedClass.getAnnotation(
javax.persistence.DiscriminatorColumn.class
);
@@ -1587,8 +1586,8 @@
else {
//define whether the type is a component or not
boolean isComponent = false;
- Embeddable embeddableAnn = (Embeddable) returnedClass.getAnnotation( Embeddable.class );
- Embedded embeddedAnn = (Embedded) property.getAnnotation( Embedded.class );
+ Embeddable embeddableAnn = returnedClass.getAnnotation( Embeddable.class );
+ Embedded embeddedAnn = property.getAnnotation( Embedded.class );
isComponent = embeddedAnn != null || embeddableAnn != null;
if ( isComponent ) {
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationConfiguration.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationConfiguration.java 2007-07-26 01:32:22 UTC (rev 12821)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationConfiguration.java 2007-07-26 02:12:05 UTC (rev 12822)
@@ -20,6 +20,7 @@
import java.util.SortedSet;
import java.util.StringTokenizer;
import java.util.TreeSet;
+
import javax.persistence.Entity;
import javax.persistence.MappedSuperclass;
@@ -317,7 +318,7 @@
}
super.secondPassCompile();
inSecondPass = false;
- Iterator tables = (Iterator<Map.Entry<Table, List<String[]>>>) tableUniqueConstraints.entrySet().iterator();
+ Iterator tables = tableUniqueConstraints.entrySet().iterator();
Table table;
Map.Entry entry;
String keyName;
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyHolderBuilder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyHolderBuilder.java 2007-07-26 01:32:22 UTC (rev 12821)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyHolderBuilder.java 2007-07-26 02:12:05 UTC (rev 12822)
@@ -27,7 +27,7 @@
//Map<String, Join> joins,
ExtendedMappings mappings
) {
- return (PropertyHolder) new ClassPropertyHolder( persistentClass, clazzToProcess, entityBinder, mappings );
+ return new ClassPropertyHolder( persistentClass, clazzToProcess, entityBinder, mappings );
}
/**
@@ -42,7 +42,7 @@
Component component, String path, PropertyData inferredData, PropertyHolder parent,
ExtendedMappings mappings
) {
- return (PropertyHolder) new ComponentPropertyHolder( component, path, inferredData, parent, mappings );
+ return new ComponentPropertyHolder( component, path, inferredData, parent, mappings );
}
/**
@@ -62,6 +62,6 @@
PersistentClass persistentClass, Map<String, Join> joins,
ExtendedMappings mappings
) {
- return (PropertyHolder) new ClassPropertyHolder( persistentClass, null, joins, mappings );
+ return new ClassPropertyHolder( persistentClass, null, joins, mappings );
}
}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/type/EnumType.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/type/EnumType.java 2007-07-26 01:32:22 UTC (rev 12821)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/type/EnumType.java 2007-07-26 02:12:05 UTC (rev 12822)
@@ -5,7 +5,6 @@
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.lang.reflect.Method;
-import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -131,115 +130,6 @@
}
}
- //TODO remove
- private void guessType(PreparedStatement statement, int index) {
- //TODO use SQLException wrapper?
- if ( ! guessed ) {
- try {
- sqlType = guessTypeFromMetaData( statement.getConnection().getMetaData() );
- }
- catch (SQLException e) {
- sqlType = guessTypeByParameter( statement, index, e );
- }
- catch (HibernateException e) {
- sqlType = guessTypeByParameter( statement, index, e );
- }
- guessed = true;
- }
- }
-
- //TODO remove
- private int guessTypeFromMetaData(DatabaseMetaData metadata) throws SQLException {
- ResultSet rs = null;
- try {
- String username = metadata.getUserName();
- int guessedType = Types.NULL;
- int numResults = 0;
- boolean nonNullType = false;
-
- // Try to find the column information up to three times. First with values as is in case
- // the database ever stores mixed case identifiers, or the supplied identifiers match
- // perfectly. Then if the metadata is not found, try using lower and upper case
- // identifiers - but only if the datbaase reports it would use them.
- rs = metadata.getColumns( catalog, schema, table, column );
-
- boolean isValid;
-
- isValid = rs.next();
-
- if ( ! isValid && metadata.storesLowerCaseIdentifiers() ) {
- rs.close();
- rs = metadata.getColumns(
- catalog == null ? catalog : catalog.toLowerCase(),
- schema == null ? schema : schema.toLowerCase(),
- table.toLowerCase(), column.toLowerCase()
- );
- isValid = rs.next();
- }
-
- if ( ! isValid && metadata.storesUpperCaseIdentifiers() ) {
- rs.close();
- rs = metadata.getColumns(
- catalog == null ? catalog : catalog.toUpperCase(),
- schema == null ? schema : schema.toUpperCase(),
- table.toUpperCase(), column.toUpperCase()
- );
- isValid = rs.next();
- }
-
- // try to find
- while ( isValid ) {
- guessedType = rs.getInt( "DATA_TYPE" );
- if ( rs.wasNull() ) {
- continue; // TODO throw exception?
- }
- else {
- nonNullType = true;
- }
-
- numResults++;
- if ( username != null ) {
- String schema = rs.getString( "TABLE_SCHEM" );
- // if the username matches the schema, there's no better guess available...
- if ( username.equalsIgnoreCase( schema ) ) return guessedType;
- }
- else if ( numResults > 1 ) {
- // if there's no username and multiple results, there's no point in continuing
- throw new HibernateException( "Several columns matching in metadata: " + column );
- }
- isValid = rs.next();
- }
- if ( numResults == 0 ) throw new HibernateException( "Enum type column not found in metadata: " + column );
- if ( numResults > 1 ) throw new HibernateException( "Several columns matching in metadata: " + column );
- if ( !nonNullType ) throw new HibernateException( "Column without type in metadata!: " + column );
- log.trace( "Enum type guessed from metadata: " + guessedType );
- return guessedType;
- }
- finally {
- try {
- if ( rs != null ) rs.close();
- }
- catch (SQLException e) {
- //swallow in purpose
- }
- }
- }
-
- //TODO remove
- private int guessTypeByParameter(PreparedStatement statement, int index, Exception e) {
- log.debug(
- "Unable to guess the column type for enum through conn.getMetadata(): "
- + e.getMessage()
- );
- try {
- return statement.getParameterMetaData().getParameterType( index );
- }
- catch (SQLException ee) {
- log.warn( "Unable to guess enum type, default to INTEGER", ee );
- return Types.INTEGER;
- }
- }
-
private boolean isOrdinal(int paramType) {
switch ( paramType ) {
case Types.INTEGER:
17 years, 5 months
Hibernate SVN: r12821 - in trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java: generics and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: d.plentz
Date: 2007-07-25 21:32:22 -0400 (Wed, 25 Jul 2007)
New Revision: 12821
Modified:
trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/JavaXPropertyTest.java
trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/generics/ApproximatingTypeEnvironmentTest.java
trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/generics/TypeUtilsTest.java
trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/generics/deep/ANN612IssueTest.java
Log:
Just some code cleanup.
Modified: trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/JavaXPropertyTest.java
===================================================================
--- trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/JavaXPropertyTest.java 2007-07-26 01:18:37 UTC (rev 12820)
+++ trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/JavaXPropertyTest.java 2007-07-26 01:32:22 UTC (rev 12821)
@@ -1,12 +1,11 @@
package org.hibernate.annotations.common.test.reflection.java;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import junit.framework.AssertionFailedError;
+
import org.hibernate.annotations.common.reflection.Filter;
import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.annotations.common.reflection.XClass;
Modified: trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/generics/ApproximatingTypeEnvironmentTest.java
===================================================================
--- trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/generics/ApproximatingTypeEnvironmentTest.java 2007-07-26 01:18:37 UTC (rev 12820)
+++ trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/generics/ApproximatingTypeEnvironmentTest.java 2007-07-26 01:32:22 UTC (rev 12821)
@@ -18,7 +18,7 @@
TypeEnvironment boundContext = teFactory.getEnvironment( SonOfBlob.class );
TypeEnvironment approximatingBoundContext = teFactory.toApproximatingEnvironment( boundContext );
- public void testDoesNothingOnClasses() throws SecurityException, NoSuchMethodException {
+ public void testDoesNothingOnClasses() throws SecurityException {
assertEquals( String[].class, approximatingUnboundContext.bind( String[].class ) );
}
Modified: trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/generics/TypeUtilsTest.java
===================================================================
--- trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/generics/TypeUtilsTest.java 2007-07-26 01:18:37 UTC (rev 12820)
+++ trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/generics/TypeUtilsTest.java 2007-07-26 01:32:22 UTC (rev 12821)
@@ -1,8 +1,6 @@
package org.hibernate.annotations.common.test.reflection.java.generics;
import java.lang.reflect.Type;
-import java.util.LinkedList;
-import java.util.List;
import junit.framework.TestCase;
Modified: trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/generics/deep/ANN612IssueTest.java
===================================================================
--- trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/generics/deep/ANN612IssueTest.java 2007-07-26 01:18:37 UTC (rev 12820)
+++ trunk/HibernateExt/commons-annotations/src/test/org/hibernate/annotations/common/test/reflection/java/generics/deep/ANN612IssueTest.java 2007-07-26 01:32:22 UTC (rev 12821)
@@ -3,8 +3,6 @@
import java.util.List;
-import javax.persistence.Transient;
-
import junit.framework.TestCase;
import org.hibernate.annotations.common.reflection.XClass;
17 years, 5 months
Hibernate SVN: r12820 - in trunk/HibernateExt/commons-annotations/src/java/org/hibernate/annotations/common: util and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: d.plentz
Date: 2007-07-25 21:18:37 -0400 (Wed, 25 Jul 2007)
New Revision: 12820
Modified:
trunk/HibernateExt/commons-annotations/src/java/org/hibernate/annotations/common/reflection/java/generics/TypeUtils.java
trunk/HibernateExt/commons-annotations/src/java/org/hibernate/annotations/common/util/StringHelper.java
Log:
Just some code cleanup.
Modified: trunk/HibernateExt/commons-annotations/src/java/org/hibernate/annotations/common/reflection/java/generics/TypeUtils.java
===================================================================
--- trunk/HibernateExt/commons-annotations/src/java/org/hibernate/annotations/common/reflection/java/generics/TypeUtils.java 2007-07-25 23:49:16 UTC (rev 12819)
+++ trunk/HibernateExt/commons-annotations/src/java/org/hibernate/annotations/common/reflection/java/generics/TypeUtils.java 2007-07-26 01:18:37 UTC (rev 12820)
@@ -65,7 +65,7 @@
@Override
public Class<? extends Collection> caseParameterizedType(ParameterizedType parameterizedType) {
- return getCollectionClass( (Class) parameterizedType.getRawType() );
+ return getCollectionClass( parameterizedType.getRawType() );
}
@Override
Modified: trunk/HibernateExt/commons-annotations/src/java/org/hibernate/annotations/common/util/StringHelper.java
===================================================================
--- trunk/HibernateExt/commons-annotations/src/java/org/hibernate/annotations/common/util/StringHelper.java 2007-07-25 23:49:16 UTC (rev 12819)
+++ trunk/HibernateExt/commons-annotations/src/java/org/hibernate/annotations/common/util/StringHelper.java 2007-07-26 01:18:37 UTC (rev 12820)
@@ -18,17 +18,10 @@
private StringHelper() { /* static methods only - hide constructor */
}
- /*public static boolean containsDigits(String string) {
- for ( int i=0; i<string.length(); i++ ) {
- if ( Character.isDigit( string.charAt(i) ) ) return true;
- }
- return false;
- }*/
-
public static int lastIndexOfLetter(String string) {
for ( int i=0; i<string.length(); i++ ) {
char character = string.charAt(i);
- if ( !Character.isLetter(character) /*&& !('_'==character)*/ ) return i-1;
+ if ( !Character.isLetter(character) ) return i-1;
}
return string.length()-1;
}
@@ -67,7 +60,6 @@
return buf.toString();
}
-
public static String replace(String template, String placeholder, String replacement) {
return replace( template, placeholder, replacement, false );
}
@@ -75,7 +67,7 @@
public static String[] replace(String templates[], String placeholder, String replacement) {
String[] result = new String[templates.length];
for ( int i =0; i<templates.length; i++ ) {
- result[i] = replace( templates[i], placeholder, replacement );;
+ result[i] = replace( templates[i], placeholder, replacement );
}
return result;
}
@@ -113,7 +105,6 @@
}
}
-
public static String[] split(String seperators, String list) {
return split( seperators, list, false );
}
@@ -234,8 +225,8 @@
ArrayList locations = new ArrayList( 20 );
- // Impl note: takes advantage of the fact that an escpaed single quote
- // embedded within a quote-block can really be handled as two seperate
+ // Impl note: takes advantage of the fact that an escaped single quote
+ // embedded within a quote-block can really be handled as two separate
// quote-blocks for the purposes of this method...
int stringLength = string.length();
boolean inQuote = false;
@@ -328,7 +319,7 @@
/**
* Generates a root alias by truncating the "root name" defined by
- * the incoming decription and removing/modifying any non-valid
+ * the incoming description and removing/modifying any non-valid
* alias characters.
*
* @param description The root name from which to generate a root alias.
@@ -427,5 +418,4 @@
return name;
}
}
-
-}
+}
\ No newline at end of file
17 years, 5 months
Hibernate SVN: r12819 - trunk/HibernateExt/search/doc/reference/en/modules.
by hibernate-commits@lists.jboss.org
Author: d.plentz
Date: 2007-07-25 19:49:16 -0400 (Wed, 25 Jul 2007)
New Revision: 12819
Modified:
trunk/HibernateExt/search/doc/reference/en/modules/query.xml
Log:
[HSEARCH-100] Rename fullTextSession.setIndexProjection() to fullTextSession.setProjection()
Modified: trunk/HibernateExt/search/doc/reference/en/modules/query.xml
===================================================================
--- trunk/HibernateExt/search/doc/reference/en/modules/query.xml 2007-07-25 20:46:44 UTC (rev 12818)
+++ trunk/HibernateExt/search/doc/reference/en/modules/query.xml 2007-07-25 23:49:16 UTC (rev 12819)
@@ -156,7 +156,7 @@
Hibernate Search allows you to return only some properties:</para>
<programlisting>org.hibernate.search.FullTextQuery query = s.createFullTextQuery( luceneQuery, Book.class );
-query.<emphasis role="bold">setIndexProjection( "id", "summary", "body", "mainAuthor.name" )</emphasis>;
+query.<emphasis role="bold">setProjection( "id", "summary", "body", "mainAuthor.name" )</emphasis>;
List results = query.list();
Object[] firstResult = (Object[]) results.get(0);
Integer id = firstResult[0];
17 years, 5 months
Hibernate SVN: r12818 - trunk/HibernateExt/search/src/java/org/hibernate/search/annotations.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-25 16:46:44 -0400 (Wed, 25 Jul 2007)
New Revision: 12818
Added:
trunk/HibernateExt/search/src/java/org/hibernate/search/annotations/Fields.java
Log:
HSEARCH-45 Support for multiple fields per property
Added: trunk/HibernateExt/search/src/java/org/hibernate/search/annotations/Fields.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/annotations/Fields.java (rev 0)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/annotations/Fields.java 2007-07-25 20:46:44 UTC (rev 12818)
@@ -0,0 +1,25 @@
+//$Id$
+package org.hibernate.search.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Documented;
+
+/**
+ * Mark a property as indexable into different fields
+ * Useful if the field is used for sorting and searching
+ *
+ * @author Emmanuel Bernard
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.METHOD, ElementType.FIELD} )
+@Documented
+public @interface Fields {
+ /**
+ * Fields
+ */
+ Field[] value();
+
+}
17 years, 5 months
Hibernate SVN: r12817 - in trunk/HibernateExt/search/src: java/org/hibernate/search/bridge and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-25 16:30:51 -0400 (Wed, 25 Jul 2007)
New Revision: 12817
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/annotations/Field.java
trunk/HibernateExt/search/src/java/org/hibernate/search/bridge/BridgeFactory.java
trunk/HibernateExt/search/src/java/org/hibernate/search/engine/DocumentBuilder.java
trunk/HibernateExt/search/src/test/org/hibernate/search/test/bridge/Cloud.java
trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/Book.java
trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java
Log:
HSEARCH-45 Support for multiple fields per property
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-25 20:15:50 UTC (rev 12816)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/annotations/Field.java 2007-07-25 20:30:51 UTC (rev 12817)
@@ -41,4 +41,9 @@
*/
Analyzer analyzer() default @Analyzer;
+ /**
+ * Field bridge used. Default is autowired.
+ */
+ FieldBridge bridge() default @FieldBridge;
+
}
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/bridge/BridgeFactory.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/bridge/BridgeFactory.java 2007-07-25 20:15:50 UTC (rev 12816)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/bridge/BridgeFactory.java 2007-07-25 20:30:51 UTC (rev 12817)
@@ -22,7 +22,9 @@
import org.hibernate.search.bridge.builtin.BooleanBridge;
import org.hibernate.search.annotations.Resolution;
import org.hibernate.search.annotations.Parameter;
+import org.hibernate.search.annotations.Field;
import org.hibernate.search.SearchException;
+import org.hibernate.search.util.BinderHelper;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XMember;
@@ -82,10 +84,16 @@
builtInBridges.put( Date.class.getName(), DATE_MILLISECOND );
}
- public static FieldBridge guessType(XMember member) {
+ public static FieldBridge guessType(Field field, XMember member) {
FieldBridge bridge = null;
- org.hibernate.search.annotations.FieldBridge bridgeAnn =
- member.getAnnotation( org.hibernate.search.annotations.FieldBridge.class );
+ org.hibernate.search.annotations.FieldBridge bridgeAnn;
+ //@Field bridge has priority over @FieldBridge
+ if ( field != null && void.class != field.bridge().impl() ) {
+ bridgeAnn = field.bridge();
+ }
+ else {
+ bridgeAnn = member.getAnnotation( org.hibernate.search.annotations.FieldBridge.class );
+ }
if ( bridgeAnn != null ) {
Class impl = bridgeAnn.impl();
try {
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/engine/DocumentBuilder.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/engine/DocumentBuilder.java 2007-07-25 20:15:50 UTC (rev 12816)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/engine/DocumentBuilder.java 2007-07-25 20:30:51 UTC (rev 12817)
@@ -18,7 +18,6 @@
import org.apache.lucene.document.Field;
import org.apache.lucene.index.Term;
import org.hibernate.Hibernate;
-import org.hibernate.proxy.HibernateProxy;
import org.hibernate.annotations.common.AssertionFailure;
import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.annotations.common.reflection.XAnnotatedElement;
@@ -26,6 +25,7 @@
import org.hibernate.annotations.common.reflection.XMember;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.annotations.common.util.ReflectHelper;
+import org.hibernate.proxy.HibernateProxy;
import org.hibernate.search.SearchException;
import org.hibernate.search.annotations.Boost;
import org.hibernate.search.annotations.ContainedIn;
@@ -88,7 +88,7 @@
rootPropertiesMetadata.analyzer = defaultAnalyzer;
Set<XClass> processedClasses = new HashSet<XClass>();
processedClasses.add( clazz );
- initializeMembers(clazz, rootPropertiesMetadata, true, "", processedClasses );
+ initializeMembers( clazz, rootPropertiesMetadata, true, "", processedClasses );
//processedClasses.remove( clazz ); for the sake of completness
this.analyzer.setGlobalAnalyzer( rootPropertiesMetadata.analyzer );
if ( idKeywordName == null ) {
@@ -125,27 +125,27 @@
private void initializeMembers(XClass clazz, PropertiesMetadata propertiesMetadata, boolean isRoot, String prefix,
Set<XClass> processedClasses) {
List<XClass> hierarchy = new ArrayList<XClass>();
- for ( XClass currClass = clazz; currClass != null; currClass = currClass.getSuperclass() ) {
+ for (XClass currClass = clazz; currClass != null; currClass = currClass.getSuperclass()) {
hierarchy.add( currClass );
}
- for (int index = hierarchy.size() -1 ; index >= 0 ; index--) {
+ for (int index = hierarchy.size() - 1; index >= 0; index--) {
XClass currClass = hierarchy.get( index );
/**
* Override the default analyzer for the properties if the class hold one
* That's the reason we go down the hierarchy
*/
Analyzer analyzer = getAnalyzer( currClass );
- if ( analyzer != null) {
+ if ( analyzer != null ) {
propertiesMetadata.analyzer = analyzer;
}
//rejecting non properties because the object is loaded from Hibernate, so indexing a non property does not make sense
List<XProperty> methods = currClass.getDeclaredProperties( XClass.ACCESS_PROPERTY );
- for ( XProperty method : methods ) {
+ for (XProperty method : methods) {
initializeMember( method, propertiesMetadata, isRoot, prefix, processedClasses );
}
List<XProperty> fields = currClass.getDeclaredProperties( XClass.ACCESS_FIELD );
- for ( XProperty field : fields ) {
+ for (XProperty field : fields) {
initializeMember( field, propertiesMetadata, isRoot, prefix, processedClasses );
}
}
@@ -163,7 +163,7 @@
if ( isRoot && keywordAnn.id() ) {
idKeywordName = name;
idBoost = getBoost( member );
- FieldBridge fieldBridge = BridgeFactory.guessType( member );
+ FieldBridge fieldBridge = BridgeFactory.guessType( null, member );
if ( fieldBridge instanceof TwoWayFieldBridge ) {
idBridge = (TwoWayFieldBridge) fieldBridge;
}
@@ -178,7 +178,7 @@
setAccessible( member );
propertiesMetadata.keywordGetters.add( member );
propertiesMetadata.keywordNames.add( name );
- propertiesMetadata.keywordBridges.add( BridgeFactory.guessType( member ) );
+ propertiesMetadata.keywordBridges.add( BridgeFactory.guessType( null, member ) );
}
}
@@ -187,7 +187,7 @@
setAccessible( member );
propertiesMetadata.unstoredGetters.add( member );
propertiesMetadata.unstoredNames.add( prefix + BinderHelper.getAttributeName( member, unstoredAnn.name() ) );
- propertiesMetadata.unstoredBridges.add( BridgeFactory.guessType( member ) );
+ propertiesMetadata.unstoredBridges.add( BridgeFactory.guessType( null, member ) );
}
Text textAnn = member.getAnnotation( Text.class );
@@ -195,7 +195,7 @@
setAccessible( member );
propertiesMetadata.textGetters.add( member );
propertiesMetadata.textNames.add( prefix + BinderHelper.getAttributeName( member, textAnn.name() ) );
- propertiesMetadata.textBridges.add( BridgeFactory.guessType( member ) );
+ propertiesMetadata.textBridges.add( BridgeFactory.guessType( null, member ) );
}
DocumentId documentIdAnn = member.getAnnotation( DocumentId.class );
@@ -205,7 +205,7 @@
+ idKeywordName + " and " + BinderHelper.getAttributeName( member, documentIdAnn.name() ) );
}
idKeywordName = prefix + BinderHelper.getAttributeName( member, documentIdAnn.name() );
- FieldBridge fieldBridge = BridgeFactory.guessType( member );
+ FieldBridge fieldBridge = BridgeFactory.guessType( null, member );
if ( fieldBridge instanceof TwoWayFieldBridge ) {
idBridge = (TwoWayFieldBridge) fieldBridge;
}
@@ -217,24 +217,22 @@
setAccessible( member );
idGetter = member;
}
-
- org.hibernate.search.annotations.Field fieldAnn =
- member.getAnnotation( org.hibernate.search.annotations.Field.class );
- if ( fieldAnn != null ) {
- setAccessible( member );
- propertiesMetadata.fieldGetters.add( member );
- String fieldName = prefix + BinderHelper.getAttributeName( member, fieldAnn.name() );
- propertiesMetadata.fieldNames.add( fieldName );
- propertiesMetadata.fieldStore.add( getStore( fieldAnn.store() ) );
- propertiesMetadata.fieldIndex.add( getIndex( fieldAnn.index() ) );
- propertiesMetadata.fieldBridges.add( BridgeFactory.guessType( member ) );
- // Field > property > entity analyzer
- Analyzer analyzer = getAnalyzer( fieldAnn.analyzer() );
- if (analyzer == null) analyzer = getAnalyzer( member );
- if (analyzer == null) analyzer = propertiesMetadata.analyzer;
- if (analyzer == null) throw new AssertionFailure( "Analizer should not be undefined" );
- this.analyzer.addScopedAnalyzer( fieldName, analyzer );
+ {
+ org.hibernate.search.annotations.Field fieldAnn =
+ member.getAnnotation( org.hibernate.search.annotations.Field.class );
+ if ( fieldAnn != null ) {
+ bindFieldAnnotation( member, propertiesMetadata, prefix, fieldAnn );
+ }
}
+ {
+ org.hibernate.search.annotations.Fields fieldsAnn =
+ member.getAnnotation( org.hibernate.search.annotations.Fields.class );
+ if ( fieldsAnn != null ) {
+ for (org.hibernate.search.annotations.Field fieldAnn : fieldsAnn.value()) {
+ bindFieldAnnotation( member, propertiesMetadata, prefix, fieldAnn );
+ }
+ }
+ }
IndexedEmbedded embeddedAnn = member.getAnnotation( IndexedEmbedded.class );
if ( embeddedAnn != null ) {
@@ -247,41 +245,41 @@
&& processedClasses.contains( elementClass ) ) {
throw new SearchException(
"Circular reference. Duplicate use of "
- + elementClass.getName()
- + " in root entity " + beanClass.getName()
- + "#" + buildEmbeddedPrefix( prefix, embeddedAnn, member )
+ + elementClass.getName()
+ + " in root entity " + beanClass.getName()
+ + "#" + buildEmbeddedPrefix( prefix, embeddedAnn, member )
);
}
- if (level <= maxLevel) {
+ if ( level <= maxLevel ) {
processedClasses.add( elementClass ); //push
setAccessible( member );
propertiesMetadata.embeddedGetters.add( member );
PropertiesMetadata metadata = new PropertiesMetadata();
- propertiesMetadata.embeddedPropertiesMetadata.add(metadata);
+ propertiesMetadata.embeddedPropertiesMetadata.add( metadata );
metadata.boost = getBoost( member );
//property > entity analyzer
Analyzer analyzer = getAnalyzer( member );
metadata.analyzer = analyzer != null ? analyzer : propertiesMetadata.analyzer;
String localPrefix = buildEmbeddedPrefix( prefix, embeddedAnn, member );
- initializeMembers( elementClass, metadata, false, localPrefix, processedClasses);
+ initializeMembers( elementClass, metadata, false, localPrefix, processedClasses );
/**
* We will only index the "expected" type but that's OK, HQL cannot do downcasting either
*/
if ( member.isArray() ) {
- propertiesMetadata.embeddedContainers.add(PropertiesMetadata.Container.ARRAY);
+ propertiesMetadata.embeddedContainers.add( PropertiesMetadata.Container.ARRAY );
}
else if ( member.isCollection() ) {
if ( Map.class.equals( member.getCollectionClass() ) ) {
//hum subclasses etc etc??
- propertiesMetadata.embeddedContainers.add(PropertiesMetadata.Container.MAP);
+ propertiesMetadata.embeddedContainers.add( PropertiesMetadata.Container.MAP );
}
else {
- propertiesMetadata.embeddedContainers.add(PropertiesMetadata.Container.COLLECTION);
+ propertiesMetadata.embeddedContainers.add( PropertiesMetadata.Container.COLLECTION );
}
}
else {
- propertiesMetadata.embeddedContainers.add(PropertiesMetadata.Container.OBJECT);
+ propertiesMetadata.embeddedContainers.add( PropertiesMetadata.Container.OBJECT );
}
processedClasses.remove( elementClass ); //pop
@@ -302,6 +300,22 @@
}
}
+ private void bindFieldAnnotation(XProperty member, PropertiesMetadata propertiesMetadata, String prefix, org.hibernate.search.annotations.Field fieldAnn) {
+ setAccessible( member );
+ propertiesMetadata.fieldGetters.add( member );
+ String fieldName = prefix + BinderHelper.getAttributeName( member, fieldAnn.name() );
+ propertiesMetadata.fieldNames.add( fieldName );
+ propertiesMetadata.fieldStore.add( getStore( fieldAnn.store() ) );
+ propertiesMetadata.fieldIndex.add( getIndex( fieldAnn.index() ) );
+ propertiesMetadata.fieldBridges.add( BridgeFactory.guessType( fieldAnn, member ) );
+ // Field > property > entity analyzer
+ Analyzer analyzer = getAnalyzer( fieldAnn.analyzer() );
+ if ( analyzer == null ) analyzer = getAnalyzer( member );
+ if ( analyzer == null ) analyzer = propertiesMetadata.analyzer;
+ if ( analyzer == null ) throw new AssertionFailure( "Analizer should not be undefined" );
+ this.analyzer.addScopedAnalyzer( fieldName, analyzer );
+ }
+
private String buildEmbeddedPrefix(String prefix, IndexedEmbedded embeddedAnn, XProperty member) {
String localPrefix = prefix;
if ( ".".equals( embeddedAnn.prefix() ) ) {
@@ -315,7 +329,7 @@
}
private Field.Store getStore(Store store) {
- switch (store) {
+ switch ( store ) {
case NO:
return Field.Store.NO;
case YES:
@@ -328,7 +342,7 @@
}
private Field.Index getIndex(Index index) {
- switch (index) {
+ switch ( index ) {
case NO:
return Field.Index.NO;
case NO_NORMS:
@@ -364,7 +378,7 @@
public void addWorkToQueue(T entity, Serializable id, WorkType workType, List<LuceneWork> queue, SearchFactoryImplementor searchFactoryImplementor) {
Class entityClass = Hibernate.getClass( entity );
//TODO with the caller loop we are in a n^2: optimize it using a HashMap for work recognition
- for ( LuceneWork luceneWork : queue) {
+ for (LuceneWork luceneWork : queue) {
//whatever the actual work, we should ignore
if ( luceneWork.getEntityClass() == entityClass
&& luceneWork.getId().equals( id ) ) {//find a way to use Type.equals(x,y)
@@ -379,7 +393,7 @@
searchForContainers = true;
}
else if ( workType == WorkType.DELETE ) {
- queue.add( new DeleteLuceneWork(id, entityClass) );
+ queue.add( new DeleteLuceneWork( id, entityClass ) );
}
else if ( workType == WorkType.UPDATE ) {
Document doc = getDocument( entity, id );
@@ -390,21 +404,21 @@
* But essentially the optimization we are doing is the same Lucene is doing, the only extra cost is the
* double file opening.
*/
- queue.add( new DeleteLuceneWork(id, entityClass) );
+ queue.add( new DeleteLuceneWork( id, entityClass ) );
queue.add( new AddLuceneWork( id, entityClass, doc ) );
searchForContainers = true;
}
else if ( workType == WorkType.INDEX ) {
Document doc = getDocument( entity, id );
- queue.add(new DeleteLuceneWork(id, entityClass) );
+ queue.add( new DeleteLuceneWork( id, entityClass ) );
LuceneWork work = new AddLuceneWork( id, entityClass, doc );
- work.setBatch(true);
- queue.add(work);
+ work.setBatch( true );
+ queue.add( work );
searchForContainers = true;
- }
-
+ }
+
else {
- throw new AssertionFailure("Unknown WorkType: " + workType);
+ throw new AssertionFailure( "Unknown WorkType: " + workType );
}
/**
@@ -412,23 +426,23 @@
* have to be updated)
* When the internal object is changed, we apply the {Add|Update}Work on containedIns
*/
- if (searchForContainers) {
- processContainedIn(entity, queue, rootPropertiesMetadata, searchFactoryImplementor);
+ if ( searchForContainers ) {
+ processContainedIn( entity, queue, rootPropertiesMetadata, searchFactoryImplementor );
}
}
private void processContainedIn(Object instance, List<LuceneWork> queue, PropertiesMetadata metadata, SearchFactoryImplementor searchFactoryImplementor) {
- for ( int i = 0; i < metadata.containedInGetters.size(); i++ ) {
+ for (int i = 0; i < metadata.containedInGetters.size(); i++) {
XMember member = metadata.containedInGetters.get( i );
Object value = getMemberValue( instance, member );
- if (value == null) continue;
+ if ( value == null ) continue;
if ( member.isArray() ) {
- for ( Object arrayValue : (Object[]) value ) {
+ for (Object arrayValue : (Object[]) value) {
//highly inneficient but safe wrt the actual targeted class
Class valueClass = Hibernate.getClass( arrayValue );
DocumentBuilder builder = searchFactoryImplementor.getDocumentBuilders().get( valueClass );
- if (builder == null) continue;
+ if ( builder == null ) continue;
processContainedInValue( arrayValue, queue, valueClass, builder, searchFactoryImplementor );
}
}
@@ -441,18 +455,18 @@
else {
collection = (Collection) value;
}
- for ( Object collectionValue : collection ) {
+ for (Object collectionValue : collection) {
//highly inneficient but safe wrt the actual targeted class
Class valueClass = Hibernate.getClass( collectionValue );
DocumentBuilder builder = searchFactoryImplementor.getDocumentBuilders().get( valueClass );
- if (builder == null) continue;
+ if ( builder == null ) continue;
processContainedInValue( collectionValue, queue, valueClass, builder, searchFactoryImplementor );
}
}
else {
Class valueClass = Hibernate.getClass( value );
DocumentBuilder builder = searchFactoryImplementor.getDocumentBuilders().get( valueClass );
- if (builder == null) continue;
+ if ( builder == null ) continue;
processContainedInValue( value, queue, valueClass, builder, searchFactoryImplementor );
}
}
@@ -483,10 +497,10 @@
}
private void buildDocumentFields(Object instance, Document doc, PropertiesMetadata propertiesMetadata) {
- if (instance == null) return;
+ if ( instance == null ) return;
//needed for field access: I cannot work in the proxied version
Object unproxiedInstance = unproxy( instance );
- for ( int i = 0; i < propertiesMetadata.keywordNames.size(); i++ ) {
+ for (int i = 0; i < propertiesMetadata.keywordNames.size(); i++) {
XMember member = propertiesMetadata.keywordGetters.get( i );
Object value = getMemberValue( unproxiedInstance, member );
propertiesMetadata.keywordBridges.get( i ).set(
@@ -494,7 +508,7 @@
Field.Index.UN_TOKENIZED, getBoost( member )
);
}
- for ( int i = 0; i < propertiesMetadata.textNames.size(); i++ ) {
+ for (int i = 0; i < propertiesMetadata.textNames.size(); i++) {
XMember member = propertiesMetadata.textGetters.get( i );
Object value = getMemberValue( unproxiedInstance, member );
propertiesMetadata.textBridges.get( i ).set(
@@ -502,7 +516,7 @@
Field.Index.TOKENIZED, getBoost( member )
);
}
- for ( int i = 0; i < propertiesMetadata.unstoredNames.size(); i++ ) {
+ for (int i = 0; i < propertiesMetadata.unstoredNames.size(); i++) {
XMember member = propertiesMetadata.unstoredGetters.get( i );
Object value = getMemberValue( unproxiedInstance, member );
propertiesMetadata.unstoredBridges.get( i ).set(
@@ -510,7 +524,7 @@
Field.Index.TOKENIZED, getBoost( member )
);
}
- for ( int i = 0; i < propertiesMetadata.fieldNames.size(); i++ ) {
+ for (int i = 0; i < propertiesMetadata.fieldNames.size(); i++) {
XMember member = propertiesMetadata.fieldGetters.get( i );
Object value = getMemberValue( unproxiedInstance, member );
propertiesMetadata.fieldBridges.get( i ).set(
@@ -518,26 +532,26 @@
propertiesMetadata.fieldIndex.get( i ), getBoost( member )
);
}
- for ( int i = 0; i < propertiesMetadata.embeddedGetters.size(); i++ ) {
+ for (int i = 0; i < propertiesMetadata.embeddedGetters.size(); i++) {
XMember member = propertiesMetadata.embeddedGetters.get( i );
Object value = getMemberValue( unproxiedInstance, member );
//TODO handle boost at embedded level: already stored in propertiesMedatada.boost
- if (value == null) continue;
+ if ( value == null ) continue;
PropertiesMetadata embeddedMetadata = propertiesMetadata.embeddedPropertiesMetadata.get( i );
- switch( propertiesMetadata.embeddedContainers.get(i) ) {
+ switch ( propertiesMetadata.embeddedContainers.get( i ) ) {
case ARRAY:
- for ( Object arrayValue : (Object[]) value ) {
+ for (Object arrayValue : (Object[]) value) {
buildDocumentFields( arrayValue, doc, embeddedMetadata );
}
break;
case COLLECTION:
- for ( Object collectionValue : (Collection) value ) {
+ for (Object collectionValue : (Collection) value) {
buildDocumentFields( collectionValue, doc, embeddedMetadata );
}
break;
case MAP:
- for ( Object collectionValue : ( (Map) value ).values() ) {
+ for (Object collectionValue : ( (Map) value ).values()) {
buildDocumentFields( collectionValue, doc, embeddedMetadata );
}
break;
@@ -545,8 +559,8 @@
buildDocumentFields( value, doc, embeddedMetadata );
break;
default:
- throw new AssertionFailure("Unknown embedded container: "
- + propertiesMetadata.embeddedContainers.get(i) );
+ throw new AssertionFailure( "Unknown embedded container: "
+ + propertiesMetadata.embeddedContainers.get( i ) );
}
}
}
@@ -554,7 +568,7 @@
private Object unproxy(Object value) {
//FIXME this service should be part of Core?
if ( value instanceof HibernateProxy ) {
- value = ( ( HibernateProxy ) value ).getHibernateLazyInitializer()
+ value = ( (HibernateProxy) value ).getHibernateLazyInitializer()
.getImplementation();
}
return value;
@@ -609,7 +623,7 @@
Object[] result = new Object[fieldNbr];
if ( builder.idKeywordName != null ) {
- populateResult(builder.idKeywordName, builder.idBridge, Field.Store.YES, fields, result, document);
+ populateResult( builder.idKeywordName, builder.idBridge, Field.Store.YES, fields, result, document );
}
final PropertiesMetadata metadata = builder.rootPropertiesMetadata;
@@ -619,20 +633,20 @@
private static void processFieldsForProjection(PropertiesMetadata metadata, String[] fields, Object[] result, Document document) {
final int nbrFoEntityFields = metadata.fieldNames.size();
- for (int index = 0 ; index < nbrFoEntityFields; index++ ) {
- populateResult( metadata.fieldNames.get(index),
- metadata.fieldBridges.get(index),
- metadata.fieldStore.get(index),
+ for (int index = 0; index < nbrFoEntityFields; index++) {
+ populateResult( metadata.fieldNames.get( index ),
+ metadata.fieldBridges.get( index ),
+ metadata.fieldStore.get( index ),
fields,
result,
document
);
}
final int nbrOfEmbeddedObjects = metadata.embeddedPropertiesMetadata.size();
- for (int index = 0 ; index < nbrOfEmbeddedObjects ; index++) {
+ for (int index = 0; index < nbrOfEmbeddedObjects; index++) {
//there is nothing we can do for collections
- if ( metadata.embeddedContainers.get(index) == PropertiesMetadata.Container.OBJECT) {
- processFieldsForProjection( metadata.embeddedPropertiesMetadata.get(index), fields, result, document );
+ if ( metadata.embeddedContainers.get( index ) == PropertiesMetadata.Container.OBJECT ) {
+ processFieldsForProjection( metadata.embeddedPropertiesMetadata.get( index ), fields, result, document );
}
}
}
@@ -640,7 +654,7 @@
private static void populateResult(String fieldName, FieldBridge fieldBridge, Field.Store store,
String[] fields, Object[] result, Document document) {
int matchingPosition = getFieldPosition( fields, fieldName );
- if (matchingPosition != -1) {
+ if ( matchingPosition != -1 ) {
//TODO make use of an isTwoWay() method
if ( store != Field.Store.NO && TwoWayFieldBridge.class.isAssignableFrom( fieldBridge.getClass() ) ) {
result[matchingPosition] = ( (TwoWayFieldBridge) fieldBridge ).get( fieldName, document );
@@ -650,7 +664,7 @@
}
else {
if ( store == Field.Store.NO ) {
- throw new SearchException("Projecting an unstored field: " + fieldName);
+ throw new SearchException( "Projecting an unstored field: " + fieldName );
}
else {
throw new SearchException( "FieldBridge is not a TwoWayFieldBridge: " + fieldBridge.getClass() );
@@ -661,7 +675,7 @@
private static int getFieldPosition(String[] fields, String fieldName) {
int fieldNbr = fields.length;
- for (int index = 0 ; index < fieldNbr ; index++) {
+ for (int index = 0; index < fieldNbr; index++) {
if ( fieldName.equals( fields[index] ) ) return index;
}
return -1;
@@ -672,7 +686,7 @@
Class plainClass = reflectionManager.toClass( beanClass );
Set<Class> tempMappedSubclasses = new HashSet<Class>();
//together with the caller this creates a o(2), but I think it's still faster than create the up hierarchy for each class
- for ( Class currentClass : indexedClasses ) {
+ for (Class currentClass : indexedClasses) {
if ( plainClass.isAssignableFrom( currentClass ) ) tempMappedSubclasses.add( currentClass );
}
mappedSubclasses = Collections.unmodifiableSet( tempMappedSubclasses );
Modified: trunk/HibernateExt/search/src/test/org/hibernate/search/test/bridge/Cloud.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/bridge/Cloud.java 2007-07-25 20:15:50 UTC (rev 12816)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/bridge/Cloud.java 2007-07-25 20:30:51 UTC (rev 12817)
@@ -56,8 +56,9 @@
this.customFieldBridge = customFieldBridge;
}
- @Text
- @FieldBridge(impl = TruncateStringBridge.class, params = @Parameter( name="dividedBy", value="4" ) )
+ @Field(index=Index.TOKENIZED, store=Store.YES,
+ bridge = @FieldBridge(impl = TruncateStringBridge.class, params = @Parameter( name="dividedBy", value="4" ) )
+ )
public String getCustomStringBridge() {
return customStringBridge;
}
Modified: trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/Book.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/Book.java 2007-07-25 20:15:50 UTC (rev 12816)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/Book.java 2007-07-25 20:30:51 UTC (rev 12817)
@@ -16,6 +16,7 @@
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Store;
import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.search.annotations.Fields;
/**
* @author Emmanuel Bernard
@@ -77,7 +78,10 @@
this.id = id;
}
- @Field(index = Index.TOKENIZED, store = Store.YES)
+ @Fields( {
+ @Field(index = Index.TOKENIZED, store = Store.YES),
+ @Field(name = "summary_forSort", index = Index.UN_TOKENIZED, store = Store.YES)
+ } )
public String getSummary() {
return summary;
}
Modified: trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java 2007-07-25 20:15:50 UTC (rev 12816)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java 2007-07-25 20:30:51 UTC (rev 12817)
@@ -66,8 +66,29 @@
id--;
}
+ // order by summary
+ query = parser.parse( "summary:lucene OR summary:action" );
+ hibQuery = s.createFullTextQuery( query, Book.class );
+ sort = new Sort( new SortField( "summary_forSort", false ) ); //ASC
+ hibQuery.setSort( sort );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Wrong number of test results.", 4, result.size() );
+ assertEquals( "Groovy in Action", result.get( 0 ).getSummary() );
+ // order by summary backwards
+ query = parser.parse( "summary:lucene OR summary:action" );
+ hibQuery = s.createFullTextQuery( query, Book.class );
+ sort = new Sort( new SortField( "summary_forSort", true ) ); //DESC
+ hibQuery.setSort( sort );
+ result = hibQuery.list();
+ assertNotNull( result );
+ assertEquals( "Wrong number of test results.", 4, result.size() );
+ assertEquals( "Hibernate & Lucene", result.get( 0 ).getSummary() );
+
tx.commit();
+
+ deleteTestBooks(s);
s.close();
}
@@ -86,15 +107,22 @@
s.save(book);
book = new Book(3, "Hibernate & Lucene", "This is a test book.");
s.save(book);
+ book = new Book(4, "Groovy in Action", "The bible of Groovy");
+ s.save(book);
tx.commit();
s.clear();
}
+ private void deleteTestBooks(FullTextSession s) {
+ Transaction tx = s.beginTransaction();
+ s.createQuery( "delete " + Book.class.getName() ).executeUpdate();
+ tx.commit();
+ s.clear();
+ }
+
protected Class[] getMappings() {
return new Class[] {
Book.class,
- AlternateBook.class,
- Clock.class,
Author.class
};
}
17 years, 5 months
Hibernate SVN: r12816 - trunk/HibernateExt/search/src/java/org/hibernate/search/query.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-25 16:15:50 -0400 (Wed, 25 Jul 2007)
New Revision: 12816
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/query/FullTextQueryImpl.java
Log:
HSEARCH-100 renaming to setProjection and mark the old name as deprecated
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-25 19:32:50 UTC (rev 12815)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2007-07-25 20:15:50 UTC (rev 12816)
@@ -490,6 +490,10 @@
return this;
}
+ public FullTextQuery setIndexProjection(String... fields) {
+ return setProjection( fields );
+ }
+
public FullTextQuery setFirstResult(int firstResult) {
this.firstResult = firstResult;
return this;
17 years, 5 months