Java Code Examples for javax.persistence.metamodel.PluralAttribute#getJavaMember()
The following examples show how to use
javax.persistence.metamodel.PluralAttribute#getJavaMember() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetamodelUtil.java From javaee-lab with Apache License 2.0 | 5 votes |
/** * 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(); }
Example 2
Source File: MetamodelUtil.java From javaee-lab with Apache License 2.0 | 5 votes |
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; }