Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Advanced Criteria is functioning client side but not server side

    I have a fairly simple AdvancedCriteria that is checking the values of an Embeddable.
    The server reports that "/status/status1 specified in criteria is not defined in data source. Skipping."
    However, DataSource.evaluateCriterion(record, criteria) will filter the results returned by the server as expected.
    Am I missing something here?

    Here is a similar implementation to our model

    Test.java
    Code:
    @Entity
    public class Test {
         @Id
         @GeneratedValue(strategy = GenerationType.IDENTITY)
         private long id;
    
         @Embedded
         private Status status;
    
         public long getId() {return id;}
         public void setId(long id) {this.id = id;}
         public Status getStatus() {return status;}
         public void setStatus(Status status) {this.status = status;}
    }
    Status.java
    Code:
    @Embeddable
    public class Status {
         private StatusType status1;
         private StatusType status2;
    
         public StatusType getStatus1() { return status1;}
         public void setStatus1(StatusType status1) {this.status1 = status1;}
         public StatusType getStatus2() {return status2;}
         public void setStatus2(StatusType status2) {this.status2 = status2;}
    }
    StatusType.java
    Code:
    public enum StatusType {
         ACTIVE, INACTIVE
    }
    Status.ds.xml
    Code:
    <DataSource beanClassName="Status" ID="Status_DS">
        <fields>
               <field name="status1" type="enum">
                     <valueMap ACTIVE="Active" INACTIVE="Inactive"/>
               </field>
               <field name="status2" type="enum">
                     <valueMap ACTIVE="Active" INACTIVE="Inactive"/>
               </field>
        </fields>
    </DataSource>
    Test.ds.xml
    Code:
    <DataSource beanClassName="Test" ID="TEST_DS" serverConstructor="com.isomorphic.jpa.JPA2DataSource">
         <fields>
              <name="id" type="sequence" primaryKey="true"/>
              <name="status" type="Status_DS"/>
         </fields>
    </DataSource>
    Criteria
    Code:
         AdvancedCriteria criteria = new AdvancedCriteria(OperatorId.AND, new Criterion[] {
              new Criterion("/status", OperatorId.NOT_NULL),
              new Criterion("/status/status1", OperatorId.NOT_NULL),
              new Criterion("/status/status1", OperatorId.EQUALS, StatusType.ACTIVE.name())
        });
    I forgot this detail: SmartClient Version: v9.1p_2015-09-26/PowerEdition Deployment (built 2015-09-26)

    #2
    We'll take a look and respond when we have more information for you.
    Regards
    Isomorphic Software

    Comment


      #3
      None of our server-side data connectors (JPA, Hibernate, SQL) support using the dataPath notation to perform filtering on sub-objects. The "dataPath" feature of AdvancedCriteria is only for client-side usage.

      Comment


        #4
        From your answer it would seem that you are telling me that I must do one of three things:
        1. Change my datasource to flatten the data model.
        2. Write a custom fetch method to filter on the sub object server side.
        3. Filter the data client side.

        The last is highly inefficient. The second stinks because especially in this particular case because I have two interfaces that essentially display the same data and so I can use abstraction for efficient code reuse presuming that only the criteria changes. And the first is likely the least preferable method, and yet probably the only one that allows me to move forward.
        Last edited by jpappalardo; 30 Sep 2015, 06:01.

        Comment


          #5
          It's unclear what you mean about the second one; what we'd do in this case would be to handle criteria that our JPADataSource would ignore by applying it to the results after the JPADataSource has executed the base criteria. A fourth option is of course Feature Sponsorship. Embeddables aren't especially common, so we haven't looked at whether JPA can filter them on most of the supported SQL engines. It might be easy.

          Comment

          Working...
          X