当前位置: 首页>>代码示例>>Java>>正文


Java UniqueConstraint类代码示例

本文整理汇总了Java中javax.persistence.UniqueConstraint的典型用法代码示例。如果您正苦于以下问题:Java UniqueConstraint类的具体用法?Java UniqueConstraint怎么用?Java UniqueConstraint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

UniqueConstraint类属于javax.persistence包,在下文中一共展示了UniqueConstraint类的21个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildUniqueConstraints

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
private static void buildUniqueConstraints(AnnotationDescriptor annotation, Element element) {
	List uniqueConstraintElementList = element.elements( "unique-constraint" );
	UniqueConstraint[] uniqueConstraints = new UniqueConstraint[uniqueConstraintElementList.size()];
	int ucIndex = 0;
	Iterator ucIt = uniqueConstraintElementList.listIterator();
	while ( ucIt.hasNext() ) {
		Element subelement = (Element) ucIt.next();
		List<Element> columnNamesElements = subelement.elements( "column-name" );
		String[] columnNames = new String[columnNamesElements.size()];
		int columnNameIndex = 0;
		Iterator it = columnNamesElements.listIterator();
		while ( it.hasNext() ) {
			Element columnNameElt = (Element) it.next();
			columnNames[columnNameIndex++] = columnNameElt.getTextTrim();
		}
		AnnotationDescriptor ucAnn = new AnnotationDescriptor( UniqueConstraint.class );
		copyStringAttribute( ucAnn, subelement, "name", false );
		ucAnn.setValue( "columnNames", columnNames );
		uniqueConstraints[ucIndex++] = AnnotationFactory.create( ucAnn );
	}
	annotation.setValue( "uniqueConstraints", uniqueConstraints );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:JPAOverriddenAnnotationReader.java


示例2: buildUniqueConstraintHolders

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
/**
 * Build a list of {@link org.hibernate.cfg.UniqueConstraintHolder} instances given a list of
 * {@link UniqueConstraint} annotations.
 *
 * @param annotations The {@link UniqueConstraint} annotations.
 *
 * @return The built {@link org.hibernate.cfg.UniqueConstraintHolder} instances.
 */
public static List<UniqueConstraintHolder> buildUniqueConstraintHolders(UniqueConstraint[] annotations) {
	List<UniqueConstraintHolder> result;
	if ( annotations == null || annotations.length == 0 ) {
		result = java.util.Collections.emptyList();
	}
	else {
		result = new ArrayList<UniqueConstraintHolder>( CollectionHelper.determineProperSizing( annotations.length ) );
		for ( UniqueConstraint uc : annotations ) {
			result.add(
					new UniqueConstraintHolder()
							.setName( uc.name() )
							.setColumns( uc.columnNames() )
			);
		}
	}
	return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:TableBinder.java


示例3: getLabels

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
@Override
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "MCRCategoryLabels",
    joinColumns = @JoinColumn(name = "category"),
    uniqueConstraints = {
        @UniqueConstraint(columnNames = { "category", "lang" }) })
public Set<MCRLabel> getLabels() {
    return super.getLabels();
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:10,代码来源:MCRCategoryImpl.java


示例4: register

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
protected <T> void register(OObjectDatabaseTx db, OSchema schema, Class<T> aClass) {
    if (schema.getClass(aClass.getSimpleName()) == null) {
        db.getEntityManager().registerEntityClasses(aClass, true);
        OClass cls = db.getMetadata().getSchema().getClass(aClass);
        String indexName = aClass.getName() + ".unq";
        Table t = aClass.getAnnotation(Table.class);
        if (t != null) {
            Set<String> fields = new HashSet<>();
            for (UniqueConstraint uc : t.uniqueConstraints()) {
                fields.addAll(Lists.newArrayList(uc.columnNames()));
            }
            if (fields.size() > 0) {
                LOG.info("Registering unique constraint for fields: " + fields);
                for (String field : fields)
                    cls.createIndex(indexName + "." + field, OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, field);
            }
        }
    } else {
        db.getEntityManager().registerEntityClasses(aClass, true);
    }
}
 
开发者ID:dmart28,项目名称:gcplot,代码行数:22,代码来源:AbstractOrientDbRepository.java


示例5: instpectUniqueConstraint

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
private void instpectUniqueConstraint(final UniqueConstraint constraint) {
	UniquePropertyQuality currentQuality = UniquePropertyQuality.onlyRequiredPrimitives;
	final List<SingularProperty<E, ?>> uniques = new ArrayList<>();
	final String[] columnNames = constraint.columnNames();
	for (final String columnName : columnNames) {
		for (final Property<E, ?> property : this.properties.values()) {
			if (property instanceof SingularProperty) {
				final SingularProperty<E, ?> singularProperty = (SingularProperty<E, ?>) property;
				if (columnName.equals(singularProperty.getColumn().getName())) {
					final UniquePropertyQuality quality = UniquePropertyQuality.getMatchingQuality(property);
					if (quality != null) {
						if (quality.ordinal() > currentQuality.ordinal()) {
							currentQuality = quality;
						}
						uniques.add(singularProperty);
					}
				}
			}
		}
	}
	if (uniques.size() == columnNames.length && isBetterUniquePropertyQuality(currentQuality)) {
		this.uniqueProperties = uniques;
		this.uniquePropertiesQuality = currentQuality;
	}
}
 
开发者ID:liefke,项目名称:org.fastnate,代码行数:26,代码来源:EntityClass.java


示例6: buildUniqueConstraints

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
/**
 * @deprecated Use {@link #buildUniqueConstraintHolders} instead
 */
@Deprecated
@SuppressWarnings({ "JavaDoc" })
public static List<String[]> buildUniqueConstraints(UniqueConstraint[] constraintsArray) {
	List<String[]> result = new ArrayList<String[]>();
	if ( constraintsArray.length != 0 ) {
		for (UniqueConstraint uc : constraintsArray) {
			result.add( uc.columnNames() );
		}
	}
	return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:TableBinder.java


示例7: _getFieldsFromUniqueConstraint

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
private ArrayList<String[]> _getFieldsFromUniqueConstraint(Object value){
    ArrayList<String[]> result = new ArrayList<>();

    if(value.getClass().isAnnotationPresent(Table.class)){
        Table ta = value.getClass().getAnnotation(Table.class);
        for(UniqueConstraint uc : ta.uniqueConstraints()){
            result.add(uc.columnNames());
        }
    }

    return result;
}
 
开发者ID:Klinton90,项目名称:UniqueValidator,代码行数:13,代码来源:UniqueValidator.java


示例8: getUniqueColumns

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
private static String getUniqueColumns(Class<?> clazz, String name) {
    return Optional.of(clazz)
        .map(c -> c.getAnnotation(Table.class))
        .map(Table::uniqueConstraints)
        .map(Stream::of)
        .flatMap(s -> s
            .filter(uc -> uc.name().equals(name))
            .findAny()
            .map(UniqueConstraint::columnNames))
        .map(Stream::of)
        .map(s -> s.collect(Collectors.joining(", ")))
        .get();
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:14,代码来源:MCRHibernateConfigHelper.java


示例9: validateCompositeUniqueConstraints

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
private List<String> validateCompositeUniqueConstraints(Identifiable<?> entity) {
    Class<?> entityClass = getClassWithoutInitializingProxy(entity);
    Table table = findAnnotation(entityClass, Table.class);
    if (table == null) {
        return emptyList();
    }
    List<String> errors = newArrayList();
    for (UniqueConstraint uniqueConstraint : table.uniqueConstraints()) {
        if (!checkCompositeUniqueConstraint(entity, entityClass, uniqueConstraint)) {
            errors.add(compositeUniqueConstraintErrorCode(entity, uniqueConstraint));
        }
    }
    return errors;
}
 
开发者ID:ddRPB,项目名称:rpb,代码行数:15,代码来源:JpaUniqueUtil.java


示例10: getPropertyConstraints

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
private Map<String, Object> getPropertyConstraints(Object entity, Class<?> entityClass, UniqueConstraint u, String prefix) {
    Map<String, Object> values = newHashMap();
    for (String column : u.columnNames()) {
        Method method = columnNameToMethod(entityClass, column);
        if (method != null) {
            values.put(prefix + methodToProperty(method), invokeMethod(method, entity));
        } else {
            Field field = columnNameToField(entityClass, column);
            if (field != null) {
                values.put(prefix + field.getName(), getValueFromField(field, entity));
            }
        }
    }
    return values;
}
 
开发者ID:ddRPB,项目名称:rpb,代码行数:16,代码来源:JpaUniqueUtil.java


示例11: buildUniqueProperties

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
private void buildUniqueProperties(final UniqueConstraint[] uniqueConstraints) {
	for (final UniqueConstraint constraint : uniqueConstraints) {
		if (constraint.columnNames().length <= this.context.getMaxUniqueProperties()) {
			instpectUniqueConstraint(constraint);
		}
	}
}
 
开发者ID:liefke,项目名称:org.fastnate,代码行数:8,代码来源:EntityClass.java


示例12: getCourtReporters_

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
@ElementCollection
@CollectionTable(name="judgment_court_reporter", uniqueConstraints={@UniqueConstraint(name="judgment_court_reporter_unique", columnNames={"fk_judgment", "court_reporter"})})
@Column(name="court_reporter")
@OrderBy("court_reporter")
private List<String> getCourtReporters_() {
    return courtReporters;
}
 
开发者ID:CeON,项目名称:saos,代码行数:8,代码来源:Judgment.java


示例13: getLegalBases_

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
@ElementCollection
@CollectionTable(name="judgment_legal_bases", uniqueConstraints={@UniqueConstraint(name="judgment_legal_base_unique", columnNames={"fk_judgment", "legal_base"})})
@Column(name="legal_base")
@OrderBy("legal_base")
private List<String> getLegalBases_() {
    return legalBases;
}
 
开发者ID:CeON,项目名称:saos,代码行数:8,代码来源:Judgment.java


示例14: getLowerCourtJudgments_

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
@ElementCollection
@CollectionTable(name="judgment_lower_court_judgments", uniqueConstraints={@UniqueConstraint(name="judgment_lower_court_judgment_unique", columnNames={"fk_judgment", "lower_court_judgment"})})
@Column(name="lower_court_judgment")
@OrderBy("lower_court_judgment")
private List<String> getLowerCourtJudgments_() {
    return lowerCourtJudgments;
}
 
开发者ID:CeON,项目名称:saos,代码行数:8,代码来源:Judgment.java


示例15: getAuthors_

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
@ElementCollection
@CollectionTable(name="ct_judgment_opinion_author",
                joinColumns = {@JoinColumn(name = "fk_ct_judgment_opinion", nullable = false)},
                uniqueConstraints={@UniqueConstraint(name="ct_judgment_opinion_author_unique", columnNames={"fk_ct_judgment_opinion", "author"})})
@Column(name="author", nullable=false)
private List<String> getAuthors_() {
    return authors;
}
 
开发者ID:CeON,项目名称:saos,代码行数:9,代码来源:ConstitutionalTribunalJudgmentDissentingOpinion.java


示例16: getMembers

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
@OrderBy("id DESC")
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "user_has_role", //
		joinColumns = {@JoinColumn(name = "role_id", referencedColumnName = "id", nullable = false, updatable = false)}, inverseJoinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id", nullable = false, updatable = false)}, uniqueConstraints = {@UniqueConstraint(columnNames = {"user_id",
		                                                                                                                                                                                                                                                                                               "role_id"})})
