use of org.hibernate.metamodel.mapping.AttributeMapping in project hibernate-orm by hibernate.
the class PluralAttributeMappingTests method testLists.
@Test
public void testLists(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getRuntimeMetamodels().getMappingMetamodel();
final EntityMappingType containerEntityDescriptor = domainModel.getEntityDescriptor(EntityOfLists.class);
assertThat(containerEntityDescriptor.getNumberOfAttributeMappings(), is(8));
final AttributeMapping listOfBasics = containerEntityDescriptor.findAttributeMapping("listOfBasics");
assertThat(listOfBasics, notNullValue());
final AttributeMapping listOfEnums = containerEntityDescriptor.findAttributeMapping("listOfEnums");
assertThat(listOfEnums, notNullValue());
final AttributeMapping listOfConvertedBasics = containerEntityDescriptor.findAttributeMapping("listOfConvertedEnums");
assertThat(listOfConvertedBasics, notNullValue());
final AttributeMapping listOfComponents = containerEntityDescriptor.findAttributeMapping("listOfComponents");
assertThat(listOfComponents, notNullValue());
final AttributeMapping listOfOneToMany = containerEntityDescriptor.findAttributeMapping("listOfOneToMany");
assertThat(listOfOneToMany, notNullValue());
final AttributeMapping listOfManyToMany = containerEntityDescriptor.findAttributeMapping("listOfManyToMany");
assertThat(listOfManyToMany, notNullValue());
}
use of org.hibernate.metamodel.mapping.AttributeMapping in project hibernate-orm by hibernate.
the class VirtualIdEmbeddable method forEachDisassembledJdbcValue.
@Override
public int forEachDisassembledJdbcValue(Object value, Clause clause, int offset, JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session) {
final Object[] values = (Object[]) value;
int span = 0;
for (int i = 0; i < attributeMappings.size(); i++) {
final AttributeMapping mapping = attributeMappings.get(i);
span += mapping.forEachDisassembledJdbcValue(values[i], clause, span + offset, valuesConsumer, session);
}
return span;
}
use of org.hibernate.metamodel.mapping.AttributeMapping in project hibernate-orm by hibernate.
the class VirtualIdEmbeddable method forEachJdbcValue.
@Override
public int forEachJdbcValue(Object value, Clause clause, int offset, JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session) {
int span = 0;
for (int i = 0; i < attributeMappings.size(); i++) {
final AttributeMapping attributeMapping = attributeMappings.get(i);
if (attributeMapping instanceof PluralAttributeMapping) {
continue;
}
final Object o = attributeMapping.getPropertyAccess().getGetter().get(value);
span += attributeMapping.forEachJdbcValue(o, clause, span + offset, valuesConsumer, session);
}
return span;
}
use of org.hibernate.metamodel.mapping.AttributeMapping in project hibernate-orm by hibernate.
the class IdClassEmbeddable method forEachJdbcValue.
@Override
public int forEachJdbcValue(Object value, Clause clause, int offset, JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session) {
int span = 0;
for (int i = 0; i < attributeMappings.size(); i++) {
final AttributeMapping attributeMapping = attributeMappings.get(i);
if (attributeMapping instanceof PluralAttributeMapping) {
continue;
}
final Object o = attributeMapping.getPropertyAccess().getGetter().get(value);
span += attributeMapping.forEachJdbcValue(o, clause, span + offset, valuesConsumer, session);
}
return span;
}
use of org.hibernate.metamodel.mapping.AttributeMapping in project hibernate-orm by hibernate.
the class EmbeddableMappingTypeImpl method disassemble.
@Override
public Object disassemble(Object value, SharedSessionContractImplementor session) {
final List<AttributeMapping> attributeMappings = getAttributeMappings();
final Object[] result = new Object[attributeMappings.size()];
for (int i = 0; i < attributeMappings.size(); i++) {
final AttributeMapping attributeMapping = attributeMappings.get(i);
Object o = attributeMapping.getPropertyAccess().getGetter().get(value);
result[i] = attributeMapping.disassemble(o, session);
}
return result;
}
Aggregations