You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Diether <di...@optis.be> on 2013/05/07 15:52:57 UTC

Problem with bean properties Map for searchContext and JPATypedQueryVisitor

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&lt;Order>> visitor = new
JPATypedQueryVisitor<Order>(getEntityManager(), Order.class,
backendBeanPropertiesMap);
	if (filter != null) {
		List<SearchCondition&lt;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.

Re: Problem with bean properties Map for searchContext and JPATypedQueryVisitor

Posted by Diether <di...@optis.be>.
Unfortunatly my company does not allow us to access the snapshot repository. 
So I cannot test it with that version.
I implemented the workaround so it is working now. But I'll test again after
we can upgrade to the newest version.
Thanks for the quick reply



--
View this message in context: http://cxf.547215.n5.nabble.com/Problem-with-bean-properties-Map-for-searchContext-and-JPATypedQueryVisitor-tp5727354p5727492.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Problem with bean properties Map for searchContext and JPATypedQueryVisitor

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 30/05/13 09:39, krish09 wrote:
> hey I am also facing the same issue. Can you please let me know the bug no
> for this so later on I can try this as in my company also I cant use
> snapshot label.
See https://issues.apache.org/jira/browse/CXF-4949

CXF 2.6.8 should have it fixed
Sergey
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Problem-with-bean-properties-Map-for-searchContext-and-JPATypedQueryVisitor-tp5727354p5728525.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


Re: Problem with bean properties Map for searchContext and JPATypedQueryVisitor

Posted by krish09 <in...@gmail.com>.
hey I am also facing the same issue. Can you please let me know the bug no
for this so later on I can try this as in my company also I cant use
snapshot label.



--
View this message in context: http://cxf.547215.n5.nabble.com/Problem-with-bean-properties-Map-for-searchContext-and-JPATypedQueryVisitor-tp5727354p5728525.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Problem with bean properties Map for searchContext and JPATypedQueryVisitor

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 07/05/13 14:52, Diether wrote:
> 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&lt;Order>>  visitor = new
> JPATypedQueryVisitor<Order>(getEntityManager(), Order.class,
> backendBeanPropertiesMap);
> 	if (filter != null) {
> 		List<SearchCondition&lt;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.
>

I believe I've got this issue fixed for CXF 2.6.8-SNAPSHOT. Can you try 
the SNAPSHOT please ? Or CXF 2.7.6-SNAPSHOT (2.7.5 is being voted upon 
now)...

Thanks, Sergey

>
>
>
> --
> 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.


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com