use of org.hibernate.mapping.Property in project hibernate-orm by hibernate.
the class AuditMetadataGenerator method addProperties.
private void addProperties(Element parent, Iterator<Property> properties, CompositeMapperBuilder currentMapper, ClassAuditingData auditingData, String entityName, EntityXmlMappingData xmlMappingData, boolean firstPass) {
while (properties.hasNext()) {
final Property property = properties.next();
final String propertyName = property.getName();
final PropertyAuditingData propertyAuditingData = auditingData.getPropertyAuditingData(propertyName);
if (propertyAuditingData != null) {
// and if so, this eliminates the mapping property as it isn't needed.
if (property instanceof SyntheticProperty) {
if (property.getValue().isAlternateUniqueKey()) {
continue;
}
}
addValue(parent, property.getValue(), currentMapper, entityName, xmlMappingData, propertyAuditingData, isPropertyInsertable(property), firstPass, true);
}
}
}
use of org.hibernate.mapping.Property in project hibernate-orm by hibernate.
the class TestTools method extractModProperties.
public static Set<String> extractModProperties(PersistentClass persistentClass, String suffix) {
final Set<String> result = new HashSet<String>();
final Iterator iterator = persistentClass.getPropertyIterator();
while (iterator.hasNext()) {
final Property property = (Property) iterator.next();
final String propertyName = property.getName();
if (propertyName.endsWith(suffix)) {
result.add(propertyName);
}
}
return result;
}
use of org.hibernate.mapping.Property in project hibernate-orm by hibernate.
the class AbstractFunctionalTest method afterMetadataBuilt.
@Override
protected void afterMetadataBuilt(Metadata metadata) {
if (addVersions) {
for (PersistentClass clazz : metadata.getEntityBindings()) {
if (clazz.getVersion() != null) {
continue;
}
try {
clazz.getMappedClass().getMethod("getVersion");
clazz.getMappedClass().getMethod("setVersion", long.class);
} catch (NoSuchMethodException e) {
continue;
}
RootClass rootClazz = clazz.getRootClass();
Property versionProperty = new Property();
versionProperty.setName("version");
SimpleValue value = new SimpleValue((MetadataImplementor) metadata, rootClazz.getTable());
value.setTypeName("long");
Column column = new Column();
column.setValue(value);
column.setName("version");
value.addColumn(column);
rootClazz.getTable().addColumn(column);
versionProperty.setValue(value);
rootClazz.setVersion(versionProperty);
rootClazz.addProperty(versionProperty);
}
}
}
use of org.hibernate.mapping.Property in project hibernate-orm by hibernate.
the class BaseNonConfigCoreFunctionalTestCase method applyCacheSettings.
protected final void applyCacheSettings(Metadata metadata) {
if (!overrideCacheStrategy()) {
return;
}
if (getCacheConcurrencyStrategy() == null) {
return;
}
for (PersistentClass entityBinding : metadata.getEntityBindings()) {
if (entityBinding.isInherited()) {
continue;
}
boolean hasLob = false;
final Iterator props = entityBinding.getPropertyClosureIterator();
while (props.hasNext()) {
final Property prop = (Property) props.next();
if (prop.getValue().isSimpleValue()) {
if (isLob(((SimpleValue) prop.getValue()).getTypeName())) {
hasLob = true;
break;
}
}
}
if (!hasLob) {
((RootClass) entityBinding).setCacheConcurrencyStrategy(getCacheConcurrencyStrategy());
}
}
for (Collection collectionBinding : metadata.getCollectionBindings()) {
boolean isLob = false;
if (collectionBinding.getElement().isSimpleValue()) {
isLob = isLob(((SimpleValue) collectionBinding.getElement()).getTypeName());
}
if (!isLob) {
collectionBinding.setCacheConcurrencyStrategy(getCacheConcurrencyStrategy());
}
}
}
use of org.hibernate.mapping.Property in project hibernate-orm by hibernate.
the class Java8DateTimeTests method basicTests.
@Test
public void basicTests() {
final PersistentClass entityBinding = metadata().getEntityBinding(TheEntity.class.getName());
final Iterator propertyBindingIterator = entityBinding.getPropertyClosureIterator();
while (propertyBindingIterator.hasNext()) {
final Property propertyBinding = (Property) propertyBindingIterator.next();
assertFalse("Found property bound as Serializable : " + propertyBinding.getName(), propertyBinding.getType() instanceof SerializableType);
}
TheEntity theEntity = new TheEntity(1);
Session s = openSession();
s.beginTransaction();
s.save(theEntity);
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
theEntity = (TheEntity) s.get(TheEntity.class, 1);
dump(entityBinding, theEntity);
assertNotNull(theEntity);
s.delete(theEntity);
s.getTransaction().commit();
s.close();
}
Aggregations