-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Need to use UserType to insert into Multiple Columns....
PostPosted: Tue May 30, 2006 3:46 am 
Newbie

Joined: Tue May 16, 2006 10:59 am
Posts: 3
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;
}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.