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

时间:2021-07-16 04:27:38

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.

我正在使用Active Objects进行开发,并且在我的表中有4列。我有一个要求,其中我必须放置一个约束,以便两列的组合始终是唯一的。

@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

1 个解决方案

#1


3  

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.

在做了一些研究之后,我发现Active Objects目前不支持这个特殊的功能。因此,如果您想要使用它,那么您可能需要修改存储数据的方法。

#1


3  

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.

在做了一些研究之后,我发现Active Objects目前不支持这个特殊的功能。因此,如果您想要使用它,那么您可能需要修改存储数据的方法。