Announcement

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

    Field name: '...' specified in criteria is non-persistent. Skipping.

    After upgrading from SmartGWT 12.1 to 13.0, we see the following WARN log and our fetches don't filter properly:

    WARN [com.isomorphic.jpa.JPADataSource] (https-jsse-nio-8443-exec-8) Field name: 'pojoId1' specified in criteria is non-persistent. Skipping.
    WARN [com.isomorphic.jpa.JPADataSource] (https-jsse-nio-8443-exec-8) Field name: 'pojoId2' specified in criteria is non-persistent. Skipping.

    The field it is referencing are the primary key fields in our POJO:

    Code:
    @Entity
    @Table(name="BasePojo")
    @Inheritance(strategy=InheritanceType.JOINED)
    @DiscriminatorColumn(name = "pojoId1", discriminatorType = DiscriminatorType.INTEGER, length = 2)
    public abstract class BasePojo  {
    
        @EmbeddedId
        private PojoKey key;
    
        @Column(name = "pojoId1", updatable = false, insertable = false)
        private int pojoId1;
    
        @Column(name = "pojoId2", updatable = false, insertable = false)
        private int pojoId2;
    }
    
    @Entity
    @Embeddable
    @Table(name = "PojoA")
    @Inheritance(strategy = InheritanceType.JOINED)
    @DiscriminatorColumn(name = "val", discriminatorType = DiscriminatorType.STRING)
    public abstract class PojoA extends BasePojo {
        @Column(name = "val", nullable = true, length = 32)
        private String val;
       ...
    }
    
    @Entity
    @Table(name="MyPojo")
    @DiscriminatorValue(value="1")
    @Embeddable
    public class MyPojo extends PojoA {
        ...
    }
    
    @Embeddable
    public class PojoKey implements Serializable {
    
        @Column(name = "pojoId1")
        private int pojoId1;
    
        @Column(name = "pojoId2")
        private int pojoId2;
    }
    And the ds.xml looks like:

    Code:
    <DataSource
            ID="myPojoDMI"
            serverConstructor="com.isomorphic.jpa.JPADataSource"
            beanClassName="app.MyPojo"
            dropExtraFields="true">
        <fields>
            <field name="pojoId1" type="integer" required="true" primaryKey="true"/>
            <field name="pojoId2" type="integer" required="true" primaryKey="true"/>
            ...
        </fields>
    </DataSource>
    Last edited by rle125; 16 Dec 2024, 13:22.

    #2
    Looks like this test case is actually just abstract..

    For the actual DataSource in question, is autoDeriveSchema set? If it is, is the field public?

    If it isn't, is the field declared explicitly in the DataSource?

    Comment


      #3
      I updated the test case to more accurately reflect our setup.

      I added autoDeriveSchema=true and schemaBean="app.MyPojo" but get the same WARN logs:

      WARN [com.isomorphic.jpa.JPADataSource] (https-jsse-nio-8443-exec-8) Field name: 'pojoId1' specified in criteria is non-persistent. Skipping.
      WARN [com.isomorphic.jpa.JPADataSource] (https-jsse-nio-8443-exec-8) Field name: 'pojoId2' specified in criteria is non-persistent. Skipping.

      The primaryKey fields are declared both the embedded PojoKey and the BasePojo classes as shown in the test case.
      Last edited by rle125; 13 Dec 2024, 08:35.

      Comment


        #4
        We tried removing the "updatable = false, insertable = false" annotations but receive errors stating they're already defined.

        We tried modifying the ds.xml to reference key.pojoId1 and key.pojoId2 through xValuePath, but receive errors stating they're not found.

        Is there a suggested approach to including these fields in a Criteria?

        Comment


          #5
          Based on the information provided, we were unable to reproduce the issue locally. In our environment, fetching filtered data from the described data model appears to work as expected. Could you please share complete details about all the components involved? Ideally, a standalone use case with a minimal setup that showcases the issue would be highly helpful.

          Filtering against such fields is fairly straightforward. Here's one of the criteria we used when attempting to reproduce the issue:
          Code:
          { _constructor: "AdvancedCriteria", fieldName: "pojoId1", operator: "greaterThan", value: 1 }

          Comment


            #6
            Are you getting the following log when performing the fetch?

            WARN [com.isomorphic.jpa.JPADataSource] (https-jsse-nio-8443-exec-8) Field name: 'pojoId1' specified in criteria is non-persistent. Skipping.
            WARN [com.isomorphic.jpa.JPADataSource] (https-jsse-nio-8443-exec-8) Field name: 'pojoId2' specified in criteria is non-persistent. Skipping.

            I assume these are because of the following annotation parameters?

            @Column(...updatable = false, insertable = false)

            However, removing updatable and insertable results in:

            Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: app.BasePojo column: pojoId1 (should be mapped with insert="false" update="false")

            Comment


              #7
              I updated the original data model in my first post with all the JPA annotations used as well as a second abstract class.

              Comment


                #8
                Checking to see if the latest updated test case from my original post is sufficient for you guys to troubleshoot, or if you still need more information.

                Comment

                Working...
                X