javax.persistence.AttributeOverride Java Examples

The following examples show how to use javax.persistence.AttributeOverride. 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
/**
 * @param mergeWithAnnotations Whether to use Java annotations for this
 * element, if present and not disabled by the XMLContext defaults.
 * In some contexts (such as an association mapping) merging with
 * annotations is never allowed.
 */
private AttributeOverrides mergeAttributeOverrides(XMLContext.Default defaults, List<AttributeOverride> attributes, boolean mergeWithAnnotations) {
	if ( mergeWithAnnotations && defaults.canUseJavaAnnotations() ) {
		AttributeOverride annotation = getPhysicalAnnotation( AttributeOverride.class );
		addAttributeOverrideIfNeeded( annotation, attributes );
		AttributeOverrides annotations = getPhysicalAnnotation( AttributeOverrides.class );
		if ( annotations != null ) {
			for ( AttributeOverride current : annotations.value() ) {
				addAttributeOverrideIfNeeded( current, attributes );
			}
		}
	}
	if ( attributes.size() > 0 ) {
		AnnotationDescriptor ad = new AnnotationDescriptor( AttributeOverrides.class );
		ad.setValue( "value", attributes.toArray( new AttributeOverride[attributes.size()] ) );
		return AnnotationFactory.create( ad );
	}
	else {
		return null;
	}
}
 
Example #2
Source File: GenericDaoBase.java    From cosmic with Apache License 2.0 6 votes vote down vote up
@DB()
protected String buildSelectByIdSql(final StringBuilder sql) {
    if (_idField == null) {
        return null;
    }

    if (_idField.getAnnotation(EmbeddedId.class) == null) {
        sql.append(_table).append(".").append(DbUtil.getColumnName(_idField, null)).append(" = ? ");
    } else {
        final Class<?> clazz = _idField.getClass();
        final AttributeOverride[] overrides = DbUtil.getAttributeOverrides(_idField);
        for (final Field field : clazz.getDeclaredFields()) {
            sql.append(_table).append(".").append(DbUtil.getColumnName(field, overrides)).append(" = ? AND ");
        }
        sql.delete(sql.length() - 4, sql.length());
    }

    return sql.toString();
}
 
Example #3
Source File: JPAOverriddenAnnotationReader.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private List<AttributeOverride> buildAttributeOverrides(List<Element> subelements, String nodeName) {
	List<AttributeOverride> overrides = new ArrayList<>();
	if ( subelements != null && subelements.size() > 0 ) {
		for ( Element current : subelements ) {
			if ( !current.getName().equals( nodeName ) ) {
				continue;
			}
			AnnotationDescriptor override = new AnnotationDescriptor( AttributeOverride.class );
			copyStringAttribute( override, current, "name", true );
			Element column = current.element( "column" );
			override.setValue( "column", getColumn( column, true, current ) );
			overrides.add( AnnotationFactory.create( override ) );
		}
	}
	return overrides;
}
 
Example #4
Source File: MapBinder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private boolean mappingDefinedAttributeOverrideOnMapKey(XProperty property) {
	if ( property.isAnnotationPresent( AttributeOverride.class ) ) {
		return namedMapKey( property.getAnnotation( AttributeOverride.class ) );
	}

	if ( property.isAnnotationPresent( AttributeOverrides.class ) ) {
		final AttributeOverrides annotations = property.getAnnotation( AttributeOverrides.class );
		for ( AttributeOverride attributeOverride : annotations.value() ) {
			if ( namedMapKey( attributeOverride ) ) {
				return true;
			}
		}
	}

	return false;
}
 
Example #5
Source File: GenericDaoBase.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
@DB()
protected String buildSelectByIdSql(final StringBuilder sql) {
    if (_idField == null) {
        return null;
    }

    if (_idField.getAnnotation(EmbeddedId.class) == null) {
        sql.append(_table).append(".").append(DbUtil.getColumnName(_idField, null)).append(" = ? ");
    } else {
        final Class<?> clazz = _idField.getClass();
        final AttributeOverride[] overrides = DbUtil.getAttributeOverrides(_idField);
        for (final Field field : clazz.getDeclaredFields()) {
            sql.append(_table).append(".").append(DbUtil.getColumnName(field, overrides)).append(" = ? AND ");
        }
        sql.delete(sql.length() - 4, sql.length());
    }

    return sql.toString();
}
 
