use of javax.persistence.AttributeOverride in project hibernate-orm by hibernate.
the class Ejb3XmlOneToManyTest method testSingleMapKeyAttributeOverride.
/**
* 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", "one-to-many.orm10.xml");
assertAnnotationPresent(OneToMany.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());
}
use of javax.persistence.AttributeOverride in project CloudStack-archive by CloudStack-extras.
the class GenericDaoBase method buildSelectByIdSql.
@DB(txn = false)
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();
}
use of javax.persistence.AttributeOverride in project cloudstack by apache.
the class DbUtil method getAttributeOverrides.
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;
}
Aggregations