[hibernate-commits] Hibernate SVN: r19220 - in core/trunk: annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass and 2 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Apr 13 10:01:57 EDT 2010


Author: steve.ebersole at jboss.com
Date: 2010-04-13 10:01:54 -0400 (Tue, 13 Apr 2010)
New Revision: 19220

Added:
   core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/
   core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/
   core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/Account.java
   core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/AccountBase.java
   core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/IntermediateMappedSuperclassTest.java
   core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/SavingsAccount.java
   core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/SavingsAccountBase.java
Modified:
   core/trunk/core/src/main/java/org/hibernate/mapping/Subclass.java
Log:
HHH-5102 - Instances of a subclass can't be loaded


Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/Account.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/Account.java	                        (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/Account.java	2010-04-13 14:01:54 UTC (rev 19220)
@@ -0,0 +1,46 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat Inc. 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.mappedsuperclass.intermediate;
+
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+/**
+ * The intermediate entity in the hierarchy
+ *
+ * @author Saša Obradović
+ */
+ at Entity
+ at Table(name = "ACCOUNT")
+ at Inheritance(strategy = InheritanceType.JOINED)
+public class Account extends AccountBase {
+	public Account() {
+	}
+
+	public Account(String accountNumber) {
+		super( accountNumber );
+	}
+}
\ No newline at end of file

Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/AccountBase.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/AccountBase.java	                        (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/AccountBase.java	2010-04-13 14:01:54 UTC (rev 19220)
@@ -0,0 +1,67 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat Inc. 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.mappedsuperclass.intermediate;
+
+
+import javax.persistence.Column;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.GenerationType;
+
+/**
+ * Represents the most base super class in the hierarchy.
+ *
+ * @author Saša Obradović
+ */
+ at MappedSuperclass
+public abstract class AccountBase {
+	@Id
+	@org.hibernate.annotations.GenericGenerator(name = "generator::Account", strategy = "increment")
+	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator::Account")
+	@Column(name = "ACC_ID")
+	private Long id;
+
+	@Column(name = "ACC_NO")
+	private String accountNumber;
+
+	public Long getId() {
+		return id;
+	}
+
+	protected AccountBase() {
+	}
+
+	protected AccountBase(String accountNumber) {
+		this.accountNumber = accountNumber;
+	}
+
+	public String getAccountNumber() {
+		return accountNumber;
+	}
+
+	public void setAccountNumber(String accountNumber) {
+		this.accountNumber = accountNumber;
+	}
+}
\ No newline at end of file

Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/IntermediateMappedSuperclassTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/IntermediateMappedSuperclassTest.java	                        (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/IntermediateMappedSuperclassTest.java	2010-04-13 14:01:54 UTC (rev 19220)
@@ -0,0 +1,59 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat Inc. 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.mappedsuperclass.intermediate;
+
+import java.math.BigDecimal;
+
+import org.hibernate.Session;
+import org.hibernate.test.annotations.TestCase;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class IntermediateMappedSuperclassTest extends TestCase {
+	@Override
+	protected Class<?>[] getAnnotatedClasses() {
+		return new Class[] { AccountBase.class, Account.class, SavingsAccountBase.class, SavingsAccount.class };
+	}
+
+	public void testGetOnIntermediateMappedSuperclass() {
+		final BigDecimal withdrawalLimit = new BigDecimal( 1000 );
+		Session session = openSession();
+		session.beginTransaction();
+		SavingsAccount savingsAccount = new SavingsAccount( "123", withdrawalLimit );
+		session.save( savingsAccount );
+		session.getTransaction().commit();
+		session.close();
+
+		session = openSession();
+		session.beginTransaction();
+		Account account = (Account) session.get( Account.class, savingsAccount.getId() );
+		assertEquals( withdrawalLimit, ( (SavingsAccount) account ).getWithdrawalLimit() );
+		session.delete( account );
+		session.getTransaction().commit();
+		session.close();
+	}
+}

Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/SavingsAccount.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/SavingsAccount.java	                        (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/SavingsAccount.java	2010-04-13 14:01:54 UTC (rev 19220)
@@ -0,0 +1,46 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat Inc. 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.mappedsuperclass.intermediate;
+
+import java.math.BigDecimal;
+import javax.persistence.Entity;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+
+/**
+ * The "leaf" entity in the hierarchy
+ *
+ * @author Saša Obradović
+ */
+ at Entity
+ at Table(name = "SAVINGS_ACCOUNT")
+ at PrimaryKeyJoinColumn(name = "SAVACC_ACC_ID")
+public class SavingsAccount extends SavingsAccountBase {
+	public SavingsAccount() {
+	}
+
+	public SavingsAccount(String accountNumber, BigDecimal withdrawalLimit) {
+		super( accountNumber, withdrawalLimit );
+	}
+}
\ No newline at end of file

Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/SavingsAccountBase.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/SavingsAccountBase.java	                        (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/SavingsAccountBase.java	2010-04-13 14:01:54 UTC (rev 19220)
@@ -0,0 +1,56 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat Inc. 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.mappedsuperclass.intermediate;
+
+import java.math.BigDecimal;
+import javax.persistence.Column;
+import javax.persistence.MappedSuperclass;
+
+
+/**
+ * Represents the intermediate mapped superclass in the hierarchy.
+ *
+ * @author Saša Obradović
+ */
+ at MappedSuperclass
+public abstract class SavingsAccountBase extends Account {
+	@Column(name = "SAVACC_WITHDRAWALLIMIT")
+	private BigDecimal withdrawalLimit;
+
+	protected SavingsAccountBase() {
+	}
+
+	protected SavingsAccountBase(String accountNumber, BigDecimal withdrawalLimit) {
+		super( accountNumber );
+		this.withdrawalLimit = withdrawalLimit;
+	}
+
+	public BigDecimal getWithdrawalLimit() {
+		return withdrawalLimit;
+	}
+
+	public void setWithdrawalLimit(BigDecimal withdrawalLimit) {
+		this.withdrawalLimit = withdrawalLimit;
+	}
+}
\ No newline at end of file

Modified: core/trunk/core/src/main/java/org/hibernate/mapping/Subclass.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/mapping/Subclass.java	2010-04-13 13:35:38 UTC (rev 19219)
+++ core/trunk/core/src/main/java/org/hibernate/mapping/Subclass.java	2010-04-13 14:01:54 UTC (rev 19220)
@@ -99,7 +99,7 @@
 		getSuperclass().addSubclassProperty(p);
 	}
 
-	public void addMappedsuperClassProperty(Property p) {
+	public void addMappedsuperclassProperty(Property p) {
 		super.addMappedsuperclassProperty( p );
 		getSuperclass().addSubclassProperty(p);
 	}



More information about the hibernate-commits mailing list