use of org.apache.deltaspike.data.impl.property.query.AnnotatedPropertyCriteria in project deltaspike by apache.
the class EntityUtils method primaryKeyPropertyCriteriaList.
private static List<PropertyCriteria> primaryKeyPropertyCriteriaList(Class<?> entityClass) {
List<PropertyCriteria> criteria = new LinkedList<PropertyCriteria>();
criteria.add(new AnnotatedPropertyCriteria(Id.class));
criteria.add(new AnnotatedPropertyCriteria(EmbeddedId.class));
String[] fromMappingFiles = PersistenceUnitDescriptorProvider.getInstance().primaryKeyFields(entityClass);
if (fromMappingFiles != null) {
for (String id : fromMappingFiles) {
criteria.add(new NamedPropertyCriteria(id));
}
}
return criteria;
}
use of org.apache.deltaspike.data.impl.property.query.AnnotatedPropertyCriteria in project deltaspike by apache.
the class TimestampsProvider method updateTimestamps.
private void updateTimestamps(Object entity, boolean create) {
long systime = System.currentTimeMillis();
List<Property<Object>> properties = new LinkedList<Property<Object>>();
PropertyQuery<Object> query = PropertyQueries.<Object>createQuery(entity.getClass()).addCriteria(new AnnotatedPropertyCriteria(ModifiedOn.class));
properties.addAll(query.getWritableResultList());
if (create) {
query = PropertyQueries.<Object>createQuery(entity.getClass()).addCriteria(new AnnotatedPropertyCriteria(CreatedOn.class));
properties.addAll(query.getWritableResultList());
}
for (Property<Object> property : properties) {
setProperty(entity, property, systime, create);
}
}
use of org.apache.deltaspike.data.impl.property.query.AnnotatedPropertyCriteria in project deltaspike by apache.
the class EntityUtils method getVersionProperty.
public static Property<Serializable> getVersionProperty(Class<?> entityClass) {
List<PropertyCriteria> criteriaList = new LinkedList<PropertyCriteria>();
criteriaList.add(new AnnotatedPropertyCriteria(Version.class));
String fromMappingFiles = PersistenceUnitDescriptorProvider.getInstance().versionField(entityClass);
if (fromMappingFiles != null) {
criteriaList.add(new NamedPropertyCriteria(fromMappingFiles));
}
for (PropertyCriteria criteria : criteriaList) {
PropertyQuery<Serializable> query = PropertyQueries.<Serializable>createQuery(entityClass).addCriteria(criteria);
Property<Serializable> result = query.getFirstResult();
if (result != null) {
return result;
}
}
return null;
}
Aggregations