javax.persistence.metamodel.PluralAttribute#getJavaMember ( )源码实例Demo

下面列出了javax.persistence.metamodel.PluralAttribute#getJavaMember ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: javaee-lab   文件: MetamodelUtil.java
/**
 * Retrieves cascade from metamodel attribute
 *
 * @param attribute given pluaral attribute
 * @return an empty collection if no jpa relation annotation can be found.
 */
public Collection<CascadeType> getCascades(PluralAttribute<?, ?, ?> attribute) {
    if (attribute.getJavaMember() instanceof AccessibleObject) {
        AccessibleObject accessibleObject = (AccessibleObject) attribute.getJavaMember();
        OneToMany oneToMany = accessibleObject.getAnnotation(OneToMany.class);
        if (oneToMany != null) {
            return newArrayList(oneToMany.cascade());
        }
        ManyToMany manyToMany = accessibleObject.getAnnotation(ManyToMany.class);
        if (manyToMany != null) {
            return newArrayList(manyToMany.cascade());
        }
    }
    return newArrayList();
}
 
源代码2 项目: javaee-lab   文件: MetamodelUtil.java
public boolean isOrphanRemoval(PluralAttribute<?, ?, ?> attribute) {
    if (attribute.getJavaMember() instanceof AccessibleObject) {
        AccessibleObject accessibleObject = (AccessibleObject) attribute.getJavaMember();
        OneToMany oneToMany = accessibleObject.getAnnotation(OneToMany.class);
        if (oneToMany != null) {
            return oneToMany.orphanRemoval();
        }
    }
    return true;
}