Hibernate SVN: r12865 - in core/branches/Branch_3_2: doc/reference/en and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-31 12:52:44 -0400 (Tue, 31 Jul 2007)
New Revision: 12865
Modified:
core/branches/Branch_3_2/build.xml
core/branches/Branch_3_2/changelog.txt
core/branches/Branch_3_2/doc/reference/en/master.xml
core/branches/Branch_3_2/readme.txt
core/branches/Branch_3_2/src/org/hibernate/cfg/Environment.java
Log:
prep 3.2.5 release
Modified: core/branches/Branch_3_2/build.xml
===================================================================
--- core/branches/Branch_3_2/build.xml 2007-07-31 16:09:42 UTC (rev 12864)
+++ core/branches/Branch_3_2/build.xml 2007-07-31 16:52:44 UTC (rev 12865)
@@ -22,8 +22,8 @@
<property name="name2" value="hibernate3"/>
<property name="version.major" value="3"/>
<property name="version.minor" value="2"/>
- <property name="version.micro" value="4"/>
- <property name="version.qualifier" value="sp1"/>
+ <property name="version.micro" value="5"/>
+ <property name="version.qualifier" value="ga"/>
<property name="version.full" value="${version.major}.${version.minor}.${version.micro}.${version.qualifier}"/>
<property name="version.major_minor" value="${version.major}.${version.minor}"/>
<property name="fullname" value="${name}-${version.full}"/>
Modified: core/branches/Branch_3_2/changelog.txt
===================================================================
--- core/branches/Branch_3_2/changelog.txt 2007-07-31 16:09:42 UTC (rev 12864)
+++ core/branches/Branch_3_2/changelog.txt 2007-07-31 16:52:44 UTC (rev 12865)
@@ -6,10 +6,56 @@
more about each case.
-Changes in version 3.2.4 (2007.05.18)
+Changes in version 3.2.5 (2007.07.31)
-------------------------------------------
** Bug
+ * [HHH-1116] - batch-size typo
+ * [HHH-1561] - Missing " in Documentation for H3, Chapter 15.8
+ * [HHH-1569] - Immutable Natural Id check fails with ArrayIndexOutOfBounds in some cases
+ * [HHH-1694] - Documentation Outdated: "10.4.4. Queries in native SQL"
+ * [HHH-2180] - minordocumentation error in hbm xml
+ * [HHH-2201] - session.iterate() does not exist
+ * [HHH-2267] - A copy/paste mistake in the documentation for <schemavalidator> ant task
+ * [HHH-2334] - Documentation error in section 5.1.3
+ * [HHH-2420] - Error in 2.5. Contextual Sessions
+ * [HHH-2502] - The second level caching documentation states that ehcache is not distributed.
+ * [HHH-2631] - Leaking PreparedStatement and ResultSet via CollectionLoadContext instances maintained in Map collectionLoadContexts in LoadContexts
+ * [HHH-2649] - Batcher configuration parameter incorrectly documented
+ * [HHH-2711] - PropertyAccessException with backref and <composite-map-key/>
+ * [HHH-2713] - duplicated phrase in docs "of the of the"
+ * [HHH-2714] - Three typos in code examples
+ * [HHH-2719] - adddress --> address
+ * [HHH-2720] - Monetory --> Monetary
+
+** Improvement
+ * [HHH-1022] - incomplete documentation in _README.txt in the lib directory
+ * [HHH-1682] - Improve the description of differences between save() and persist()
+ * [HHH-2048] - Incomplete MappingException at org.hibernate.mapping.SimpleValue
+ * [HHH-2417] - Update book on Hibernate reference
+ * [HHH-2418] - Refer HSQL DB website in chapter 1.2.3
+ * [HHH-2487] - Typo in "5.1.7. version (optional)"
+ * [HHH-2550] - Update API Class in 10.4.3. Criteria queries
+ * [HHH-2662] - Workaround PostgreSQL issues in testsuite
+ * [HHH-2663] - Map java.sql.Types.REAL to Hibernate FloatType for auto-discovery stuff
+ * [HHH-2665] - Split Oracle9Dialect into Oracle9iDialect and Oracle10gDialect
+
+** Patch
+ * [HHH-2520] - Miscellaneous config doc spelling fixes
+ * [HHH-2630] - Hibernate Dialect is not auto-detected for Sybase ASE and DB2 (Shelley McGowan)
+ * [HHH-2758] - Patch IngresDialect based on certification
+
+** Task
+ * [HHH-2551] - Deprecate org.hibernate.criterion.Expression
+ * [HHH-2566] - Replace usages of FlushMode.NEVER with FlushMode.MANUAL
+ * [HHH-2567] - Update reference to use FlushMode.MANUAL
+ * [HHH-2568] - Hibernate javadoc overview refering wrong classes and packages
+
+
+Changes in version 3.2.4.sp1 (2007.05.18)
+-------------------------------------------
+
+** Bug
* [HHH-2605] - Since 3.2.4 no value specified for row id
* [HHH-2613] - LockMode.FORCE on non versioned entity leads to NPE
Modified: core/branches/Branch_3_2/doc/reference/en/master.xml
===================================================================
--- core/branches/Branch_3_2/doc/reference/en/master.xml 2007-07-31 16:09:42 UTC (rev 12864)
+++ core/branches/Branch_3_2/doc/reference/en/master.xml 2007-07-31 16:52:44 UTC (rev 12865)
@@ -33,7 +33,7 @@
<bookinfo>
<title>HIBERNATE - Relational Persistence for Idiomatic Java</title>
<subtitle>Hibernate Reference Documentation</subtitle>
- <releaseinfo>3.2.4.sp1</releaseinfo>
+ <releaseinfo>3.2.5</releaseinfo>
</bookinfo>
<toc/>
Modified: core/branches/Branch_3_2/readme.txt
===================================================================
--- core/branches/Branch_3_2/readme.txt 2007-07-31 16:09:42 UTC (rev 12864)
+++ core/branches/Branch_3_2/readme.txt 2007-07-31 16:52:44 UTC (rev 12865)
@@ -1,6 +1,6 @@
Hibernate - Relational Persistence for Idiomatic Java
=====================================================
-version 3.2.4.sp1, May 18, 2007
+version 3.2.5, July 31, 2007
Instructions
------------
Modified: core/branches/Branch_3_2/src/org/hibernate/cfg/Environment.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/cfg/Environment.java 2007-07-31 16:09:42 UTC (rev 12864)
+++ core/branches/Branch_3_2/src/org/hibernate/cfg/Environment.java 2007-07-31 16:52:44 UTC (rev 12865)
@@ -153,7 +153,7 @@
*/
public final class Environment {
- public static final String VERSION = "3.2.4.sp1";
+ public static final String VERSION = "3.2.5";
/**
* <tt>ConnectionProvider</tt> implementor to use when obtaining connections
17 years, 5 months
Hibernate SVN: r12864 - core/tags.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-31 12:09:42 -0400 (Tue, 31 Jul 2007)
New Revision: 12864
Removed:
core/tags/v325/
Log:
17 years, 5 months
Hibernate SVN: r12863 - core/tags.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-31 11:58:19 -0400 (Tue, 31 Jul 2007)
New Revision: 12863
Added:
core/tags/v325/
Log:
17 years, 5 months
Hibernate SVN: r12862 - core/trunk/core/src/main/java/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-31 11:24:13 -0400 (Tue, 31 Jul 2007)
New Revision: 12862
Modified:
core/trunk/core/src/main/java/org/hibernate/dialect/IngresDialect.java
Log:
HHH-2758 : IngresDialect certification
Modified: core/trunk/core/src/main/java/org/hibernate/dialect/IngresDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/IngresDialect.java 2007-07-31 15:23:40 UTC (rev 12861)
+++ core/trunk/core/src/main/java/org/hibernate/dialect/IngresDialect.java 2007-07-31 15:24:13 UTC (rev 12862)
@@ -43,16 +43,16 @@
registerColumnType( Types.VARCHAR, "long varchar" );
registerColumnType( Types.LONGVARCHAR, "long varchar" );
registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "date" );
- registerColumnType( Types.TIMESTAMP, "date" );
- registerColumnType( Types.BLOB, "long byte" );
- registerColumnType( Types.CLOB, "long varchar" );
+ registerColumnType( Types.TIME, "time with time zone" );
+ registerColumnType( Types.TIMESTAMP, "timestamp with time zone" );
+ registerColumnType( Types.BLOB, "blob" );
+ registerColumnType( Types.CLOB, "clob" );
registerFunction( "abs", new StandardSQLFunction( "abs" ) );
registerFunction( "atan", new StandardSQLFunction( "atan", Hibernate.DOUBLE ) );
registerFunction( "bit_add", new StandardSQLFunction( "bit_add" ) );
registerFunction( "bit_and", new StandardSQLFunction( "bit_and" ) );
- registerFunction( "bit_length", new StandardSQLFunction( "bit_length" ) );
+ registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "octet_length(hex(?1))*4" ) );
registerFunction( "bit_not", new StandardSQLFunction( "bit_not" ) );
registerFunction( "bit_or", new StandardSQLFunction( "bit_or" ) );
registerFunction( "bit_xor", new StandardSQLFunction( "bit_xor" ) );
@@ -101,7 +101,7 @@
registerFunction( "sqrt", new StandardSQLFunction( "sqrt", Hibernate.DOUBLE ) );
registerFunction( "substring", new SQLFunctionTemplate( Hibernate.STRING, "substring(?1 FROM ?2 FOR ?3)" ) );
registerFunction( "system_user", new NoArgSQLFunction( "system_user", Hibernate.STRING, false ) );
- registerFunction( "trim", new StandardSQLFunction( "trim", Hibernate.STRING ) );
+ //registerFunction( "trim", new StandardSQLFunction( "trim", Hibernate.STRING ) );
registerFunction( "unhex", new StandardSQLFunction( "unhex", Hibernate.STRING ) );
registerFunction( "upper", new StandardSQLFunction( "upper" ) );
registerFunction( "uppercase", new StandardSQLFunction( "uppercase" ) );
@@ -170,6 +170,10 @@
return "select nextval for " + sequenceName;
}
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return sequenceName + ".nextval";
+ }
+
/**
* The syntax used to create a sequence, if sequences are supported.
*
@@ -289,4 +293,13 @@
public boolean supportsSubselectAsInPredicateLHS() {
return false;
}
+
+ public boolean supportsEmptyInList() {
+ return false;
+ }
+
+ public boolean supportsExpectedLobUsagePattern () {
+ return false;
+ }
}
+
17 years, 5 months
Hibernate SVN: r12861 - core/branches/Branch_3_2/src/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-31 11:23:40 -0400 (Tue, 31 Jul 2007)
New Revision: 12861
Modified:
core/branches/Branch_3_2/src/org/hibernate/dialect/IngresDialect.java
Log:
HHH-2758 : IngresDialect certification
Modified: core/branches/Branch_3_2/src/org/hibernate/dialect/IngresDialect.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/dialect/IngresDialect.java 2007-07-31 13:39:45 UTC (rev 12860)
+++ core/branches/Branch_3_2/src/org/hibernate/dialect/IngresDialect.java 2007-07-31 15:23:40 UTC (rev 12861)
@@ -43,16 +43,16 @@
registerColumnType( Types.VARCHAR, "long varchar" );
registerColumnType( Types.LONGVARCHAR, "long varchar" );
registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "date" );
- registerColumnType( Types.TIMESTAMP, "date" );
- registerColumnType( Types.BLOB, "long byte" );
- registerColumnType( Types.CLOB, "long varchar" );
+ registerColumnType( Types.TIME, "time with time zone" );
+ registerColumnType( Types.TIMESTAMP, "timestamp with time zone" );
+ registerColumnType( Types.BLOB, "blob" );
+ registerColumnType( Types.CLOB, "clob" );
registerFunction( "abs", new StandardSQLFunction( "abs" ) );
registerFunction( "atan", new StandardSQLFunction( "atan", Hibernate.DOUBLE ) );
registerFunction( "bit_add", new StandardSQLFunction( "bit_add" ) );
registerFunction( "bit_and", new StandardSQLFunction( "bit_and" ) );
- registerFunction( "bit_length", new StandardSQLFunction( "bit_length" ) );
+ registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "octet_length(hex(?1))*4" ) );
registerFunction( "bit_not", new StandardSQLFunction( "bit_not" ) );
registerFunction( "bit_or", new StandardSQLFunction( "bit_or" ) );
registerFunction( "bit_xor", new StandardSQLFunction( "bit_xor" ) );
@@ -101,7 +101,7 @@
registerFunction( "sqrt", new StandardSQLFunction( "sqrt", Hibernate.DOUBLE ) );
registerFunction( "substring", new SQLFunctionTemplate( Hibernate.STRING, "substring(?1 FROM ?2 FOR ?3)" ) );
registerFunction( "system_user", new NoArgSQLFunction( "system_user", Hibernate.STRING, false ) );
- registerFunction( "trim", new StandardSQLFunction( "trim", Hibernate.STRING ) );
+ //registerFunction( "trim", new StandardSQLFunction( "trim", Hibernate.STRING ) );
registerFunction( "unhex", new StandardSQLFunction( "unhex", Hibernate.STRING ) );
registerFunction( "upper", new StandardSQLFunction( "upper" ) );
registerFunction( "uppercase", new StandardSQLFunction( "uppercase" ) );
@@ -170,6 +170,10 @@
return "select nextval for " + sequenceName;
}
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return sequenceName + ".nextval";
+ }
+
/**
* The syntax used to create a sequence, if sequences are supported.
*
@@ -289,4 +293,13 @@
public boolean supportsSubselectAsInPredicateLHS() {
return false;
}
+
+ public boolean supportsEmptyInList() {
+ return false;
+ }
+
+ public boolean supportsExpectedLobUsagePattern () {
+ return false;
+ }
}
+
17 years, 5 months
Hibernate SVN: r12860 - in core/branches/Branch_3_2: test/org/hibernate/test/collection and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-31 09:39:45 -0400 (Tue, 31 Jul 2007)
New Revision: 12860
Added:
core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/
core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/
core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/
core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/BackrefCompositeMapKeyTest.java
core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/MapKey.java
core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/Mappings.hbm.xml
core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/Part.java
core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/Product.java
Modified:
core/branches/Branch_3_2/src/org/hibernate/tuple/component/PojoComponentTuplizer.java
core/branches/Branch_3_2/test/org/hibernate/test/collection/CollectionSuite.java
Log:
HHH-2711 : composite-map-key + unidir map can lead to PropertyAccessException
Modified: core/branches/Branch_3_2/src/org/hibernate/tuple/component/PojoComponentTuplizer.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/tuple/component/PojoComponentTuplizer.java 2007-07-31 13:39:23 UTC (rev 12859)
+++ core/branches/Branch_3_2/src/org/hibernate/tuple/component/PojoComponentTuplizer.java 2007-07-31 13:39:45 UTC (rev 12860)
@@ -1,25 +1,25 @@
//$Id: PojoComponentTuplizer.java 9619 2006-03-15 00:12:47Z steve.ebersole(a)jboss.com $
package org.hibernate.tuple.component;
+import java.io.Serializable;
import java.lang.reflect.Method;
-import java.io.Serializable;
+import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
-import org.hibernate.AssertionFailure;
-import org.hibernate.tuple.component.AbstractComponentTuplizer;
-import org.hibernate.tuple.Instantiator;
-import org.hibernate.tuple.PojoInstantiator;
-import org.hibernate.util.ReflectHelper;
+import org.hibernate.bytecode.BasicProxyFactory;
import org.hibernate.bytecode.ReflectionOptimizer;
-import org.hibernate.bytecode.BasicProxyFactory;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Property;
+import org.hibernate.property.BackrefPropertyAccessor;
import org.hibernate.property.Getter;
import org.hibernate.property.PropertyAccessor;
import org.hibernate.property.PropertyAccessorFactory;
import org.hibernate.property.Setter;
+import org.hibernate.tuple.Instantiator;
+import org.hibernate.tuple.PojoInstantiator;
+import org.hibernate.util.ReflectHelper;
/**
* A {@link ComponentTuplizer} specific to the pojo entity mode.
@@ -76,6 +76,9 @@
}
public Object[] getPropertyValues(Object component) throws HibernateException {
+ if ( component == BackrefPropertyAccessor.UNKNOWN ) {
+ return new Object[ propertySpan ];
+ }
if ( optimizer != null && optimizer.getAccessOptimizer() != null ) {
return optimizer.getAccessOptimizer().getPropertyValues( component );
}
Modified: core/branches/Branch_3_2/test/org/hibernate/test/collection/CollectionSuite.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/collection/CollectionSuite.java 2007-07-31 13:39:23 UTC (rev 12859)
+++ core/branches/Branch_3_2/test/org/hibernate/test/collection/CollectionSuite.java 2007-07-31 13:39:45 UTC (rev 12860)
@@ -3,6 +3,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.hibernate.test.collection.backref.map.compkey.BackrefCompositeMapKeyTest;
import org.hibernate.test.collection.bag.PersistentBagTest;
import org.hibernate.test.collection.idbag.PersistentIdBagTest;
import org.hibernate.test.collection.list.PersistentListTest;
@@ -25,6 +26,7 @@
suite.addTest( PersistentMapTest.suite() );
suite.addTest( CollectionTest.suite() );
suite.addTest( PersistentSetTest.suite() );
+ suite.addTest( BackrefCompositeMapKeyTest.suite() );
return suite;
}
Added: core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/BackrefCompositeMapKeyTest.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/BackrefCompositeMapKeyTest.java (rev 0)
+++ core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/BackrefCompositeMapKeyTest.java 2007-07-31 13:39:45 UTC (rev 12860)
@@ -0,0 +1,284 @@
+/*
+ * 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.test.collection.backref.map.compkey;
+
+import junit.framework.Test;
+
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.LockMode;
+import org.hibernate.Hibernate;
+import org.hibernate.util.SerializationHelper;
+
+/**
+ * BackrefCompositeMapKeyTest implementation. Test access to a composite map-key
+ * backref via a number of different access methods.
+ *
+ * @author Steve Ebersole
+ */
+public class BackrefCompositeMapKeyTest extends FunctionalTestCase {
+ public BackrefCompositeMapKeyTest(String string) {
+ super( string );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "collection/backref/map/compkey/Mappings.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( BackrefCompositeMapKeyTest.class );
+ }
+
+ public void testOrphanDeleteOnDelete() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey( "Bottom" ), part2 );
+ session.persist( prod );
+ session.flush();
+
+ prod.getParts().remove( mapKey );
+
+ session.delete( prod );
+
+ t.commit();
+ session.close();
+
+ session = openSession();
+ t = session.beginTransaction();
+ assertNull( "Orphan 'Widge' was not deleted", session.get(Part.class, "Widge") );
+ assertNull( "Orphan 'Get' was not deleted", session.get(Part.class, "Get") );
+ assertNull( "Orphan 'Widget' was not deleted", session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+
+ public void testOrphanDeleteAfterPersist() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey( "Bottom" ), part2 );
+ session.persist( prod );
+
+ prod.getParts().remove( mapKey );
+
+ t.commit();
+ session.close();
+
+ session = openSession();
+ t = session.beginTransaction();
+ session.delete( session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+
+ public void testOrphanDeleteAfterPersistAndFlush() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey( "Bottom" ), part2 );
+ session.persist( prod );
+ session.flush();
+
+ prod.getParts().remove( mapKey );
+
+ t.commit();
+ session.close();
+
+ session = openSession();
+ t = session.beginTransaction();
+ assertNull( session.get(Part.class, "Widge") );
+ assertNotNull( session.get(Part.class, "Get") );
+ session.delete( session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+
+ public void testOrphanDeleteAfterLock() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey( "Bottom" ),part2 );
+ session.persist( prod );
+ t.commit();
+ session.close();
+
+
+ session = openSession();
+ t = session.beginTransaction();
+ session.lock(prod, LockMode.READ);
+ prod.getParts().remove(mapKey);
+ t.commit();
+ session.close();
+
+ session = openSession();
+ t = session.beginTransaction();
+ assertNull( session.get(Part.class, "Widge") );
+ assertNotNull( session.get(Part.class, "Get") );
+ session.delete( session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+
+ public void testOrphanDeleteOnSaveOrUpdate() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey( "Bottom" ), part2 );
+ session.persist( prod );
+ t.commit();
+ session.close();
+
+ prod.getParts().remove( mapKey );
+
+ session = openSession();
+ t = session.beginTransaction();
+ session.saveOrUpdate(prod);
+ t.commit();
+ session.close();
+
+ session = openSession();
+ t = session.beginTransaction();
+ assertNull( session.get(Part.class, "Widge") );
+ assertNotNull( session.get(Part.class, "Get") );
+ session.delete( session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+
+ public void testOrphanDeleteOnSaveOrUpdateAfterSerialization() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey( "Bottom" ), part2 );
+ session.persist( prod );
+ t.commit();
+ session.close();
+
+ prod.getParts().remove( mapKey );
+
+ prod = (Product) SerializationHelper.clone( prod );
+
+ session = openSession();
+ t = session.beginTransaction();
+ session.saveOrUpdate(prod);
+ t.commit();
+ session.close();
+
+ session = openSession();
+ t = session.beginTransaction();
+ assertNull( session.get(Part.class, "Widge") );
+ assertNotNull( session.get(Part.class, "Get") );
+ session.delete( session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+
+ public void testOrphanDelete() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey( "Bottom" ), part2 );
+ session.persist( prod );
+ t.commit();
+ session.close();
+
+ getSessions().evict(Product.class);
+ getSessions().evict(Part.class);
+
+ session = openSession();
+ t = session.beginTransaction();
+ prod = (Product) session.get(Product.class, "Widget");
+ assertTrue( Hibernate.isInitialized( prod.getParts() ) );
+ part = (Part) session.get(Part.class, "Widge");
+ prod.getParts().remove(mapKey);
+ t.commit();
+ session.close();
+
+ getSessions().evict(Product.class);
+ getSessions().evict(Part.class);
+
+ session = openSession();
+ t = session.beginTransaction();
+ prod = (Product) session.get(Product.class, "Widget");
+ assertTrue( Hibernate.isInitialized( prod.getParts() ) );
+ assertNull( prod.getParts().get(new MapKey("Top")));
+ assertNotNull( session.get(Part.class, "Get") );
+ session.delete( session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+
+ public void testOrphanDeleteOnMerge() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey("Bottom"), part2 );
+ session.persist( prod );
+ t.commit();
+ session.close();
+
+ prod.getParts().remove( mapKey );
+
+ session = openSession();
+ t = session.beginTransaction();
+ session.merge(prod);
+ t.commit();
+ session.close();
+
+ session = openSession();
+ t = session.beginTransaction();
+ assertNull( session.get(Part.class, "Widge") );
+ assertNotNull( session.get(Part.class, "Get") );
+ session.delete( session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+}
Added: core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/MapKey.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/MapKey.java (rev 0)
+++ core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/MapKey.java 2007-07-31 13:39:45 UTC (rev 12860)
@@ -0,0 +1,59 @@
+/*
+ * 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.test.collection.backref.map.compkey;
+
+import java.io.Serializable;
+
+/**
+ * A composite map key.
+ *
+ * @author Steve Ebersole
+ */
+public class MapKey implements Serializable {
+ private String role;
+
+ public MapKey() {
+ }
+
+ public MapKey(String role) {
+ this.role = role;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+
+ MapKey mapKey = ( MapKey ) o;
+
+ if ( !role.equals( mapKey.role ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode() {
+ return role.hashCode();
+ }
+}
Added: core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/Mappings.hbm.xml
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/Mappings.hbm.xml (rev 0)
+++ core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/Mappings.hbm.xml 2007-07-31 13:39:45 UTC (rev 12860)
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+ ~ 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
+ -->
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+ Demonstrates a unidirectional map mapping where the map key is a
+ composite. The unidirectional collection forces Hibernate to use
+ a backref. We want to make sure the backref works properly with
+ the component.
+-->
+<hibernate-mapping package="org.hibernate.test.collection.backref.map.compkey" default-access="field">
+
+ <class name="Product" table="t_product">
+ <id name="name"/>
+ <map name="parts" table="Parts" cascade="all,delete-orphan" fetch="join">
+ <key column="productName" not-null="true"/>
+ <composite-map-key class="MapKey">
+ <key-property name="role"/>
+ </composite-map-key>
+ <one-to-many class="Part"/>
+ </map>
+ </class>
+
+ <class name="Part" table="t_part">
+ <id name="name"/>
+ <property name="description" not-null="true"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/Part.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/Part.java (rev 0)
+++ core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/Part.java 2007-07-31 13:39:45 UTC (rev 12860)
@@ -0,0 +1,52 @@
+/*
+ * 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.test.collection.backref.map.compkey;
+
+import java.io.Serializable;
+
+/**
+ * Part implementation
+ *
+ * @author Steve Ebersole
+ */
+public class Part implements Serializable {
+ private String name;
+ private String description;
+
+ public Part() {
+ }
+
+ public Part(String name) {
+ this.name = name;
+ }
+
+ public Part(String name, String description) {
+ this.name = name;
+ this.description = description;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
Added: core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/Product.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/Product.java (rev 0)
+++ core/branches/Branch_3_2/test/org/hibernate/test/collection/backref/map/compkey/Product.java 2007-07-31 13:39:45 UTC (rev 12860)
@@ -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.test.collection.backref.map.compkey;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Product implementation
+ *
+ * @author Steve Ebersole
+ */
+public class Product implements Serializable {
+ private String name;
+ private Map parts = new HashMap();
+
+ public Product() {
+ }
+
+ public Product(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Map getParts() {
+ return parts;
+ }
+
+ public void setParts(Map parts) {
+ this.parts = parts;
+ }
+}
17 years, 5 months
Hibernate SVN: r12859 - in core/trunk: testsuite/src/test/java/org/hibernate/test/collection and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-31 09:39:23 -0400 (Tue, 31 Jul 2007)
New Revision: 12859
Added:
core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/
core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/
core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/
core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/BackrefCompositeMapKeyTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/MapKey.java
core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/Mappings.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/Part.java
core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/Product.java
Modified:
core/trunk/core/src/main/java/org/hibernate/tuple/component/PojoComponentTuplizer.java
core/trunk/testsuite/src/test/java/org/hibernate/test/collection/CollectionSuite.java
Log:
HHH-2711 : composite-map-key + unidir map can lead to PropertyAccessException
Modified: core/trunk/core/src/main/java/org/hibernate/tuple/component/PojoComponentTuplizer.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/tuple/component/PojoComponentTuplizer.java 2007-07-31 01:27:24 UTC (rev 12858)
+++ core/trunk/core/src/main/java/org/hibernate/tuple/component/PojoComponentTuplizer.java 2007-07-31 13:39:23 UTC (rev 12859)
@@ -1,25 +1,25 @@
//$Id: PojoComponentTuplizer.java 9619 2006-03-15 00:12:47Z steve.ebersole(a)jboss.com $
package org.hibernate.tuple.component;
+import java.io.Serializable;
import java.lang.reflect.Method;
-import java.io.Serializable;
+import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
-import org.hibernate.AssertionFailure;
-import org.hibernate.tuple.component.AbstractComponentTuplizer;
-import org.hibernate.tuple.Instantiator;
-import org.hibernate.tuple.PojoInstantiator;
-import org.hibernate.util.ReflectHelper;
+import org.hibernate.bytecode.BasicProxyFactory;
import org.hibernate.bytecode.ReflectionOptimizer;
-import org.hibernate.bytecode.BasicProxyFactory;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Property;
+import org.hibernate.property.BackrefPropertyAccessor;
import org.hibernate.property.Getter;
import org.hibernate.property.PropertyAccessor;
import org.hibernate.property.PropertyAccessorFactory;
import org.hibernate.property.Setter;
+import org.hibernate.tuple.Instantiator;
+import org.hibernate.tuple.PojoInstantiator;
+import org.hibernate.util.ReflectHelper;
/**
* A {@link ComponentTuplizer} specific to the pojo entity mode.
@@ -76,6 +76,9 @@
}
public Object[] getPropertyValues(Object component) throws HibernateException {
+ if ( component == BackrefPropertyAccessor.UNKNOWN ) {
+ return new Object[ propertySpan ];
+ }
if ( optimizer != null && optimizer.getAccessOptimizer() != null ) {
return optimizer.getAccessOptimizer().getPropertyValues( component );
}
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/collection/CollectionSuite.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/collection/CollectionSuite.java 2007-07-31 01:27:24 UTC (rev 12858)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/collection/CollectionSuite.java 2007-07-31 13:39:23 UTC (rev 12859)
@@ -9,6 +9,7 @@
import org.hibernate.test.collection.map.PersistentMapTest;
import org.hibernate.test.collection.original.CollectionTest;
import org.hibernate.test.collection.set.PersistentSetTest;
+import org.hibernate.test.collection.backref.map.compkey.BackrefCompositeMapKeyTest;
/**
* Suite of collection (i.e. PersistentCollection) related tests
@@ -25,6 +26,7 @@
suite.addTest( PersistentMapTest.suite() );
suite.addTest( CollectionTest.suite() );
suite.addTest( PersistentSetTest.suite() );
+ suite.addTest( BackrefCompositeMapKeyTest.suite() );
return suite;
}
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/BackrefCompositeMapKeyTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/BackrefCompositeMapKeyTest.java (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/BackrefCompositeMapKeyTest.java 2007-07-31 13:39:23 UTC (rev 12859)
@@ -0,0 +1,284 @@
+/*
+ * 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.test.collection.backref.map.compkey;
+
+import junit.framework.Test;
+
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.LockMode;
+import org.hibernate.Hibernate;
+import org.hibernate.util.SerializationHelper;
+
+/**
+ * BackrefCompositeMapKeyTest implementation. Test access to a composite map-key
+ * backref via a number of different access methods.
+ *
+ * @author Steve Ebersole
+ */
+public class BackrefCompositeMapKeyTest extends FunctionalTestCase {
+ public BackrefCompositeMapKeyTest(String string) {
+ super( string );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "collection/backref/map/compkey/Mappings.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( BackrefCompositeMapKeyTest.class );
+ }
+
+ public void testOrphanDeleteOnDelete() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey( "Bottom" ), part2 );
+ session.persist( prod );
+ session.flush();
+
+ prod.getParts().remove( mapKey );
+
+ session.delete( prod );
+
+ t.commit();
+ session.close();
+
+ session = openSession();
+ t = session.beginTransaction();
+ assertNull( "Orphan 'Widge' was not deleted", session.get(Part.class, "Widge") );
+ assertNull( "Orphan 'Get' was not deleted", session.get(Part.class, "Get") );
+ assertNull( "Orphan 'Widget' was not deleted", session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+
+ public void testOrphanDeleteAfterPersist() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey( "Bottom" ), part2 );
+ session.persist( prod );
+
+ prod.getParts().remove( mapKey );
+
+ t.commit();
+ session.close();
+
+ session = openSession();
+ t = session.beginTransaction();
+ session.delete( session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+
+ public void testOrphanDeleteAfterPersistAndFlush() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey( "Bottom" ), part2 );
+ session.persist( prod );
+ session.flush();
+
+ prod.getParts().remove( mapKey );
+
+ t.commit();
+ session.close();
+
+ session = openSession();
+ t = session.beginTransaction();
+ assertNull( session.get(Part.class, "Widge") );
+ assertNotNull( session.get(Part.class, "Get") );
+ session.delete( session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+
+ public void testOrphanDeleteAfterLock() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey( "Bottom" ),part2 );
+ session.persist( prod );
+ t.commit();
+ session.close();
+
+
+ session = openSession();
+ t = session.beginTransaction();
+ session.lock(prod, LockMode.READ);
+ prod.getParts().remove(mapKey);
+ t.commit();
+ session.close();
+
+ session = openSession();
+ t = session.beginTransaction();
+ assertNull( session.get(Part.class, "Widge") );
+ assertNotNull( session.get(Part.class, "Get") );
+ session.delete( session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+
+ public void testOrphanDeleteOnSaveOrUpdate() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey( "Bottom" ), part2 );
+ session.persist( prod );
+ t.commit();
+ session.close();
+
+ prod.getParts().remove( mapKey );
+
+ session = openSession();
+ t = session.beginTransaction();
+ session.saveOrUpdate(prod);
+ t.commit();
+ session.close();
+
+ session = openSession();
+ t = session.beginTransaction();
+ assertNull( session.get(Part.class, "Widge") );
+ assertNotNull( session.get(Part.class, "Get") );
+ session.delete( session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+
+ public void testOrphanDeleteOnSaveOrUpdateAfterSerialization() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey( "Bottom" ), part2 );
+ session.persist( prod );
+ t.commit();
+ session.close();
+
+ prod.getParts().remove( mapKey );
+
+ prod = (Product) SerializationHelper.clone( prod );
+
+ session = openSession();
+ t = session.beginTransaction();
+ session.saveOrUpdate(prod);
+ t.commit();
+ session.close();
+
+ session = openSession();
+ t = session.beginTransaction();
+ assertNull( session.get(Part.class, "Widge") );
+ assertNotNull( session.get(Part.class, "Get") );
+ session.delete( session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+
+ public void testOrphanDelete() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey( "Bottom" ), part2 );
+ session.persist( prod );
+ t.commit();
+ session.close();
+
+ getSessions().evict(Product.class);
+ getSessions().evict(Part.class);
+
+ session = openSession();
+ t = session.beginTransaction();
+ prod = (Product) session.get(Product.class, "Widget");
+ assertTrue( Hibernate.isInitialized( prod.getParts() ) );
+ part = (Part) session.get(Part.class, "Widge");
+ prod.getParts().remove(mapKey);
+ t.commit();
+ session.close();
+
+ getSessions().evict(Product.class);
+ getSessions().evict(Part.class);
+
+ session = openSession();
+ t = session.beginTransaction();
+ prod = (Product) session.get(Product.class, "Widget");
+ assertTrue( Hibernate.isInitialized( prod.getParts() ) );
+ assertNull( prod.getParts().get(new MapKey("Top")));
+ assertNotNull( session.get(Part.class, "Get") );
+ session.delete( session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+
+ public void testOrphanDeleteOnMerge() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product( "Widget" );
+ Part part = new Part( "Widge", "part if a Widget" );
+ MapKey mapKey = new MapKey( "Top" );
+ prod.getParts().put( mapKey, part );
+ Part part2 = new Part( "Get", "another part if a Widget" );
+ prod.getParts().put( new MapKey("Bottom"), part2 );
+ session.persist( prod );
+ t.commit();
+ session.close();
+
+ prod.getParts().remove( mapKey );
+
+ session = openSession();
+ t = session.beginTransaction();
+ session.merge(prod);
+ t.commit();
+ session.close();
+
+ session = openSession();
+ t = session.beginTransaction();
+ assertNull( session.get(Part.class, "Widge") );
+ assertNotNull( session.get(Part.class, "Get") );
+ session.delete( session.get(Product.class, "Widget") );
+ t.commit();
+ session.close();
+ }
+}
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/MapKey.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/MapKey.java (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/MapKey.java 2007-07-31 13:39:23 UTC (rev 12859)
@@ -0,0 +1,59 @@
+/*
+ * 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.test.collection.backref.map.compkey;
+
+import java.io.Serializable;
+
+/**
+ * A composite map key.
+ *
+ * @author Steve Ebersole
+ */
+public class MapKey implements Serializable {
+ private String role;
+
+ public MapKey() {
+ }
+
+ public MapKey(String role) {
+ this.role = role;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+
+ MapKey mapKey = ( MapKey ) o;
+
+ if ( !role.equals( mapKey.role ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode() {
+ return role.hashCode();
+ }
+}
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/Mappings.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/Mappings.hbm.xml (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/Mappings.hbm.xml 2007-07-31 13:39:23 UTC (rev 12859)
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+ ~ 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
+ -->
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+ Demonstrates a unidirectional map mapping where the map key is a
+ composite. The unidirectional collection forces Hibernate to use
+ a backref. We want to make sure the backref works properly with
+ the component.
+-->
+<hibernate-mapping package="org.hibernate.test.collection.backref.map.compkey" default-access="field">
+
+ <class name="Product" table="t_product">
+ <id name="name"/>
+ <map name="parts" table="Parts" cascade="all,delete-orphan" fetch="join">
+ <key column="productName" not-null="true"/>
+ <composite-map-key class="MapKey">
+ <key-property name="role"/>
+ </composite-map-key>
+ <one-to-many class="Part"/>
+ </map>
+ </class>
+
+ <class name="Part" table="t_part">
+ <id name="name"/>
+ <property name="description" not-null="true"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/Part.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/Part.java (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/Part.java 2007-07-31 13:39:23 UTC (rev 12859)
@@ -0,0 +1,52 @@
+/*
+ * 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.test.collection.backref.map.compkey;
+
+import java.io.Serializable;
+
+/**
+ * Part implementation
+ *
+ * @author Steve Ebersole
+ */
+public class Part implements Serializable {
+ private String name;
+ private String description;
+
+ public Part() {
+ }
+
+ public Part(String name) {
+ this.name = name;
+ }
+
+ public Part(String name, String description) {
+ this.name = name;
+ this.description = description;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/Product.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/Product.java (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/Product.java 2007-07-31 13:39:23 UTC (rev 12859)
@@ -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.test.collection.backref.map.compkey;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Product implementation
+ *
+ * @author Steve Ebersole
+ */
+public class Product implements Serializable {
+ private String name;
+ private Map parts = new HashMap();
+
+ public Product() {
+ }
+
+ public Product(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Map getParts() {
+ return parts;
+ }
+
+ public void setParts(Map parts) {
+ this.parts = parts;
+ }
+}
17 years, 5 months
Hibernate SVN: r12858 - in trunk/HibernateExt/search/src: java/org/hibernate/search/engine and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-30 21:27:24 -0400 (Mon, 30 Jul 2007)
New Revision: 12858
Added:
trunk/HibernateExt/search/src/java/org/hibernate/search/store/IndexShardingStrategy.java
Removed:
trunk/HibernateExt/search/src/java/org/hibernate/search/store/DirectoryProviderShardingStrategy.java
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java
trunk/HibernateExt/search/src/java/org/hibernate/search/engine/DocumentBuilder.java
trunk/HibernateExt/search/src/java/org/hibernate/search/store/DirectoryProviderFactory.java
trunk/HibernateExt/search/src/java/org/hibernate/search/store/IdHashShardingStrategy.java
trunk/HibernateExt/search/src/java/org/hibernate/search/store/NotShardedStrategy.java
trunk/HibernateExt/search/src/test/org/hibernate/search/test/shards/ShardsTest.java
Log:
HSEARCH-86 Rename ShardingStrategy change _<index> for .<index>
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java 2007-07-31 00:46:10 UTC (rev 12857)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java 2007-07-31 01:27:24 UTC (rev 12858)
@@ -16,7 +16,7 @@
import org.hibernate.search.engine.SearchFactoryImplementor;
import org.hibernate.search.engine.DocumentBuilder;
import org.hibernate.search.store.DirectoryProvider;
-import org.hibernate.search.store.DirectoryProviderShardingStrategy;
+import org.hibernate.search.store.IndexShardingStrategy;
import org.hibernate.annotations.common.AssertionFailure;
/**
@@ -49,7 +49,7 @@
List<LuceneWorker.WorkWithPayload> queueWithFlatDPs = new ArrayList<LuceneWorker.WorkWithPayload>( queue.size()*2 );
for ( LuceneWork work : queue ) {
DocumentBuilder documentBuilder = searchFactoryImplementor.getDocumentBuilders().get( work.getEntityClass() );
- DirectoryProviderShardingStrategy shardingStrategy = documentBuilder.getDirectoryProviderSelectionStrategy();
+ IndexShardingStrategy shardingStrategy = documentBuilder.getDirectoryProviderSelectionStrategy();
if ( AddLuceneWork.class.isAssignableFrom( work.getClass() ) ) {
DirectoryProvider provider = shardingStrategy.getDirectoryProviderForAddition(
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-31 00:46:10 UTC (rev 12857)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/engine/DocumentBuilder.java 2007-07-31 01:27:24 UTC (rev 12858)
@@ -44,7 +44,7 @@
import org.hibernate.search.bridge.FieldBridge;
import org.hibernate.search.bridge.TwoWayFieldBridge;
import org.hibernate.search.store.DirectoryProvider;
-import org.hibernate.search.store.DirectoryProviderShardingStrategy;
+import org.hibernate.search.store.IndexShardingStrategy;
import org.hibernate.search.util.BinderHelper;
import org.hibernate.search.util.ScopedAnalyzer;
@@ -63,7 +63,7 @@
private final PropertiesMetadata rootPropertiesMetadata;
private final XClass beanClass;
private final DirectoryProvider[] directoryProviders;
- private final DirectoryProviderShardingStrategy shardingStrategy;
+ private final IndexShardingStrategy shardingStrategy;
private String idKeywordName;
private XMember idGetter;
private Float idBoost;
@@ -77,7 +77,7 @@
public DocumentBuilder(XClass clazz, Analyzer defaultAnalyzer, DirectoryProvider[] directoryProviders,
- DirectoryProviderShardingStrategy shardingStrategy, ReflectionManager reflectionManager) {
+ IndexShardingStrategy shardingStrategy, ReflectionManager reflectionManager) {
this.analyzer = new ScopedAnalyzer();
this.beanClass = clazz;
this.directoryProviders = directoryProviders;
@@ -586,7 +586,7 @@
return directoryProviders;
}
- public DirectoryProviderShardingStrategy getDirectoryProviderSelectionStrategy() {
+ public IndexShardingStrategy getDirectoryProviderSelectionStrategy() {
return shardingStrategy;
}
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/store/DirectoryProviderFactory.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/store/DirectoryProviderFactory.java 2007-07-31 00:46:10 UTC (rev 12857)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/store/DirectoryProviderFactory.java 2007-07-31 01:27:24 UTC (rev 12858)
@@ -5,7 +5,6 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
import org.hibernate.HibernateException;
@@ -72,13 +71,13 @@
DirectoryProvider[] providers = new DirectoryProvider[nbrOfProviders];
for (int index = 0 ; index < nbrOfProviders ; index++) {
String providerName = nbrOfProviders > 1 ?
- directoryProviderName + "_" + index :
+ directoryProviderName + "." + index :
directoryProviderName;
providers[index] = createDirectoryProvider( providerName,indexProps[index], searchFactoryImplementor);
}
//define sharding strategy
- DirectoryProviderShardingStrategy shardingStrategy;
+ IndexShardingStrategy shardingStrategy;
Properties shardingProperties = new Properties();
for (Map.Entry entry : indexProps[0].entrySet()) {
if ( ( (String) entry.getKey() ).startsWith( SHARDING_STRATEGY ) ) {
@@ -97,7 +96,7 @@
else {
try {
Class shardigStrategyClass = ReflectHelper.classForName( shardingStrategyName, this.getClass() );
- shardingStrategy = (DirectoryProviderShardingStrategy) shardigStrategyClass.newInstance();
+ shardingStrategy = (IndexShardingStrategy) shardigStrategyClass.newInstance();
}
catch (ClassNotFoundException e) {
throw new SearchException("Unable to find ShardingStrategy class " + shardingStrategyName + " for " + directoryProviderName, e);
@@ -115,7 +114,7 @@
+ shardingStrategyName, e);
}
}
- shardingStrategy.init( shardingProperties, providers );
+ shardingStrategy.initialize( shardingProperties, providers );
return new DirectoryProviders( shardingStrategy, providers );
}
@@ -371,17 +370,17 @@
}
public class DirectoryProviders {
- private DirectoryProviderShardingStrategy shardingStrategy;
+ private IndexShardingStrategy shardingStrategy;
private DirectoryProvider[] providers;
- public DirectoryProviders(DirectoryProviderShardingStrategy shardingStrategy, DirectoryProvider[] providers) {
+ public DirectoryProviders(IndexShardingStrategy shardingStrategy, DirectoryProvider[] providers) {
this.shardingStrategy = shardingStrategy;
this.providers = providers;
}
- public DirectoryProviderShardingStrategy getSelectionStrategy() {
+ public IndexShardingStrategy getSelectionStrategy() {
return shardingStrategy;
}
Deleted: trunk/HibernateExt/search/src/java/org/hibernate/search/store/DirectoryProviderShardingStrategy.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/store/DirectoryProviderShardingStrategy.java 2007-07-31 00:46:10 UTC (rev 12857)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/store/DirectoryProviderShardingStrategy.java 2007-07-31 01:27:24 UTC (rev 12858)
@@ -1,17 +0,0 @@
-//$Id$
-package org.hibernate.search.store;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-import org.apache.lucene.document.Document;
-
-/**
- * @author Emmanuel Bernard
- */
-public interface DirectoryProviderShardingStrategy {
- void init(Properties properties, DirectoryProvider[] providers);
- DirectoryProvider[] getDirectoryProvidersForAllShards();
- DirectoryProvider getDirectoryProviderForAddition(Class entity, Serializable id, String idInString, Document document);
- DirectoryProvider[] getDirectoryProvidersForDeletion(Class entity, Serializable id, String idInString);
-}
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/store/IdHashShardingStrategy.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/store/IdHashShardingStrategy.java 2007-07-31 00:46:10 UTC (rev 12857)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/store/IdHashShardingStrategy.java 2007-07-31 01:27:24 UTC (rev 12858)
@@ -11,9 +11,9 @@
*
* @author Emmanuel Bernard
*/
-public class IdHashShardingStrategy implements DirectoryProviderShardingStrategy {
+public class IdHashShardingStrategy implements IndexShardingStrategy {
private DirectoryProvider[] providers;
- public void init(Properties properties, DirectoryProvider[] providers) {
+ public void initialize(Properties properties, DirectoryProvider[] providers) {
this.providers = providers;
}
Copied: trunk/HibernateExt/search/src/java/org/hibernate/search/store/IndexShardingStrategy.java (from rev 12845, trunk/HibernateExt/search/src/java/org/hibernate/search/store/DirectoryProviderShardingStrategy.java)
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/store/IndexShardingStrategy.java (rev 0)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/store/IndexShardingStrategy.java 2007-07-31 01:27:24 UTC (rev 12858)
@@ -0,0 +1,34 @@
+//$Id$
+package org.hibernate.search.store;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+import org.apache.lucene.document.Document;
+
+/**
+ * Defines how a given virtual index shards data into different DirectoryProviders
+ *
+ * @author Emmanuel Bernard
+ */
+public interface IndexShardingStrategy {
+ /**
+ * provides access to sharding properties (under the suffix sharding_strategy)
+ * and provide access to all the DirectoryProviders for a given index
+ */
+ void initialize(Properties properties, DirectoryProvider[] providers);
+
+ /**
+ * Ask for all shards (eg to query or optimize)
+ */
+ DirectoryProvider[] getDirectoryProvidersForAllShards();
+
+ /**
+ * return the DirectoryProvider where the given entity will be indexed
+ */
+ DirectoryProvider getDirectoryProviderForAddition(Class entity, Serializable id, String idInString, Document document);
+ /**
+ * return the DirectoryProvider(s) where the given entity is stored and where the deletion operation needs to be applied
+ */
+ DirectoryProvider[] getDirectoryProvidersForDeletion(Class entity, Serializable id, String idInString);
+}
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/store/NotShardedStrategy.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/store/NotShardedStrategy.java 2007-07-31 00:46:10 UTC (rev 12857)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/store/NotShardedStrategy.java 2007-07-31 01:27:24 UTC (rev 12858)
@@ -10,9 +10,9 @@
/**
* @author Emmanuel Bernard
*/
-public class NotShardedStrategy implements DirectoryProviderShardingStrategy {
+public class NotShardedStrategy implements IndexShardingStrategy {
private DirectoryProvider[] directoryProvider;
- public void init(Properties properties, DirectoryProvider[] providers) {
+ public void initialize(Properties properties, DirectoryProvider[] providers) {
this.directoryProvider = providers;
if ( directoryProvider.length > 1) {
throw new AssertionFailure("Using SingleDirectoryProviderSelectionStrategy with multiple DirectryProviders");
Modified: trunk/HibernateExt/search/src/test/org/hibernate/search/test/shards/ShardsTest.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/shards/ShardsTest.java 2007-07-31 00:46:10 UTC (rev 12857)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/shards/ShardsTest.java 2007-07-31 01:27:24 UTC (rev 12858)
@@ -2,7 +2,6 @@
package org.hibernate.search.test.shards;
import java.io.File;
-import java.util.Properties;
import java.util.List;
import org.hibernate.search.test.SearchTestCase;
@@ -43,7 +42,7 @@
public void testIdShardingStrategy() {
DirectoryProvider[] dps = new DirectoryProvider[] { new RAMDirectoryProvider(), new RAMDirectoryProvider() };
IdHashShardingStrategy shardingStrategy = new IdHashShardingStrategy();
- shardingStrategy.init( null, dps);
+ shardingStrategy.initialize( null, dps);
assertTrue( dps[1] == shardingStrategy.getDirectoryProviderForAddition( Animal.class, 1, "1", null) );
assertTrue( dps[0] == shardingStrategy.getDirectoryProviderForAddition( Animal.class, 2, "2", null) );
}
@@ -112,7 +111,7 @@
finally {
reader.close();
}
- reader = IndexReader.open( new File( getBaseIndexDir(), "Animal_1" ) );
+ reader = IndexReader.open( new File( getBaseIndexDir(), "Animal.1" ) );
try {
int num = reader.numDocs();
assertEquals( 1, num );
@@ -129,7 +128,7 @@
s.clear();
- reader = IndexReader.open( new File( getBaseIndexDir(), "Animal_1" ) );
+ reader = IndexReader.open( new File( getBaseIndexDir(), "Animal.1" ) );
try {
int num = reader.numDocs();
assertEquals( 1, num );
17 years, 5 months
Hibernate SVN: r12857 - trunk/HibernateExt/search/src/test/org/hibernate/search/test/shards.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-30 20:46:10 -0400 (Mon, 30 Jul 2007)
New Revision: 12857
Added:
trunk/HibernateExt/search/src/test/org/hibernate/search/test/shards/Furniture.java
Modified:
trunk/HibernateExt/search/src/test/org/hibernate/search/test/shards/ShardsTest.java
Log:
HSEARCH-86 more test on sharding
Added: trunk/HibernateExt/search/src/test/org/hibernate/search/test/shards/Furniture.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/shards/Furniture.java (rev 0)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/shards/Furniture.java 2007-07-31 00:46:10 UTC (rev 12857)
@@ -0,0 +1,38 @@
+//$Id$
+package org.hibernate.search.test.shards;
+
+import javax.persistence.Entity;
+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;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed
+public class Furniture {
+ @Id @GeneratedValue @DocumentId
+ private Integer id;
+ @Field
+ private String color;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getColor() {
+ return color;
+ }
+
+ public void setColor(String color) {
+ this.color = color;
+ }
+}
Modified: trunk/HibernateExt/search/src/test/org/hibernate/search/test/shards/ShardsTest.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/shards/ShardsTest.java 2007-07-31 00:13:51 UTC (rev 12856)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/shards/ShardsTest.java 2007-07-31 00:46:10 UTC (rev 12857)
@@ -66,6 +66,9 @@
tx = s.beginTransaction();
a = (Animal) s.get(Animal.class, 1);
a.setName( "Mouse" );
+ Furniture fur = new Furniture();
+ fur.setColor( "dark blue");
+ s.persist( fur );
tx.commit();
s.clear();
@@ -76,6 +79,11 @@
List results = fts.createFullTextQuery( parser.parse( "name:mouse OR name:bear" ) ).list();
assertEquals( "Either double insert, single update, or query fails with shards", 2, results.size() );
+
+ results = fts.createFullTextQuery( parser.parse( "name:mouse OR name:bear OR color:blue" ) ).list();
+ assertEquals( "Mixing shared and non sharded properties fails", 3, results.size() );
+ results = fts.createFullTextQuery( parser.parse( "name:mouse OR name:bear OR color:blue" ) ).list();
+ assertEquals( "Mixing shared and non sharded properties fails with indexreader reuse", 3, results.size() );
for (Object o : results) s.delete( o );
tx.commit();
s.close();
@@ -184,7 +192,8 @@
protected Class[] getMappings() {
return new Class[] {
- Animal.class
+ Animal.class,
+ Furniture.class
};
}
}
17 years, 5 months
Hibernate SVN: r12856 - trunk/HibernateExt/search/src/java/org/hibernate/search/reader.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-30 20:13:51 -0400 (Mon, 30 Jul 2007)
New Revision: 12856
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/reader/ReaderProviderFactory.java
Log:
HSEARCH-106 set shared as the default reader strategy
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/reader/ReaderProviderFactory.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/reader/ReaderProviderFactory.java 2007-07-31 00:04:27 UTC (rev 12855)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/reader/ReaderProviderFactory.java 2007-07-31 00:13:51 UTC (rev 12856)
@@ -34,7 +34,7 @@
ReaderProvider readerProvider;
if ( StringHelper.isEmpty( impl ) ) {
//put another one
- readerProvider = new NotSharedReaderProvider();
+ readerProvider = new SharedReaderProvider();
}
else if ( "not-shared".equalsIgnoreCase( impl ) ) {
readerProvider = new NotSharedReaderProvider();
17 years, 5 months