Hi,
I am using Hibernate version 3.1.2.
I have a basic problem here. My data table looks like this
Conditions_Id(int) Operand (int) OperandType(int)
Now since I got three columns and two fields in my Condition Class the problem arises there. I need to save the Condition Object in the DB in which the OperandType is there to differentiate the SubClassses of Operand. I dont want to use different tables for the SubClasses.
Hence I am using UserType provided by Hibernate for this purpose.
My problem is [b]How do I set the value for OperandType in the nullSafeSet method of UserType as the PreparedStatement does not contain this field.[/b]
My Condition class is as followed.
@Entity()
@Table (name = "CONDITIONS")
@Proxy(lazy = false)
@TypeDef(name = "operands", typeClass = OperandType.class)
@AuditIgnore
@AccessType(value = "property")
public class Condition {
private Integer id;
private Operand operand;
public void setId(Integer id) {
this.id = id;
}
public void setOperand(Operand operand) {
this.operand = operand;
}
@Id
@GeneratedValue(generator = "uuid-generator")
@Column(name = "Conditions_Id", unique = true, nullable = false, insertable = true)
public Integer getId() {
return id;
}
@Column(name = "Operand")
@Type(type = "operands")
public Operand getOperand() {
return operand;
}
}
|