Hi,
I think I found a problem when using a beanPropertiesMap for the
searchcontext and when using such a map with a JPATypedQueryVisitor
Let's say we have to following (simplified) Domain objects:
public class Order(){
private String orderName;
private List<PartInfo> partInfos
//Getters and setters omitted
}
public class PartInfo(){
private String partDescription;
//Getters and setters omitted
}
And defined a map with the properties as follows:
Map<String, String> backendBeanPropertiesMap<String, String>();
backendBeanPropertiesMap.put("ordername", "orderName");
//value same
as property on Order Object
backendBeanPropertiesMap.put("partdescription",
"partInfos.partDescription"); //value same as property on Order and
OrderInfo object
If we then call eg http://localhost:8080/current?_s=partdescription==X
The incomingFilter is retrieved and passed to our backend to find the
matching records in the database:
public List<Order> findOrders(AndSearchCondition<Order> filter) {
SearchConditionVisitor<Order, TypedQuery<Order>> visitor = new
JPATypedQueryVisitor<Order>(getEntityManager(), Order.class,
backendBeanPropertiesMap);
if (filter != null) {
List<SearchCondition<Order>> conditions =
filter.getSearchConditions();
if (conditions != null) {
filter.accept(visitor);
TypedQuery<Order> query = visitor.getQuery();
return query.getResultList();
}
}
return null;
}
In our REST interface we do the following to retrieve the filter:
SearchCondition<Order> incomingFilter =
searchContext.getCondition(Order.class, beanPropertiesMap);
And this filter is passed to the backend.
But I noticed that I cannot use the same beanPropertiesMap for this.
There is a difference in the required casing. This is what is required to
allow this to work:
Map<String, String> beanPropertiesMap<String, String>();
beanPropertiesMap.put("ordername", "ordername");
//Value lowercase
ordername, even thoug the property is called orderName
beanPropertiesMap.put("partdescription", "partInfos.partDescription");
//Value same as property name on objects for some reason...
So it seems that the problem is withing the
searchContext.getCondition(Order.class, beanPropertiesMap);
Which handles the casing differently.
If I would use the backendPropertiesMap for this the incomingFilter is
always null.
It would be a lot easier if I could just use the same map.
Please note that I am very new to FIQL and CFX, and I inherited this project
from an ex-collegue.
--
View this message in context:
http://cxf.547215.n5.nabble.com/Problem-with-bean-properties-Map-for-searchContext-and-JPATypedQueryVisitor-tp5727354.html
Sent from the cxf-user mailing list archive at Nabble.com.