public List<UserEntity> getMembers()
{
	return members;
}
 
开发者ID:petergeneric,项目名称:stdlib,代码行数:10,代码来源:RoleEntity.java


示例17: setUniqueConstraints

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
public void setUniqueConstraints(UniqueConstraint[] uniqueConstraints) {
	this.uniqueConstraints = TableBinder.buildUniqueConstraintHolders( uniqueConstraints );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:TableBinder.java


示例18: compositeUniqueConstraintErrorCode

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
private String compositeUniqueConstraintErrorCode(Identifiable<?> entity, UniqueConstraint uniqueConstraint) {
    return getEntityName(entity).toLowerCase() + "_"
            + (uniqueConstraint.name() == null ? "composite_unique_constraint_error" : uniqueConstraint.name().toLowerCase());
}
 
开发者ID:ddRPB,项目名称:rpb,代码行数:5,代码来源:JpaUniqueUtil.java


示例19: checkCompositeUniqueConstraint

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
private boolean checkCompositeUniqueConstraint(Identifiable<?> entity, Class<?> entityClass, UniqueConstraint u) {
    Map<String, Object> values = newHashMap();
    values.putAll(getPropertyConstraints(entity, entityClass, u, ""));
    return !existsInDatabaseOnAllObjects(entity, values);
}
 
开发者ID:ddRPB,项目名称:rpb,代码行数:6,代码来源:JpaUniqueUtil.java


示例20: UniqueConstraintDef

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
public UniqueConstraintDef(UniqueConstraint unique) {
	this.name=unique.name();
	this.columnNames=unique.columnNames();
}
 
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:5,代码来源:UniqueConstraintDef.java


示例21: getValidation

import javax.persistence.UniqueConstraint; //导入依赖的package包/类
/**
 * Gets the value of the validation property.
 *
 * <p>
 * This accessor method returns a reference to the live list, not a
 * snapshot. Therefore any modification you make to the returned list will
 * be present inside the JAXB object. This is why there is not a
 * <CODE>set</CODE> method for the validation property.
 *
 * <p>
 * For example, to add a new item, do as follows:
 * <pre>
 *    getValidation().add(newItem);
 * </pre>
 *
 *
 * <p>
 * Objects of the following type(s) are allowed in the list
 * {@link Validation }
 *
 *
 */
@ManyToMany(targetEntity = Validation.class, cascade = {
    CascadeType.ALL
})
@JoinTable(name = "VALIDATION_REPORT_VALIDATION", joinColumns = {
    @JoinColumn(name = "validationreport", referencedColumnName = "HJID")
}, inverseJoinColumns = {
    @JoinColumn(name = "validation", referencedColumnName = "HJID")
}, uniqueConstraints =
        @UniqueConstraint(columnNames = {"validationreport", "validation"}))
@OrderColumn(name = "VALIDATION_HJORDER")
public Set<Validation> getValidation() {
    if (validation == null) {
        validation = new HashSet<>();
    }
    return this.validation;
}
 
开发者ID:mpi2,项目名称:exportlibrary,代码行数:39,代码来源:ValidationReport.java



注:本文中的javax.persistence.UniqueConstraint类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。