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?
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