Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
JPA Container - Filter problem
I have a JPA container, and I am trying to add a couple of filters to it (not necessarily at the same time). In both cases, the filter is a text string, and the code to add the filters looks like this:
jc_RRD_Record.addNestedContainerProperty("trafficReport.desc");
...
...
private void applyDescFilter(){
String fString = txt_Desc_Filter.getValue() + "%";
Filter f = Filters.like("trafficReport.desc", fString, false);
jc_RRD_Record.addFilter(f);
}
private void applyRRDFilter(){
String fString = txt_RRD_Filter.getValue() + "%";
Filter f = Filters.like("rPath", fString, false);
jc_RRD_Record.addFilter(f);
}
A call to the second filter (on rPath) works. The first one fails with this error:
SEVERE: Terminal error:
com.vaadin.event.ListenerMethod$MethodException
Cause: java.lang.IllegalArgumentException: Invalid filter
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:532)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219)
at com.vaadin.ui.AbstractField.fireValueChange(AbstractField.java:922)
at com.vaadin.ui.AbstractField.setValue(AbstractField.java:559)
at com.vaadin.ui.AbstractTextField.changeVariables(AbstractTextField.java:242)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.changeVariables(AbstractCommunicationManager.java:1445)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1393)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1312)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:763)
at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:296)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501)
at org.vaadin.artur.icepush.ICEPushServlet.service(ICEPushServlet.java:72)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IllegalArgumentException: Invalid filter
at com.vaadin.addon.jpacontainer.filter.util.AdvancedFilterableSupport.addFilter(AdvancedFilterableSupport.java:182)
at com.vaadin.addon.jpacontainer.JPAContainer.addFilter(JPAContainer.java:746)
at com.verisign.jart.window.Win_AddGraphs.applyDescFilter(Win_AddGraphs.java:354)
at com.verisign.jart.window.Win_AddGraphs.access$12(Win_AddGraphs.java:351)
at com.verisign.jart.window.Win_AddGraphs$4.valueChange(Win_AddGraphs.java:214)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:512)
... 25 more
The only difference I can see is that the rPath field comes directly from the table associated with the JPAContainer. The description column is a generated column (a foreign key field). Can someone tell me what I need to do to get the first filter to work properly?
At one time, I think I had this working - but I don't remember changing anything in this area of the code... I'm guessing I've done something really dumb...
thanks very much,
nbc
After much digging, I found the correct way to create a one-to-one mapping, and that seems to have solved this issue. I had a many-to-one mapping of the TrafficReport object and it should be one-to-one. Fixing this seems to have made the problem go away.
For the record, the code looks like this:
In the RRDRecord class:
@OneToOne(mappedBy="rrdRecord",fetch=FetchType.EAGER)
private TrafficReport trafficReport;
and in the TrafficReport object:
@OneToOne
@PrimaryKeyJoinColumn
private RrdRecord rrdRecord;
This, along with the appropriate getters and setters seems to work.
nbc