Example #6
Source File: DbUtil.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
public static final AttributeOverride[] getAttributeOverrides(AnnotatedElement ae) {
    AttributeOverride[] overrides = null;

    AttributeOverrides aos = ae.getAnnotation(AttributeOverrides.class);
    if (aos != null) {
        overrides = aos.value();
    }

    if (overrides == null || overrides.length == 0) {
        AttributeOverride override = ae.getAnnotation(AttributeOverride.class);
        if (override != null) {
            overrides = new AttributeOverride[1];
            overrides[0] = override;
        } else {
            overrides = new AttributeOverride[0];
        }
    }

    return overrides;
}
 
Example #7
Source File: DbUtil.java    From cosmic with Apache License 2.0 6 votes vote down vote up
public static final AttributeOverride[] getAttributeOverrides(final AnnotatedElement ae) {
    AttributeOverride[] overrides = null;

    final AttributeOverrides aos = ae.getAnnotation(AttributeOverrides.class);
    if (aos != null) {
        overrides = aos.value();
    }

    if (overrides == null || overrides.length == 0) {
        final AttributeOverride override = ae.getAnnotation(AttributeOverride.class);
        if (override != null) {
            overrides = new AttributeOverride[1];
            overrides[0] = override;
        } else {
            overrides = new AttributeOverride[0];
        }
    }

    return overrides;
}
 
Example #8
Source File: ViewApplicationActionEventPageElementAnnualSummary.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the value of the embeddedId property.
 * 
 * @return
 *     possible object is
 *     {@link ApplicationActionEventPageElementPeriodSummaryEmbeddedId }
 *     
 */
@EmbeddedId
@AttributeOverrides({
    @AttributeOverride(name = "createdDate", column = @Column(name = "EMBEDDED_ID_CREATED_DATE")),
    @AttributeOverride(name = "page", column = @Column(name = "EMBEDDED_ID_PAGE")),
    @AttributeOverride(name = "elementId", column = @Column(name = "EMBEDDED_ID_ELEMENT_ID"))
})
public ApplicationActionEventPageElementPeriodSummaryEmbeddedId getEmbeddedId() {
    return embeddedId;
}
 
Example #9
Source File: CountryElement.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the lending type.
*
* @return the lending type
*/
  @Embedded
  @AttributeOverrides({
      @AttributeOverride(name = "value", column = @Column(name = "LENDING_TYPE_VALUE")),
      @AttributeOverride(name = "id", column = @Column(name = "LENDING_TYPE_ID"))
  })
  public LendingType getLendingType() {
      return lendingType;
  }
 
Example #10
Source File: ViewApplicationActionEventPageModeWeeklySummary.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the value of the embeddedId property.
 * 
 * @return
 *     possible object is
 *     {@link ApplicationActionEventPageModePeriodSummaryEmbeddedId }
 *     
 */
@EmbeddedId
@AttributeOverrides({
    @AttributeOverride(name = "createdDate", column = @Column(name = "EMBEDDED_ID_CREATED_DATE")),
    @AttributeOverride(name = "page", column = @Column(name = "EMBEDDED_ID_PAGE")),
    @AttributeOverride(name = "pageMode", column = @Column(name = "EMBEDDED_ID_PAGE_MODE"))
})
public ApplicationActionEventPageModePeriodSummaryEmbeddedId getEmbeddedId() {
    return embeddedId;
}
 
Example #11
Source File: ViewRiksdagenPartyDocumentDailySummary.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the value of the embeddedId property.
 * 
 * @return
 *     possible object is
 *     {@link RiksdagenDocumentPartySummaryEmbeddedId }
 *     
 */
@EmbeddedId
@AttributeOverrides({
    @AttributeOverride(name = "publicDate", column = @Column(name = "EMBEDDED_ID_PUBLIC_DATE")),
    @AttributeOverride(name = "partyShortCode", column = @Column(name = "EMBEDDED_ID_PARTY_SHORT_CODE")),
    @AttributeOverride(name = "documentType", column = @Column(name = "EMBEDDED_ID_DOCUMENT_TYPE"))
})
public RiksdagenDocumentPartySummaryEmbeddedId getEmbeddedId() {
    return embeddedId;
}
 
