use of org.apache.deltaspike.data.impl.property.query.PropertyCriteria 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.PropertyCriteria 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