0

I'm creating a model entity in ColdBox.

component persistent="true" {
  property name="id" type="int" fieldType="id"  generator="increment";
  property name="stamptime" type="timestamp";
  property name="type" type="string" length="1" sqltype="varchar(1)";
  property name="serial" type="string" length="100" sqltype="varchar(100)";}

the id field is set as identity and as primary key. the problem is i want to set serial field as unique key.. is there any way to set this field as unique key?

Sudarsono Sung
  • 83
  • 1
  • 11

1 Answers1

1

Have you tried defining in the property as follow:

component persistent="true" {
  property name="serial" type="string" length="100" sqltype="varchar(100)" unique="true";

  // and / or as a validation via constraints?
  this.constraints = {
    serial = { unique=true };
  } //constraints
} //component
Yieng Ly
  • 129
  • 3