Example #12
Source File: ViewRiksdagenDocumentTypeDailySummary.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the value of the embeddedId property.
 * 
 * @return
 *     possible object is
 *     {@link RiksdagenDocumentTypeSummaryEmbeddedId }
 *     
 */
@EmbeddedId
@AttributeOverrides({
    @AttributeOverride(name = "publicDate", column = @Column(name = "EMBEDDED_ID_PUBLIC_DATE")),
    @AttributeOverride(name = "documentType", column = @Column(name = "EMBEDDED_ID_DOCUMENT_TYPE"))
})
public RiksdagenDocumentTypeSummaryEmbeddedId getEmbeddedId() {
    return embeddedId;
}
 
Example #13
Source File: NominalLabelTrainingData.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
@EmbeddedId
@AttributeOverrides({
		@AttributeOverride(name = "documentId", column = @Column(name = "documentID", nullable = false)),
		@AttributeOverride(name = "crisisId", column = @Column(name = "crisisID", nullable = false)),
		@AttributeOverride(name = "nominalLabelId", column = @Column(name = "nominalLabelID", nullable = false)),
		@AttributeOverride(name = "nominalAttributeId", column = @Column(name = "nominalAttributeID", nullable = false)),
		@AttributeOverride(name = "wordFeatures", column = @Column(name = "wordFeatures", length = 65535)) })
public NominalLabelTrainingDataId getId() {
	return this.id;
}
 
Example #14
Source File: PublisherAssertion.java    From juddi with Apache License 2.0 5 votes vote down vote up
@EmbeddedId
@AttributeOverrides({
        @AttributeOverride(name = "fromKey", column = @Column(name = "from_key", nullable = false, length = 255)),
	@AttributeOverride(name = "toKey", column = @Column(name = "to_key", nullable = false, length = 255))})
public PublisherAssertionId getId() {
        return this.id;
}
 
Example #15
Source File: DbUtil.java    From cloudstack with Apache License 2.0 5 votes vote down vote up
public static String getColumnName(Field field, AttributeOverride[] overrides) {
    if (overrides != null) {
        for (AttributeOverride override : overrides) {
            if (override.name().equals(field.getName())) {
                return override.column().name();
            }
        }
    }

    assert (field.getAnnotation(Embedded.class) == null) : "Cannot get column name from embedded field: " + field.getName();

    Column column = field.getAnnotation(Column.class);
    return column != null ? column.name() : field.getName();
}
 
Example #16
Source File: NominalLabelEvaluationData.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
@EmbeddedId
@AttributeOverrides({
		@AttributeOverride(name = "documentId", column = @Column(name = "documentID", nullable = false)),
		@AttributeOverride(name = "crisisId", column = @Column(name = "crisisID", nullable = false)),
		@AttributeOverride(name = "nominalLabelId", column = @Column(name = "nominalLabelID", nullable = false)),
		@AttributeOverride(name = "nominalAttributeId", column = @Column(name = "nominalAttributeID", nullable = false)),
		@AttributeOverride(name = "wordFeatures", column = @Column(name = "wordFeatures", length = 65535)) })
public NominalLabelEvaluationDataId getId() {
	return this.id;
}
 
Example #17
Source File: DocumentNominalLabel.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
@EmbeddedId
@AttributeOverrides({
		@AttributeOverride(name = "documentId", column = @Column(name = "documentID", nullable = false)),
		@AttributeOverride(name = "nominalLabelId", column = @Column(name = "nominalLabelID", nullable = false)),
		@AttributeOverride(name = "userId", column = @Column(name = "userID", nullable = false)) })
public DocumentNominalLabelId getId() {
	return this.id;
}
 
Example #18
Source File: TaskAnswer.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
@EmbeddedId
@AttributeOverrides({
	@AttributeOverride(name = "taskId", column = @Column(name = "taskID", unique = true, nullable = false)),
	@AttributeOverride(name = "documentId", column = @Column(name = "documentID", nullable = false)),
	@AttributeOverride(name = "userId", column = @Column(name = "userID", nullable = false)) })
public TaskAnswerId getId() {
	return this.id;
}
 
