0

GroupSequence を機能させることができません。一意の制約が検証される前に、プロパティの内部制約がid最初に検証されるようにします。

各インターフェースで

実在物

@UniqueNaturalId(groups = {Create.class, Update.class})
public abstract Entity
{
    @Null(groups = {PreCreate.class})
    @NotNull(groups = {PreUpdate.class, PreDelete.class })
    private Integer id;

    // other properties without groups
}

グループ インターフェイス

@GroupSequence({PreUpdate.class, Update.class})
public interface PreUpdate {}

// PreCreate and PreDelete follow same structure

更新操作のためのグループの呼び出し

<property name="javax.persistence.validation.group.pre-update">
    javax.validation.groups.Default, 
    package.PreUpdate
</property>

環境

Hibernate-Validator 4.2 が組み込まれた Glassfish 3.1.2。

4

1 に答える 1