Java Code Examples for javax.persistence.AccessType#FIELD

The following examples show how to use javax.persistence.AccessType#FIELD . 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: PropertyAccessMixedImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
protected static AccessType getAccessType(Class<?> containerJavaType, String propertyName) {
	Field field = fieldOrNull( containerJavaType, propertyName );
	AccessType fieldAccessType = getAccessTypeOrNull( field );
	if ( fieldAccessType != null ) {
		return fieldAccessType;
	}
	AccessType methodAccessType = getAccessTypeOrNull( getterMethodOrNull( containerJavaType, propertyName ) );
	if ( methodAccessType != null ) {
		return methodAccessType;
	}
	// No @Access on property or field; check to see if containerJavaType has an explicit @Access
	AccessType classAccessType = getAccessTypeOrNull( containerJavaType );
	if ( classAccessType != null ) {
		return classAccessType;
	}
	return field != null ? AccessType.FIELD : AccessType.PROPERTY;
}
 
Example 2
Source File: PersistentAttributesHelper.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public static <T extends Annotation> T getAnnotation(CtClass ctClass, String attributeName, Class<T> annotation) {
	AccessType classAccessType = getAccessTypeOrNull( ctClass );
	CtField field = findFieldOrNull( ctClass, attributeName );
	CtMethod getter = findGetterOrNull( ctClass, attributeName );

	if ( classAccessType == AccessType.FIELD || ( field != null && getAccessTypeOrNull( field ) == AccessType.FIELD ) ) {
		return field == null ? null : getAnnotationOrNull( field, annotation );
	}
	if ( classAccessType == AccessType.PROPERTY || ( getter != null && getAccessTypeOrNull( getter ) == AccessType.PROPERTY ) ) {
		return getter == null ? null : getAnnotationOrNull( getter, annotation );
	}

	T found = ( getter == null ? null : getAnnotationOrNull( getter, annotation ) );
	if ( found == null && field != null ) {
		return getAnnotationOrNull( field, annotation );
	}
	return found;
}
 
Example 3
Source File: PersistentAttributesHelper.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Consistent with hasAnnotation()
 */
private static String inferTypeName(CtClass ctClass, String attributeName ) {
	AccessType classAccessType = getAccessTypeOrNull( ctClass );
	CtField field = findFieldOrNull( ctClass, attributeName );
	CtMethod getter = findGetterOrNull( ctClass, attributeName );

	if ( classAccessType == AccessType.FIELD || ( field != null && getAccessTypeOrNull( field ) == AccessType.FIELD ) ) {
		return field == null ? null : inferFieldTypeName( field );
	}
	if ( classAccessType == AccessType.PROPERTY || ( getter != null && getAccessTypeOrNull( getter ) == AccessType.PROPERTY ) ) {
		return getter == null ? null : inferMethodTypeName( getter );
	}

	String found = ( getter == null ? null : inferMethodTypeName( getter ) );
	if ( found == null && field != null ) {
		return inferFieldTypeName( field );
	}
	return found;
}
 
Example 4
Source File: BiDirectionalAssociationHandler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private static TypeDescription.Generic target(FieldDescription persistentField) {
	AnnotationDescription.Loadable<Access> access = persistentField.getDeclaringType().asErasure().getDeclaredAnnotations().ofType( Access.class );
	if ( access != null && access.loadSilent().value() == AccessType.FIELD ) {
		return persistentField.getType();
	}
	else {
		MethodDescription getter = EnhancerImpl.getterOf( persistentField );
		if ( getter == null ) {
			return persistentField.getType();
		}
		else {
			return getter.getReturnType();
		}
	}
}
 
Example 5
Source File: MCRCategoryImpl.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
@Override
@OneToMany(targetEntity = MCRCategoryImpl.class,
    cascade = {
        CascadeType.ALL },
    mappedBy = "parent")
@OrderColumn(name = "positionInParent")
@Access(AccessType.FIELD)
public List<MCRCategory> getChildren() {
    return super.getChildren();
}
 
Example 6
Source File: MCRCategoryImpl.java    From mycore with GNU General Public License v3.0 4 votes vote down vote up
@ManyToOne(optional = true, targetEntity = MCRCategoryImpl.class)
@JoinColumn(name = "parentID")
@Access(AccessType.FIELD)
public MCRCategory getParent() {
    return super.getParent();
}