Example #19
Source File: WorldBankData.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the country.
*
* @return the country
*/
  @Embedded
  @AttributeOverrides({
      @AttributeOverride(name = "value", column = @Column(name = "COUNTRY_VALUE")),
      @AttributeOverride(name = "id", column = @Column(name = "COUNTRY_ID"))
  })
  public Country getCountry() {
      return country;
  }
 
Example #20
Source File: ViewApplicationActionEventPageHourlySummary.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the value of the embeddedId property.
 * 
 * @return
 *     possible object is
 *     {@link ApplicationActionEventPagePeriodSummaryEmbeddedId }
 *     
 */
@EmbeddedId
@AttributeOverrides({
    @AttributeOverride(name = "createdDate", column = @Column(name = "EMBEDDED_ID_CREATED_DATE")),
    @AttributeOverride(name = "page", column = @Column(name = "EMBEDDED_ID_PAGE"))
})
public ApplicationActionEventPagePeriodSummaryEmbeddedId getEmbeddedId() {
    return embeddedId;
}
 
Example #21
Source File: ViewApplicationActionEventPageAnnualSummary.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the value of the embeddedId property.
 * 
 * @return
 *     possible object is
 *     {@link ApplicationActionEventPagePeriodSummaryEmbeddedId }
 *     
 */
@EmbeddedId
@AttributeOverrides({
    @AttributeOverride(name = "createdDate", column = @Column(name = "EMBEDDED_ID_CREATED_DATE")),
    @AttributeOverride(name = "page", column = @Column(name = "EMBEDDED_ID_PAGE"))
})
public ApplicationActionEventPagePeriodSummaryEmbeddedId getEmbeddedId() {
    return embeddedId;
}
 
Example #22
Source File: ViewApplicationActionEventPageModeAnnualSummary.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the value of the embeddedId property.
 * 
 * @return
 *     possible object is
 *     {@link ApplicationActionEventPageModePeriodSummaryEmbeddedId }
 *     
 */
@EmbeddedId
@AttributeOverrides({
    @AttributeOverride(name = "createdDate", column = @Column(name = "EMBEDDED_ID_CREATED_DATE")),
    @AttributeOverride(name = "page", column = @Column(name = "EMBEDDED_ID_PAGE")),
    @AttributeOverride(name = "pageMode", column = @Column(name = "EMBEDDED_ID_PAGE_MODE"))
})
public ApplicationActionEventPageModePeriodSummaryEmbeddedId getEmbeddedId() {
    return embeddedId;
}
 
Example #23
Source File: ViewApplicationActionEventPageWeeklySummary.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the value of the embeddedId property.
 * 
 * @return
 *     possible object is
 *     {@link ApplicationActionEventPagePeriodSummaryEmbeddedId }
 *     
 */
@EmbeddedId
@AttributeOverrides({
    @AttributeOverride(name = "createdDate", column = @Column(name = "EMBEDDED_ID_CREATED_DATE")),
    @AttributeOverride(name = "page", column = @Column(name = "EMBEDDED_ID_PAGE"))
})
public ApplicationActionEventPagePeriodSummaryEmbeddedId getEmbeddedId() {
    return embeddedId;
}
 
Example #24
Source File: ViewWorldbankIndicatorDataCountrySummary.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the value of the embeddedId property.
 * 
 * @return
 *     possible object is
 *     {@link WorldbankIndicatorDataCountrySummaryEmbeddedId }
 *     
 */
@EmbeddedId
@AttributeOverrides({
    @AttributeOverride(name = "indicatorId", column = @Column(name = "EMBEDDED_ID_INDICATOR_ID")),
    @AttributeOverride(name = "countryId", column = @Column(name = "EMBEDDED_ID_COUNTRY_ID"))
})
public WorldbankIndicatorDataCountrySummaryEmbeddedId getEmbeddedId() {
    return embeddedId;
}
 
Example #25
Source File: ViewApplicationActionEventPageModeDailySummary.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the value of the embeddedId property.
 * 
 * @return
 *     possible object is
 *     {@link ApplicationActionEventPageModePeriodSummaryEmbeddedId }
 *     
 */
