类javax.persistence.JoinColumns源码实例Demo

下面列出了怎么用javax.persistence.JoinColumns的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: olingo-odata2   文件: JPAEdmProperty.java
private void addForeignKey(final Attribute<?, ?> jpaAttribute) throws ODataJPAModelException,
    ODataJPARuntimeException {

  AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember();
  joinColumnNames = null;
  if (annotatedElement == null) {
    return;
  }
  JoinColumn joinColumn = annotatedElement.getAnnotation(JoinColumn.class);
  if (joinColumn == null) {
    JoinColumns joinColumns = annotatedElement.getAnnotation(JoinColumns.class);
    if (joinColumns != null) {
      for (JoinColumn jc : joinColumns.value()) {
        buildForeignKey(jc, jpaAttribute);
      }
    }
  } else {
    buildForeignKey(joinColumn, jpaAttribute);
  }
}
 
源代码2 项目: lams   文件: JPAOverriddenAnnotationReader.java
private void buildJoinColumns(List<Annotation> annotationList, Element element) {
	JoinColumn[] joinColumns = getJoinColumns( element, false );
	if ( joinColumns.length > 0 ) {
		AnnotationDescriptor ad = new AnnotationDescriptor( JoinColumns.class );
		ad.setValue( "value", joinColumns );
		annotationList.add( AnnotationFactory.create( ad ) );
	}
}
 
源代码3 项目: hyperjaxb3   文件: CreateXAnnotations.java
public XAnnotation<?> createJoinColumns(List<JoinColumn> cJoinColumns) {
	return transform(
			JoinColumns.class,
			javax.persistence.JoinColumn.class,
			cJoinColumns,
			new Transformer<JoinColumn, XAnnotation<javax.persistence.JoinColumn>>() {
				public XAnnotation<javax.persistence.JoinColumn> transform(
						JoinColumn input) {
					return createJoinColumn(input);
				}
			});
}
 
源代码4 项目: ankush   文件: Node.java
/**
 * @return the configuration
 */
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JoinColumns({
		@JoinColumn(name = "clusterId", referencedColumnName = "clusterId"),
		@JoinColumn(name = "host", referencedColumnName = "publicIp") })
public List<Event> getEvents() {
	return events;
}
 
源代码5 项目: ankush   文件: Node.java
/**
 * @return the configuration
 */
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JoinColumns({
		@JoinColumn(name = "clusterId", referencedColumnName = "clusterId"),
		@JoinColumn(name = "host", referencedColumnName = "publicIp") })
public List<Configuration> getConfiguration() {
	return configuration;
}
 
