Hibernate SVN: r14167 - entitymanager/tags.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-10-31 16:49:52 -0400 (Wed, 31 Oct 2007)
New Revision: 14167
Added:
entitymanager/tags/v3_3_2_Beta1/
Log:
update HEM 3.3.2.Beta1
Copied: entitymanager/tags/v3_3_2_Beta1 (from rev 14166, entitymanager/trunk)
17 years, 2 months
Hibernate SVN: r14166 - entitymanager/tags.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-10-31 16:49:12 -0400 (Wed, 31 Oct 2007)
New Revision: 14166
Removed:
entitymanager/tags/v3_3_2_Beta1/
Log:
update HEM 3.3.2.Beta1
17 years, 2 months
Hibernate SVN: r14165 - annotations/tags.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-10-31 16:48:32 -0400 (Wed, 31 Oct 2007)
New Revision: 14165
Added:
annotations/tags/v3_3_1_Beta1/
Log:
update HAN 3.3.1.Beta1
Copied: annotations/tags/v3_3_1_Beta1 (from rev 14164, annotations/trunk)
17 years, 2 months
Hibernate SVN: r14164 - annotations/tags.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-10-31 16:48:01 -0400 (Wed, 31 Oct 2007)
New Revision: 14164
Removed:
annotations/tags/v3_3_1_Beta1/
Log:
update HAN 3.3.1.Beta1
17 years, 2 months
Hibernate SVN: r14163 - entitymanager/trunk.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-10-31 16:18:01 -0400 (Wed, 31 Oct 2007)
New Revision: 14163
Modified:
entitymanager/trunk/changelog.txt
entitymanager/trunk/readme.txt
Log:
release
Modified: entitymanager/trunk/changelog.txt
===================================================================
--- entitymanager/trunk/changelog.txt 2007-10-31 19:17:27 UTC (rev 14162)
+++ entitymanager/trunk/changelog.txt 2007-10-31 20:18:01 UTC (rev 14163)
@@ -1,6 +1,25 @@
Hibernate EntityManager Changelog
==================================
+3.3.2.Beta1 (31-10-2007)
+------------------------
+
+** Bug
+ * [EJB-284] - Scanning for META-INF/orm.xml does not work on Windows in EE mode
+ * [EJB-308] - Space in path result in error during deployment in JBoss AS
+ * [EJB-310] - Typo in warn message when the container lacks temporary classloader support
+ * [EJB-321] - TCK enforces PERSISTENCE_PROVIDER value including the typo
+
+
+** Improvement
+ * [EJB-316] - java.persistence.Persistence#PERSISTENCE_PROVIDER should be a final String
+
+
+
+** Task
+ * [EJB-302] - Move away from ArchiveBrowser and use JarVisitor
+
+
3.3.1.GA (28-03-2007)
---------------------
Modified: entitymanager/trunk/readme.txt
===================================================================
--- entitymanager/trunk/readme.txt 2007-10-31 19:17:27 UTC (rev 14162)
+++ entitymanager/trunk/readme.txt 2007-10-31 20:18:01 UTC (rev 14163)
@@ -1,6 +1,6 @@
Hibernate EntityManager
==================================================
-Version: 3.3.1.GA, 28.03.2007
+Version: 3.3.2.Beta1, 31.10.2007
THIS RELEASE OF HIBERNATE ENTITYMANAGER REQUIRES HIBERNATE CORE 3.2.0.GA (and above)
17 years, 2 months
Hibernate SVN: r14162 - annotations/trunk.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-10-31 15:17:27 -0400 (Wed, 31 Oct 2007)
New Revision: 14162
Modified:
annotations/trunk/readme.txt
Log:
release
Modified: annotations/trunk/readme.txt
===================================================================
--- annotations/trunk/readme.txt 2007-10-31 19:12:02 UTC (rev 14161)
+++ annotations/trunk/readme.txt 2007-10-31 19:17:27 UTC (rev 14162)
@@ -1,6 +1,6 @@
Hibernate Annotations
==================================================
-Version: 3.3.0.GA, 19.03.2007
+Version: 3.3.1.Beta1, 31.10.2007
THIS RELEASE OF HIBERNATE ANNOTATIONS REQUIRES HIBERNATE CORE 3.2.0.GA (and above)
17 years, 2 months
Hibernate SVN: r14161 - annotations/trunk.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-10-31 15:12:02 -0400 (Wed, 31 Oct 2007)
New Revision: 14161
Modified:
annotations/trunk/changelog.txt
Log:
release
Modified: annotations/trunk/changelog.txt
===================================================================
--- annotations/trunk/changelog.txt 2007-10-31 00:14:49 UTC (rev 14160)
+++ annotations/trunk/changelog.txt 2007-10-31 19:12:02 UTC (rev 14161)
@@ -1,6 +1,49 @@
Hibernate Annotations Changelog
===============================
+3.3.1.Beta1 (31-10-2007)
+------------------------
+
+** Bug
+ * [ANN-434] - Confusing error message with @EmbeddedId and @Id
+ * [ANN-602] - SecondaryTable with EmbeddedId or IdClass containing @ManyToOne fail
+ * [ANN-608] - NullPointerException from AnnotationConfiguration with specific order of calling addResource and addPackage when package-info.java present
+ * [ANN-613] - NPE when mappedBy property is wrong on a @OneToOne
+ * [ANN-616] - Mistakes in 2.4.6.2.3 of Manual
+ * [ANN-617] - NullPointerException when handling @OrderBy
+ * [ANN-618] - @AccessType("propery") cannot be overriden by @AccessType("field")
+ * [ANN-619] - @OneToOne in primary key fails
+ * [ANN-621] - Unable to handle JOINED stragegy when the root entity id contains a @ManyToOne
+ * [ANN-631] - Mistake in "2.2.5.2. Many-to-one"
+ * [ANN-634] - @CollectionOfElements cannot be combined with @Filter (or @Where) and EAGER fetching
+ * [ANN-637] - @o.h.a.Table.indexes returns obscur message when the table does not exist
+ * [ANN-643] - Missing .configure() on session factory creation examples
+ * [ANN-647] - @Where JavaDoc does not specify that it describes a SQL fragment
+ * [ANN-648] - o.h.a.Table.comment and o.h.a.Table.indexes fail on secondary tables
+
+
+** Improvement
+ * [ANN-605] - docs say @Enumerated(STRING), should be @Enumerated(EnumType.STRING)
+ * [ANN-606] - @Immutable does not throw error or warning on usage on subclass
+ * [ANN-633] - JAR file should contain vendor- and versioning information
+ * [ANN-671] - Log "Validator not present" only once
+
+** New Feature
+ * [ANN-28] - @Any
+ * [ANN-122] - Add @NaturalId annotation (Nicol�s Lichtmaier)
+
+** Patch
+ * [ANN-575] - Mistakes in "2.2.5.1. One-to-one"
+ * [ANN-576] - Mistake in "2.2.5.2. Many-to-one"
+ * [ANN-577] - Improvement in "2.2.5.3.2.3. Unidirectional with join table"
+ * [ANN-578] - Improvement in "2.2.5.3.3.1. Definition"
+ * [ANN-579] - Mistake in "2.2.5.3.3.1. Definition"
+ * [ANN-580] - Mistake in "2.2.2.3. Embedded objects (aka components)"
+ * [ANN-581] - Improvement in "2.4.8. Filters"
+ * [ANN-588] - ProxyBreakingTest fails on case sensitive file systems
+ * [ANN-595] - Remove FlushModeType.NEVER
+
+
3.3.0.GA (19-03-2007)
---------------------
17 years, 2 months
Hibernate SVN: r14160 - core/trunk/testsuite/src/test/java/org/hibernate/test/discriminator.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2007-10-30 20:14:49 -0400 (Tue, 30 Oct 2007)
New Revision: 14160
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/discriminator/DiscriminatorTest.java
Log:
HHH-2921 : added test cases that execute polymorphic queries when there is a superclass proxy for the resulting entity in the session cache
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/discriminator/DiscriminatorTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/discriminator/DiscriminatorTest.java 2007-10-31 00:13:38 UTC (rev 14159)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/discriminator/DiscriminatorTest.java 2007-10-31 00:14:49 UTC (rev 14160)
@@ -1,4 +1,4 @@
-//$Id: DiscriminatorTest.java 10977 2006-12-12 23:28:04Z steve.ebersole(a)jboss.com $
+//$Id: DiscriminatorTest.java 10976 2006-12-12 23:22:26Z steve.ebersole(a)jboss.com $
package org.hibernate.test.discriminator;
import java.math.BigDecimal;
@@ -10,7 +10,9 @@
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.proxy.HibernateProxy;
import org.hibernate.criterion.Property;
+import org.hibernate.criterion.Restrictions;
import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
@@ -171,6 +173,82 @@
s.close();
}
+ public void testLoadSuperclassProxyPolymorphicAccess() {
+ Session s = openSession();
+ s.beginTransaction();
+ Employee e = new Employee();
+ e.setName( "Steve" );
+ e.setSex( 'M' );
+ e.setTitle( "grand poobah" );
+ s.save( e );
+ s.getTransaction().commit();
+ s.close();
+ s = openSession();
+ s.beginTransaction();
+ // load the superclass proxy.
+ Person pLoad = ( Person ) s.load( Person.class, new Long( e.getId() ) );
+ assertTrue( pLoad instanceof HibernateProxy);
+ Person pGet = ( Person ) s.get( Person.class, new Long( e.getId() ));
+ Person pQuery = ( Person ) s.createQuery( "from Person where id = :id" )
+ .setLong( "id", e.getId() )
+ .uniqueResult();
+ Person pCriteria = ( Person ) s.createCriteria( Person.class )
+ .add( Restrictions.idEq( new Long( e.getId() ) ) )
+ .uniqueResult();
+ // assert that executing the queries polymorphically returns the same proxy
+ assertSame( pLoad, pGet );
+ assertSame( pLoad, pQuery );
+ assertSame( pLoad, pCriteria );
+
+ // assert that the proxy is not an instance of Employee
+ assertFalse( pLoad instanceof Employee );
+
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ s.delete( e );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testLoadSuperclassProxyEvictPolymorphicAccess() {
+ Session s = openSession();
+ s.beginTransaction();
+ Employee e = new Employee();
+ e.setName( "Steve" );
+ e.setSex( 'M' );
+ e.setTitle( "grand poobah" );
+ s.save( e );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ // load the superclass proxy.
+ Person pLoad = ( Person ) s.load( Person.class, new Long( e.getId() ) );
+ assertTrue( pLoad instanceof HibernateProxy);
+ // evict the proxy
+ s.evict( pLoad );
+ Employee pGet = ( Employee ) s.get( Person.class, new Long( e.getId() ));
+ Employee pQuery = ( Employee ) s.createQuery( "from Person where id = :id" )
+ .setLong( "id", e.getId() )
+ .uniqueResult();
+ Employee pCriteria = ( Employee ) s.createCriteria( Person.class )
+ .add( Restrictions.idEq( new Long( e.getId() ) ) )
+ .uniqueResult();
+ // assert that executing the queries polymorphically returns the same Employee instance
+ assertSame( pGet, pQuery );
+ assertSame( pGet, pCriteria );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ s.delete( e );
+ s.getTransaction().commit();
+ s.close();
+ }
}
-
17 years, 2 months
Hibernate SVN: r14159 - core/branches/Branch_3_2/test/org/hibernate/test/discriminator.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2007-10-30 20:13:38 -0400 (Tue, 30 Oct 2007)
New Revision: 14159
Modified:
core/branches/Branch_3_2/test/org/hibernate/test/discriminator/DiscriminatorTest.java
Log:
HHH-2921 : added test cases that execute polymorphic queries when there is a superclass proxy for the resulting entity in the session cache
Modified: core/branches/Branch_3_2/test/org/hibernate/test/discriminator/DiscriminatorTest.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/discriminator/DiscriminatorTest.java 2007-10-29 23:27:09 UTC (rev 14158)
+++ core/branches/Branch_3_2/test/org/hibernate/test/discriminator/DiscriminatorTest.java 2007-10-31 00:13:38 UTC (rev 14159)
@@ -10,7 +10,9 @@
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.proxy.HibernateProxy;
import org.hibernate.criterion.Property;
+import org.hibernate.criterion.Restrictions;
import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
@@ -171,6 +173,82 @@
s.close();
}
+ public void testLoadSuperclassProxyPolymorphicAccess() {
+ Session s = openSession();
+ s.beginTransaction();
+ Employee e = new Employee();
+ e.setName( "Steve" );
+ e.setSex( 'M' );
+ e.setTitle( "grand poobah" );
+ s.save( e );
+ s.getTransaction().commit();
+ s.close();
+ s = openSession();
+ s.beginTransaction();
+ // load the superclass proxy.
+ Person pLoad = ( Person ) s.load( Person.class, new Long( e.getId() ) );
+ assertTrue( pLoad instanceof HibernateProxy);
+ Person pGet = ( Person ) s.get( Person.class, new Long( e.getId() ));
+ Person pQuery = ( Person ) s.createQuery( "from Person where id = :id" )
+ .setLong( "id", e.getId() )
+ .uniqueResult();
+ Person pCriteria = ( Person ) s.createCriteria( Person.class )
+ .add( Restrictions.idEq( new Long( e.getId() ) ) )
+ .uniqueResult();
+ // assert that executing the queries polymorphically returns the same proxy
+ assertSame( pLoad, pGet );
+ assertSame( pLoad, pQuery );
+ assertSame( pLoad, pCriteria );
+
+ // assert that the proxy is not an instance of Employee
+ assertFalse( pLoad instanceof Employee );
+
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ s.delete( e );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testLoadSuperclassProxyEvictPolymorphicAccess() {
+ Session s = openSession();
+ s.beginTransaction();
+ Employee e = new Employee();
+ e.setName( "Steve" );
+ e.setSex( 'M' );
+ e.setTitle( "grand poobah" );
+ s.save( e );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ // load the superclass proxy.
+ Person pLoad = ( Person ) s.load( Person.class, new Long( e.getId() ) );
+ assertTrue( pLoad instanceof HibernateProxy);
+ // evict the proxy
+ s.evict( pLoad );
+ Employee pGet = ( Employee ) s.get( Person.class, new Long( e.getId() ));
+ Employee pQuery = ( Employee ) s.createQuery( "from Person where id = :id" )
+ .setLong( "id", e.getId() )
+ .uniqueResult();
+ Employee pCriteria = ( Employee ) s.createCriteria( Person.class )
+ .add( Restrictions.idEq( new Long( e.getId() ) ) )
+ .uniqueResult();
+ // assert that executing the queries polymorphically returns the same Employee instance
+ assertSame( pGet, pQuery );
+ assertSame( pGet, pCriteria );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ s.delete( e );
+ s.getTransaction().commit();
+ s.close();
+ }
}
-
17 years, 2 months
Hibernate SVN: r14158 - in search/trunk/src/test/org/hibernate/search/test/embedded: doubleinsert and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-10-29 19:27:09 -0400 (Mon, 29 Oct 2007)
New Revision: 14158
Added:
search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/
search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/Address.java
search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/BusinessContact.java
search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/Contact.java
search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/DoubleInsertEmbeddedTest.java
search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/PersonalContact.java
search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/Phone.java
Log:
HSEARCH-124 Test for the double insert issue (not reproduced)
Added: search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/Address.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/Address.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/Address.java 2007-10-29 23:27:09 UTC (rev 14158)
@@ -0,0 +1,250 @@
+package org.hibernate.search.test.embedded.doubleinsert;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Type;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.search.annotations.Store;
+
+@Entity
+@Indexed
+@Table(name="T_ADDRESS")
+public class Address implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+
+ @Id @GeneratedValue(strategy=GenerationType.AUTO)
+ @Column(name="A_ADDRESS_ID")
+ @DocumentId
+ private long id;
+
+ @Column(name="A_ADDRESS1")
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ private String address1;
+
+ @Column(name="A_ADDRESS2")
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ private String address2;
+
+ @Column(name="A_TOWN")
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ private String town;
+
+ @Column(name="A_COUNTY")
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ private String county;
+
+ @Column(name="A_COUNTRY")
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ private String country;
+
+ @Column(name="A_POSTCODE")
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ private String postcode;
+
+ @Column(name="A_ACTIVE")
+ @Type(type="boolean")
+ private boolean active;
+
+ @Column(name="A_CREATEDON")
+ @Type(type="java.util.Date")
+ private Date createdOn;
+
+ @Column(name="A_LASTUPDATEDON")
+ @Type(type="java.util.Date")
+ private Date lastUpdatedOn;
+
+ @ManyToOne
+ @JoinColumn(name="C_CONTACT_ID")
+ @IndexedEmbedded
+ private Contact contact;
+
+ public Address(String address1, String address2, String town,
+ String county, String country, String postcode, boolean active, Contact contact) {
+ super();
+ this.address1 = address1;
+ this.address2 = address2;
+ this.town = town;
+ this.county = county;
+ this.country = country;
+ this.postcode = postcode;
+ this.active = active;
+ this.contact = contact;
+ }
+
+ public Address() {
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getAddress1() {
+ return address1;
+ }
+
+ public void setAddress1(String address1) {
+ this.address1 = address1;
+ }
+
+ public String getAddress2() {
+ if (null == this.address2 || "".equals(this.address2)) {
+ return "N/A";
+ }
+ return address2;
+ }
+
+ public void setAddress2(String address2) {
+ this.address2 = address2;
+ }
+
+ public String getTown() {
+ return town;
+ }
+
+ public void setTown(String town) {
+ this.town = town;
+ }
+
+ public String getCounty() {
+ if (null == this.county || "".equals(this.county)) {
+ return "N/A";
+ }
+ return county;
+ }
+
+ public void setCounty(String county) {
+ this.county = county;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+
+ public String getPostcode() {
+ return postcode;
+ }
+
+ public void setPostcode(String postcode) {
+ this.postcode = postcode;
+ }
+
+ public boolean isActive() {
+ return active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+
+ public Date getCreatedOn() {
+ return createdOn;
+ }
+
+ public void setCreatedOn(Date createdOn) {
+ this.createdOn = createdOn;
+ }
+
+ public Date getLastUpdatedOn() {
+ return lastUpdatedOn;
+ }
+
+ public void setLastUpdatedOn(Date lastUpdatedOn) {
+ this.lastUpdatedOn = lastUpdatedOn;
+ }
+
+
+
+ public Contact getContact() {
+ return contact;
+ }
+
+ public void setContact(Contact contact) {
+ this.contact = contact;
+ }
+
+ public boolean equals(Object object) {
+ if (!(object instanceof Address)) {
+ return false;
+ }
+ Address that = (Address)object;
+ if ( ! equals(this.getAddress1(), that.getAddress1() ) ) return false;
+ if ( ! equals(this.getAddress2(), that.getAddress2() ) ) return false;
+ if ( ! equals(this.getCounty(), that.getCounty() ) ) return false;
+ if ( ! equals(this.getTown(), that.getTown() ) ) return false;
+ if ( ! equals(this.getPostcode(), that.getPostcode() ) ) return false;
+ if ( ! equals(this.getContact(), that.getContact() ) ) return false;
+ return true;
+// EqualsBuilder equalsBuilder = new EqualsBuilder();
+// return equalsBuilder.append(new Object[]{this.getAddress1(), this.getAddress2(), this.getCounty(), this.getTown(), this.getPostcode(), this.contact}, new Object[]{address.getAddress1(), address.getAddress2(), address.getCounty(), address.getTown(), address.getPostcode(), address.getContact()}).isEquals();
+ }
+
+ private boolean equals(Object o1, Object o2) {
+ if ( o1 == o2 ) return true;
+ if ( o1 == null || o2 == null ) return false;
+ return o1.equals( o1.equals( o2 ) );
+ }
+
+ private int hashCode(Object o) {
+ return o == null ? 0 : o.hashCode();
+ }
+
+
+ public int hashCode() {
+ int a = 13;
+ a = a*23 + hashCode( this.getAddress1());
+ a = a*23 + hashCode( this.getAddress2());
+ a = a*23 + hashCode( this.getCounty());
+ a = a*23 + hashCode( this.getTown());
+ a = a*23 + hashCode( this.getPostcode());
+ a = a*23 + hashCode( this.getContact());
+ return a;
+// return new HashCodeBuilder().append(new Object[]{this.getAddress1(), this.getAddress2(), this.getCounty(), this.getTown(), this.getPostcode(), this.getContact()}).hashCode();
+ }
+
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ displayAddress(buf, this);
+ return buf.toString();
+ }
+ private void displayAddress(StringBuffer buf, Address address) {
+// buf.append(Constants.TAB + Constants.TAB + "Address 1: " + address.getAddress1() + Constants.NEW_LINE);
+// buf.append(Constants.TAB + Constants.TAB +"Address 2: " + address.getAddress2() + Constants.NEW_LINE);
+// buf.append(Constants.TAB + Constants.TAB +"Town: " + address.getTown() + Constants.NEW_LINE);
+// buf.append(Constants.TAB + Constants.TAB +"County: " + address.getCounty() + Constants.NEW_LINE);
+// buf.append(Constants.TAB + Constants.TAB +"Postcode: " + address.getPostcode() + Constants.NEW_LINE);
+// buf.append(Constants.TAB + Constants.TAB +"Country: " + address.getCountry() + Constants.NEW_LINE);
+// buf.append(Constants.TAB + Constants.TAB +"Is current: " + (address.isActive()? "Yes" : "No") + Constants.NEW_LINE);
+// buf.append(Constants.NEW_LINE);
+ }
+
+ public boolean isValidPostcode() {
+
+ return false;
+ }
+
+}
Added: search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/BusinessContact.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/BusinessContact.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/BusinessContact.java 2007-10-29 23:27:09 UTC (rev 14158)
@@ -0,0 +1,70 @@
+package org.hibernate.search.test.embedded.doubleinsert;
+
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+
+@Entity
+@DiscriminatorValue("BusinessContact")
+@Indexed
+public class BusinessContact extends Contact {
+
+ @Column(name="P_BUSINESSNAME")
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ private String businessName;
+
+ @Column(name="P_BUSINESSURL")
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ private String url;
+
+ public BusinessContact() {
+ }
+
+ public String getBusinessName() {
+ return businessName;
+ }
+
+ public void setBusinessName(String businessName) {
+ this.businessName = businessName;
+ }
+
+ public String getUrl() {
+ if (null == this.url || "".equals(this.url)) {
+ return "Not provided";
+ }
+ return url;
+ }
+
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+// public boolean equals(Object object) {
+// if (!(object instanceof BusinessContact)) {
+// return false;
+// }
+// BusinessContact businessContact = (BusinessContact)object;
+// return new EqualsBuilder().append(new Object[]{this.getId(), this.getBusinessName(), this.getUrl()}, new Object[]{businessContact.getId(), businessContact.getBusinessName(), businessContact.getUrl()}).isEquals();
+// }
+//
+// public int hashCode() {
+// return new HashCodeBuilder().append(new Object[]{new Long(this.getId()), this.getBusinessName(), this.getUrl()}).toHashCode();
+// }
+// public String toString() {
+// StringBuffer buf = new StringBuffer();
+// buf.append("Business Name: " + this.getBusinessName() + Constants.NEW_LINE);
+// buf.append("Business Url: " + this.getUrl() + Constants.NEW_LINE);
+// buf.append("Email: " + this.getEmail() + Constants.NEW_LINE);
+// super.displayPhonesAndAddresses(buf);
+// return buf.toString();
+// }
+
+
+
+}
Added: search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/Contact.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/Contact.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/Contact.java 2007-10-29 23:27:09 UTC (rev 14158)
@@ -0,0 +1,221 @@
+package org.hibernate.search.test.embedded.doubleinsert;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.Predicate;
+import org.apache.log4j.Logger;
+import org.hibernate.annotations.Type;
+import org.hibernate.search.annotations.ContainedIn;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+
+@Entity
+@Table(name="T_CONTACT")
+(a)Inheritance(strategy=InheritanceType.SINGLE_TABLE)
+@DiscriminatorValue("Contact")
+@DiscriminatorColumn(name="contactType",discriminatorType=javax.persistence.DiscriminatorType.STRING)
+@Indexed
+public class Contact implements Serializable {
+
+ private static Logger logger = Logger.getLogger(Contact.class);
+
+ private static final long serialVersionUID = 1L;
+
+ @Id @GeneratedValue(strategy=GenerationType.AUTO)
+ @Column(name="C_CONTACT_ID")
+ @DocumentId
+ private long id;
+
+ @Column(name="C_EMAIL")
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ private String email;
+
+ @Column(name="C_CREATEDON")
+ @Type(type="java.util.Date")
+ private Date createdOn;
+
+ @Column(name="C_LASTUPDATEDON")
+ @Type(type="java.util.Date")
+ private Date lastUpdatedOn;
+
+ @ContainedIn
+ @OneToMany( cascade = { CascadeType.ALL}, fetch=FetchType.EAGER)
+ @Type(type="java.util.Set")
+ private Set<Address> addresses;
+
+ @ContainedIn
+ @OneToMany(cascade = { CascadeType.ALL}, fetch=FetchType.EAGER)
+ @Type(type="java.util.Set")
+ private Set<Phone> phoneNumbers;
+
+ @Column(name="C_NOTES")
+ private String notes;
+
+ public Contact() {
+ }
+
+ public long getId() {
+ return id;
+ }
+ public void setId(long id) {
+ this.id = id;
+ }
+ public String getEmail() {
+ if (null == this.email || "".equals(this.email)) {
+ return "N/A";
+ }
+ return email;
+ }
+ public void setEmail(String email) {
+ this.email = email;
+ }
+ public Date getCreatedOn() {
+ return createdOn;
+ }
+ public void setCreatedOn(Date createdOn) {
+ this.createdOn = createdOn;
+ }
+ public Date getLastUpdatedOn() {
+ return lastUpdatedOn;
+ }
+ public void setLastUpdatedOn(Date lastUpdatedOn) {
+ this.lastUpdatedOn = lastUpdatedOn;
+ }
+ public Set<Address> getAddresses() {
+ return addresses;
+ }
+ public void setAddresses(Set<Address> addresses) {
+ this.addresses = addresses;
+ }
+ public Set<Phone> getPhoneNumbers() {
+ return phoneNumbers;
+ }
+ public void setPhoneNumbers(Set<Phone> phoneNumbers) {
+ this.phoneNumbers = phoneNumbers;
+ }
+
+
+ public String getNotes() {
+ return notes;
+ }
+
+ public void setNotes(String notes) {
+ this.notes = notes;
+ }
+
+ public void addAddressToContact(Address address) {
+ if (address == null) {
+ throw new IllegalArgumentException("Address cannot be null");
+ }
+ if (addresses == null) {
+ addresses = new HashSet<Address>();
+ }
+ address.setContact(this);
+ addresses.add(address);
+ }
+
+
+ public void addPhoneToContact(Phone phone) {
+ if (phone == null) {
+ throw new IllegalArgumentException("Phone cannot be null");
+ }
+ if (phoneNumbers == null) {
+ phoneNumbers = new HashSet<Phone>();
+ }
+ phone.setContact(this);
+ phoneNumbers.add(phone);
+ }
+
+
+ public void removePhoneFromContact(Phone phone) {
+ if (phone == null) {
+ throw new IllegalArgumentException("Phone cannot be null");
+ }
+ if (this.phoneNumbers.contains(phone)) {
+ this.phoneNumbers.remove(phone);
+ }
+ }
+
+ public void removeAddressFromContact(Address address) {
+ if (address == null) {
+ throw new IllegalArgumentException("Address cannot be null");
+ }
+ if (this.addresses.contains(address)) {
+ this.addresses.remove(address);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected List<Phone> filterPhoneNumbersByType(final String phoneType) {
+// Assert.notNull(phoneType, "Phone type cannot be null");
+// Assert.hasText(phoneType, "Phone type cannot be empty");
+ return (List<Phone>)CollectionUtils.select(this.phoneNumbers, new Predicate() {
+ public boolean evaluate(Object object) {
+ Phone phone = (Phone)object;
+ return phoneType.equals(phone.getType());
+ }
+ });
+ }
+
+
+ @SuppressWarnings("unchecked")
+ protected List<Address> showActiveAddresses() {
+ return (List<Address>) CollectionUtils.select(this.addresses,new Predicate() {
+ public boolean evaluate(Object object) {
+ Address address = (Address)object;
+ return address.isActive();
+ }
+ });
+ }
+
+ @SuppressWarnings("unchecked")
+ protected List<Address> showInactiveAddresses() {
+ return (List<Address>) CollectionUtils.select(this.addresses, new Predicate() {
+ public boolean evaluate(Object object) {
+ Address address = (Address)object;
+ return !address.isActive();
+ }
+ });
+ }
+
+ protected void displayPhonesAndAddresses(StringBuffer buf) {
+// buf.append(Constants.NEW_LINE);
+// buf.append("Phone Detail(s):" + Constants.NEW_LINE);
+// if (null != this.getPhoneNumbers() && 0 != this.getPhoneNumbers().size()) {
+// for (Phone phone: this.getPhoneNumbers()) {
+// buf.append(phone);
+// }
+// }
+// buf.append(Constants.NEW_LINE);
+// buf.append("Address Details:" + Constants.NEW_LINE );
+// if (null != this.getAddresses() && 0 != this.getAddresses().size()) {
+// for (Address address: this.getAddresses()) {
+// buf.append(address);
+// }
+// }
+ }
+
+
+}
Added: search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/DoubleInsertEmbeddedTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/DoubleInsertEmbeddedTest.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/DoubleInsertEmbeddedTest.java 2007-10-29 23:27:09 UTC (rev 14158)
@@ -0,0 +1,90 @@
+//$
+package org.hibernate.search.test.embedded.doubleinsert;
+
+import java.util.Date;
+import java.io.File;
+
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.hibernate.Query;
+import org.hibernate.event.PostDeleteEventListener;
+import org.hibernate.event.PostUpdateEventListener;
+import org.hibernate.event.PostInsertEventListener;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.Environment;
+import org.hibernate.search.event.FullTextIndexEventListener;
+import org.hibernate.search.store.FSDirectoryProvider;
+import org.hibernate.search.test.SearchTestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class DoubleInsertEmbeddedTest extends SearchTestCase {
+ public void testDoubleInsert() throws Exception {
+ Address address = new Address();
+ address.setAddress1( "TEST1" );
+ address.setAddress2( "N/A" );
+ address.setTown( "TEST TOWN" );
+ address.setCounty( "TEST COUNTY" );
+ address.setCountry( "UK" );
+ address.setPostcode( "XXXXXXX" );
+ address.setActive( true );
+ address.setCreatedOn( new Date() );
+ address.setLastUpdatedOn( new Date() );
+
+ Phone phone = new Phone();
+ phone.setNumber( "01273234122" );
+ phone.setType( "HOME" );
+ phone.setCreatedOn( new Date() );
+ phone.setLastUpdatedOn( new Date() );
+
+ PersonalContact contact = new PersonalContact();
+ contact.setFirstname( "Amin" );
+ contact.setSurname( "Mohammed-Coleman" );
+ contact.setEmail( "address(a)hotmail.com" );
+ contact.setDateOfBirth( new Date() );
+ contact.setNotifyBirthDay( false );
+ contact.setCreatedOn( new Date() );
+ contact.setLastUpdatedOn( new Date() );
+ contact.setNotes( "TEST" );
+ contact.addAddressToContact( address );
+ contact.addPhoneToContact( phone );
+
+ FullTextSession s = Search.createFullTextSession( openSession( ) );
+ s.getTransaction().begin();
+ s.save( contact);
+ s.getTransaction().commit();
+
+ s.close();
+
+ s = Search.createFullTextSession( openSession( ) );
+ s.getTransaction().begin();
+ Term term = new Term("county", "county");
+ TermQuery termQuery = new TermQuery( term );
+ Query query = s.createFullTextQuery( termQuery );
+ assertEquals( 1, query.list().size() );
+ contact = (PersonalContact) s.get( PersonalContact.class, contact.getId() );
+ contact.getPhoneNumbers().clear();
+ contact.getAddresses().clear();
+ s.flush();
+ s.clear();
+ s.createQuery( "delete " + Address.class.getName() ).executeUpdate();
+ s.createQuery( "delete " + Phone.class.getName() ).executeUpdate();
+ s.createQuery( "delete " + Contact.class.getName() ).executeUpdate();
+ s.getTransaction().commit();
+
+ s.close();
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ Address.class,
+ Contact.class,
+ PersonalContact.class,
+ BusinessContact.class,
+ Phone.class
+ };
+ }
+}
Added: search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/PersonalContact.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/PersonalContact.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/PersonalContact.java 2007-10-29 23:27:09 UTC (rev 14158)
@@ -0,0 +1,159 @@
+package org.hibernate.search.test.embedded.doubleinsert;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+
+import org.hibernate.annotations.Type;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+
+@Entity
+@DiscriminatorValue("PersonalContact")
+@Indexed
+public class PersonalContact extends Contact {
+ private static final long serialVersionUID = 1L;
+
+ @Column(name="P_FIRSTNAME")
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ private String firstname;
+
+ @Column(name="P_SURNAME")
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ private String surname;
+
+ @Column(name="P_DATEOFBIRTH")
+ @Type(type="java.util.Date")
+ private Date dateOfBirth;
+
+ @Column(name="P_NOTIFYBIRTHDAY")
+ @Type(type="boolean")
+ private boolean notifyBirthDay;
+
+ @Column(name="P_MYFACESURL")
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ private String myFacesUrl;
+
+ @Column(name="P_REMINDERCOUNT")
+ private int reminderCount;
+
+ @Column(name="P_REMINDERRESET")
+ @Type(type="boolean")
+ private boolean reset;
+
+
+ public PersonalContact() {
+ }
+
+ public String getFirstname() {
+ return firstname;
+ }
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+ public String getSurname() {
+ return surname;
+ }
+ public void setSurname(String surname) {
+ this.surname = surname;
+ }
+ public Date getDateOfBirth() {
+ return dateOfBirth;
+ }
+ public void setDateOfBirth(Date dateOfBirth) {
+ this.dateOfBirth = dateOfBirth;
+ }
+
+ public boolean isNotifyBirthDay() {
+ return notifyBirthDay;
+ }
+
+ public void setNotifyBirthDay(boolean notifyBirthDay) {
+ this.notifyBirthDay = notifyBirthDay;
+ }
+
+
+ public String getMyFacesUrl() {
+ return myFacesUrl;
+ }
+
+ public void setMyFacesUrl(String myFacesUrl) {
+ this.myFacesUrl = myFacesUrl;
+ }
+
+
+
+ public int getReminderCount() {
+ return reminderCount;
+ }
+
+ public void setReminderCount(int reminderCount) {
+ this.reminderCount = reminderCount;
+ }
+
+
+ public boolean isReset() {
+ return reset;
+ }
+
+ public void setReset(boolean reset) {
+ this.reset = reset;
+ }
+
+ private boolean equals(Object o1, Object o2) {
+ if ( o1 == o2 ) return true;
+ if ( o1 == null || o2 == null ) return false;
+ return o1.equals( o1.equals( o2 ) );
+ }
+
+ private int hashCode(Object o) {
+ return o == null ? 0 : o.hashCode();
+ }
+
+ public boolean equals(Object object) {
+ if (!(object instanceof PersonalContact)) {
+ return false;
+ }
+ PersonalContact that = (PersonalContact)object;
+ if ( ! equals(this.getId(), that.getId() ) ) return false;
+ if ( ! equals(this.getFirstname(), that.getFirstname() ) ) return false;
+ if ( ! equals(this.getSurname(), that.getSurname() ) ) return false;
+ return true;
+ }
+
+ public int hashCode() {
+ int a = 13;
+ a = a*23 + hashCode( this.getId());
+ a = a*23 + hashCode( this.getFirstname());
+ a = a*23 + hashCode( this.getSurname());
+ return a;
+ }
+
+// public boolean equals(Object object) {
+// if (!(object instanceof PersonalContact)) {
+// return false;
+// }
+// PersonalContact personalContact = (PersonalContact)object;
+// return new EqualsBuilder().append(new Object[]{this.getId(), this.getFirstname(), this.getSurname()}, new Object[]{personalContact.getId(), personalContact.getFirstname(), personalContact.getSurname()}).isEquals();
+// }
+//
+// public int hashCode() {
+// return new HashCodeBuilder().append(new Object[]{new Long(this.getId()), this.getFirstname(), this.getSurname()}).toHashCode();
+// }
+//
+// public String toString() {
+// StringBuffer buf = new StringBuffer();
+// buf.append("First Name: " + this.getFirstname()+ Constants.NEW_LINE);
+// buf.append("Surname: " + this.getSurname() + Constants.NEW_LINE);
+// buf.append("Email: " + this.getEmail() + Constants.NEW_LINE);
+// buf.append("Date of Birth: " + (null == this.getDateOfBirth() ? "Not Provided" : this.getDateOfBirth()) + Constants.NEW_LINE);
+// displayPhonesAndAddresses(buf);
+// return buf.toString();
+// }
+
+
+}
Added: search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/Phone.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/Phone.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/Phone.java 2007-10-29 23:27:09 UTC (rev 14158)
@@ -0,0 +1,129 @@
+package org.hibernate.search.test.embedded.doubleinsert;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Type;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.search.annotations.Store;
+
+@Entity
+@Table(name="T_PHONE")
+@Indexed
+public class Phone implements Serializable{
+
+ private static final long serialVersionUID = 1L;
+
+ @Id @GeneratedValue(strategy=GenerationType.AUTO)
+ @Column(name="P_PHONE_ID")
+ @DocumentId
+ private long id;
+
+ @Column(name="P_NUMBER")
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ private String number;
+
+ @Column(name="P_TYPE")
+ @Field(index=Index.TOKENIZED, store=Store.YES)
+ private String type;
+
+ @Column(name="P_CREATEDON")
+ @Type(type="java.util.Date")
+ private Date createdOn;
+
+ @Column(name="P_LASTUPDATEDON")
+ @Type(type="java.util.Date")
+ private Date lastUpdatedOn;
+
+ @ManyToOne
+ @JoinColumn(name="C_CONTACT_ID")
+ @IndexedEmbedded
+ private Contact contact;
+
+
+ public Phone() {
+ }
+
+ public long getId() {
+ return id;
+ }
+ public void setId(long id) {
+ this.id = id;
+ }
+ public String getNumber() {
+ return number;
+ }
+
+ public void setNumber(String number) {
+ this.number = number;
+ }
+
+ public String getType() {
+ if (null == this.type || "".equals(this.type)) {
+ return "N/A";
+ }
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+ public Date getCreatedOn() {
+ return createdOn;
+ }
+ public void setCreatedOn(Date createdOn) {
+ this.createdOn = createdOn;
+ }
+ public Date getLastUpdatedOn() {
+ return lastUpdatedOn;
+ }
+ public void setLastUpdatedOn(Date lastUpdatedOn) {
+ this.lastUpdatedOn = lastUpdatedOn;
+ }
+
+
+ public Contact getContact() {
+ return contact;
+ }
+
+ public void setContact(Contact contact) {
+ this.contact = contact;
+ }
+
+
+// public int hashCode() {
+// return new HashCodeBuilder().append(new Object[]{this.number, this.type}).hashCode();
+// }
+//
+// public boolean equals(Object object) {
+// if (!(object instanceof Phone)) {
+// return false;
+// }
+//
+// return new EqualsBuilder().append(new Object[]{}, new Object[]{}).isEquals();
+// }
+//
+// public String toString() {
+// StringBuffer buf = new StringBuffer();
+// displayPhoneDetails(buf, this);
+// return buf.toString();
+// }
+
+ private void displayPhoneDetails(StringBuffer buf, Phone phone) {
+// buf.append(Constants.TAB + Constants.TAB + "Type: " + phone.getType() );
+// buf.append(Constants.SPACE + "Number: " + phone.getNumber() + Constants.NEW_LINE);
+ }
+}
17 years, 2 months