Hi everybody.
I use spring 3.1.Release, with Hibernate 3.2.1, annotation 3.3.0.ga
I have the following hieracy.
Code:
@Entity
public class Property implements Serializable {
private static final long serialVersionUID = 6817800702395453171L;
@Id
Long id;
String name;
@ManyToMany
//@JoinColumns({ @JoinColumn(name = "propertyAction_id"), @JoinColumn(name = "propertyAction_type") }) --> I try to solve my prolbem whit @JoinColumns
List<Trasformation> trasformationList = new ArrayList<Trasformation>();
@ManyToMany
//@JoinColumns({ @JoinColumn(name = "propertyAction_id", referencedColumnName = "id"),
// @JoinColumn(name = "propertyAction_type", referencedColumnName = "type") })
List<Validation> validationList = new ArrayList<Validation>();
@ManyToMany
//@JoinColumns({ @JoinColumn(name = "propertyAction_id", referencedColumnName = "id"),
// @JoinColumn(name = "propertyAction_type", referencedColumnName = "type") })
List<Rule> ruleList = new ArrayList<Rule>();
..getter , setter, equals, toString, hashCode
}
Code:
@Entity
@DiscriminatorValue("trasformation")
public class Trasformation extends PropertyAction {
private static final long serialVersionUID = 3584615686231696769L;
}
Code:
@Entity
@DiscriminatorValue("validation")
public class Validation extends PropertyAction {
private static final long serialVersionUID = 8753530871622916273L;
}
Code:
@Entity
@DiscriminatorValue("rule")
public class Rule extends PropertyAction {
private static final long serialVersionUID = 2165118757521500208L;
}
Code:
@Entity
@DiscriminatorColumn(name = "type")
public abstract class PropertyAction implements Serializable {
private static final long serialVersionUID = 8675454718412016262L;
@Id
Long id;
@Column(insertable = false, updatable = false)
protected String type;
String name;
String beanName;
@OrderBy
Integer order;
..getter , setter, equals, toString, hashCode
The table of relathionship between Property and Rule , Validation and Trasformation has 4 column, one per type id.
Property_PropertyAction has
property_id
validationList_id
ruleList_id
trasformationList_id
Is it possible to have this table in this way,
property_id
type --> which is the discriminator column between all type
actionProperty_id
which i think is more readable?
Moreover, when i start my application, the table actionProperty is not create, but if i create the field are added corretly.
I don't know what happen!!! I use the same structure for another entity which, when I ran in update mode on my db, is correctly created. This is not a problem by I am really curious about it!