Author: smarlow(a)redhat.com
Date: 2010-01-04 11:03:21 -0500 (Mon, 04 Jan 2010)
New Revision: 18392
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/WealthyPerson.java
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java
Log:
HHH-4682 Check that @CollectionTable (or its absence) defaults to the right table/column
names
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java 2010-01-04
15:57:18 UTC (rev 18391)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java 2010-01-04
16:03:21 UTC (rev 18392)
@@ -365,6 +365,50 @@
s.close();
}
+ // quick test based on testSimple
+ public void testCollectionTable() throws Exception {
+ Session s;
+ Transaction tx;
+ WealthyPerson p = new WealthyPerson();
+ Address a = new Address();
+ Address vacation = new Address();
+ Country c = new Country();
+ Country bornCountry = new Country();
+ c.setIso2( "DM" );
+ c.setName( "Matt Damon Land" );
+ bornCountry.setIso2( "US" );
+ bornCountry.setName( "United States of America" );
+
+ a.address1 = "colorado street";
+ a.city = "Springfield";
+ a.country = c;
+ vacation.address1 = "rock street";
+ vacation.city = "Plymouth";
+ vacation.country = c;
+ p.vacationHomes.add(vacation);
+ p.address = a;
+ p.bornIn = bornCountry;
+ p.name = "Homer";
+ s = openSession();
+ tx = s.beginTransaction();
+ s.persist( p );
+ tx.commit();
+ s.close();
+
+ s = openSession();
+ tx = s.beginTransaction();
+ p = (WealthyPerson) s.get( WealthyPerson.class, p.id );
+ assertNotNull( p );
+ assertNotNull( p.address );
+ assertEquals( "Springfield", p.address.city );
+ assertNotNull( p.address.country );
+ assertEquals( "DM", p.address.country.getIso2() );
+ assertNotNull( p.bornIn );
+ assertEquals( "US", p.bornIn.getIso2() );
+ tx.commit();
+ s.close();
+ }
+
public EmbeddedTest(String x) {
super( x );
}
@@ -372,6 +416,7 @@
protected Class[] getMappings() {
return new Class[]{
Person.class,
+ WealthyPerson.class,
RegionalArticle.class,
AddressType.class,
VanillaSwap.class,
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/WealthyPerson.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/WealthyPerson.java
(rev 0)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/WealthyPerson.java 2010-01-04
16:03:21 UTC (rev 18392)
@@ -0,0 +1,31 @@
+package org.hibernate.test.annotations.embedded;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.CollectionTable;
+import javax.persistence.Column;
+import javax.persistence.ElementCollection;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+@Entity
+public class WealthyPerson extends Person {
+
+ @ElementCollection
+ @CollectionTable(name="XXXHOMES")
+ @AttributeOverrides({
+ @AttributeOverride(name="address1",
+ column=@Column(name="HOME_STREET")),
+ @AttributeOverride(name="city",
+ column=@Column(name="HOME_CITY")),
+ @AttributeOverride(name="country",
+ column=@Column(name="HOME_COUNTRY"))
+ })
+ protected Set<Address> vacationHomes = new HashSet();
+}
Show replies by date