Announcement

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

    JPA, ManyToOne, Server-side AdvancedCriteria

    Hi,

    I'm using SmartGWTPower 3.1p.

    I'm using a JPADatasource with a bean with a ManyToOne field named 'group'.

    My goal is to add an additional Criterion checking if the value of the field 'group' is in a given Set retrieved from the Session. This should apply to all operations (fetch, add, update, delete).

    The current approach I'm planning is to extend JPADatasource to override execute(DSRequest) and access HttpSession to get the Set and modify the request's AdvancedCriteria from there. What I can't figure out is how to create the new Criterion and pass the entities to the Criterion. It seems Criterion constructors only take primitive arrays.

    Is there a simpler or correct way to achieve my goal?

    Thanks,

    Ech

    #2
    What were you hoping to pass as the set that cannot be represented by a primitive array?

    If you are trying to figure out if some foreignKey field points to specific beans, you would want to pass a primitive array of whatever type the foreignKey field has, for example.

    Comment


      #3
      Hi,

      Thanks for the quick reply.

      I was under the impression that the datasource will map the field "group" to the entity bean instead of the foreign key.

      I suppose I can pass as set of foreign keys instead. If I do this, should the field name still be "group" or something like "group.id"? I assume i should still use SetCriterion with an operatorId DefaultOperators.InSet.getID()?

      Thanks again,

      Ech

      Comment


        #4
        You would apply the criteria to the name of the foreignKey field. Do not use a path.

        Comment


          #5
          Ok that worked.

          Thanks,

          Ech

          Comment

          Working...
          X