类javax.persistence.Index源码实例Demo

下面列出了怎么用javax.persistence.Index的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jstarcraft-core   文件: HibernateMetadata.java
/**
 * 构造方法
 * 
 * @param metadata
 */
HibernateMetadata(Class<?> clazz) {
    ormClass = clazz;
    ormName = clazz.getName();
    ReflectionUtility.doWithFields(ormClass, (field) -> {
        if (Modifier.isStatic(field.getModifiers()) || Modifier.isTransient(field.getModifiers())) {
            return;
        }
        if (field.isAnnotationPresent(Version.class)) {
            versionName = field.getName();
            return;
        }
        Class<?> type = ClassUtility.primitiveToWrapper(field.getType());
        if (String.class == type) {
            fields.put(field.getName(), type);
        } else if (type.isEnum()) {
            fields.put(field.getName(), type);
        } else if (Collection.class.isAssignableFrom(type) || type.isArray()) {
            fields.put(field.getName(), List.class);
        } else if (Date.class.isAssignableFrom(type)) {
            fields.put(field.getName(), Date.class);
        } else {
            fields.put(field.getName(), Map.class);
        }
        if (field.isAnnotationPresent(Id.class) || field.isAnnotationPresent(EmbeddedId.class)) {
            primaryName = field.getName();
            primaryClass = type;
        }
    });
    Table table = clazz.getAnnotation(Table.class);
    if (table != null) {
        for (Index index : table.indexes()) {
            indexNames.add(index.columnList());
        }
    }
}
 
源代码2 项目: o2oa   文件: CheckCore.java
public static void checkLobIndex(List<Class<?>> classes) throws Exception {
	for (Class<?> cls : classes) {
		List<Field> fields = FieldUtils.getAllFieldsList(cls);
		for (Field field : fields) {
			Lob lob = field.getAnnotation(Lob.class);
			Index index = field.getAnnotation(Index.class);
			if ((null != lob) && (null != index)) {
				System.err.println(String.format("checkLobIndex error: class: %s, field: %s.", cls.getName(),
						field.getName()));
			}
		}
	}
}
 
源代码3 项目: o2oa   文件: CheckCore.java
public static void checkIdCreateTimeUpdateTimeSequenceIndex(List<Class<?>> classes) throws Exception {
	for (Class<?> cls : classes) {
		Field idField = FieldUtils.getField(cls, JpaObject.id_FIELDNAME, true);
		Field createTimeField = FieldUtils.getField(cls, JpaObject.createTime_FIELDNAME, true);
		Field updateTimeField = FieldUtils.getField(cls, JpaObject.updateTime_FIELDNAME, true);
		Field sequenceField = FieldUtils.getField(cls, JpaObject.sequence_FIELDNAME, true);
		if ((null != idField.getAnnotation(Index.class)) || (null != createTimeField.getAnnotation(Index.class))
				|| (null != updateTimeField.getAnnotation(Index.class))
				|| (null != sequenceField.getAnnotation(Index.class))) {
			System.err.println(
					String.format("checkIdCreateTimeUpdateTimeSequenceIndex error: class: %s.", cls.getName()));
		}
	}
}
 
源代码4 项目: lams   文件: JPAIndexHolder.java
public JPAIndexHolder(Index index) {
	StringTokenizer tokenizer = new StringTokenizer( index.columnList(), "," );
	List<String> tmp = new ArrayList<String>();
	while ( tokenizer.hasMoreElements() ) {
		tmp.add( tokenizer.nextToken().trim() );
	}
	this.name = index.name();
	this.columns = new String[tmp.size()];
	this.ordering = new String[tmp.size()];
	this.unique = index.unique();
	initializeColumns( columns, ordering, tmp );
}
 
