Announcement

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

    Hibernate HQL Clause

    I'm trying to add a whereCluase to my Hibernate DataSource file and I'm not seeing any difference in the generated query. Here's my ds.xml:

    Code:
    <DataSource ID="CodeType"
                serverType="hibernate"
                beanClassName="com.assaabloy.protech.domain.CodeType"
                autoDeriveSchema="false"
                dropExtraFields="true">
        <fields>
            <field name="codeTypeId" type="integer" primaryKey="true" hidden="false"/>
            <field name="description" type="text"/>
            <field name="allowEdits" type="boolean"/>
        </fields>
    
        <operationBinding operationType="fetch">
            <whereClause><![CDATA[
            codeType.codeTypeId < 20 AND ($defaultWhereClause)
            ]]></whereClause>
        </operationBinding>
    </DataSource>
    I've tried escaping the XML with CDATA as above and like this:
    Code:
    <whereClause>codeType.codeTypeId &lt; 20 AND ($defaultWhereClause)</whereClause>
    but no difference. I've also attached the console log.

    I'm using version:Isomorphic SmartClient/SmartGWT Framework (v11.1p_2018-08-01/PowerEdition Deployment 2018-08-01)

    Is there something I'm doing wrong to get this clause to work properly?

    Attached Files

    #2
    <whereClause> and other clause-by-clause customizations are only available for SQLDataSource, not HibernateDataSource. For HibernateDataSource, the only customization we're able to provide is whole-query replacement, via the <customHQL> tag.

    This is one of several reasons we strongly recommend using our SQLDataSource rather than Hibernate unless you have *extremely* compelling reasons to use Hibernate.

    Comment


      #3
      Is there any plan in the near future for this feature?

      HQL templating is listed as a feature both here:

      https://www.smartclient.com/product/#sqlTemplating

      and here:

      https://www.smartclient.com/smartgwt...mQuerying.html

      Comment


        #4
        Using the HibernateDataSource, is there an easy way of adding a computed or aggregate field while maintaining the default behavior of the fetch (like pagination)? We're specifically trying to add a "sum(field)" value to our returned data and were wondering if this is possible without being able to replace the select clause?

        Comment


          #5
          Take a look at the Server Summaries overview for server-side aggregation features. In the future, please start a new thread for a new question like that.

          As far as your question about clause-by-clause HQL customization: there has been zero interest in this feature, so it's not on our near-term roadmap. It's easy to see why: most of the SQL customizations people want to do can be easily done without introducing vendor-specific syntax, as HQL is meant to prevent you from doing. Then, in the rare case when you really want vendor-specific syntax, HQL becomes a big roadblock. So it adds complexity and limitations without adding real value.

          However, this feature would be valid for Feature Sponsorship if you really, really want it for some reason.

          Comment

          Working...
          X