下面列出了javax.persistence.metamodel.PluralAttribute#getJavaMember ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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();
}
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;
}