Help with creating a collection of composite elements]
by Frank Kyle
Hibernators:
Can anyone help with hibernate xdoclet syntax? Here's what I am
trying to do:
I want to create a collection (an array) of "Instruction"objects.
The code to
create the collection presently looks like this:
/**
* @hibernate.array name="program"
* table="VUNET.GROUP_CODE"
* lazy="true"
* @hibernate.collection-key column="GRP_ID"
* on-delete="cascade"
* @hibernate.collection-index column="SEQ"
* base="1"
* @hibernate.collection-composite-element
* class="Instruction"
*/
public Instruction[] getProgram(){
return this.program;
}
public void setProgram(Instruction[] program){
this.program = program;
}
The "Instruction" class looks like this:
public class Instruction implements Serializable {
private Character operation;
private Long argument;
/**
* @hibernate.property
*/
public Character getOperation(){
return this.operation;
}
public void setOperation(Character operation){
this.operation=operation;
}
/**
* @hibernate.property
*/
public Long getArgument(){
return this.argument;
}
public void setArgument(Long argument){
this.argument=argument;
}
}
And finally, the (legacy) database table contains the columns:
GRP_ID Long A foreign key
SEQ int A sequence number
OP_COD char A value for Instruction.operator
ARG_ID Long A value for Instruction.argument
The question is:
How can I modify the collection definition to point the
collection composite element properties to the last two
columns of the table? Or maybe, what is a better way to do this?
Thanks ahead of time.
Frank
18 years, 3 months