Author: hardy.ferentschik
Date: 2008-06-18 14:04:17 -0400 (Wed, 18 Jun 2008)
New Revision: 14781
Modified:
annotations/trunk/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
annotations/trunk/src/test/org/hibernate/test/annotations/manytomany/Employee.java
Log:
ANN-625
* Added a patch in order to make it work for 'table per class hierarchy' strategy.
Still not work for joined subclasses, but the problem might lie in hibernate core.
* Changed Employee class to server as test
Modified: annotations/trunk/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
---
annotations/trunk/src/java/org/hibernate/cfg/annotations/CollectionBinder.java 2008-06-18
17:59:30 UTC (rev 14780)
+++
annotations/trunk/src/java/org/hibernate/cfg/annotations/CollectionBinder.java 2008-06-18
18:04:17 UTC (rev 14781)
@@ -77,17 +77,19 @@
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.mapping.Table;
import org.hibernate.util.StringHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Collection binder
+ * Base class for binding different types of collections to Hibernate configuration
objects.
*
* @author inger
* @author Emmanuel Bernard
*/
+@SuppressWarnings({"unchecked", "serial"})
public abstract class CollectionBinder {
private Logger log = LoggerFactory.getLogger( CollectionBinder.class );
@@ -875,12 +877,16 @@
//TODO check whether @ManyToOne @JoinTable in @IdClass used for @OrderBy works:
doh!
table = "";
}
- else if ( pc != associatedClass ) {
+
+ else if (pc == associatedClass
+ || (associatedClass instanceof SingleTableSubclass && pc
+ .getMappedClass().isAssignableFrom(
+ associatedClass.getMappedClass()))) {
+ table = "";
+ } else {
table = pc.getTable().getQuotedName() + ".";
}
- else {
- table = "";
- }
+
Iterator propertyColumns = p.getColumnIterator();
while ( propertyColumns.hasNext() ) {
Selectable column = (Selectable) propertyColumns.next();
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/manytomany/Employee.java
===================================================================
---
annotations/trunk/src/test/org/hibernate/test/annotations/manytomany/Employee.java 2008-06-18
17:59:30 UTC (rev 14780)
+++
annotations/trunk/src/test/org/hibernate/test/annotations/manytomany/Employee.java 2008-06-18
18:04:17 UTC (rev 14781)
@@ -7,6 +7,8 @@
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
import javax.persistence.ManyToMany;
import javax.persistence.Column;
@@ -18,6 +20,7 @@
* @author Emmanuel Bernard
*/
@Entity
+@Inheritance(strategy = InheritanceType.JOINED)
@SuppressWarnings("serial")
public class Employee implements Serializable {
private Integer id;