Author: galder.zamarreno(a)jboss.com
Date: 2009-08-17 03:46:18 -0400 (Mon, 17 Aug 2009)
New Revision: 17331
Added:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/access/
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Contact.hbm.xml
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Contact.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Customer.hbm.xml
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Customer.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/
Removed:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/Contact.hbm.xml
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/Contact.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/Customer.java
Modified:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/InfinispanCollectionRegion.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/ReadOnlyAccess.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/TransactionalAccess.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/InfinispanEntityRegion.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/TransactionalAccess.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.hbm.xml
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/AbstractDualNodeTestCase.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/EntityCollectionInvalidationTestCase.java
Log:
[ISPN-6] Added bulk operation test case and modelled cache access implementations like the
ones in the JBC2 integration layer.
Added:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java 2009-08-17
07:46:18 UTC (rev 17331)
@@ -0,0 +1,115 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.cache.infinispan.access;
+
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.access.CollectionRegionAccessStrategy;
+import org.hibernate.cache.access.EntityRegionAccessStrategy;
+import org.hibernate.cache.access.SoftLock;
+import org.infinispan.Cache;
+
+/**
+ * Defines the strategy for transactional access to entity or collection data in a
Infinispan instance.
+ * <p>
+ * The intent of this class is to encapsulate common code and serve as a delegate for
+ * {@link EntityRegionAccessStrategy} and {@link CollectionRegionAccessStrategy}
implementations.
+ *
+ * @author Brian Stansberry
+ * @author Galder Zamarreño
+ */
+public class TransactionalAccessDelegate {
+
+ protected final Cache cache;
+
+ public TransactionalAccessDelegate(Cache cache) {
+ this.cache = cache;
+ }
+
+ public Object get(Object key, long txTimestamp) throws CacheException {
+ return cache.get(key);
+ }
+
+ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version)
throws CacheException {
+ cache.putForExternalRead(key, value);
+ return true;
+ }
+
+ 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 {
+ 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
{
+ cache.put(key, value);
+ 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 {
+ cache.put(key, value);
+ 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 {
+ cache.remove(key);
+ }
+
+ public void removeAll() throws CacheException {
+ cache.clear();
+ }
+
+ public void evict(Object key) throws CacheException {
+ cache.evict(key);
+ }
+
+ public void evictAll() throws CacheException {
+ evictOrRemoveAll();
+ }
+
+ private void evictOrRemoveAll() throws CacheException {
+ cache.clear();
+ }
+}
Property changes on:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java
___________________________________________________________________
Name: svn:executable
+ *
Modified:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/InfinispanCollectionRegion.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/InfinispanCollectionRegion.java 2009-08-16
16:44:10 UTC (rev 17330)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/InfinispanCollectionRegion.java 2009-08-17
07:46:18 UTC (rev 17331)
@@ -10,6 +10,7 @@
/**
* @author Chris Bredesen
+ * @author Galder Zamarreño
*/
public class InfinispanCollectionRegion extends BaseTransactionalDataRegion implements
CollectionRegion {
@@ -23,7 +24,7 @@
} else if (AccessType.TRANSACTIONAL.equals(accessType)) {
return new TransactionalAccess(this);
}
- throw new CacheException("unsupported access type [" +
accessType.getName() + "]");
+ throw new CacheException("Unsupported access type [" +
accessType.getName() + "]");
}
}
Modified:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/ReadOnlyAccess.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/ReadOnlyAccess.java 2009-08-16
16:44:10 UTC (rev 17330)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/ReadOnlyAccess.java 2009-08-17
07:46:18 UTC (rev 17331)
@@ -1,77 +1,37 @@
package org.hibernate.cache.infinispan.collection;
import org.hibernate.cache.CacheException;
-import org.hibernate.cache.CollectionRegion;
-import org.hibernate.cache.access.CollectionRegionAccessStrategy;
import org.hibernate.cache.access.SoftLock;
/**
+ * This defines the strategy for transactional access to collection data in a
+ * Infinispan instance.
+ * <p/>
+ * The read-only access to a Infinispan really is still transactional, just with
+ * the extra semantic or guarantee that we will not update data.
+ *
* @author Chris Bredesen
+ * @author Galder Zamarreño
*/
-public class ReadOnlyAccess implements CollectionRegionAccessStrategy {
- private final InfinispanCollectionRegion region;
+class ReadOnlyAccess extends TransactionalAccess {
- public ReadOnlyAccess(InfinispanCollectionRegion region) {
- this.region = region;
+ ReadOnlyAccess(InfinispanCollectionRegion region) {
+ super(region);
}
-
- public void evict(Object key) throws CacheException {
- region.getCache().evict(key);
- }
-
- public void evictAll() throws CacheException {
- // TODO ensure proper clustering semantics here
- region.getCache().clear();
- }
-
- public Object get(Object key, long txTimestamp) throws CacheException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public CollectionRegion getRegion() {
- return region;
- }
-
public SoftLock lockItem(Object key, Object version) throws CacheException {
- // TODO Auto-generated method stub
return null;
}
public SoftLock lockRegion() throws CacheException {
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException("Illegal attempt to edit read only
region");
}
- public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version)
throws CacheException {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version,
boolean minimalPutOverride)
- throws CacheException {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void remove(Object key) throws CacheException {
- // TODO Auto-generated method stub
-
- }
-
- public void removeAll() throws CacheException {
- // TODO Auto-generated method stub
-
- }
-
public void unlockItem(Object key, SoftLock lock) throws CacheException {
- // TODO Auto-generated method stub
-
+ // no-op
}
public void unlockRegion(SoftLock lock) throws CacheException {
- // TODO Auto-generated method stub
-
+ throw new UnsupportedOperationException("Illegal attempt to edit read only
region");
}
}
Modified:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/TransactionalAccess.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/TransactionalAccess.java 2009-08-16
16:44:10 UTC (rev 17330)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/TransactionalAccess.java 2009-08-17
07:46:18 UTC (rev 17331)
@@ -4,57 +4,57 @@
import org.hibernate.cache.CollectionRegion;
import org.hibernate.cache.access.CollectionRegionAccessStrategy;
import org.hibernate.cache.access.SoftLock;
+import org.hibernate.cache.infinispan.access.TransactionalAccessDelegate;
/**
* Transactional collection region access for Infinispan.
*
* @author Chris Bredesen
+ * @author Galder Zamarreño
*/
-public class TransactionalAccess implements CollectionRegionAccessStrategy {
+class TransactionalAccess implements CollectionRegionAccessStrategy {
+
private final InfinispanCollectionRegion region;
+
+ private final TransactionalAccessDelegate delegate;
- public TransactionalAccess(InfinispanCollectionRegion region) {
+ TransactionalAccess(InfinispanCollectionRegion region) {
this.region = region;
+ this.delegate = new TransactionalAccessDelegate(region.getCache());
}
public void evict(Object key) throws CacheException {
- region.getCache().evict(key);
+ delegate.evict(key);
}
public void evictAll() throws CacheException {
- // TODO ensure proper clustering semantics
- region.getCache().clear();
+ delegate.evictAll();
}
public Object get(Object key, long txTimestamp) throws CacheException {
- return region.getCache().get(key);
+ return delegate.get(key, txTimestamp);
}
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version)
throws CacheException {
- region.getCache().putForExternalRead(key, value);
- return true;
+ return delegate.putFromLoad(key, value, txTimestamp, version);
}
- public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version,
boolean minimalPutOverride)
- throws CacheException {
- region.getCache().putForExternalRead(key, value);
- return true;
+ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version,
boolean minimalPutOverride) throws CacheException {
+ return delegate.putFromLoad(key, value, txTimestamp, version, minimalPutOverride);
}
public void remove(Object key) throws CacheException {
- region.getCache().remove(key);
+ delegate.remove(key);
}
public void removeAll() throws CacheException {
- region.getCache().clear();
+ delegate.removeAll();
}
public CollectionRegion getRegion() {
return region;
}
- // following methods copied from o.h.c.jbc2.collection.TransactionalAccess
-
public SoftLock lockItem(Object key, Object version) throws CacheException {
return null;
}
Modified:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/InfinispanEntityRegion.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/InfinispanEntityRegion.java 2009-08-16
16:44:10 UTC (rev 17330)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/InfinispanEntityRegion.java 2009-08-17
07:46:18 UTC (rev 17331)
@@ -8,6 +8,10 @@
import org.hibernate.cache.infinispan.impl.BaseTransactionalDataRegion;
import org.infinispan.Cache;
+/**
+ * @author Chris Bredesen
+ * @author Galder Zamarreño
+ */
public class InfinispanEntityRegion extends BaseTransactionalDataRegion implements
EntityRegion {
public InfinispanEntityRegion(Cache<Object, Object> cache, String name,
CacheDataDescription metadata) {
@@ -20,7 +24,7 @@
} else if (AccessType.TRANSACTIONAL.equals(accessType)) {
return new TransactionalAccess(this);
}
- throw new CacheException("unsupported access type [" +
accessType.getName() + "]");
+ throw new CacheException("Unsupported access type [" +
accessType.getName() + "]");
}
}
\ No newline at end of file
Modified:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/TransactionalAccess.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/TransactionalAccess.java 2009-08-16
16:44:10 UTC (rev 17330)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/TransactionalAccess.java 2009-08-17
07:46:18 UTC (rev 17331)
@@ -4,32 +4,35 @@
import org.hibernate.cache.EntityRegion;
import org.hibernate.cache.access.EntityRegionAccessStrategy;
import org.hibernate.cache.access.SoftLock;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.hibernate.cache.infinispan.access.TransactionalAccessDelegate;
/**
* Transactional entity region access for Infinispan.
*
* @author Chris Bredesen
+ * @author Galder Zamarreño
*/
class TransactionalAccess implements EntityRegionAccessStrategy {
- private static final Logger log = LoggerFactory.getLogger(TransactionalAccess.class);
+
private final InfinispanEntityRegion region;
+
+ private final TransactionalAccessDelegate delegate;
TransactionalAccess(InfinispanEntityRegion region) {
this.region = region;
+ this.delegate = new TransactionalAccessDelegate(region.getCache());
}
public void evict(Object key) throws CacheException {
- region.getCache().evict(key);
+ delegate.evict(key);
}
public void evictAll() throws CacheException {
- region.getCache().clear();
+ delegate.evictAll();
}
public Object get(Object key, long txTimestamp) throws CacheException {
- return region.getCache().get(key);
+ return delegate.get(key, txTimestamp);
}
public EntityRegion getRegion() {
@@ -42,31 +45,25 @@
}
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version)
throws CacheException {
- region.getCache().putForExternalRead(key, value);
- return true;
+ return delegate.putFromLoad(key, value, txTimestamp, version);
}
- public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version,
boolean minimalPutOverride)
- throws CacheException {
- region.getCache().putForExternalRead(key, value);
- return true;
+ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version,
boolean minimalPutOverride) throws CacheException {
+ return delegate.putFromLoad(key, value, txTimestamp, version, minimalPutOverride);
}
public void remove(Object key) throws CacheException {
- region.getCache().remove(key);
+ delegate.remove(key);
}
public void removeAll() throws CacheException {
- region.getCache().clear(); // TODO is this right?
+ delegate.removeAll();
}
public boolean update(Object key, Object value, Object currentVersion, Object
previousVersion) throws CacheException {
- region.getCache().put(key, value);
- return true; // JBC2 provider does this...
+ return delegate.update(key, value, currentVersion, previousVersion);
}
- // all remaining methods copied from the o.h.c.jbc2.entity.TransactionalAccess
-
public SoftLock lockItem(Object key, Object version) throws CacheException {
return null;
}
@@ -85,8 +82,7 @@
return false;
}
- public boolean afterUpdate(Object key, Object value, Object currentVersion, Object
previousVersion, SoftLock lock)
- throws CacheException {
+ public boolean afterUpdate(Object key, Object value, Object currentVersion, Object
previousVersion, SoftLock lock) throws CacheException {
return false;
}
}
\ No newline at end of file
Copied:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Contact.hbm.xml
(from rev 17244,
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/Contact.hbm.xml)
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Contact.hbm.xml
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Contact.hbm.xml 2009-08-17
07:46:18 UTC (rev 17331)
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+ <!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java ~ ~
+ Copyright (c) 2007, Red Hat Middleware LLC or third-party
+ contributors as ~ indicated by the @author tags or express
+ copyright attribution ~ statements applied by the authors. All
+ third-party contributions are ~ distributed under license by Red
+ Hat Middleware LLC. ~ ~ 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, as published by the Free Software
+ Foundation. ~ ~ This program is distributed in the hope that it
+ will be useful, ~ but WITHOUT ANY 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 ~ along with this distribution; if not,
+ write to: ~ Free Software Foundation, Inc. ~ 51 Franklin Street,
+ Fifth Floor ~ Boston, MA 02110-1301 USA
+ -->
+<hibernate-mapping
+ package="org.hibernate.test.cache.infinispan.functional">
+
+ <class name="Contact" table="Contacts">
+ <id name="id">
+ <generator class="increment" />
+ </id>
+ <property name="name" not-null="true" />
+ <property name="tlf" not-null="true" />
+ <many-to-one name="customer" column="cust_id"
class="Customer" />
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Copied:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Contact.java
(from rev 17244,
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/Contact.java)
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Contact.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Contact.java 2009-08-17
07:46:18 UTC (rev 17331)
@@ -0,0 +1,90 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.infinispan.functional;
+
+import java.io.Serializable;
+
+/**
+ * Entity that has a many-to-one relationship to a Customer
+ */
+public class Contact implements Serializable {
+ Integer id;
+ String name;
+ String tlf;
+ Customer customer;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getTlf() {
+ return tlf;
+ }
+
+ public void setTlf(String tlf) {
+ this.tlf = tlf;
+ }
+
+ public Customer getCustomer() {
+ return customer;
+ }
+
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) return true;
+ if (!(o instanceof Contact)) return false;
+ Contact c = (Contact) o;
+ return c.id.equals(id)
+ && c.name.equals(name)
+ && c.tlf.equals(tlf);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+ result = 31 * result + (id == null ? 0 : id.hashCode());
+ result = 31 * result + name.hashCode();
+ result = 31 * result + tlf.hashCode();
+ return result;
+ }
+
+
+
+}
Added:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Customer.hbm.xml
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Customer.hbm.xml
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Customer.hbm.xml 2009-08-17
07:46:18 UTC (rev 17331)
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+ <!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java ~ ~
+ Copyright (c) 2007, Red Hat Middleware LLC or third-party
+ contributors as ~ indicated by the @author tags or express
+ copyright attribution ~ statements applied by the authors. All
+ third-party contributions are ~ distributed under license by Red
+ Hat Middleware LLC. ~ ~ 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, as published by the Free Software
+ Foundation. ~ ~ This program is distributed in the hope that it
+ will be useful, ~ but WITHOUT ANY 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 ~ along with this distribution; if not,
+ write to: ~ Free Software Foundation, Inc. ~ 51 Franklin Street,
+ Fifth Floor ~ Boston, MA 02110-1301 USA
+ -->
+<hibernate-mapping
+ package="org.hibernate.test.cache.infinispan.functional">
+
+ <class name="Customer" table="Customers">
+ <id name="id">
+ <generator class="increment" />
+ </id>
+ <property name="name" not-null="true" />
+ <set name="contacts" inverse="true"
cascade="save-update">
+ <key column="cust_id" />
+ <one-to-many class="Contact" />
+ </set>
+
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Copied:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Customer.java
(from rev 17244,
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/Customer.java)
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Customer.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Customer.java 2009-08-17
07:46:18 UTC (rev 17331)
@@ -0,0 +1,67 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.infinispan.functional;
+
+import java.io.Serializable;
+import java.util.Set;
+
+/**
+ * Company customer
+ *
+ * @author Emmanuel Bernard
+ * @author Kabir Khan
+ */
+public class Customer implements Serializable {
+ Integer id;
+ String name;
+
+ private transient Set<Contact> contacts;
+
+ public Customer() {
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String string) {
+ name = string;
+ }
+
+ public Set<Contact> getContacts() {
+ return contacts;
+ }
+
+ public void setContacts(Set<Contact> contacts) {
+ this.contacts = contacts;
+ }
+}
Modified:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.hbm.xml
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.hbm.xml 2009-08-16
16:44:10 UTC (rev 17330)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.hbm.xml 2009-08-17
07:46:18 UTC (rev 17331)
@@ -3,52 +3,47 @@
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!--
- ~ Hibernate, Relational Persistence for Idiomatic Java
- ~
- ~ Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
- ~ indicated by the @author tags or express copyright attribution
- ~ statements applied by the authors. All third-party contributions are
- ~ distributed under license by Red Hat Middleware LLC.
- ~
- ~ 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, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY 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
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
-<hibernate-mapping
- package="org.hibernate.test.cache.infinispan.functional">
+ <!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java ~ ~
+ Copyright (c) 2007, Red Hat Middleware LLC or third-party
+ contributors as ~ indicated by the @author tags or express
+ copyright attribution ~ statements applied by the authors. All
+ third-party contributions are ~ distributed under license by Red
+ Hat Middleware LLC. ~ ~ 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, as published by the Free Software
+ Foundation. ~ ~ This program is distributed in the hope that it
+ will be useful, ~ but WITHOUT ANY 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 ~ along with this distribution; if not,
+ write to: ~ Free Software Foundation, Inc. ~ 51 Franklin Street,
+ Fifth Floor ~ Boston, MA 02110-1301 USA
+ -->
+<hibernate-mapping
package="org.hibernate.test.cache.infinispan.functional">
- <class name="Item" table="Items">
- <id name="id">
- <generator class="increment"/>
- </id>
- <property name="name" not-null="true"/>
- <property name="description" not-null="true"/>
- <many-to-one name="owner" column="owner_id"
class="Item" />
- <set name="items" inverse="true">
- <key column="owner_id" />
- <one-to-many class="Item"/>
- </set>
- </class>
+ <class name="Item" table="Items">
+ <id name="id">
+ <generator class="increment" />
+ </id>
+ <property name="name" not-null="true" />
+ <property name="description" not-null="true" />
+ <many-to-one name="owner" column="owner_id"
class="Item" />
+ <set name="items" inverse="true">
+ <key column="owner_id" />
+ <one-to-many class="Item" />
+ </set>
+ </class>
- <class name="VersionedItem" table="VersionedItems">
- <id name="id">
- <generator class="increment"/>
- </id>
- <version name="version" type="long"/>
- <property name="name" not-null="true"/>
- <property name="description" not-null="true"/>
- </class>
+ <class name="VersionedItem" table="VersionedItems">
+ <id name="id">
+ <generator class="increment" />
+ </id>
+ <version name="version" type="long" />
+ <property name="name" not-null="true" />
+ <property name="description" not-null="true" />
+ </class>
</hibernate-mapping>
\ No newline at end of file
Added:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java 2009-08-17
07:46:18 UTC (rev 17331)
@@ -0,0 +1,277 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.hibernate.test.cache.infinispan.functional.bulk;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.hibernate.FlushMode;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.classic.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.test.cache.infinispan.functional.Contact;
+import org.hibernate.test.cache.infinispan.functional.Customer;
+import org.hibernate.test.tm.SimpleJtaTransactionManagerImpl;
+import org.hibernate.transaction.CMTTransactionFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * BulkOperationsTestCase.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public class BulkOperationsTestCase extends FunctionalTestCase {
+
+ private static final Logger log =
LoggerFactory.getLogger(BulkOperationsTestCase.class);
+
+ public BulkOperationsTestCase(String string) {
+ super(string);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "cache/infinispan/functional/Contact.hbm.xml",
"cache/infinispan/functional/Customer.hbm.xml" };
+ }
+
+ @Override
+ public String getCacheConcurrencyStrategy() {
+ return "transactional";
+ }
+
+ protected Class getTransactionFactoryClass() {
+ return CMTTransactionFactory.class;
+ }
+
+ protected Class getConnectionProviderClass() {
+ return org.hibernate.test.tm.ConnectionProviderImpl.class;
+ }
+
+ protected Class getTransactionManagerLookupClass() {
+ return org.hibernate.test.tm.TransactionManagerLookupImpl.class;
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure(cfg);
+
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ cfg.setProperty(Environment.CONNECTION_PROVIDER,
getConnectionProviderClass().getName());
+ cfg.setProperty(Environment.TRANSACTION_MANAGER_STRATEGY,
getTransactionManagerLookupClass().getName());
+
+ Class transactionFactory = getTransactionFactoryClass();
+ cfg.setProperty( Environment.TRANSACTION_STRATEGY, transactionFactory.getName());
+ }
+
+ public void testBulkOperations() throws Exception {
+ System.out.println("*** testBulkOperations()");
+ try {
+ createContacts();
+
+ List<Integer> rhContacts = getContactsByCustomer("Red Hat");
+ assertNotNull("Red Hat contacts exist", rhContacts);
+ assertEquals("Created expected number of Red Hat contacts", 10,
rhContacts.size());
+
+ assertEquals("Deleted all Red Hat contacts", 10, deleteContacts());
+
+ List<Integer> jbContacts = getContactsByCustomer("JBoss");
+ assertNotNull("JBoss contacts exist", jbContacts);
+ assertEquals("JBoss contacts remain", 10, jbContacts.size());
+
+ for (Integer id : rhContacts) {
+ assertNull("Red Hat contact " + id + " cannot be
retrieved", getContact(id));
+ }
+ rhContacts = getContactsByCustomer("Red Hat");
+ if (rhContacts != null) {
+ assertEquals("No Red Hat contacts remain", 0, rhContacts.size());
+ }
+
+ updateContacts("Kabir", "Updated");
+ for (Integer id : jbContacts) {
+ Contact contact = getContact(id);
+ assertNotNull("JBoss contact " + id + " exists",
contact);
+ String expected = ("Kabir".equals(contact.getName())) ?
"Updated" : "2222";
+ assertEquals("JBoss contact " + id + " has correct TLF",
expected, contact.getTlf());
+ }
+
+ List<Integer> updated = getContactsByTLF("Updated");
+ assertNotNull("Got updated contacts", updated);
+ assertEquals("Updated contacts", 5, updated.size());
+ } finally {
+ // cleanup the db so we can run this test multiple times w/o restarting the
cluster
+ cleanup();
+ }
+ }
+
+ public void createContacts() throws Exception {
+ SimpleJtaTransactionManagerImpl.getInstance().begin();
+ try {
+ for (int i = 0; i < 10; i++)
+ createCustomer(i);
+ SimpleJtaTransactionManagerImpl.getInstance().commit();
+ } catch (Exception e) {
+ log.error("Unable to create customer", e);
+ SimpleJtaTransactionManagerImpl.getInstance().rollback();
+ throw e;
+ }
+ }
+
+ public int deleteContacts() throws Exception {
+ String deleteHQL = "delete Contact where customer in ";
+ deleteHQL += " (select customer FROM Customer as customer ";
+ deleteHQL += " where customer.name = :cName)";
+
+ SimpleJtaTransactionManagerImpl.getInstance().begin();
+ try {
+
+ Session session = getSessions().getCurrentSession();
+ int rowsAffected = session.createQuery(deleteHQL).setFlushMode(FlushMode.AUTO)
+ .setParameter("cName", "Red Hat").executeUpdate();
+ SimpleJtaTransactionManagerImpl.getInstance().commit();
+ return rowsAffected;
+ } catch (Exception e) {
+ SimpleJtaTransactionManagerImpl.getInstance().rollback();
+ throw e;
+ }
+ }
+
+ public List<Integer> getContactsByCustomer(String customerName) throws Exception
{
+ String selectHQL = "select contact.id from Contact contact";
+ selectHQL += " where contact.customer.name = :cName";
+
+ SimpleJtaTransactionManagerImpl.getInstance().begin();
+ try {
+
+ Session session = getSessions().getCurrentSession();
+ List results =
session.createQuery(selectHQL).setFlushMode(FlushMode.AUTO).setParameter("cName",
customerName)
+ .list();
+ SimpleJtaTransactionManagerImpl.getInstance().commit();
+ return results;
+ } catch (Exception e) {
+ SimpleJtaTransactionManagerImpl.getInstance().rollback();
+ throw e;
+ }
+ }
+
+ public List<Integer> getContactsByTLF(String tlf) throws Exception {
+ String selectHQL = "select contact.id from Contact contact";
+ selectHQL += " where contact.tlf = :cTLF";
+
+ SimpleJtaTransactionManagerImpl.getInstance().begin();
+ try {
+
+ Session session = getSessions().getCurrentSession();
+ List results =
session.createQuery(selectHQL).setFlushMode(FlushMode.AUTO).setParameter("cTLF",
tlf).list();
+ SimpleJtaTransactionManagerImpl.getInstance().commit();
+ return results;
+ } catch (Exception e) {
+ SimpleJtaTransactionManagerImpl.getInstance().rollback();
+ throw e;
+ }
+ }
+
+ public int updateContacts(String name, String newTLF) throws Exception {
+ String updateHQL = "update Contact set tlf = :cNewTLF where name =
:cName";
+
+ SimpleJtaTransactionManagerImpl.getInstance().begin();
+ try {
+
+ Session session = getSessions().getCurrentSession();
+ int rowsAffected =
session.createQuery(updateHQL).setFlushMode(FlushMode.AUTO).setParameter("cNewTLF",
newTLF)
+ .setParameter("cName", name).executeUpdate();
+ SimpleJtaTransactionManagerImpl.getInstance().commit();
+ return rowsAffected;
+ } catch (Exception e) {
+ SimpleJtaTransactionManagerImpl.getInstance().rollback();
+ throw e;
+ }
+ }
+
+ public Contact getContact(Integer id) throws Exception {
+
+ SimpleJtaTransactionManagerImpl.getInstance().begin();
+ try {
+
+ Session session = getSessions().getCurrentSession();
+ Contact contact = (Contact) session.get(Contact.class, id);
+ SimpleJtaTransactionManagerImpl.getInstance().commit();
+ return contact;
+ } catch (Exception e) {
+ SimpleJtaTransactionManagerImpl.getInstance().rollback();
+ throw e;
+ }
+ }
+
+ public void cleanup() throws Exception {
+ String deleteContactHQL = "delete from Contact";
+ String deleteCustomerHQL = "delete from Customer";
+
+ SimpleJtaTransactionManagerImpl.getInstance().begin();
+ try {
+
+ Session session = getSessions().getCurrentSession();
+
session.createQuery(deleteContactHQL).setFlushMode(FlushMode.AUTO).executeUpdate();
+
session.createQuery(deleteCustomerHQL).setFlushMode(FlushMode.AUTO).executeUpdate();
+ SimpleJtaTransactionManagerImpl.getInstance().commit();
+ } catch (Exception e) {
+ SimpleJtaTransactionManagerImpl.getInstance().rollback();
+ throw e;
+ }
+
+ }
+
+ private Customer createCustomer(int id) throws Exception {
+ System.out.println("CREATE CUSTOMER " + id);
+ try {
+ Customer customer = new Customer();
+ customer.setName((id % 2 == 0) ? "JBoss" : "Red Hat");
+ Set<Contact> contacts = new HashSet<Contact>();
+
+ Contact kabir = new Contact();
+ kabir.setCustomer(customer);
+ kabir.setName("Kabir");
+ kabir.setTlf("1111");
+ contacts.add(kabir);
+
+ Contact bill = new Contact();
+ bill.setCustomer(customer);
+ bill.setName("Bill");
+ bill.setTlf("2222");
+ contacts.add(bill);
+
+ customer.setContacts(contacts);
+
+ Session s = openSession();
+ s.getTransaction().begin();
+ s.persist(customer);
+ s.getTransaction().commit();
+ s.close();
+
+ return customer;
+ } finally {
+ System.out.println("CREATE CUSTOMER " + id + " - END");
+ }
+ }
+
+}
Modified:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/AbstractDualNodeTestCase.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/AbstractDualNodeTestCase.java 2009-08-16
16:44:10 UTC (rev 17330)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/AbstractDualNodeTestCase.java 2009-08-17
07:46:18 UTC (rev 17331)
@@ -39,6 +39,7 @@
* @author Galder Zamarreño
*/
public class AbstractDualNodeTestCase extends FunctionalTestCase {
+
private static final Logger log =
LoggerFactory.getLogger(AbstractDualNodeTestCase.class);
public static final String NODE_ID_PROP = "hibernate.test.cluster.node.id";
public static final String LOCAL = "local";
@@ -51,7 +52,7 @@
}
public String[] getMappings() {
- return new String[] {
"cache/infinispan/functional/cluster/Contact.hbm.xml" };
+ return new String[] { "cache/infinispan/functional/Contact.hbm.xml",
"cache/infinispan/functional/Customer.hbm.xml" };
}
@Override
Deleted:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/Contact.hbm.xml
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/Contact.hbm.xml 2009-08-16
16:44:10 UTC (rev 17330)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/Contact.hbm.xml 2009-08-17
07:46:18 UTC (rev 17331)
@@ -1,53 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<!--
- ~ Hibernate, Relational Persistence for Idiomatic Java
- ~
- ~ Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
- ~ indicated by the @author tags or express copyright attribution
- ~ statements applied by the authors. All third-party contributions are
- ~ distributed under license by Red Hat Middleware LLC.
- ~
- ~ 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, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY 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
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
-<hibernate-mapping
- package="org.hibernate.test.cache.infinispan.functional.cluster">
-
- <class name="Contact" table="Contacts">
- <id name="id">
- <generator class="increment"/>
- </id>
- <property name="name" not-null="true"/>
- <property name="tlf" not-null="true"/>
- <many-to-one name="customer" column="cust_id"
class="Customer" />
- </class>
-
- <class name="Customer" table="Customers">
- <id name="id">
- <generator class="increment"/>
- </id>
- <property name="name" not-null="true"/>
- <set name="contacts" inverse="true" cascade =
"save-update">
- <key column="cust_id" />
- <one-to-many class="Contact"/>
- </set>
-
- </class>
-
-</hibernate-mapping>
\ No newline at end of file
Deleted:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/Contact.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/Contact.java 2009-08-16
16:44:10 UTC (rev 17330)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/Contact.java 2009-08-17
07:46:18 UTC (rev 17331)
@@ -1,90 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * 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, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.test.cache.infinispan.functional.cluster;
-
-import java.io.Serializable;
-
-/**
- * Entity that has a many-to-one relationship to a Customer
- */
-public class Contact implements Serializable {
- Integer id;
- String name;
- String tlf;
- Customer customer;
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getTlf() {
- return tlf;
- }
-
- public void setTlf(String tlf) {
- this.tlf = tlf;
- }
-
- public Customer getCustomer() {
- return customer;
- }
-
- public void setCustomer(Customer customer) {
- this.customer = customer;
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) return true;
- if (!(o instanceof Contact)) return false;
- Contact c = (Contact) o;
- return c.id.equals(id)
- && c.name.equals(name)
- && c.tlf.equals(tlf);
- }
-
- @Override
- public int hashCode() {
- int result = 17;
- result = 31 * result + (id == null ? 0 : id.hashCode());
- result = 31 * result + name.hashCode();
- result = 31 * result + tlf.hashCode();
- return result;
- }
-
-
-
-}
Deleted:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/Customer.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/Customer.java 2009-08-16
16:44:10 UTC (rev 17330)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/Customer.java 2009-08-17
07:46:18 UTC (rev 17331)
@@ -1,67 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * 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, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.test.cache.infinispan.functional.cluster;
-
-import java.io.Serializable;
-import java.util.Set;
-
-/**
- * Company customer
- *
- * @author Emmanuel Bernard
- * @author Kabir Khan
- */
-public class Customer implements Serializable {
- Integer id;
- String name;
-
- private transient Set<Contact> contacts;
-
- public Customer() {
- }
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String string) {
- name = string;
- }
-
- public Set<Contact> getContacts() {
- return contacts;
- }
-
- public void setContacts(Set<Contact> contacts) {
- this.contacts = contacts;
- }
-}
Modified:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/EntityCollectionInvalidationTestCase.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/EntityCollectionInvalidationTestCase.java 2009-08-16
16:44:10 UTC (rev 17330)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/EntityCollectionInvalidationTestCase.java 2009-08-17
07:46:18 UTC (rev 17331)
@@ -30,6 +30,8 @@
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cache.CacheKey;
+import org.hibernate.test.cache.infinispan.functional.Contact;
+import org.hibernate.test.cache.infinispan.functional.Customer;
import org.infinispan.Cache;
import org.infinispan.manager.CacheManager;
import org.infinispan.marshall.MarshalledValue;
@@ -244,7 +246,7 @@
Set<Contact> contacts = customer.getContacts();
for (Contact c : contacts) {
- if (c.name.equals("Kabir")) {
+ if (c.getName().equals("Kabir")) {
contacts.remove(c);
} else {
contactIds.add(c.getId());