我使用FIQL查询使用Apache CXF 3.0.0-milestone1构建的Web服务。当我尝试引用java.util.Calendar类型的任何属性时,我得到一个org.apache.cxf.jaxrs.ext.search.PropertyNotFoundException。我已经跟踪了FiqlParser.parse(String表达式)调用的行为,我可以使用下面的简单代码重现它。
搜索bean: import java.util.Calendar; import java.util.Date;
public class Book {
private Long id;
private String title;
private Date published;
private Calendar created;
public Book() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Date getPublished() {
return published;
}
public void setPublished(Date published) {
this.published = published;
}
public Calendar getCreated() {
return created;
}
public void setCreated(Calendar created) {
this.created = created;
}
}
可执行类:
import org.apache.cxf.jaxrs.ext.search.SearchCondition;
import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
public class PlayGround {
public static void main(String[] args) {
FiqlParser<Book> parser = new FiqlParser(Book.class);
SearchCondition<Book> condition1 = parser.parse("id=ge=0");
SearchCondition<Book> condition2 = parser.parse("title==*wind*");
SearchCondition<Book> condition3 = parser.parse("published=ge=2014-01-01");
SearchCondition<Book> condition4 = parser.parse("created=ge=2013-01-01");
}
}
PlayGround在以下行失败:
SearchCondition<Book> condition4 = parser.parse("created=ge=2013-01-01");
堆栈追踪:
Exception in thread "main" org.apache.cxf.jaxrs.ext.search.PropertyNotFoundException
at org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser.parseComparison(FiqlParser.java:294)
at org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser.parseAndsOrsBrackets(FiqlParser.java:252)
at org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser.parse(FiqlParser.java:187)
at PlayGround.main(PlayGround.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
答案 0 :(得分:0)
如果在方法org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser.parseType(String,String,String)中的catch块中放置断点,则会看到此消息的异常:< / p>
org.apache.cxf.jaxrs.ext.search.SearchParseException: Cannot convert String value "2013-01-01" to a value of class java.util.Calendar