[hibernate-commits] Hibernate SVN: r19908 - core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Wed Jul 7 10:05:02 EDT 2010


Author: sharathjreddy
Date: 2010-07-07 10:05:01 -0400 (Wed, 07 Jul 2010)
New Revision: 19908

Added:
   core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/Company.java
   core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/Customer.java
   core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/LegalEntity.java
Modified:
   core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java
Log:
HHH-4240 - SecondaryTables not recognized when using JOINED inheritance

Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/Company.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/Company.java	                        (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/Company.java	2010-07-07 14:05:01 UTC (rev 19908)
@@ -0,0 +1,71 @@
+/*
+  * Hibernate, Relational Persistence for Idiomatic Java
+  *
+  * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc.
+  *
+  * 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.annotations.inheritance.joined;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.SecondaryTable;
+import javax.persistence.Table;
+
+/**
+ * @author Sharath Reddy
+ *
+ */
+ at Entity
+ at Table(name = "Company")
+ at SecondaryTable(name = "CompanyAddress")
+public class Company extends Customer {
+
+	private String companyName;	
+	private String companyAddress;
+
+	@Column
+	public String getCompanyName() {
+		return companyName;
+	}
+
+	public void setCompanyName(String companyName) {
+		this.companyName = companyName;
+	}
+
+	@Column(table = "CompanyAddress")
+	public String getCompanyAddress() {
+		return companyAddress;
+	}
+
+	public void setCompanyAddress(String companyAddress) {
+		this.companyAddress = companyAddress;
+	}
+
+	
+	
+	
+	
+	
+	
+}

Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/Customer.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/Customer.java	                        (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/Customer.java	2010-07-07 14:05:01 UTC (rev 19908)
@@ -0,0 +1,67 @@
+/*
+  * Hibernate, Relational Persistence for Idiomatic Java
+  *
+  * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc.
+  *
+  * 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.annotations.inheritance.joined;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.SecondaryTable;
+import javax.persistence.Table;
+import javax.persistence.InheritanceType;
+
+/**
+ * @author Sharath Reddy
+ *
+ */
+ at Entity
+ at Inheritance(strategy = InheritanceType.JOINED)
+ at Table(name = "Customer")
+ at SecondaryTable(name = "CustomerDetails")
+public class Customer extends LegalEntity {
+
+	public String customerName;
+	public String customerCode;
+
+	@Column
+	public String getCustomerName() {
+		return customerName;
+	}
+
+	public void setCustomerName(String val) {
+		this.customerName = val;
+	}
+
+	@Column(table="CustomerDetails")
+	public String getCustomerCode() {
+		return customerCode;
+	}
+
+	public void setCustomerCode(String val) {
+		this.customerCode = val;
+	}
+}
\ No newline at end of file

Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java	2010-07-07 13:39:12 UTC (rev 19907)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java	2010-07-07 14:05:01 UTC (rev 19908)
@@ -167,6 +167,38 @@
 		s.close();
 	}
 
+	/**
+     *   HHH-4240 - SecondaryTables not recognized when using JOINED inheritance
+	 */	
+	public void testSecondaryTables() {
+		
+		Session s = openSession();
+		s.getTransaction().begin();
+		
+		Company company = new Company();
+		company.setCustomerName("Mama");
+		company.setCustomerCode("123");
+		company.setCompanyName("Mama Mia Pizza");
+		company.setCompanyAddress("Rome");
+		
+		s.persist( company );
+		s.getTransaction().commit();
+		s.clear();
+		
+		s = openSession();
+		s.getTransaction().begin();
+		company = (Company) s.get( Company.class, company.getId());
+		assertEquals("Mama", company.getCustomerName());
+		assertEquals("123", company.getCustomerCode());
+		assertEquals("Mama Mia Pizza", company.getCompanyName());
+		assertEquals("Rome", company.getCompanyAddress());
+				
+		s.delete( company );
+		s.getTransaction().commit();
+		s.close();
+	}
+	
+	
 //	public void testManyToOneAndJoin() throws Exception {
 //		Session session = openSession();
 //		Transaction transaction = session.beginTransaction();

Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/LegalEntity.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/LegalEntity.java	                        (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/inheritance/joined/LegalEntity.java	2010-07-07 14:05:01 UTC (rev 19908)
@@ -0,0 +1,56 @@
+/*
+  * Hibernate, Relational Persistence for Idiomatic Java
+  *
+  * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc.
+  *
+  * 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.annotations.inheritance.joined;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+
+/**
+ * @author Sharath Reddy
+ *
+ */
+ at MappedSuperclass
+public class LegalEntity {
+	
+	private Long id;
+	
+	@Id
+	@GeneratedValue(strategy=GenerationType.AUTO)
+	public Long getId() {
+		return this.id;
+	}
+	
+	public void setId(Long id) {
+		this.id = id;
+	}
+	
+	
+	
+}



More information about the hibernate-commits mailing list