Announcement

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

    OperationBinding's "outputs" field with HibernateDatasource and ListGrid

    v8.3d_2012-11-06/PowerEdition Deployment (built 2012-11-06)

    datasource
    Code:
    <DataSource ID="users" serverType="hibernate" beanClassName="ru.eurotechnologygroup.etgcrm.server.model.User"
                schemaBean="ru.eurotechnologygroup.etgcrm.server.model.User" allowAdvancedCriteria="true">
        [b]<operationBindings>
            <operationBinding operationType="fetch" operationId="listFetch" outputs="lastName"/>
        </operationBindings>[/b]
        <fields>
            <field name="id" title="Идентификатор" required="true" detail="true" hidden="false"/>
            <field name="lastName" title="Фамилия" length="30" required="true"/>
            <field name="firstName" title="Имя" length="30"/>
            <field name="secondName" title="Отчество"  length="30"/>
            <field name="departmentName" title="Подразделение" type="text" valueXPath="department/name"/>
            <field name="department" title="Подразделение" displayField="departmentName" hidden="true"/>
            <!--<field name="departmentName" includeFrom="departments.name" hidden="true"/>
            <field name="department" title="Подразделение" foreignKey="departments.id" displayField="departmentName"/>-->
            <field name="phone" title="Телефон" length="50"/>
            <field name="email" title="EMail" length="50"/>
            <field name="login" title="Логин" length="20" required="true"/>
            <field name="password" title="Пароль" hidden="true" length="20" required="true"/>
            <field name="maskip" title="IP-маска" length="100"/>
            <field name="datebirth" title="Дата рождения" dateFormatter="toEuropeanShortDate"/>
            <field name="blocked" title="Заблокирован"/>
            <field name="roles" title="Роли" detail="true"/>
        </fields>
    </DataSource>
    And ListGrid:
    Code:
            ListGrid listGrid = new ListGrid();
            listGrid.setDataSource(DataSource.get("users"));
            listGrid.setFetchOperation("listFetch");
            listGrid.setAutoFetchData(true);
    Problems:
    1. Fetch operation is processed using all-fields sql(HQL)
    Code:
    === 2012-11-07 03:29:33,613 [l0-4] DEBUG RPCManager - Processing 1 requests.
    === 2012-11-07 03:29:33,627 [l0-4] DEBUG RPCManager - Request #1 (DSRequest) payload: {
        criteria:{
        },
        operationConfig:{
            dataSource:"users",
            operationType:"fetch",
            textMatchStyle:"substring"
        },
        startRow:0,
        endRow:75,
        componentId:"isc_ListGrid_0",
        appID:"builtinApplication",
        operation:"listFetch",
        oldValues:{
        }
    }
    === 2012-11-07 03:29:33,627 [l0-4] INFO  IDACall - Performing 1 operation(s)
    === 2012-11-07 03:29:33,628 [l0-4] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
    === 2012-11-07 03:29:33,628 [l0-4] DEBUG DeclarativeSecurity - DataSource users is not in the pre-checked list, processing...
    === 2012-11-07 03:29:33,633 [l0-4] DEBUG AppBase - [builtinApplication.listFetch] No userTypes defined, allowing anyone access to all operations for this application
    === 2012-11-07 03:29:33,634 [l0-4] DEBUG AppBase - [builtinApplication.listFetch] No public zero-argument method named '_listFetch' found, performing generic datasource operation
    === 2012-11-07 03:29:33,634 [l0-4] INFO  HibernateDataSource - [builtinApplication.listFetch] Performing fetch operation with
    	criteria: {}	values: {}
    === 2012-11-07 03:29:33,639 [l0-4] DEBUG HibernateTransaction - [builtinApplication.listFetch] Started new transaction "1555285483"
    === 2012-11-07 03:29:33,639 [l0-4] INFO  HibernateDataSource - [builtinApplication.listFetch] Query string: select _User, department1 from ru.eurotechnologygroup.etgcrm.server.model.User _User left outer join _User.department department1
    === 2012-11-07 03:29:33,647 [l0-4] DEBUG SQL - select count(*) as col_0_0_ from suser user0_
    === 2012-11-07 03:29:33,655 [l0-4] DEBUG SQL - select top 75 user0_.USERID as USERID0_0_, department1_.DID as DID2_1_, user0_.USERBLOCKED as USERBLOC2_0_0_, user0_.USERDATEBIRTH as USERDATE3_0_0_, user0_.DID as DID0_0_, user0_.USEREMAIL as USEREMAIL0_0_, user0_.USERFIRSNAME as USERFIRS5_0_0_, user0_.USERLASTNAME as USERLAST6_0_0_, user0_.USERLOGIN as USERLOGIN0_0_, user0_.USERMASKIP as USERMASKIP0_0_, user0_.USERPASSWORD as USERPASS9_0_0_, user0_.USERPHONE as USERPHONE0_0_, user0_.USERPATRONYMIC as USERPAT11_0_0_, department1_.DNAME as DNAME2_1_ from suser user0_ left outer join department department1_ on user0_.DID=department1_.DID
    === 2012-11-07 03:29:33,688 [l0-4] INFO  DSResponse - [builtinApplication.listFetch] DSResponse: List with 75 items
    while quick start guide says:
    With the built-in DataSources, it also limits the fields requested from the underlying data store.
    Maybe this is not a big problem until generated HQL contains extra joins which are totally unnecessary.

    2. The second problem is that ListGrid still contains all the other columns from datasource (with outputs="lastName" - only one field). They are rendered but contain no data. I don't know, whether it works as designed... Should i manually setup fields in my java-code every time i'm using operationBinding or is it a bug?

    TY
    Last edited by vostapenko; 6 Nov 2012, 15:55.

    #2
    1. Right now some combinations of Hibernate/JPA and specific databases will not limit fields in the SQL query. Regardless, the data never leaves the application server; the impact of selecting them depends on the quality of the JDBC driver. Whether we can improve this is something we're looking at for 4.0.

    2. Yes, you do need to set fields on a grid or you will show blanks for data that is not retrieved. It's not done automatically based on operationBinding.outputs because there are many other reasons why fields are added (such as calculated fields).

    Comment


      #3
      Thanks for the answer.

      About 1.

      Probably you've missed my statement.

      Maybe this is not a big problem until generated HQL contains extra joins which are totally unnecessary.
      You're right about limiting fields in plain single-table sql-query. That's not a big deal.

      But including unnecessary joins into HQL/sql queries can make a drammatic performance difference.

      Comment


        #4
        Many-1 or 1-1 joins such as those generated by field.includeFrom, typically used for the classic problem of fetching a displayValue from a related record, would generally be fine.

        Fetching entire related lists of entities through a 1-Many relation (such that a nested structure is delivered to the client) is something we don't generally recommend doing at all. Create a separate DataSource for the child object and use Queuing (see QuickStart) for the rare cases when you want parent and children loaded together. This is more flexible, less complex, and doesn't have performance gotchas.

        Comment

        Working...
        X