Hi all,
I have the strangest schema: I have identical tables where only the name of the table is different. The purpose of the copy table is to move data from the main table, (don't ask...) and store it in the copy table instead. Problem is, I need to have a perfect replica of the main table, including relations (I also have copies of the relation tables, which include 1-N, N-1, etc).
Obviously, I do not want to replicate the properties and mapping for all entities. I have tried to use the table_per_class hierarchy but I couldn't perform polymorphic jpa queries.
I mapped the superclass this way:
Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class GenericFulfillmentRequestEJB implements java.io.Serializable {
(...) //class properties
}
And the child classes this way:
Code:
@Entity
@Table(name = "OMP_FULFILLMENT_REQUEST")
public class FulfillmentRequestEJB extends GenericFulfillmentRequestEJB implements java.io.Serializable{
//zero properties
}
Problem is, my Generic classes have also other Generic classes in 1-n and n-1 relations, and it seems that I can't get polymorphic queries to work. If I query the superclass, hibernate can't distinguish between the instances, altough the query reveals a union and a correct clazz_ column to differentiate instance types. The hibernate docs state that joins do work if I use the union-class strategy, which is equivalent to jpa's table_per_class strategy.
Is this possible with minimum effort? I want to be able to do polymorphic queries, besides not replicating same attributes for the 2 entities.
Thanks in advance