Java 类javax.persistence.AttributeOverride 实例源码
项目:lams
文件:JPAOverriddenAnnotationReader.java
/**
* @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;
}
}
项目:lams
文件:JPAOverriddenAnnotationReader.java
private List<AttributeOverride> buildAttributeOverrides(List<Element> subelements, String nodeName) {
List<AttributeOverride> overrides = new ArrayList<AttributeOverride>();
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( (AttributeOverride) AnnotationFactory.create( override ) );
}
}
return overrides;
}
项目:cosmic
文件:DbUtil.java
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;
}
项目:cosmic
文件:GenericDaoBase.java
@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();
}
项目:IGSN
文件:RasterColumns.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "RTableCatalog", column = @Column(name = "r_table_catalog")),
@AttributeOverride(name = "RTableSchema", column = @Column(name = "r_table_schema")),
@AttributeOverride(name = "RTableName", column = @Column(name = "r_table_name")),
@AttributeOverride(name = "RRasterColumn", column = @Column(name = "r_raster_column")),
@AttributeOverride(name = "srid", column = @Column(name = "srid")),
@AttributeOverride(name = "scaleX", column = @Column(name = "scale_x", precision = 17, scale = 17)),
@AttributeOverride(name = "scaleY", column = @Column(name = "scale_y", precision = 17, scale = 17)),
@AttributeOverride(name = "blocksizeX", column = @Column(name = "blocksize_x")),
@AttributeOverride(name = "blocksizeY", column = @Column(name = "blocksize_y")),
@AttributeOverride(name = "sameAlignment", column = @Column(name = "same_alignment")),
@AttributeOverride(name = "regularBlocking", column = @Column(name = "regular_blocking")),
@AttributeOverride(name = "numBands", column = @Column(name = "num_bands")),
@AttributeOverride(name = "pixelTypes", column = @Column(name = "pixel_types")),
@AttributeOverride(name = "nodataValues", column = @Column(name = "nodata_values")),
@AttributeOverride(name = "outDb", column = @Column(name = "out_db")),
@AttributeOverride(name = "extent", column = @Column(name = "extent")) })
public RasterColumnsId getId() {
return this.id;
}
项目:petit
文件:BeanMappingReflectionUtils.java
private static Column getAttributeOverride(Class<?> type, String name) {
AttributeOverride ao = type.getAnnotation(AttributeOverride.class);
if (ao != null) {
if (ao.name().equals(name)) {
return ao.column();
}
}
AttributeOverrides aos = type.getAnnotation(AttributeOverrides.class);
if (aos != null) {
for (AttributeOverride a : aos.value()) {
if (a.name().equals(name)) {
return a.column();
}
}
}
return null;
}
项目:SyncRunner-Pub
文件:SkuShoeView.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "skuItem", column = @Column(name = "SKU_Item", length = 13)),
@AttributeOverride(name = "upc", column = @Column(name = "UPC", length = 12)),
@AttributeOverride(name = "sku", column = @Column(name = "SKU", length = 6)),
@AttributeOverride(name = "itemNumber", column = @Column(name = "Item_Number", length = 6)),
@AttributeOverride(name = "brand", column = @Column(name = "Brand", nullable = false, length = 45)),
@AttributeOverride(name = "style", column = @Column(name = "Style", nullable = false, length = 45)),
@AttributeOverride(name = "colorMap", column = @Column(name = "Color_Map", length = 45)),
@AttributeOverride(name = "color", column = @Column(name = "Color", length = 45)),
@AttributeOverride(name = "sizeMap", column = @Column(name = "Size_Map", length = 45)),
@AttributeOverride(name = "size", column = @Column(name = "Size", length = 45)),
@AttributeOverride(name = "sortSize", column = @Column(name = "Sort_Size", nullable = false)),
@AttributeOverride(name = "inStock", column = @Column(name = "In_Stock", precision = 23, scale = 0)),
@AttributeOverride(name = "material", column = @Column(name = "Material", nullable = false, length = 45)),
@AttributeOverride(name = "shoeType", column = @Column(name = "Shoe_Type", nullable = false, length = 4)),
@AttributeOverride(name = "description", column = @Column(name = "Description", nullable = false, length = 11)) })
public SkuShoeViewId getId() {
return this.id;
}
项目:cloudstack
文件:DbUtil.java
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;
}
项目:cloudstack
文件:GenericDaoBase.java
@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();
}
项目:GitHub
文件:Payment.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "customerNumber", column = @Column(name = "customerNumber", nullable = false)),
@AttributeOverride(name = "checkNumber", column = @Column(name = "checkNumber", nullable = false, length = 50)) })
public PaymentId getId() {
return this.id;
}
项目:lams
文件:AbstractPropertyHolder.java
private static Map<String, Column[]> buildColumnOverride(XAnnotatedElement element, String path) {
Map<String, Column[]> columnOverride = new HashMap<String, Column[]>();
if ( element == null ) return columnOverride;
AttributeOverride singleOverride = element.getAnnotation( AttributeOverride.class );
AttributeOverrides multipleOverrides = element.getAnnotation( AttributeOverrides.class );
AttributeOverride[] overrides;
if ( singleOverride != null ) {
overrides = new AttributeOverride[] { singleOverride };
}
else if ( multipleOverrides != null ) {
overrides = multipleOverrides.value();
}
else {
overrides = null;
}
//fill overridden columns
if ( overrides != null ) {
for (AttributeOverride depAttr : overrides) {
columnOverride.put(
StringHelper.qualify( path, depAttr.name() ),
new Column[] { depAttr.column() }
);
}
}
return columnOverride;
}
项目:lams
文件:JPAOverriddenAnnotationReader.java
/**
* As per sections 12.2.3.23.9, 12.2.4.8.9 and 12.2.5.3.6 of the JPA 2.0
* specification, the element-collection subelement completely overrides the
* mapping for the specified field or property. Thus, any methods which
* might in some contexts merge with annotations must not do so in this
* context.
*/
private void getElementCollection(List<Annotation> annotationList, XMLContext.Default defaults) {
for ( Element element : elementsForProperty ) {
if ( "element-collection".equals( element.getName() ) ) {
AnnotationDescriptor ad = new AnnotationDescriptor( ElementCollection.class );
addTargetClass( element, ad, "target-class", defaults );
getFetchType( ad, element );
getOrderBy( annotationList, element );
getOrderColumn( annotationList, element );
getMapKey( annotationList, element );
getMapKeyClass( annotationList, element, defaults );
getMapKeyTemporal( annotationList, element );
getMapKeyEnumerated( annotationList, element );
getMapKeyColumn( annotationList, element );
buildMapKeyJoinColumns( annotationList, element );
Annotation annotation = getColumn( element.element( "column" ), false, element );
addIfNotNull( annotationList, annotation );
getTemporal( annotationList, element );
getEnumerated( annotationList, element );
getLob( annotationList, element );
//Both map-key-attribute-overrides and attribute-overrides
//translate into AttributeOverride annotations, which need
//need to be wrapped in the same AttributeOverrides annotation.
List<AttributeOverride> attributes = new ArrayList<AttributeOverride>();
attributes.addAll( buildAttributeOverrides( element, "map-key-attribute-override" ) );
attributes.addAll( buildAttributeOverrides( element, "attribute-override" ) );
annotation = mergeAttributeOverrides( defaults, attributes, false );
addIfNotNull( annotationList, annotation );
annotation = getAssociationOverrides( element, defaults, false );
addIfNotNull( annotationList, annotation );
getCollectionTable( annotationList, element, defaults );
annotationList.add( AnnotationFactory.create( ad ) );
getAccessType( annotationList, element );
}
}
}
项目:lams
文件:JPAOverriddenAnnotationReader.java
private void addAttributeOverrideIfNeeded(AttributeOverride annotation, List<AttributeOverride> overrides) {
if ( annotation != null ) {
String overrideName = annotation.name();
boolean present = false;
for ( AttributeOverride current : overrides ) {
if ( current.name().equals( overrideName ) ) {
present = true;
break;
}
}
if ( !present ) {
overrides.add( annotation );
}
}
}
项目:cosmic
文件:DbUtil.java
public static String getColumnName(final Field field, final AttributeOverride[] overrides) {
if (overrides != null) {
for (final 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();
final Column column = field.getAnnotation(Column.class);
return column != null ? column.name() : field.getName();
}
项目:bygle-ldp
文件:Relations.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "refIdRecord1", column = @Column(name = "ref_id_record_1", nullable = false)),
@AttributeOverride(name = "refIdRecord2", column = @Column(name = "ref_id_record_2", nullable = false)),
@AttributeOverride(name = "refIdRelationType", column = @Column(name = "ref_id_relation_type", nullable = false)) })
public RelationsId getId() {
return this.id;
}
项目:submerge
文件:UserAuthorities.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "fkIdAccount", column = @Column(name = "fk_id_account", nullable = false)),
@AttributeOverride(name = "fkIdAuthorities", column = @Column(name = "fk_id_authorities", nullable = false)) })
public UserAuthoritiesId getId() {
return this.id;
}
项目:alex
文件:Statistics.java
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "learner", column = @Column(name = "duration_learner")),
@AttributeOverride(name = "eqOracle", column = @Column(name = "duration_eqOracle"))
})
public DetailedStatistics getDuration() {
return duration;
}
项目:alex
文件:Statistics.java
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "learner", column = @Column(name = "mqs_learner")),
@AttributeOverride(name = "eqOracle", column = @Column(name = "mqs_eqOracle"))
})
public DetailedStatistics getMqsUsed() {
return mqsUsed;
}
项目:alex
文件:Statistics.java
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "learner", column = @Column(name = "symbolsUsed_learner")),
@AttributeOverride(name = "eqOracle", column = @Column(name = "symbolsUsed_eqOracle"))
})
public DetailedStatistics getSymbolsUsed() {
return symbolsUsed;
}
项目:sample-java-spring-genericdao
文件:StudentClasses.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "studentId", column = @Column(name = "STUDENT_ID", nullable = false, precision = 5, scale = 0)),
@AttributeOverride(name = "classesId", column = @Column(name = "CLASSES_ID", nullable = false, precision = 4, scale = 0)),
@AttributeOverride(name = "status", column = @Column(name = "STU_CLASSES_STATUS", nullable = false, length = 1)) })
public StudentClassesId getId() {
return this.id;
}
项目:nics-common
文件:Assignment.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "unitId", column = @Column(name = "unit_id", nullable = false)),
@AttributeOverride(name = "operationalPeriodId", column = @Column(name = "operational_period_id", nullable = false)) })
public AssignmentId getId() {
return this.id;
}
项目:pedal-dialect
文件:EmbeddedIdColumnEvaluator.java
@Override
public void evaluate(Method method, EvaluatorChain chain) {
if (method.isAnnotationPresent(EmbeddedId.class)) {
Map<String, AttributeOverride> overrides = getAttributeOverrides(method);
Class<?> embeddedClz = method.getReturnType();
BeanInfo info = null;
try {
info = Introspector.getBeanInfo(embeddedClz);
} catch (IntrospectionException e) {
throw new RuntimeException(e);
}
for (String propertyName : overrides.keySet()) {
for (PropertyDescriptor propDesc : info.getPropertyDescriptors()) {
if (propDesc.getName().equals(propertyName)) {
CopyAttribute attribute = new CopyAttribute();
attribute.getMethods().add(method);
attribute.getMethods().add(propDesc.getReadMethod());
attribute.setColumnName(overrides.get(propertyName).column().name());
chain.add(attribute);
break;
}
}
}
} else {
chain.doNext();
}
}
项目:pedal-dialect
文件:EmbeddedColumnEvaluator.java
@Override
public void evaluate(Method method, EvaluatorChain chain) {
if (method.getReturnType().isAnnotationPresent(Embeddable.class) &&
!method.isAnnotationPresent(Transient.class)) {
Map<String, AttributeOverride> overrides = getAttributeOverrides(method);
Class<?> embeddedClz = method.getReturnType();
for (Method embeddedMethod : Arrays.stream(embeddedClz.getMethods()) //
.filter(it -> it.isAnnotationPresent(Column.class)) //
.collect(toList())) {
String name = getPropertyName(embeddedMethod);
String columnName = null;
if (overrides.containsKey(name)) {
columnName = overrides.get(name).column().name();
} else {
columnName = embeddedMethod.getAnnotation(Column.class).name();
}
CopyAttribute attribute = new CopyAttribute();
attribute.getMethods().add(method);
attribute.getMethods().add(embeddedMethod);
attribute.setColumnName(columnName);
chain.add(attribute);
}
} else {
chain.doNext();
}
}
项目:pedal-dialect
文件:Planet.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "name", column = @Column(name = "name", nullable = false)),
@AttributeOverride(name = "position", column = @Column(name = "position", nullable = false)) })
public PlanetId getId() {
return id;
}
项目:watchout
文件:PlayersHasInsurances.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "playersIdplayers", column = @Column(name = "players_idplayers", nullable = false)),
@AttributeOverride(name = "insurancesIdinsurances", column = @Column(name = "insurances_idinsurances", nullable = false)) })
public PlayersHasInsurancesId getId() {
return this.id;
}
项目:watchout
文件:TurnsHistory.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "playersHasQuestsPlayersIdplayers", column = @Column(name = "players_has_quests_players_idplayers", nullable = false)),
@AttributeOverride(name = "playersHasQuestsQuestsIdquests", column = @Column(name = "players_has_quests_quests_idquests", nullable = false)),
@AttributeOverride(name = "placesHasTransportsPlacesOrigin", column = @Column(name = "places_has_transports_places_origin", nullable = false)),
@AttributeOverride(name = "placesHasTransportsTransportation", column = @Column(name = "places_has_transports_transportation", nullable = false)),
@AttributeOverride(name = "placesHasTransportsPlacesDestination", column = @Column(name = "places_has_transports_places_destination", nullable = false)) })
public TurnsHistoryId getId() {
return this.id;
}
项目:watchout
文件:InsurancesHasTransportationrisks.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "insurancesIdinsurances", column = @Column(name = "insurances_idinsurances", nullable = false)),
@AttributeOverride(name = "risksIdrisks", column = @Column(name = "risks_idrisks", nullable = false)) })
public InsurancesHasTransportationrisksId getId() {
return this.id;
}
项目:watchout
文件:QuestInsurances.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "playersHasQuestsPlayersIdplayers", column = @Column(name = "players_has_quests_players_idplayers", nullable = false)),
@AttributeOverride(name = "playersHasQuestsQuestsIdquests", column = @Column(name = "players_has_quests_quests_idquests", nullable = false)),
@AttributeOverride(name = "insurancesIdinsurances", column = @Column(name = "insurances_idinsurances", nullable = false)) })
public QuestInsurancesId getId() {
return this.id;
}
项目:watchout
文件:PlacesHasTransports.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "placesOrigin", column = @Column(name = "places_origin", nullable = false)),
@AttributeOverride(name = "transportation", column = @Column(name = "transportation", nullable = false)),
@AttributeOverride(name = "placesDestination", column = @Column(name = "places_destination", nullable = false)) })
public PlacesHasTransportsId getId() {
return this.id;
}
项目:watchout
文件:TurnsHistoryHasTransportationrisks.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "turnsHistoryPlayersHasQuestsPlayersIdplayers", column = @Column(name = "turns_history_players_has_quests_players_idplayers", nullable = false)),
@AttributeOverride(name = "turnsHistoryPlayersHasQuestsQuestsIdquests", column = @Column(name = "turns_history_players_has_quests_quests_idquests", nullable = false)),
@AttributeOverride(name = "turnsHistoryPlacesHasTransportsPlacesOrigin", column = @Column(name = "turns_history_places_has_transports_places_origin", nullable = false)),
@AttributeOverride(name = "turnsHistoryPlacesHasTransportsTransportation", column = @Column(name = "turns_history_places_has_transports_transportation", nullable = false)),
@AttributeOverride(name = "turnsHistoryPlacesHasTransportsPlacesDestination", column = @Column(name = "turns_history_places_has_transports_places_destination", nullable = false)),
@AttributeOverride(name = "transportationrisksIdrisks", column = @Column(name = "transportationrisks_idrisks", nullable = false)) })
public TurnsHistoryHasTransportationrisksId getId() {
return this.id;
}
项目:watchout
文件:PlayersHasQuests.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "playersIdplayers", column = @Column(name = "players_idplayers", nullable = false)),
@AttributeOverride(name = "questsIdquests", column = @Column(name = "quests_idquests", nullable = false)) })
public PlayersHasQuestsId getId() {
return this.id;
}
项目:watchout
文件:InsurancesHasPlacesrisks.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "insurancesIdinsurances", column = @Column(name = "insurances_idinsurances", nullable = false)),
@AttributeOverride(name = "placesrisksIdrisks", column = @Column(name = "placesrisks_idrisks", nullable = false)) })
public InsurancesHasPlacesrisksId getId() {
return this.id;
}
项目:watchout
文件:TurnsHistoryHasPlacesrisks.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "turnsHistoryPlayersHasQuestsPlayersIdplayers", column = @Column(name = "turns_history_players_has_quests_players_idplayers", nullable = false)),
@AttributeOverride(name = "turnsHistoryPlayersHasQuestsQuestsIdquests", column = @Column(name = "turns_history_players_has_quests_quests_idquests", nullable = false)),
@AttributeOverride(name = "turnsHistoryPlacesHasTransportsPlacesOrigin", column = @Column(name = "turns_history_places_has_transports_places_origin", nullable = false)),
@AttributeOverride(name = "turnsHistoryPlacesHasTransportsTransportation", column = @Column(name = "turns_history_places_has_transports_transportation", nullable = false)),
@AttributeOverride(name = "turnsHistoryPlacesHasTransportsPlacesDestination", column = @Column(name = "turns_history_places_has_transports_places_destination", nullable = false)),
@AttributeOverride(name = "placesrisksIdrisks", column = @Column(name = "placesrisks_idrisks", nullable = false)) })
public TurnsHistoryHasPlacesrisksId getId() {
return this.id;
}
项目:IGSN
文件:RasterOverviews.java
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "OTableCatalog", column = @Column(name = "o_table_catalog")),
@AttributeOverride(name = "OTableSchema", column = @Column(name = "o_table_schema")),
@AttributeOverride(name = "OTableName", column = @Column(name = "o_table_name")),
@AttributeOverride(name = "ORasterColumn", column = @Column(name = "o_raster_column")),
@AttributeOverride(name = "RTableCatalog", column = @Column(name = "r_table_catalog")),
@AttributeOverride(name = "RTableSchema", column = @Column(name = "r_table_schema")),
@AttributeOverride(name = "RTableName", column = @Column(name = "r_table_name")),
@AttributeOverride(name = "RRasterColumn", column = @Column(name = "r_raster_column")),
@AttributeOverride(name = "overviewFactor", column = @Column(name = "overview_factor")) })
public RasterOverviewsId getId() {
return this.id;
}