JPAContainer - Filter transient column fails

Hello,

I have a JPA entity with @Transient column, which is a joined column from another table. If I filter in JPA Container on the @Transient column, I get an exception (please see source code below). I tested it on BeanContainer filled by JPA query and it works there.

Can you help me how to solve this problem please? Has to JPAContainer source be modified or can I change something in my code to solve it? I could rewrite my project to BeanContainer but I can not see problems that could occure.

Many thanks in advance.

JPA Entity:

@Entity
public class Project {
...
@ManyToOne
    @JoinColumn(name="customerId")        
    private Company customer;
    
    @Transient
    private String customerName;

public void setCustomer(Company customer) {
        this.customer = customer;
    }
    
    public String getCustomerName() {
        if (this.customer != null)
            return this.customer.getName();
        else return null;
    }

} //@Entity

I filter on any value in customerName column:

JPAContainer<Project> container = JPAContainerFactory.make(Project.class, em);
Filter filter = new Compare.Equal("customerName", "Stabia");

container.addContainerFilter(filter);

And I get an exception:

XII 23, 2013 8:35:31 ODP. com.vaadin.server.DefaultErrorHandler doDefault
SEVERE:
com.vaadin.event.ListenerMethod$MethodException: Invocation of method valueChange in org.tepi.filtertable.FilterFieldGenerator$2 failed.
    at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:528)
    at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)
    at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
    at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:969)
    at com.vaadin.ui.AbstractField.fireValueChange(AbstractField.java:1126)
    at com.vaadin.ui.AbstractField.setValue(AbstractField.java:542)
    at com.vaadin.ui.AbstractTextField.changeVariables(AbstractTextField.java:181)
    at com.vaadin.server.communication.ServerRpcHandler.changeVariables(ServerRpcHandler.java:396)
    at com.vaadin.server.communication.ServerRpcHandler.handleBurst(ServerRpcHandler.java:221)
    at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:111)
    at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:91)
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1382)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    at org.eclipse.jetty.server.Server.handle(Server.java:370)
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
    at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:960)
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1021)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
    at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.IllegalArgumentException: The attribute [customerName]
 is not present in the managed type [EntityTypeImpl@4211868:Project [ javaType: class eu.ranna.jpatest.Project descriptor: RelationalDescriptor(eu.ranna.jpatest.Project --> [DatabaseTable(PROJECT)]
), mappings: 8]].
    at org.eclipse.persistence.internal.jpa.metamodel.ManagedTypeImpl.getAttribute(ManagedTypeImpl.java:148)
    at org.eclipse.persistence.internal.jpa.querydef.FromImpl.get(FromImpl.java:312)
    at com.vaadin.addon.jpacontainer.filter.util.AdvancedFilterableSupport.getPropertyPathTyped(AdvancedFilterableSupport.java:242)
    at com.vaadin.addon.jpacontainer.filter.util.AdvancedFilterableSupport.getPropertyPath(AdvancedFilterableSupport.java:235)
    at com.vaadin.addon.jpacontainer.filter.util.FilterConverter$SimpleStringFilterConverter.toPredicate(FilterConverter.java:167)
    at com.vaadin.addon.jpacontainer.filter.util.FilterConverter.convertFilter(FilterConverter.java:278)
    at com.vaadin.addon.jpacontainer.provider.LocalEntityProvider.doGetEntityCount(LocalEntityProvider.java:518)
    at com.vaadin.addon.jpacontainer.provider.CachingSupport$FilterCacheEntry.getEntityCount(CachingSupport.java:157)
    at com.vaadin.addon.jpacontainer.provider.CachingSupport.getEntityCount(CachingSupport.java:826)
    at com.vaadin.addon.jpacontainer.provider.CachingMutableLocalEntityProvider.getEntityCount(CachingMutableLocalEntityProvider.java:130)
    at com.vaadin.addon.jpacontainer.JPAContainer.size(JPAContainer.java:912)
    at com.vaadin.ui.AbstractSelect.size(AbstractSelect.java:762)
    at com.vaadin.ui.CustomTable.setCurrentPageFirstItemIndex(CustomTable.java:1473)
    at com.vaadin.ui.CustomTable.containerItemSetChange(CustomTable.java:4448)
    at com.vaadin.addon.jpacontainer.JPAContainer.fireContainerItemSetChange(JPAContainer.java:262)
    at com.vaadin.addon.jpacontainer.JPAContainer$1.filtersApplied(JPAContainer.java:179)
    at com.vaadin.addon.jpacontainer.filter.util.AdvancedFilterableSupport.fireListeners(AdvancedFilterableSupport.java:99)
    at com.vaadin.addon.jpacontainer.filter.util.AdvancedFilterableSupport.applyFilters(AdvancedFilterableSupport.java:222)
    at com.vaadin.addon.jpacontainer.filter.util.AdvancedFilterableSupport.addFilter(AdvancedFilterableSupport.java:256)
    at com.vaadin.addon.jpacontainer.JPAContainer.addContainerFilter(JPAContainer.java:1006)
    at org.tepi.filtertable.FilterFieldGenerator.setFilter(FilterFieldGenerator.java:282)
    at org.tepi.filtertable.FilterFieldGenerator.access$1000(FilterFieldGenerator.java:41)
    at org.tepi.filtertable.FilterFieldGenerator$2.valueChange(FilterFieldGenerator.java:479)
    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.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
    ... 39 more

