本文整理了Java中javax.persistence.AttributeOverride.name()
方法的一些代码示例,展示了AttributeOverride.name()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AttributeOverride.name()
方法的具体详情如下:
包路径:javax.persistence.AttributeOverride
类名称:AttributeOverride
方法名:name
暂无
代码示例来源:origin: hibernate/hibernate-orm
private boolean namedMapKey(AttributeOverride annotation) {
return annotation.name().startsWith( "key." );
}
代码示例来源:origin: hibernate/hibernate-orm
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 );
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
String qualifiedName = StringHelper.qualify( path, depAttr.name() );
代码示例来源:origin: org.hibernate/hibernate-annotations
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 );
}
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Tests that map-key-attribute-override and attribute-override elements
* both end up in the AttributeOverrides annotation.
*/
@Test
public void testMixedAttributeOverrides() throws Exception {
reader = getReader( Entity3.class, "field1", "element-collection.orm23.xml" );
assertAnnotationPresent( ElementCollection.class );
assertAnnotationNotPresent( AttributeOverride.class );
assertAnnotationPresent( AttributeOverrides.class );
AttributeOverrides overridesAnno = reader
.getAnnotation( AttributeOverrides.class );
AttributeOverride[] overrides = overridesAnno.value();
assertEquals( 2, overrides.length );
assertEquals( "field1", overrides[0].name() );
assertEquals( "col1", overrides[0].column().name() );
assertEquals( "field2", overrides[1].name() );
assertEquals( "col2", overrides[1].column().name() );
}
代码示例来源:origin: Impetus/Kundera
/**
* Bind attribute.
*
* @param annotation
* the annotation
*/
private void bindAttribute(Annotation annotation)
{
String fieldname = ((AttributeOverride) annotation).name();
Column column = ((AttributeOverride) annotation).column();
((AbstractManagedType) this.superClazzType).columnBindings.put(fieldname, column);
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* When there's a single attribute override, we still wrap it with an
* AttributeOverrides annotation.
*/
@Test
public void testSingleAttributeOverride() throws Exception {
reader = getReader( Entity3.class, "field1", "element-collection.orm21.xml" );
assertAnnotationPresent( ElementCollection.class );
assertAnnotationNotPresent( AttributeOverride.class );
assertAnnotationPresent( AttributeOverrides.class );
AttributeOverrides overridesAnno = reader
.getAnnotation( AttributeOverrides.class );
AttributeOverride[] overrides = overridesAnno.value();
assertEquals( 1, overrides.length );
assertEquals( "field1", overrides[0].name() );
assertEquals( "col1", overrides[0].column().name() );
}
代码示例来源:origin: apache/cloudstack
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();
}
代码示例来源:origin: ebean-orm/ebean
/**
* Read an AttributeOverrides if they exist for this embedded bean.
*/
protected void readEmbeddedAttributeOverrides(DeployBeanPropertyAssocOne<?> prop) {
Set<AttributeOverride> attrOverrides = getAll(prop, AttributeOverride.class);
if (!attrOverrides.isEmpty()) {
HashMap<String, String> propMap = new HashMap<>(attrOverrides.size());
for (AttributeOverride attrOverride : attrOverrides) {
propMap.put(attrOverride.name(), attrOverride.column().name());
}
prop.getDeployEmbedded().putAll(propMap);
}
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* When there's a single map key attribute override, we still wrap it with
* an AttributeOverrides annotation.
*/
@Test
public void testSingleMapKeyAttributeOverride() throws Exception {
reader = getReader( Entity3.class, "field1", "element-collection.orm10.xml" );
assertAnnotationPresent( ElementCollection.class );
assertAnnotationNotPresent( MapKey.class );
assertAnnotationNotPresent( MapKeyClass.class );
assertAnnotationNotPresent( MapKeyTemporal.class );
assertAnnotationNotPresent( MapKeyEnumerated.class );
assertAnnotationNotPresent( MapKeyColumn.class );
assertAnnotationNotPresent( MapKeyJoinColumns.class );
assertAnnotationNotPresent( MapKeyJoinColumn.class );
assertAnnotationNotPresent( AttributeOverride.class );
assertAnnotationPresent( AttributeOverrides.class );
AttributeOverrides overridesAnno = reader
.getAnnotation( AttributeOverrides.class );
AttributeOverride[] overrides = overridesAnno.value();
assertEquals( 1, overrides.length );
assertEquals( "field1", overrides[0].name() );
assertEquals( "col1", overrides[0].column().name() );
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* When there's a single map key attribute override, we still wrap it with
* an AttributeOverrides annotation.
*/
@Test
public void testSingleMapKeyAttributeOverride() throws Exception {
reader = getReader( Entity3.class, "field1", "many-to-many.orm10.xml" );
assertAnnotationPresent( ManyToMany.class );
assertAnnotationNotPresent( MapKey.class );
assertAnnotationNotPresent( MapKeyClass.class );
assertAnnotationNotPresent( MapKeyTemporal.class );
assertAnnotationNotPresent( MapKeyEnumerated.class );
assertAnnotationNotPresent( MapKeyColumn.class );
assertAnnotationNotPresent( MapKeyJoinColumns.class );
assertAnnotationNotPresent( MapKeyJoinColumn.class );
assertAnnotationNotPresent( AttributeOverride.class );
assertAnnotationPresent( AttributeOverrides.class );
AttributeOverrides overridesAnno = reader
.getAnnotation( AttributeOverrides.class );
AttributeOverride[] overrides = overridesAnno.value();
assertEquals( 1, overrides.length );
assertEquals( "field1", overrides[0].name() );
assertEquals( "col1", overrides[0].column().name() );
}
代码示例来源:origin: org.hibernate/hibernate-annotations
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;
}
代码示例来源:origin: ebean-orm/ebean
/**
* Parse any AttributeOverride set on the class.
*/
public void parseAttributeOverride() {
Class<?> cls = descriptor.getBeanType();
AttributeOverride override = AnnotationUtil.findAnnotationRecursive(cls, AttributeOverride.class);
if (override != null) {
String propertyName = override.name();
Column column = override.column();
DeployBeanProperty beanProperty = descriptor.getBeanProperty(propertyName);
if (beanProperty == null) {
logger.error("AttributeOverride property [" + propertyName + "] not found on " + descriptor.getFullName());
} else {
readColumn(column, beanProperty);
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
AttributeOverride[] overrides = overridesAnno.value();
assertEquals( 2, overrides.length );
assertEquals( "field1", overrides[0].name() );
assertEquals( "", overrides[0].column().name() );
assertFalse( overrides[0].column().unique() );
assertEquals( 0, overrides[0].column().precision() );
assertEquals( 0, overrides[0].column().scale() );
assertEquals( "field2", overrides[1].name() );
assertEquals( "col1", overrides[1].column().name() );
assertTrue( overrides[1].column().unique() );
代码示例来源:origin: hibernate/hibernate-orm
AttributeOverride[] overrides = overridesAnno.value();
assertEquals( 2, overrides.length );
assertEquals( "field1", overrides[0].name() );
assertEquals( "", overrides[0].column().name() );
assertFalse( overrides[0].column().unique() );
assertEquals( 0, overrides[0].column().precision() );
assertEquals( 0, overrides[0].column().scale() );
assertEquals( "field2", overrides[1].name() );
assertEquals( "col1", overrides[1].column().name() );
assertTrue( overrides[1].column().unique() );
代码示例来源:origin: hibernate/hibernate-orm
AttributeOverride[] overrides = overridesAnno.value();
assertEquals( 2, overrides.length );
assertEquals( "field1", overrides[0].name() );
assertEquals( "", overrides[0].column().name() );
assertFalse( overrides[0].column().unique() );
assertEquals( 0, overrides[0].column().precision() );
assertEquals( 0, overrides[0].column().scale() );
assertEquals( "field2", overrides[1].name() );
assertEquals( "col1", overrides[1].column().name() );
assertTrue( overrides[1].column().unique() );
代码示例来源:origin: com.haulmont.cuba/cuba-core
private void overrideAttributes(AttributeOverrides overrides, Map<String, FieldEntry> embeddedFields) {
AttributeOverride[] overriddenAttributes = overrides.value();
for (AttributeOverride overriddenAttribute : overriddenAttributes) {
embeddedFields.put(overriddenAttribute.name(), new FieldEntry(overriddenAttribute.name(), overriddenAttribute.column().name()));
}
}
代码示例来源:origin: jerolba/jfleet
private Map<String, String> getMappingOverrride(AttributeOverrides multiple, AttributeOverride simple) {
Stream<AttributeOverride> overrides = getMappingOverride(multiple)
.orElseGet(() -> getMappingOverride(simple).orElse(Stream.empty()));
return overrides.collect(toMap(attr -> attr.name(), attr -> attr.column().name()));
}
代码示例来源:origin: org.apache.openjpa/openjpa-all
/**
* Parse given @AttributeOverride annotations on an embedded mapping.
*/
private void parseAttributeOverrides(FieldMapping fm,
AttributeOverride... attrs) {
for (AttributeOverride attr : attrs) {
String attrName = attr.name();
FieldMapping efm = getEmbeddedFieldMapping(fm, attrName);
if (attr.column() != null)
parseColumns(efm, attr.column());
}
}
代码示例来源:origin: org.apache.openejb.patch/openjpa
/**
* Parse given @AttributeOverride annotations on an embedded mapping.
*/
private void parseAttributeOverrides(FieldMapping fm,
AttributeOverride... attrs) {
for (AttributeOverride attr : attrs) {
String attrName = attr.name();
FieldMapping efm = getEmbeddedFieldMapping(fm, attrName);
if (attr.column() != null)
parseColumns(efm, attr.column());
}
}
内容来源于网络,如有侵权,请联系作者删除!