javax.persistence.Access Java Examples

The following examples show how to use javax.persistence.Access. 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: JPAOverriddenAnnotationReader.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void getAccessType(List<Annotation> annotationList, Element element) {
	if ( element == null ) {
		return;
	}
	String access = element.attributeValue( "access" );
	if ( access != null ) {
		AnnotationDescriptor ad = new AnnotationDescriptor( Access.class );
		AccessType type;
		try {
			type = AccessType.valueOf( access );
		}
		catch ( IllegalArgumentException e ) {
			throw new AnnotationException( access + " is not a valid access type. Check you xml confguration." );
		}

		if ( ( AccessType.PROPERTY.equals( type ) && this.element instanceof Method ) ||
				( AccessType.FIELD.equals( type ) && this.element instanceof Field ) ) {
			return;
		}

		ad.setValue( "value", type );
		annotationList.add( AnnotationFactory.create( ad ) );
	}
}
 
Example #2
Source File: Address.java    From vaadinator with Apache License 2.0 5 votes vote down vote up
@Column(length = 1024)
@Access(AccessType.PROPERTY)
public String getMagFilmeAsString() {
	StringBuffer res = new StringBuffer();
	Set<Filme> set = getMagFilme();
	if (set != null) {
		for (Filme f : set) {
			if (res.length() > 0) {
				res.append(",");
			}
			res.append(f.name());
		}
	}
	return res.toString();
}
 
Example #3
Source File: PropertyContainer.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private AccessType determineLocalClassDefinedAccessStrategy() {
	AccessType classDefinedAccessType;

	AccessType hibernateDefinedAccessType = AccessType.DEFAULT;
	AccessType jpaDefinedAccessType = AccessType.DEFAULT;

	org.hibernate.annotations.AccessType accessType = xClass.getAnnotation( org.hibernate.annotations.AccessType.class );
	if ( accessType != null ) {
		hibernateDefinedAccessType = AccessType.getAccessStrategy( accessType.value() );
	}

	Access access = xClass.getAnnotation( Access.class );
	if ( access != null ) {
		jpaDefinedAccessType = AccessType.getAccessStrategy( access.value() );
	}

	if ( hibernateDefinedAccessType != AccessType.DEFAULT
			&& jpaDefinedAccessType != AccessType.DEFAULT
			&& hibernateDefinedAccessType != jpaDefinedAccessType ) {
		throw new MappingException(
				"@AccessType and @Access specified with contradicting values. Use of @Access only is recommended. "
		);
	}

	if ( hibernateDefinedAccessType != AccessType.DEFAULT ) {
		classDefinedAccessType = hibernateDefinedAccessType;
	}
	else {
		classDefinedAccessType = jpaDefinedAccessType;
	}
	return classDefinedAccessType;
}
 
Example #4
Source File: Address.java    From vaadinator with Apache License 2.0 5 votes vote down vote up
@Column(length = 1024)
@Access(AccessType.PROPERTY)
public String getMagFilmeAsString() {
	StringBuffer res = new StringBuffer();
	Set<Filme> set = getMagFilme();
	if (set != null) {
		for (Filme f : set) {
			if (res.length() > 0) {
				res.append(",");
			}
			res.append(f.name());
		}
	}
	return res.toString();
}
 
Example #5
Source File: SavedSearch.java    From find with MIT License 5 votes vote down vote up
@SuppressWarnings("unused")
@Access(AccessType.PROPERTY)
@Column(name = Table.Column.DATE_RANGE_TYPE)
@JsonIgnore
public Integer getDateRangeInt() {
    return dateRange == null ? null : dateRange.getId();
}
 