源代码5 项目: lams   文件: JPAOverriddenAnnotationReader.java
private static void buildIndex(AnnotationDescriptor annotation, Element element){
	List indexElementList = element.elements( "index" );
	Index[] indexes = new Index[indexElementList.size()];
	for(int i=0;i<indexElementList.size();i++){
		Element subelement = (Element)indexElementList.get( i );
		AnnotationDescriptor indexAnn = new AnnotationDescriptor( Index.class );
		copyStringAttribute( indexAnn, subelement, "name", false );
		copyStringAttribute( indexAnn, subelement, "column-list", true );
		copyBooleanAttribute( indexAnn, subelement, "unique" );
		indexes[i] = AnnotationFactory.create( indexAnn );
	}
	annotation.setValue( "indexes", indexes );
}
 
源代码6 项目: mycore   文件: MCRUser.java
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "MCRUserAttr",
    joinColumns = @JoinColumn(name = "id"),
    indexes = { @Index(name = "MCRUserAttributes", columnList = "name, value"),
        @Index(name = "MCRUserValues", columnList = "value") })
@SortNatural
@XmlElementWrapper(name = "attributes")
@XmlElement(name = "attribute")
public SortedSet<MCRUserAttribute> getAttributes() {
    return this.attributes;
}
 
源代码7 项目: requery   文件: EntityType.java
@Override
public String[] tableUniqueIndexes() {
    if (annotationOf(javax.persistence.Table.class).isPresent()) {
        Index[] indexes = annotationOf(javax.persistence.Table.class)
                .map(javax.persistence.Table::indexes)
                .orElse(new Index[0]);
        Set<String> names = Stream.of(indexes).filter(Index::unique)
                .map(Index::name).collect(Collectors.toSet());
        return names.toArray(new String[names.size()]);
    }
    return annotationOf(Table.class).map(Table::uniqueIndexes).orElse(new String[]{});
}
 
源代码8 项目: scheduling   文件: TaskData.java
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "TASK_DATA_DEPENDENCIES", joinColumns = { @JoinColumn(name = "JOB_ID", referencedColumnName = "TASK_ID_JOB"),
                                                                  @JoinColumn(name = "TASK_ID", referencedColumnName = "TASK_ID_TASK") }, indexes = { @Index(name = "TASK_DATA_DEP_JOB_ID", columnList = "JOB_ID"),
                                                                                                                                                      @Index(name = "TASK_DATA_DEP_TASK_ID_JOB_ID", columnList = "TASK_ID,JOB_ID"),
                                                                                                                                                      @Index(name = "TASK_DATA_DEP_TASK_ID", columnList = "TASK_ID"), })
@BatchSize(size = 100)
public List<DBTaskId> getDependentTasks() {
    return dependentTasks;
}
 
源代码9 项目: scheduling   文件: TaskData.java
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "TASK_DATA_JOINED_BRANCHES", joinColumns = { @JoinColumn(name = "JOB_ID", referencedColumnName = "TASK_ID_JOB"),
                                                                     @JoinColumn(name = "TASK_ID", referencedColumnName = "TASK_ID_TASK") }, indexes = { @Index(name = "TASK_DATA_JB_JOB_ID", columnList = "JOB_ID"),
                                                                                                                                                         @Index(name = "TASK_DATA_JB_TASK_ID_JOB_ID", columnList = "TASK_ID,JOB_ID"),
                                                                                                                                                         @Index(name = "TASK_DATA_JB_TASK_ID", columnList = "TASK_ID"), })
@BatchSize(size = 100)
public List<DBTaskId> getJoinedBranches() {
    return joinedBranches;
}
 
源代码10 项目: vpn-over-dns   文件: User.java
@OneToMany(cascade = javax.persistence.CascadeType.ALL, fetch = javax.persistence.FetchType.EAGER)
@JoinTable(indexes = { @Index(columnList = "user_id"), @Index(columnList = "accounts_id") })
public Collection<Account> getAccounts() {
	return accounts;
}
 
 类所在包
 类方法
 同包方法