简体   繁体   中英

Unique Constraint on two column Combination in Active Objects

I am developing with Active Objects and have 4 columns in my table. I have a requirement wherein I have to place a constraint so that combination of two columns will always be unique.

@Table("TEST")
@Preload("*")
public interface TestEntity extends RawEntity<Long>{

@AutoIncrement
@NotNull
@PrimaryKey("ID")
Long getID();

@NotNull
Long getItemId();

@NotNull
String getItemName();

@StringLength(767)
String getDescription();

void setItemId(Long itemId);

void setItemName(String itemName);

void setDescription(String description);
}

The requirement here is that ItemId and ItemName combination should have a Unique Constraint.

I tried to do some searching but could only find a way to make a single column unique using net.java.ao.schema.Unique class.

Can someone point me to some right direction on how this can be achieved.

Thanks

After doing some research I found that Active Objects at present does not support this particular feature. So in case you want to use this badly then you might have to modify your approach of storing data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM