Ссылочный тип атрибута с мультивыбором#
Используется для хранения в атрибуте нескольких ссылок на справочники.
Варианты использования#
ссылки на справочник пользователей
ссылки на справочник тегов
Подключение#
описываем тип
code: example_type_with_directory_links name: Пример типа с ссылками на справочник directory: directory_code multi-value: trueреализуем -
ru.sbt.swtr.track.core.entity.type.CustomAttributeTypeEntityаннотируем -
ru.sbt.swtr.track.core.entity.type.CustomAttributeTypeаннотируем -
javax.persistence.Entity
Пример#
Сущность справочника
@Entity @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED, force = true) @CustomDirectory(code = "directory_code") public class ExampleDirectoryValue extends AbstractDirectoryEntity { @Getter @EqualsAndHashCode.Include @Column(name = "external_id", length = 240, nullable = false) private String externalId; @Getter @NaturalId @EqualsAndHashCode.Include @Basic @Column(name = "code") protected String code; }Сущность типа
@CustomAttributeType(code = "example_type_with_directory_links", type = ExampleDirectoryValue.class) @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) public class ExampleCustomTypeEntity extends AbstractMultipleComplexTypeEntity<ExampleDirectoryValue> { public ExampleCustomTypeEntity(final UnitAttributeEntity unitAttribute) { super(unitAttribute); } }Holder
public class CustomTypeEntityClassHolder implements CustomAttributeTypeEntityClassHolder { @Override public Collection<Class<? extends CustomAttributeTypeEntity>> getClasses() { return List.of( ExampleCustomTypeEntity.class ); } }