XII 23, 2013 8:35:31 ODP. com.vaadin.server.DefaultErrorHandler doDefault
SEVERE:
java.lang.IllegalArgumentException: The attribute [customerName]
 is not present in the managed type [EntityTypeImpl@4211868:Project [ javaType: class eu.ranna.jpatest.Project descriptor: RelationalDescriptor(eu.ranna.jpatest.Project --> [DatabaseTable(PROJECT)]
), mappings: 8]].
    at org.eclipse.persistence.internal.jpa.metamodel.ManagedTypeImpl.getAttribute(ManagedTypeImpl.java:148)
    at org.eclipse.persistence.internal.jpa.querydef.FromImpl.get(FromImpl.java:312)
    at com.vaadin.addon.jpacontainer.filter.util.AdvancedFilterableSupport.getPropertyPathTyped(AdvancedFilterableSupport.java:242)
    at com.vaadin.addon.jpacontainer.filter.util.AdvancedFilterableSupport.getPropertyPath(AdvancedFilterableSupport.java:235)
    at com.vaadin.addon.jpacontainer.filter.util.FilterConverter$SimpleStringFilterConverter.toPredicate(FilterConverter.java:167)
    at com.vaadin.addon.jpacontainer.filter.util.FilterConverter.convertFilter(FilterConverter.java:278)
    at com.vaadin.addon.jpacontainer.provider.LocalEntityProvider.doGetEntityCount(LocalEntityProvider.java:518)
    at com.vaadin.addon.jpacontainer.provider.CachingSupport$FilterCacheEntry.getEntityCount(CachingSupport.java:157)
    at com.vaadin.addon.jpacontainer.provider.CachingSupport.getEntityCount(CachingSupport.java:826)
    at com.vaadin.addon.jpacontainer.provider.CachingMutableLocalEntityProvider.getEntityCount(CachingMutableLocalEntityProvider.java:130)
    at com.vaadin.addon.jpacontainer.JPAContainer.size(JPAContainer.java:912)
    at com.vaadin.ui.AbstractSelect.size(AbstractSelect.java:762)
    at com.vaadin.ui.CustomTable.doPaintContent(CustomTable.java:3212)
    at com.vaadin.ui.CustomTable.paintContent(CustomTable.java:3196)
    at org.tepi.filtertable.FilterTable.paintContent(FilterTable.java:69)
    at com.vaadin.server.LegacyPaint.paint(LegacyPaint.java:65)
    at com.vaadin.server.communication.LegacyUidlWriter.write(LegacyUidlWriter.java:81)
    at com.vaadin.server.communication.UidlWriter.write(UidlWriter.java:106)
    at com.vaadin.server.communication.UidlRequestHandler.writeUidl(UidlRequestHandler.java:149)
    at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:97)
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1382)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    at org.eclipse.jetty.server.Server.handle(Server.java:370)
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
    at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:960)
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1021)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
    at java.lang.Thread.run(Thread.java:724)

I have it, thank you. I solve the problem by removing @Transient attributes, since desired funkcionality can be achieved by JPAContainer.addNestedContainerProperty(PropertyId).

So the problem with filtering on @Transient columns remains, but it doesn’t annoy me now.

Hi,

did anyone manage to fix this?

What if you have a @Transient calculated property and not a nested property?

How does one make the filter work on a @Transient property?

Regards,
George