Example #6
Source File: MybatisPersistentPropertyImpl.java    From spring-data-mybatis with Apache License 2.0 5 votes vote down vote up
@Nullable
private Boolean detectPropertyAccess() {

	org.springframework.data.annotation.AccessType accessType = findAnnotation(
			org.springframework.data.annotation.AccessType.class);

	if (accessType != null) {
		return Type.PROPERTY.equals(accessType.value());
	}

	Access access = findAnnotation(Access.class);

	if (access != null) {
		return AccessType.PROPERTY.equals(access.value());
	}

	accessType = findPropertyOrOwnerAnnotation(
			org.springframework.data.annotation.AccessType.class);

	if (accessType != null) {
		return Type.PROPERTY.equals(accessType.value());
	}

	access = findPropertyOrOwnerAnnotation(Access.class);

	if (access != null) {
		return AccessType.PROPERTY.equals(access.value());
	}

	return null;
}
 
Example #7
Source File: Zone.java    From cosmic with Apache License 2.0 5 votes vote down vote up
@Access(AccessType.PROPERTY)
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
public long getId() {
    return super.getId();
}
 
Example #8
Source File: EntityBinder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public AccessType getExplicitAccessType(XAnnotatedElement element) {
	AccessType accessType = null;

	AccessType hibernateAccessType = null;
	AccessType jpaAccessType = null;

	org.hibernate.annotations.AccessType accessTypeAnnotation = element.getAnnotation( org.hibernate.annotations.AccessType.class );
	if ( accessTypeAnnotation != null ) {
		hibernateAccessType = AccessType.getAccessStrategy( accessTypeAnnotation.value() );
	}

	Access access = element.getAnnotation( Access.class );
	if ( access != null ) {
		jpaAccessType = AccessType.getAccessStrategy( access.value() );
	}

	if ( hibernateAccessType != null && jpaAccessType != null && hibernateAccessType != jpaAccessType ) {
		throw new MappingException(
				"Found @Access and @AccessType with conflicting values on a property in class " + annotatedClass.toString()
		);
	}

	if ( hibernateAccessType != null ) {
		accessType = hibernateAccessType;
	}
	else if ( jpaAccessType != null ) {
		accessType = jpaAccessType;
	}

	return accessType;
}
 
Example #9
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 #10
Source File: PropertyAccessMixedImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private static AccessType getAccessTypeOrNull(AnnotatedElement element) {
	if ( element == null ) {
		return null;
	}
	Access elementAccess = element.getAnnotation( Access.class );
	return elementAccess == null ? null : elementAccess.value();
}
 
Example #11
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 #12
Source File: PropertyInferredData.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public AccessType getDefaultAccess() throws MappingException {
	AccessType accessType = defaultAccess;

	AccessType hibernateAccessType = AccessType.DEFAULT;
	AccessType jpaAccessType = AccessType.DEFAULT;

	org.hibernate.annotations.AccessType accessTypeAnnotation = property.getAnnotation( org.hibernate.annotations.AccessType.class );
	if ( accessTypeAnnotation != null ) {
		hibernateAccessType = AccessType.getAccessStrategy( accessTypeAnnotation.value() );
	}

	Access access = property.getAnnotation( Access.class );
	if ( access != null ) {
		jpaAccessType = AccessType.getAccessStrategy( access.value() );
	}

	if ( hibernateAccessType != AccessType.DEFAULT
			&& jpaAccessType != AccessType.DEFAULT
			&& hibernateAccessType != jpaAccessType ) {

		StringBuilder builder = new StringBuilder();
		builder.append( property.toString() );
		builder.append(
				" defines @AccessType and @Access with contradicting values. Use of @Access only is recommended."
		);
		throw new MappingException( builder.toString() );
	}

	if ( hibernateAccessType != AccessType.DEFAULT ) {
		accessType = hibernateAccessType;
	}
	else if ( jpaAccessType != AccessType.DEFAULT ) {
		accessType = jpaAccessType;
	}
	return accessType;
}
 
Example #13
Source File: ContactResource.java    From nomulus with Apache License 2.0 4 votes vote down vote up
@Override
@javax.persistence.Id
@Access(AccessType.PROPERTY)
public String getRepoId() {
  return super.getRepoId();
}
 
Example #14
Source File: Zone.java    From cosmic with Apache License 2.0 4 votes vote down vote up
@Access(AccessType.PROPERTY)
@Column(name = "name")
public String getName() {
    return super.getName();
}
 