源代码6 项目: lams   文件: AnnotationBinder.java
private static int addProperty(
		PropertyContainer propertyContainer,
		XProperty property,
		List<PropertyData> inFlightPropertyDataList,
		MetadataBuildingContext context) {
	// see if inFlightPropertyDataList already contains a PropertyData for this name,
	// and if so, skip it..
	for ( PropertyData propertyData : inFlightPropertyDataList ) {
		if ( propertyData.getPropertyName().equals( property.getName() ) ) {
			// EARLY EXIT!!!
			return 0;
		}
	}

	final XClass declaringClass = propertyContainer.getDeclaringClass();
	final XClass entity = propertyContainer.getEntityAtStake();
	int idPropertyCounter = 0;
	PropertyData propertyAnnotatedElement = new PropertyInferredData(
			declaringClass,
			property,
			propertyContainer.getClassLevelAccessType().getType(),
			context.getBootstrapContext().getReflectionManager()
	);

	/*
	 * put element annotated by @Id in front
	 * since it has to be parsed before any association by Hibernate
	 */
	final XAnnotatedElement element = propertyAnnotatedElement.getProperty();
	if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) {
		inFlightPropertyDataList.add( 0, propertyAnnotatedElement );
		/**
		 * The property must be put in hibernate.properties as it's a system wide property. Fixable?
		 * TODO support true/false/default on the property instead of present / not present
		 * TODO is @Column mandatory?
		 * TODO add method support
		 */
		if ( context.getBuildingOptions().isSpecjProprietarySyntaxEnabled() ) {
			if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) {
				String columnName = element.getAnnotation( Column.class ).name();
				for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) {
					if ( !prop.isAnnotationPresent( MapsId.class ) ) {
						/**
						 * The detection of a configured individual JoinColumn differs between Annotation
						 * and XML configuration processing.
						 */
						boolean isRequiredAnnotationPresent = false;
						JoinColumns groupAnnotation = prop.getAnnotation( JoinColumns.class );
						if ( (prop.isAnnotationPresent( JoinColumn.class )
								&& prop.getAnnotation( JoinColumn.class ).name().equals( columnName )) ) {
							isRequiredAnnotationPresent = true;
						}
						else if ( prop.isAnnotationPresent( JoinColumns.class ) ) {
							for ( JoinColumn columnAnnotation : groupAnnotation.value() ) {
								if ( columnName.equals( columnAnnotation.name() ) ) {
									isRequiredAnnotationPresent = true;
									break;
								}
							}
						}
						if ( isRequiredAnnotationPresent ) {
							//create a PropertyData fpr the specJ property holding the mapping
							PropertyData specJPropertyData = new PropertyInferredData(
									declaringClass,
									//same dec
									prop,
									// the actual @XToOne property
									propertyContainer.getClassLevelAccessType().getType(),
									//TODO we should get the right accessor but the same as id would do
									context.getBootstrapContext().getReflectionManager()
							);
							context.getMetadataCollector().addPropertyAnnotatedWithMapsIdSpecj(
									entity,
									specJPropertyData,
									element.toString()
							);
						}
					}
				}
			}
		}

		if ( element.isAnnotationPresent( ManyToOne.class ) || element.isAnnotationPresent( OneToOne.class ) ) {
			context.getMetadataCollector().addToOneAndIdProperty( entity, propertyAnnotatedElement );
		}
		idPropertyCounter++;
	}
	else {
		inFlightPropertyDataList.add( propertyAnnotatedElement );
	}
	if ( element.isAnnotationPresent( MapsId.class ) ) {
		context.getMetadataCollector().addPropertyAnnotatedWithMapsId( entity, propertyAnnotatedElement );
	}

	return idPropertyCounter;
}
 
源代码7 项目: olingo-odata2   文件: JPAJavaMemberMock.java
@Override
public Class<? extends Annotation> annotationType() {
  return JoinColumns.class;
}
 
源代码8 项目: ankush   文件: Node.java
/**
 * @return the configuration
 */
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JoinColumns({ @JoinColumn(name = "node", referencedColumnName = "publicIp") })
public List<Service> getServices() {
	return services;
}
 
private void extractJoinColumns() {
  /*
   * Check against Static Buffer whether the join column was already
   * extracted.
   */
  if (!jpaAttribute.equals(bufferedJPAAttribute)) {
    bufferedJPAAttribute = jpaAttribute;
    bufferedJoinColumns.clear();
  } else if (bufferedJoinColumns.isEmpty()) {
    roleExists = false;
    return;
  } else {
    roleExists = true;
    return;
  }

  AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute
      .getJavaMember();

  if (annotatedElement == null) {
    return;
  }

  JoinColumn joinColumn = annotatedElement
      .getAnnotation(JoinColumn.class);
  if (joinColumn == null) {
    JoinColumns joinColumns = annotatedElement
        .getAnnotation(JoinColumns.class);

    if (joinColumns != null) {
      JoinColumn[] joinColumnArray = joinColumns.value();

      for (JoinColumn element : joinColumnArray) {
        bufferedJoinColumns.add(element);
      }
    } else {
      return;
    }
  } else {
    bufferedJoinColumns.add(joinColumn);
  }
  roleExists = true;
}
 
源代码10 项目: cloud-odata-java   文件: JPAJavaMemberMock.java
@Override
public Class<? extends Annotation> annotationType() {
  return JoinColumns.class;
}
 
 类所在包
 类方法
 同包方法