@EmbeddedId
@AttributeOverrides({
    @AttributeOverride(name = "createdDate", column = @Column(name = "EMBEDDED_ID_CREATED_DATE")),
    @AttributeOverride(name = "page", column = @Column(name = "EMBEDDED_ID_PAGE")),
    @AttributeOverride(name = "pageMode", column = @Column(name = "EMBEDDED_ID_PAGE_MODE"))
})
public ApplicationActionEventPageModePeriodSummaryEmbeddedId getEmbeddedId() {
    return embeddedId;
}
 
Example #26
Source File: ViewApplicationActionEventPageElementWeeklySummary.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the value of the embeddedId property.
 * 
 * @return
 *     possible object is
 *     {@link ApplicationActionEventPageElementPeriodSummaryEmbeddedId }
 *     
 */
@EmbeddedId
@AttributeOverrides({
    @AttributeOverride(name = "createdDate", column = @Column(name = "EMBEDDED_ID_CREATED_DATE")),
    @AttributeOverride(name = "page", column = @Column(name = "EMBEDDED_ID_PAGE")),
    @AttributeOverride(name = "elementId", column = @Column(name = "EMBEDDED_ID_ELEMENT_ID"))
})
public ApplicationActionEventPageElementPeriodSummaryEmbeddedId getEmbeddedId() {
    return embeddedId;
}
 
Example #27
Source File: ViewApplicationActionEventPageElementDailySummary.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the value of the embeddedId property.
 * 
 * @return
 *     possible object is
 *     {@link ApplicationActionEventPageElementPeriodSummaryEmbeddedId }
 *     
 */
@EmbeddedId
@AttributeOverrides({
    @AttributeOverride(name = "createdDate", column = @Column(name = "EMBEDDED_ID_CREATED_DATE")),
    @AttributeOverride(name = "page", column = @Column(name = "EMBEDDED_ID_PAGE")),
    @AttributeOverride(name = "elementId", column = @Column(name = "EMBEDDED_ID_ELEMENT_ID"))
})
public ApplicationActionEventPageElementPeriodSummaryEmbeddedId getEmbeddedId() {
    return embeddedId;
}
 
Example #28
Source File: ViewApplicationActionEventPageModeHourlySummary.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the value of the embeddedId property.
 * 
 * @return
 *     possible object is
 *     {@link ApplicationActionEventPageModePeriodSummaryEmbeddedId }
 *     
 */
@EmbeddedId
@AttributeOverrides({
    @AttributeOverride(name = "createdDate", column = @Column(name = "EMBEDDED_ID_CREATED_DATE")),
    @AttributeOverride(name = "page", column = @Column(name = "EMBEDDED_ID_PAGE")),
    @AttributeOverride(name = "pageMode", column = @Column(name = "EMBEDDED_ID_PAGE_MODE"))
})
public ApplicationActionEventPageModePeriodSummaryEmbeddedId getEmbeddedId() {
    return embeddedId;
}
 
Example #29
Source File: ViewApplicationActionEventPageDailySummary.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the value of the embeddedId property.
 * 
 * @return
 *     possible object is
 *     {@link ApplicationActionEventPagePeriodSummaryEmbeddedId }
 *     
 */
@EmbeddedId
@AttributeOverrides({
    @AttributeOverride(name = "createdDate", column = @Column(name = "EMBEDDED_ID_CREATED_DATE")),
    @AttributeOverride(name = "page", column = @Column(name = "EMBEDDED_ID_PAGE"))
})
public ApplicationActionEventPagePeriodSummaryEmbeddedId getEmbeddedId() {
    return embeddedId;
}
 
Example #30
Source File: ViewApplicationActionEventPageElementHourlySummary.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the value of the embeddedId property.
 * 
 * @return
 *     possible object is
 *     {@link ApplicationActionEventPageElementPeriodSummaryEmbeddedId }
 *     
 */
@EmbeddedId
@AttributeOverrides({
    @AttributeOverride(name = "createdDate", column = @Column(name = "EMBEDDED_ID_CREATED_DATE")),
    @AttributeOverride(name = "page", column = @Column(name = "EMBEDDED_ID_PAGE")),
    @AttributeOverride(name = "elementId", column = @Column(name = "EMBEDDED_ID_ELEMENT_ID"))
})
public ApplicationActionEventPageElementPeriodSummaryEmbeddedId getEmbeddedId() {
    return embeddedId;
}