Example #15
Source File: Zone.java    From cosmic with Apache License 2.0 4 votes vote down vote up
@Access(AccessType.PROPERTY)
@Column(name = "removed")
public Date getRemoved() {
    return super.getRemoved();
}
 
Example #16
Source File: Zone.java    From cosmic with Apache License 2.0 4 votes vote down vote up
@Access(AccessType.PROPERTY)
@Column(name = "router_mac_address", updatable = false, nullable = false)
public String getRouterMacAddress() {
    return super.getRouterMacAddress();
}
 
Example #17
Source File: Zone.java    From cosmic with Apache License 2.0 4 votes vote down vote up
@Access(AccessType.PROPERTY)
@Column(name = "userdata_provider")
public String getUserDataProvider() {
    return super.getUserDataProvider();
}
 
Example #18
Source File: Zone.java    From cosmic with Apache License 2.0 4 votes vote down vote up
@Access(AccessType.PROPERTY)
@Column(name = "uuid")
public String getUuid() {
    return super.getUuid();
}
 
Example #19
Source File: Zone.java    From cosmic with Apache License 2.0 4 votes vote down vote up
@Access(AccessType.PROPERTY)
@Column(name = "vpn_provider")
public String getVpnProvider() {
    return super.getVpnProvider();
}
 
Example #20
Source File: Zone.java    From cosmic with Apache License 2.0 4 votes vote down vote up
@Access(AccessType.PROPERTY)
@Column(name = "zone_token")
public String getZoneToken() {
    return super.getZoneToken();
}
 
Example #21
Source File: PersistentAttributesHelper.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private static AccessType getAccessTypeOrNull(CtMember ctMember) {
	Access access = getAnnotationOrNull( ctMember, Access.class );
	return access == null ? null : access.value();
}
 
Example #22
Source File: HostResource.java    From nomulus with Apache License 2.0 4 votes vote down vote up
@Override
@javax.persistence.Id
@Access(AccessType.PROPERTY) // to tell it to use the non-default property-as-ID
public String getRepoId() {
  return super.getRepoId();
}
 
Example #23
Source File: DomainBase.java    From nomulus with Apache License 2.0 4 votes vote down vote up
@Override
@javax.persistence.Id
@Access(AccessType.PROPERTY)
public String getRepoId() {
  return super.getRepoId();
}
 
Example #24
Source File: AbstractJpaBaseEntity.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
@Access(AccessType.PROPERTY)
@Column(name = "created_at", insertable = true, updatable = false, nullable = false)
public long getCreatedAt() {
    return createdAt;
}
 
Example #25
Source File: AbstractJpaBaseEntity.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
@Access(AccessType.PROPERTY)
@Column(name = "created_by", insertable = true, updatable = false, nullable = false, length = 64)
public String getCreatedBy() {
    return createdBy;
}
 
Example #26
Source File: AbstractJpaBaseEntity.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
@Access(AccessType.PROPERTY)
@Column(name = "last_modified_at", insertable = true, updatable = true, nullable = false)
public long getLastModifiedAt() {
    return lastModifiedAt;
}
 
Example #27
Source File: AbstractJpaBaseEntity.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
@Access(AccessType.PROPERTY)
@Column(name = "last_modified_by", insertable = true, updatable = true, nullable = false, length = 64)
public String getLastModifiedBy() {
    return lastModifiedBy;
}
 
Example #28
Source File: ContractApplication.java    From vaadinator with Apache License 2.0 4 votes vote down vote up
@Access(AccessType.PROPERTY)
public int getMonthlyFee() {
	// (we want to have it in the DB also so we can query - see below)
	return 0 + (isRetirementProtection() ? 1111 : 0) + (isLazinessProtection() ? 8888 : 0);
}
 
Example #29
Source File: Zone.java    From cosmic with Apache License 2.0 4 votes vote down vote up
@Access(AccessType.PROPERTY)
@Column(name = "firewall_provider")
public String getFirewallProvider() {
    return super.getFirewallProvider();
}
 
Example #30
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();
}