diff --git a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/AssociationOverrideTest.java b/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/AssociationOverrideTest.java deleted file mode 100644 index 82d34e0fa4..0000000000 --- a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/AssociationOverrideTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.hibernate.test.annotations.collectionelement; - -import junit.framework.Assert; -import org.hibernate.Session; -import org.hibernate.Transaction; -import org.hibernate.test.annotations.TestCase; -import org.hibernate.test.util.SchemaUtil; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -public class AssociationOverrideTest extends TestCase { - - public void testDottedNotation() throws Exception { - assertTrue( SchemaUtil.isTablePresent( "Employee", getCfg() ) ); - assertTrue( "Overridden @JoinColumn fails", - SchemaUtil.isColumnPresent( "Employee", "fld_address_fk", getCfg() ) ); - - assertTrue( "Overridden @JoinTable name fails", SchemaUtil.isTablePresent( "tbl_empl_sites", getCfg() ) ); - assertTrue( "Overridden @JoinTable with default @JoinColumn fails", - SchemaUtil.isColumnPresent( "tbl_empl_sites", "employee_id", getCfg() ) ); - assertTrue( "Overridden @JoinTable.inverseJoinColumn fails", - SchemaUtil.isColumnPresent( "tbl_empl_sites", "to_website_fk", getCfg() ) ); - - Session s = openSession(); - Transaction tx = s.beginTransaction(); - ContactInfo ci = new ContactInfo(); - Address address = new Address(); - address.setCity("Boston"); - address.setCountry("USA"); - address.setState("MA"); - address.setStreet("27 School Street"); - address.setZipcode("02108"); - ci.setAddress(address); - List phoneNumbers = new ArrayList(); - PhoneNumber num = new PhoneNumber(); - num.setNumber(5577188); - Employee e = new Employee(); - Collection employeeList = new ArrayList(); - employeeList.add(e); - e.setContactInfo(ci); - num.setEmployees(employeeList); - phoneNumbers.add(num); - ci.setPhoneNumbers(phoneNumbers); - SocialTouchPoints socialPoints = new SocialTouchPoints(); - List sites = new ArrayList(); - SocialSite site = new SocialSite(); - site.setEmployee(employeeList); - site.setWebsite("www.jboss.org"); - sites.add(site); - socialPoints.setWebsite(sites); - ci.setSocial(socialPoints); - s.persist(e); - tx.commit(); - - tx = s.beginTransaction(); - s.clear(); - e = (Employee) s.get(Employee.class,e.getId()); - tx.commit(); - s.close(); - } - - protected Class[] getMappings() { - return new Class[] { - Employee.class, - PhoneNumber.class, - Address.class, - SocialSite.class, - SocialTouchPoints.class - }; - } - -} \ No newline at end of file diff --git a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/PhoneNumber.java b/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/PhoneNumber.java deleted file mode 100644 index 7c0311e15c..0000000000 --- a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/PhoneNumber.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.hibernate.test.annotations.collectionelement; - -import javax.persistence.CascadeType; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.ManyToMany; -import java.util.Collection; - -@Entity -public class PhoneNumber { - - @Id - int id; - - public void setId(int id) { - this.id = id; - } - - int number; - - @ManyToMany(mappedBy = "contactInfo.phoneNumbers", cascade = CascadeType.ALL) - Collection employees; - - public Collection getEmployees() { - return employees; - } - - public void setEmployees(Collection employees) { - this.employees = employees; - } - - public int getNumber() { - return number; - } - - public void setNumber(int number) { - this.number = number; - } - - public int getId() { - return id; - } -} diff --git a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Address.java b/annotations/src/test/java/org/hibernate/test/annotations/override/Addr.java similarity index 91% rename from annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Address.java rename to annotations/src/test/java/org/hibernate/test/annotations/override/Addr.java index 52ed325feb..0ce0bd86f8 100644 --- a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Address.java +++ b/annotations/src/test/java/org/hibernate/test/annotations/override/Addr.java @@ -1,11 +1,11 @@ -package org.hibernate.test.annotations.collectionelement; +package org.hibernate.test.annotations.override; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.OneToMany; @Entity -public class Address { +public class Addr { @Id int id; diff --git a/annotations/src/test/java/org/hibernate/test/annotations/override/Address.java b/annotations/src/test/java/org/hibernate/test/annotations/override/Address.java index ceaf1edab4..bbb61d8bce 100644 --- a/annotations/src/test/java/org/hibernate/test/annotations/override/Address.java +++ b/annotations/src/test/java/org/hibernate/test/annotations/override/Address.java @@ -11,4 +11,29 @@ public class Address { public String street; public String city; public String state; + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getStreet() { + + return street; + } + + public void setStreet(String street) { + this.street = street; + } } diff --git a/annotations/src/test/java/org/hibernate/test/annotations/override/AssociationOverrideTest.java b/annotations/src/test/java/org/hibernate/test/annotations/override/AssociationOverrideTest.java index 3142d290a3..7bde8871bb 100644 --- a/annotations/src/test/java/org/hibernate/test/annotations/override/AssociationOverrideTest.java +++ b/annotations/src/test/java/org/hibernate/test/annotations/override/AssociationOverrideTest.java @@ -5,6 +5,11 @@ import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.test.annotations.TestCase; +import org.hibernate.test.util.SchemaUtil; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; /** * @author Emmanuel Bernard @@ -37,11 +42,65 @@ public class AssociationOverrideTest extends TestCase { } } + public void testDottedNotation() throws Exception { + assertTrue( SchemaUtil.isTablePresent( "Employee", getCfg() ) ); + assertTrue( "Overridden @JoinColumn fails", + SchemaUtil.isColumnPresent( "Employee", "fld_address_fk", getCfg() ) ); + + assertTrue( "Overridden @JoinTable name fails", SchemaUtil.isTablePresent( "tbl_empl_sites", getCfg() ) ); + assertTrue( "Overridden @JoinTable with default @JoinColumn fails", + SchemaUtil.isColumnPresent( "tbl_empl_sites", "employee_id", getCfg() ) ); + assertTrue( "Overridden @JoinTable.inverseJoinColumn fails", + SchemaUtil.isColumnPresent( "tbl_empl_sites", "to_website_fk", getCfg() ) ); + + Session s = openSession(); + Transaction tx = s.beginTransaction(); + ContactInfo ci = new ContactInfo(); + Addr address = new Addr(); + address.setCity("Boston"); + //address.setCountry("USA"); + address.setState("MA"); + address.setStreet("27 School Street"); + //address.setZipcode("02108"); + ci.setAddr(address); + List phoneNumbers = new ArrayList(); + PhoneNumber num = new PhoneNumber(); + num.setNumber(5577188); + Employee e = new Employee(); + Collection employeeList = new ArrayList(); + employeeList.add(e); + e.setContactInfo(ci); + num.setEmployees(employeeList); + phoneNumbers.add(num); + ci.setPhoneNumbers(phoneNumbers); + SocialTouchPoints socialPoints = new SocialTouchPoints(); + List sites = new ArrayList(); + SocialSite site = new SocialSite(); + site.setEmployee(employeeList); + site.setWebsite("www.jboss.org"); + sites.add(site); + socialPoints.setWebsite(sites); + ci.setSocial(socialPoints); + s.persist(e); + tx.commit(); + + tx = s.beginTransaction(); + s.clear(); + e = (Employee) s.get(Employee.class,e.getId()); + tx.commit(); + s.close(); + } + protected Class[] getMappings() { return new Class[]{ + Employee.class, Location.class, Move.class, - Trip.class + Trip.class, + PhoneNumber.class, + Addr.class, + SocialSite.class, + SocialTouchPoints.class }; } } diff --git a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/ContactInfo.java b/annotations/src/test/java/org/hibernate/test/annotations/override/ContactInfo.java similarity index 81% rename from annotations/src/test/java/org/hibernate/test/annotations/collectionelement/ContactInfo.java rename to annotations/src/test/java/org/hibernate/test/annotations/override/ContactInfo.java index 6d79f17434..e2d1a9f4bf 100644 --- a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/ContactInfo.java +++ b/annotations/src/test/java/org/hibernate/test/annotations/override/ContactInfo.java @@ -1,10 +1,9 @@ -package org.hibernate.test.annotations.collectionelement; +package org.hibernate.test.annotations.override; import javax.persistence.CascadeType; import javax.persistence.Embeddable; import javax.persistence.Embedded; import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; import java.util.List; @@ -14,7 +13,7 @@ import java.util.List; public class ContactInfo { @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name="address_id_fk") - Address address; + Addr address; @ManyToMany(cascade = CascadeType.ALL) List phoneNumbers; @@ -22,11 +21,11 @@ public class ContactInfo { @Embedded SocialTouchPoints social; - public Address getAddress() { + public Addr getAddress() { return address; } - public void setAddress(Address address) { + public void setAddr(Addr address) { this.address = address; } diff --git a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Employee.java b/annotations/src/test/java/org/hibernate/test/annotations/override/Employee.java similarity index 94% rename from annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Employee.java rename to annotations/src/test/java/org/hibernate/test/annotations/override/Employee.java index 2a7170ad1a..0edcb9f6e4 100644 --- a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Employee.java +++ b/annotations/src/test/java/org/hibernate/test/annotations/override/Employee.java @@ -1,4 +1,4 @@ -package org.hibernate.test.annotations.collectionelement; +package org.hibernate.test.annotations.override; import javax.persistence.AssociationOverride; import javax.persistence.AssociationOverrides; diff --git a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/SocialSite.java b/annotations/src/test/java/org/hibernate/test/annotations/override/SocialSite.java similarity index 91% rename from annotations/src/test/java/org/hibernate/test/annotations/collectionelement/SocialSite.java rename to annotations/src/test/java/org/hibernate/test/annotations/override/SocialSite.java index 13b56614f9..e49a530fd9 100644 --- a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/SocialSite.java +++ b/annotations/src/test/java/org/hibernate/test/annotations/override/SocialSite.java @@ -1,4 +1,4 @@ -package org.hibernate.test.annotations.collectionelement; +package org.hibernate.test.annotations.override; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/SocialTouchPoints.java b/annotations/src/test/java/org/hibernate/test/annotations/override/SocialTouchPoints.java similarity index 79% rename from annotations/src/test/java/org/hibernate/test/annotations/collectionelement/SocialTouchPoints.java rename to annotations/src/test/java/org/hibernate/test/annotations/override/SocialTouchPoints.java index fc8c4436b1..dccd873d0e 100644 --- a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/SocialTouchPoints.java +++ b/annotations/src/test/java/org/hibernate/test/annotations/override/SocialTouchPoints.java @@ -1,4 +1,6 @@ -package org.hibernate.test.annotations.collectionelement; +package org.hibernate.test.annotations.override; + +import org.hibernate.test.annotations.override.SocialSite; import javax.persistence.CascadeType; import javax.persistence.Embeddable;