简体   繁体   English

活动对象中两列组合的唯一约束

[英]Unique Constraint on two column Combination in Active Objects

I am developing with Active Objects and have 4 columns in my table. 我正在使用Active Objects进行开发,并且在我的表中有4列。 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. 这里的要求是ItemId和ItemName组合应该具有唯一约束。

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. 我尝试进行一些搜索,但只能找到一种方法,使用net.java.ao.schema.Unique类使单个列唯一。

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. 在做了一些研究之后,我发现Active Objects目前不支持这个特殊功能。 So in case you want to use this badly then you might have to modify your approach of storing data. 因此,如果您想要使用它,那么您可能必须修改存储数据的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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