Announcement

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

    Criterio on a foreign key issue

    Hello,

    We are curently investigating the implementation of a complete solution based on SmartGWT framework. In order to do so we have installed SmartGWTee 2.5 and GWT 2.3. We are using Firefox 3.6.12 as browser.

    So far, we are quite happy about the possibilities of smartGWT, but we are facing difficulties with foreign keys and JPA.

    We have implemented Many to One relation base on the sample provide by this link: http://www.smartclient.com/smartgwtee/showcase/#jpaRelationManyToOneSimple

    We tried to filter the ListGrid with a criteria on the foreign key where we select only the invoices with the applicant id 1, but it doesn't work:
    Code:
     
    ListGrid listgrid= new ListGrid();
    listgrid.setDataSource(DataSource.get("invoice"));
    Criteria criteria = new Criteria();
    criteria.addCriteria("applicant",1);
    listgrid.fetchData(criteria);
    We have warning in the logs:
    === 2011-10-05 10:40:30,832 [l0-5] WARN JPA2DataSource - [builtinApplication.invoice_fetch] Failed to cast value for field 'applicant'.
    Value '1' of type 'class java.lang.Long' can not be casted to type 'class dataModel.Applicant'.
    Skipping.

    We also tried to change the criterio to match the valueXPath:
    Code:
     
    criteria.addCriteria("applicantid",1);
    and we have the following warning:
    === 2011-10-05 10:45:08,724 [l0-2] WARN JPA2DataSource - [builtinApplication.invoice_fetch] Failed to identify path for field 'applicant.id'.
    java.lang.NullPointerException
    at org.hibernate.ejb.criteria.path.AbstractPathImpl.unknownAttribute(AbstractPathImpl.java:110)
    at org.hibernate.ejb.criteria.path.AbstractPathImpl.locateAttribute(AbstractPathImpl.java:218)
    at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:189)
    at com.isomorphic.jpa.JPA2DataSource.getPropertyPath(JPA2DataSource.java:1978)
    ...

    In two words, an applicant has many invoices and an invoices belongs to one and only one applicant, so the JPA definition of the list to be displayed is:
    Code:
     
    @Entity
    @Table(name = "T_INVOICE")
    @Audited
    public class Invoice{
    
    	@Id   
    	@Column (nullable = false)
                 @GeneratedValue(strategy = GenerationType.TABLE)
    	private long id;
    	
    	@ManyToOne
    	@JoinColumn(name="applicant", referencedColumnName="id")  
    	private Applicant applicant;
    
    	@Basic
    	private String invoiceNumber;
    }
    And the JPA definition for the applicant:
    Code:
    @Entity
    @Table(name = "T_APPLICANT")
    @Audited
    public class Applicant {
    	@Id
    	@Column (nullable = false)  
    	@GeneratedValue(strategy = GenerationType.TABLE)
    	private long id;
    
    	@OneToMany(mappedBy="applicant")
    	private List<Invoice> invoices = new ArrayList<Invoice>();
    
    	@Basic
    	private String name;
    }
    The data source definition are the following:
    Code:
    <DataSource ID="invoice" serverConstructor="com.isomorphic.jpa.JPA2DataSource"
    	beanClassName="dataModel.Invoice" schemaBean="dataModel.Invoice">
    	<fields>
    
    		<field name="applicantid" type="number" valueXPath="applicant/id" />
    
    		<field name="applicant" title="Applicant" displayField="name"
    			foreignKey="applicant.id" />
    		<field name="invoiceNumber" type="text" title="Invoice Number"
    			required="true" />
    	</fields>
    </DataSource>
    and:
    Code:
    <DataSource ID="applicant" serverConstructor="com.isomorphic.jpa.JPA2DataSource"
    	beanClassName="dataModel.Applicant"
    	schemaBean="dataModel.Applicant">
    	
    	<fields>
    		<field primaryKey="true" name="id" hidden="true" type="sequence" />
    		
    		<field name="name" title="Applicant Name" type="text" />
    	</fields>
    </DataSource>
    Thank you in advance for your help.

    Kind regards,

    Samuel Boclinville

    #2
    Please show the complete server log for the request, not just snippets (this is always needed for a server issue).

    Comment


      #3
      Here is the complete server log for the request using this first approach:
      Code:
      ListGrid listgrid= new ListGrid();
      listgrid.setDataSource(DataSource.get("invoice"));
      Criteria criteria = new Criteria();
      criteria.addCriteria("applicant",1);
      listgrid.fetchData(criteria);
      Code:
      === 2011-10-06 12:23:34,246 [l0-8] INFO  Compression - /JPADS_js/sc/IDACall: 74557 -> 5373 bytes
      === 2011-10-06 12:23:39,222 [l0-8] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\button\button_Over_start.png
      === 2011-10-06 12:23:39,222 [l0-3] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\button\button_Over_end.png
      === 2011-10-06 12:23:39,222 [l0-8] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\button\button_Over_stretch.png
      === 2011-10-06 12:23:39,987 [l0-8] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\button\button_stretch.png
      === 2011-10-06 12:23:39,987 [l0-8] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\button\button_end.png
      === 2011-10-06 12:23:39,987 [l0-3] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\button\button_start.png
      === 2011-10-06 12:23:44,215 [l0-3] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\button\button_Over_start.png
      === 2011-10-06 12:23:44,215 [l0-8] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\button\button_Over_stretch.png
      === 2011-10-06 12:23:44,215 [l0-6] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\button\button_Over_end.png
      === 2011-10-06 12:23:44,356 [l0-6] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\button\button_Down_start.png
      === 2011-10-06 12:23:44,372 [l0-8] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\button\button_Down_stretch.png
      === 2011-10-06 12:23:44,372 [l0-3] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\button\button_Down_end.png
      === 2011-10-06 12:23:44,434 [l0-8] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\button\button_stretch.png
      === 2011-10-06 12:23:44,434 [l0-6] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\button\button_end.png
      === 2011-10-06 12:23:44,434 [l0-3] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\button\button_start.png
      === 2011-10-06 12:23:44,450 [l0-3] INFO  RequestContext - URL: '/JPADS_js/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12': Moz (Gecko) with Accept-Encoding header
      === 2011-10-06 12:23:44,466 [l0-3] DEBUG XML - Parsed XML from (in memory stream): 16ms
      === 2011-10-06 12:23:44,466 [l0-3] DEBUG RPCManager - Processing 1 requests.
      === 2011-10-06 12:23:44,466 [l0-3] DEBUG RPCManager - Request #1 (DSRequest) payload: {
          criteria:{
              applicant:1
          },
          operationConfig:{
              dataSource:"invoice",
              operationType:"fetch",
              textMatchStyle:"exact"
          },
          startRow:0,
          endRow:50,
          componentId:"isc_CheckInvoiceView_1_0",
          appID:"builtinApplication",
          operation:"invoice_fetch",
          oldValues:{
              applicant:1
          }
      }
      === 2011-10-06 12:23:44,466 [l0-3] INFO  IDACall - Performing 1 operation(s)
      === 2011-10-06 12:23:44,466 [l0-3] DEBUG ServerObject - Couldn't find a public method named: fetch on class: com.avrs.server.InvoiceDMI
      === 2011-10-06 12:23:44,466 [l0-3] DEBUG DataSourceDMI - DataSourceDMI: no public method name: fetch available on class: com.avrs.server.InvoiceDMI - defaulting to builtin operations.
      === 2011-10-06 12:23:44,466 [l0-3] DEBUG AppBase - [builtinApplication.invoice_fetch] No userTypes defined, allowing anyone access to all operations for this application
      === 2011-10-06 12:23:44,466 [l0-3] DEBUG AppBase - [builtinApplication.invoice_fetch] No public zero-argument method named '_invoice_fetch' found, performing generic datasource operation
      === 2011-10-06 12:23:44,466 [l0-3] DEBUG JPADataSource - [builtinApplication.invoice_fetch] Creating EntityManager and starting transaction.
      === 2011-10-06 12:23:44,466 [l0-3] DEBUG DSRequest - [builtinApplication.invoice_fetch] Clobbering existing FreeResourcesHandler of type 'com.isomorphic.jpa.JPA2DataSource' with a 'com.isomorphic.jpa.JPA2DataSource'
      === 2011-10-06 12:23:44,466 [l0-3] DEBUG JPA2DataSource - [builtinApplication.invoice_fetch] Executing fetch.
      === 2011-10-06 12:23:44,466 [l0-3] WARN  JPA2DataSource - [builtinApplication.invoice_fetch] Failed to cast value for field 'applicant'.
      Value '1' of type 'class java.lang.Long' can not be casted to type 'class com.avrs.server.dataModel.Applicant'.
      Skipping.
      === 2011-10-06 12:23:44,512 [l0-3] INFO  DSResponse - [builtinApplication.invoice_fetch] DSResponse: List with 41 items
      === 2011-10-06 12:23:44,512 [l0-3] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
      === 2011-10-06 12:23:44,512 [l0-3] DEBUG JPADataSource - Committing current transaction.
      === 2011-10-06 12:23:44,528 [l0-3] DEBUG RPCManager - non-DMI response, dropExtraFields: false
      === 2011-10-06 12:23:44,637 [l0-3] DEBUG JPADataSource - Releasing entity manager.
      === 2011-10-06 12:23:44,637 [l0-3] INFO  Compression - /JPADS_js/sc/IDACall: 36182 -> 2258 bytes
      === 2011-10-06 12:23:44,762 [l0-3] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\loadingSmall.gif
      === 2011-10-06 12:23:47,461 [l0-6] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\Scrollbar\vscroll_track.png
      === 2011-10-06 12:23:47,461 [l0-3] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\Scrollbar\vscroll_start.png
      === 2011-10-06 12:23:47,461 [l0-8] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\Scrollbar\vscroll_end.png
      === 2011-10-06 12:23:47,461 [l0-8] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\Scrollbar\vthumb_grip.png
      === 2011-10-06 12:23:47,477 [l0-4] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\Scrollbar\vthumb_stretch.png
      === 2011-10-06 12:23:47,477 [l0-6] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\Scrollbar\vthumb_end.png
      === 2011-10-06 12:23:47,477 [l0-3] INFO  Download - Returning 304: Not modified on conditional get of: C:\Users\sboclinville\Documents\dvp\gitRepository\gitAVRS\AVRS\war\JPADS_js\sc\skins\Enterprise\images\Scrollbar\vthumb_start.png
      === 2011-10-06 12:23:50,894 [l0-3] INFO  RequestContext - URL: '/JPADS_js/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12': Moz (Gecko) with Accept-Encoding header
      Thank you for the help

      Comment


        #4
        Rename your field "applicant" to "applicantId" and apply the criteria to that field. Right now the field definition creates ambiguity because it seems to be a field for the getter/setter getApplicant()/setApplicant() whereas you actually want a field from the related object.

        Make sure you have also looked at the complete examples for this here.

        Comment


          #5
          Originally posted by Isomorphic View Post
          Rename your field "applicant" to "applicantId" and apply the criteria to that field. Right now the field definition creates ambiguity because it seems to be a field for the getter/setter getApplicant()/setApplicant() whereas you actually want a field from the related object
          I have the same problem, that filtering is done on the object itself and not on its id (FK). Can you give an correct example *.ds.xml for which filtering is working out of the box (esp. with the filtereditor of the listgrid). In your quoted example filtering is done only client side.

          Thank you
          Andreas
          (evaluating smartgwt enterprise edition)

          Comment


            #6
            Take a look at the examples in the EE Showcase for Many-to-One relations. There are multiple parallel samples for both JPA and Hibernate.

            Comment


              #7
              I took the example from http://www.smartclient.com/smartgwte...anyToOneSimple

              and stored many records in the database. So the filtering needs a server trip. And it doesn't work. Here is the log:

              Code:
              === 2012-09-18 22:30:09,044 [80-2] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projekte\test\smartgwtee-3.0p\samples\test\out\artifacts\test_war_exploded\test\sc\skins\Enterprise\images\pickers\comboBoxPicker_Over.png
              === 2012-09-18 22:30:09,055 [80-2] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projekte\test\smartgwtee-3.0p\samples\test\out\artifacts\test_war_exploded\test\sc\skins\Enterprise\images\pickers\comboBoxPicker_Over.png
              === 2012-09-18 22:30:09,060 [80-2] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projekte\test\smartgwtee-3.0p\samples\test\out\artifacts\test_war_exploded\test\sc\skins\Enterprise\images\pickers\comboBoxPicker_Over.png
              === 2012-09-18 22:30:09,067 [80-2] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projekte\test\smartgwtee-3.0p\samples\test\out\artifacts\test_war_exploded\test\sc\skins\Enterprise\images\pickers\comboBoxPicker_Over.png
              === 2012-09-18 22:30:09,074 [80-2] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projekte\test\smartgwtee-3.0p\samples\test\out\artifacts\test_war_exploded\test\sc\skins\Enterprise\images\pickers\comboBoxPicker_Over.png
              === 2012-09-18 22:30:12,396 [80-2] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projekte\test\smartgwtee-3.0p\samples\test\out\artifacts\test_war_exploded\test\sc\skins\Enterprise\images\RecordEditor\filter_Over.png
              === 2012-09-18 22:30:13,278 [80-2] INFO  RequestContext - URL: '/test/sc/skins/Enterprise/images/ListGrid/header_Over.png', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2': Moz (Gecko) with Accept-Encoding header
              === 2012-09-18 22:30:13,281 [80-2] INFO  Download - done streaming: C:/Projekte/test/smartgwtee-3.0p/samples/test/out/artifacts/test_war_exploded/test/sc/skins/Enterprise/images/ListGrid/header_Over.png
              === 2012-09-18 22:30:13,434 [80-2] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projekte\test\smartgwtee-3.0p\samples\test\out\artifacts\test_war_exploded\test\sc\skins\Enterprise\images\Scrollbar\vthumb_Over_start.png
              === 2012-09-18 22:30:13,436 [80-1] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projekte\test\smartgwtee-3.0p\samples\test\out\artifacts\test_war_exploded\test\sc\skins\Enterprise\images\Scrollbar\vthumb_Over_stretch.png
              === 2012-09-18 22:30:13,437 [80-5] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projekte\test\smartgwtee-3.0p\samples\test\out\artifacts\test_war_exploded\test\sc\skins\Enterprise\images\Scrollbar\vthumb_Over_end.png
              === 2012-09-18 22:30:13,504 [80-5] INFO  RequestContext - URL: '/test/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2': Moz (Gecko) with Accept-Encoding header
              === 2012-09-18 22:30:13,507 [80-5] DEBUG XML - Parsed XML from (in memory stream): 2ms
              === 2012-09-18 22:30:13,510 [80-5] DEBUG RPCManager - Processing 1 requests.
              === 2012-09-18 22:30:13,515 [80-5] DEBUG RPCManager - Request #1 (DSRequest) payload: {
                  criteria:{
                      country:3
                  },
                  operationConfig:{
                      dataSource:"cityManyToOneSimpleHB",
                      operationType:"fetch",
                      textMatchStyle:"substring"
                  },
                  startRow:0,
                  endRow:50,
                  componentId:"isc_ListGrid_0",
                  appID:"builtinApplication",
                  operation:"cityManyToOneSimpleHB_fetch",
                  oldValues:{
                      country:3
                  }
              }
              === 2012-09-18 22:30:13,516 [80-5] INFO  IDACall - Performing 1 operation(s)
              === 2012-09-18 22:30:13,521 [80-5] DEBUG AppBase - [builtinApplication.cityManyToOneSimpleHB_fetch] No userTypes defined, allowing anyone access to all operations for this application
              === 2012-09-18 22:30:13,521 [80-5] DEBUG AppBase - [builtinApplication.cityManyToOneSimpleHB_fetch] No public zero-argument method named '_cityManyToOneSimpleHB_fetch' found, performing generic datasource operation
              === 2012-09-18 22:30:13,522 [80-5] INFO  HibernateDataSource - [builtinApplication.cityManyToOneSimpleHB_fetch] Performing fetch operation with
              	criteria: {country:3}	values: {country:3}
              === 2012-09-18 22:30:13,551 [80-5] DEBUG HibernateTransaction - [builtinApplication.cityManyToOneSimpleHB_fetch] Started new transaction "306587185"
              === 2012-09-18 22:30:13,551 [80-5] WARN  HibernateDataSource - [builtinApplication.cityManyToOneSimpleHB_fetch] Failed to cast value for field 'country'.
              Value '3' of type 'class java.lang.Long' can not be casted to type 'class com.smartgwt.sample.showcase.server.CountryManyToOneSimple'.
              Skipping.
              === 2012-09-18 22:30:13,551 [80-5] INFO  HibernateDataSource - [builtinApplication.cityManyToOneSimpleHB_fetch] Query string: select _CityManyToOneSimple, country1 from com.smartgwt.sample.showcase.server.CityManyToOneSimple _CityManyToOneSimple left outer join _CityManyToOneSimple.country country1
              === 2012-09-18 22:30:13,567 [80-5] INFO  DSResponse - [builtinApplication.cityManyToOneSimpleHB_fetch] DSResponse: List with 50 items
              === 2012-09-18 22:30:13,568 [80-5] INFO  HibernateTransaction - [builtinApplication.cityManyToOneSimpleHB_fetch] Attempting to commit 0 database update(s)
              === 2012-09-18 22:30:13,568 [80-5] DEBUG HibernateTransaction - [builtinApplication.cityManyToOneSimpleHB_fetch] Committing transaction "306587185"
              === 2012-09-18 22:30:13,572 [80-5] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
              === 2012-09-18 22:30:13,575 [80-5] DEBUG RPCManager - non-DMI response, dropExtraFields: false
              === 2012-09-18 22:30:13,641 [80-2] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projekte\test\smartgwtee-3.0p\samples\test\out\artifacts\test_war_exploded\test\sc\skins\Enterprise\images\Scrollbar\vscroll_Disabled_start.png
              === 2012-09-18 22:30:13,642 [80-1] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projekte\test\smartgwtee-3.0p\samples\test\out\artifacts\test_war_exploded\test\sc\skins\Enterprise\images\loadingSmall.gif
              === 2012-09-18 22:30:13,645 [80-2] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projekte\test\smartgwtee-3.0p\samples\test\out\artifacts\test_war_exploded\test\sc\skins\Enterprise\images\Scrollbar\vscroll_Disabled_track.png
              === 2012-09-18 22:30:13,646 [80-1] INFO  Download - Returning 304: Not modified on conditional get of: C:\Projekte\test\smartgwtee-3.0p\samples\test\out\artifacts\test_war_exploded\test\sc\skins\Enterprise\images\Scrollbar\vscroll_Disabled_end.png
              === 2012-09-18 22:30:13,666 [80-5] DEBUG HibernateTransaction - Closing session "306587185"
              === 2012-09-18 22:30:13,667 [80-5] DEBUG HibernateTransaction - Removed transaction "306587185"
              === 2012-09-18 22:30:13,667 [80-5] INFO  Compression - /test/sc/IDACall: 3751 -> 896 bytes
              Also in the filter each country appears more than one time (it isn't distinct)

              Comment


                #8
                This would now work in 3.1d (get it from SmartClient.com/builds). In earlier versions, you must explicitly declare the countryId field in JPA and as the foreignKey field in your DataSource.

                Comment


                  #9
                  The Filter in the example is still not working correctly. There is a like query surrounded by % for the ID field ( like '%7%' ) which returns too many results. I know that I can adjust these setting within the Criteria but I think this should work out of the box without any custom coding.

                  Here is the log:

                  Code:
                  === 2012-09-19 00:36:12,942 [80-3] INFO  RequestContext - URL: '/test/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2': Moz (Gecko) with Accept-Encoding header
                  === 2012-09-19 00:36:12,943 [80-3] DEBUG IDACall - Header Name:Value pair: host:127.0.0.1:8080
                  === 2012-09-19 00:36:12,943 [80-3] DEBUG IDACall - Header Name:Value pair: user-agent:Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
                  === 2012-09-19 00:36:12,943 [80-3] DEBUG IDACall - Header Name:Value pair: accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
                  === 2012-09-19 00:36:12,944 [80-3] DEBUG IDACall - Header Name:Value pair: accept-language:de,de-de;q=0.7,en;q=0.3
                  === 2012-09-19 00:36:12,944 [80-3] DEBUG IDACall - Header Name:Value pair: accept-encoding:gzip, deflate
                  === 2012-09-19 00:36:12,944 [80-3] DEBUG IDACall - Header Name:Value pair: connection:keep-alive
                  === 2012-09-19 00:36:12,944 [80-3] DEBUG IDACall - Header Name:Value pair: content-type:application/x-www-form-urlencoded; charset=UTF-8
                  === 2012-09-19 00:36:12,944 [80-3] DEBUG IDACall - Header Name:Value pair: referer:http://127.0.0.1:8080/index.html?gwt.codesvr=127.0.0.1:9997
                  === 2012-09-19 00:36:12,946 [80-3] DEBUG IDACall - Header Name:Value pair: content-length:1164
                  === 2012-09-19 00:36:12,946 [80-3] DEBUG IDACall - Header Name:Value pair: cookie:GLog=%7B%0D%20%20%20%20left%3A960%2C%20%0D%20%20%20%20top%3A0%2C%20%0D%20%20%20%20width%3A940%2C%20%0D%20%20%20%20height%3A892%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A4%2C%20%0D%20%20%20%20trackRPC%3Atrue%0D%7D; isc_cState=ready; JSESSIONID=CD45C2CCFF41486B735139163BAA7256
                  === 2012-09-19 00:36:12,948 [80-3] DEBUG IDACall - Header Name:Value pair: pragma:no-cache
                  === 2012-09-19 00:36:12,948 [80-3] DEBUG IDACall - Header Name:Value pair: cache-control:no-cache
                  === 2012-09-19 00:36:12,948 [80-3] DEBUG IDACall - session exists: CD45C2CCFF41486B735139163BAA7256
                  === 2012-09-19 00:36:12,948 [80-3] DEBUG IDACall - remote user: null
                  === 2012-09-19 00:36:12,950 [80-3] DEBUG XML - Parsed XML from (in memory stream): 1ms
                  === 2012-09-19 00:36:12,955 [80-3] DEBUG RPCManager - Processing 1 requests.
                  === 2012-09-19 00:36:12,958 [80-3] DEBUG RPCManager - Request #1 (DSRequest) payload: {
                      criteria:{
                          country:7
                      },
                      operationConfig:{
                          dataSource:"cityManyToOneSimpleHB",
                          operationType:"fetch",
                          textMatchStyle:"substring"
                      },
                      startRow:0,
                      endRow:50,
                      componentId:"isc_ListGrid_0",
                      appID:"builtinApplication",
                      operation:"cityManyToOneSimpleHB_fetch",
                      oldValues:{
                          country:7
                      }
                  }
                  === 2012-09-19 00:36:12,959 [80-3] INFO  IDACall - Performing 1 operation(s)
                  === 2012-09-19 00:36:12,959 [80-3] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
                  === 2012-09-19 00:36:12,959 [80-3] DEBUG DeclarativeSecurity - DataSource cityManyToOneSimpleHB is not in the pre-checked list, processing...
                  === 2012-09-19 00:36:12,959 [80-3] DEBUG AppBase - [builtinApplication.cityManyToOneSimpleHB_fetch] No userTypes defined, allowing anyone access to all operations for this application
                  === 2012-09-19 00:36:12,961 [80-3] DEBUG AppBase - [builtinApplication.cityManyToOneSimpleHB_fetch] No public zero-argument method named '_cityManyToOneSimpleHB_fetch' found, performing generic datasource operation
                  === 2012-09-19 00:36:12,961 [80-3] INFO  HibernateDataSource - [builtinApplication.cityManyToOneSimpleHB_fetch] Performing fetch operation with
                  	criteria: {country:7}	values: {country:7}
                  === 2012-09-19 00:36:12,984 [80-3] DEBUG HibernateTransaction - [builtinApplication.cityManyToOneSimpleHB_fetch] Started new transaction "366435968"
                  === 2012-09-19 00:36:12,985 [80-3] INFO  HibernateDataSource - [builtinApplication.cityManyToOneSimpleHB_fetch] Query string: select _CityManyToOneSimple, country1 from com.smartgwt.sample.showcase.server.CityManyToOneSimple _CityManyToOneSimple left outer join _CityManyToOneSimple.country country1 where (lower(concat(_CityManyToOneSimple.country.countryId,'')) like lower(:p0) escape '~')
                  === 2012-09-19 00:36:12,989 [80-3] DEBUG HibernateDataSource - [builtinApplication.cityManyToOneSimpleHB_fetch] Parameter p0: %7%
                  Hibernate: 
                      select
                          count(*) as col_0_0_ 
                      from
                          city citymanyto0_ 
                      where
                          lower(concat(citymanyto0_.countryId, '')) like lower(?) escape '~'
                  Hibernate: 
                      select
                          citymanyto0_.cityId as cityId0_0_,
                          countryman1_.countryId as countryId1_1_,
                          citymanyto0_.cityName as cityName0_0_,
                          citymanyto0_.countryId as countryId0_0_,
                          countryman1_.countryCode as countryC2_1_1_,
                          countryman1_.countryName as countryN3_1_1_ 
                      from
                          city citymanyto0_ 
                      left outer join
                          country countryman1_ 
                              on citymanyto0_.countryId=countryman1_.countryId 
                      where
                          lower(concat(citymanyto0_.countryId, '')) like lower(?) escape '~' limit ?
                  === 2012-09-19 00:36:13,002 [80-3] INFO  DSResponse - [builtinApplication.cityManyToOneSimpleHB_fetch] DSResponse: List with 50 items
                  === 2012-09-19 00:36:13,002 [80-3] INFO  HibernateTransaction - [builtinApplication.cityManyToOneSimpleHB_fetch] Attempting to commit 0 database update(s)
                  === 2012-09-19 00:36:13,002 [80-3] DEBUG HibernateTransaction - [builtinApplication.cityManyToOneSimpleHB_fetch] Committing transaction "366435968"
                  === 2012-09-19 00:36:13,005 [80-3] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
                  === 2012-09-19 00:36:13,008 [80-3] DEBUG RPCManager - non-DMI response, dropExtraFields: false
                  === 2012-09-19 00:36:13,093 [80-3] DEBUG HibernateTransaction - Closing session "366435968"
                  === 2012-09-19 00:36:13,095 [80-3] DEBUG HibernateTransaction - Removed transaction "366435968"
                  === 2012-09-19 00:36:13,095 [80-3] INFO  Compression - /test/sc/IDACall: 3792 -> 893 bytes
                  === 2012-09-19 00:36:18,453 [80-3] INFO  RequestContext - URL: '/test/sc/system/reference/skin/images/server_client_exchange.png', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2': Moz (Gecko) with Accept-Encoding header
                  === 2012-09-19 00:36:18,455 [80-3] INFO  Download - File C:/Projekte/test/smartgwtee-3.0p/samples/test/out/artifacts/test_war_exploded/test/sc/system/reference/skin/images/server_client_exchange.png not found, sending 404
                  === 2012-09-19 00:36:18,567 [80-3] INFO  RequestContext - URL: '/test/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2': Moz (Gecko) with Accept-Encoding header
                  === 2012-09-19 00:36:18,567 [80-3] DEBUG IDACall - Header Name:Value pair: host:127.0.0.1:8080
                  === 2012-09-19 00:36:18,567 [80-3] DEBUG IDACall - Header Name:Value pair: user-agent:Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
                  === 2012-09-19 00:36:18,567 [80-3] DEBUG IDACall - Header Name:Value pair: accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
                  === 2012-09-19 00:36:18,571 [80-3] DEBUG IDACall - Header Name:Value pair: accept-language:de,de-de;q=0.7,en;q=0.3
                  === 2012-09-19 00:36:18,571 [80-3] DEBUG IDACall - Header Name:Value pair: accept-encoding:gzip, deflate
                  === 2012-09-19 00:36:18,571 [80-3] DEBUG IDACall - Header Name:Value pair: connection:keep-alive
                  === 2012-09-19 00:36:18,571 [80-3] DEBUG IDACall - Header Name:Value pair: content-type:application/x-www-form-urlencoded; charset=UTF-8
                  === 2012-09-19 00:36:18,571 [80-3] DEBUG IDACall - Header Name:Value pair: referer:http://127.0.0.1:8080/index.html?gwt.codesvr=127.0.0.1:9997
                  === 2012-09-19 00:36:18,573 [80-3] DEBUG IDACall - Header Name:Value pair: content-length:1166
                  === 2012-09-19 00:36:18,573 [80-3] DEBUG IDACall - Header Name:Value pair: cookie:GLog=%7B%0D%20%20%20%20left%3A960%2C%20%0D%20%20%20%20top%3A0%2C%20%0D%20%20%20%20width%3A940%2C%20%0D%20%20%20%20height%3A892%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A4%2C%20%0D%20%20%20%20trackRPC%3Atrue%0D%7D; isc_cState=ready; JSESSIONID=CD45C2CCFF41486B735139163BAA7256
                  === 2012-09-19 00:36:18,575 [80-3] DEBUG IDACall - Header Name:Value pair: pragma:no-cache
                  === 2012-09-19 00:36:18,575 [80-3] DEBUG IDACall - Header Name:Value pair: cache-control:no-cache
                  === 2012-09-19 00:36:18,575 [80-3] DEBUG IDACall - session exists: CD45C2CCFF41486B735139163BAA7256
                  === 2012-09-19 00:36:18,575 [80-3] DEBUG IDACall - remote user: null
                  === 2012-09-19 00:36:18,578 [80-3] DEBUG XML - Parsed XML from (in memory stream): 2ms
                  === 2012-09-19 00:36:18,580 [80-3] DEBUG RPCManager - Processing 1 requests.
                  === 2012-09-19 00:36:18,583 [80-3] DEBUG RPCManager - Request #1 (DSRequest) payload: {
                      criteria:{
                          country:7
                      },
                      operationConfig:{
                          dataSource:"cityManyToOneSimpleHB",
                          operationType:"fetch",
                          textMatchStyle:"substring"
                      },
                      startRow:50,
                      endRow:100,
                      componentId:"isc_ListGrid_0",
                      appID:"builtinApplication",
                      operation:"cityManyToOneSimpleHB_fetch",
                      oldValues:{
                          country:7
                      }
                  }
                  === 2012-09-19 00:36:18,586 [80-3] INFO  IDACall - Performing 1 operation(s)
                  === 2012-09-19 00:36:18,586 [80-3] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
                  === 2012-09-19 00:36:18,586 [80-3] DEBUG DeclarativeSecurity - DataSource cityManyToOneSimpleHB is not in the pre-checked list, processing...
                  === 2012-09-19 00:36:18,586 [80-3] DEBUG AppBase - [builtinApplication.cityManyToOneSimpleHB_fetch] No userTypes defined, allowing anyone access to all operations for this application
                  === 2012-09-19 00:36:18,588 [80-3] DEBUG AppBase - [builtinApplication.cityManyToOneSimpleHB_fetch] No public zero-argument method named '_cityManyToOneSimpleHB_fetch' found, performing generic datasource operation
                  === 2012-09-19 00:36:18,588 [80-3] INFO  HibernateDataSource - [builtinApplication.cityManyToOneSimpleHB_fetch] Performing fetch operation with
                  	criteria: {country:7}	values: {country:7}
                  === 2012-09-19 00:36:18,609 [80-3] DEBUG HibernateTransaction - [builtinApplication.cityManyToOneSimpleHB_fetch] Started new transaction "1022276960"
                  === 2012-09-19 00:36:18,610 [80-3] INFO  HibernateDataSource - [builtinApplication.cityManyToOneSimpleHB_fetch] Query string: select _CityManyToOneSimple, country1 from com.smartgwt.sample.showcase.server.CityManyToOneSimple _CityManyToOneSimple left outer join _CityManyToOneSimple.country country1 where (lower(concat(_CityManyToOneSimple.country.countryId,'')) like lower(:p0) escape '~')
                  === 2012-09-19 00:36:18,610 [80-3] DEBUG HibernateDataSource - [builtinApplication.cityManyToOneSimpleHB_fetch] Parameter p0: %7%
                  Hibernate: 
                      select
                          count(*) as col_0_0_ 
                      from
                          city citymanyto0_ 
                      where
                          lower(concat(citymanyto0_.countryId, '')) like lower(?) escape '~'
                  Hibernate: 
                      select
                          citymanyto0_.cityId as cityId0_0_,
                          countryman1_.countryId as countryId1_1_,
                          citymanyto0_.cityName as cityName0_0_,
                          citymanyto0_.countryId as countryId0_0_,
                          countryman1_.countryCode as countryC2_1_1_,
                          countryman1_.countryName as countryN3_1_1_ 
                      from
                          city citymanyto0_ 
                      left outer join
                          country countryman1_ 
                              on citymanyto0_.countryId=countryman1_.countryId 
                      where
                          lower(concat(citymanyto0_.countryId, '')) like lower(?) escape '~' limit ?, ?
                  === 2012-09-19 00:36:18,627 [80-3] INFO  DSResponse - [builtinApplication.cityManyToOneSimpleHB_fetch] DSResponse: List with 26 items
                  === 2012-09-19 00:36:18,628 [80-3] INFO  HibernateTransaction - [builtinApplication.cityManyToOneSimpleHB_fetch] Attempting to commit 0 database update(s)
                  === 2012-09-19 00:36:18,628 [80-3] DEBUG HibernateTransaction - [builtinApplication.cityManyToOneSimpleHB_fetch] Committing transaction "1022276960"
                  === 2012-09-19 00:36:18,631 [80-3] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
                  === 2012-09-19 00:36:18,635 [80-3] DEBUG RPCManager - non-DMI response, dropExtraFields: false
                  === 2012-09-19 00:36:18,679 [80-3] DEBUG HibernateTransaction - Closing session "1022276960"
                  === 2012-09-19 00:36:18,681 [80-3] DEBUG HibernateTransaction - Removed transaction "1022276960"
                  === 2012-09-19 00:36:18,681 [80-3] INFO  Compression - /test/sc/IDACall: 1994 -> 584 bytes
                  === 2012-09-19 00:36:19,033 [80-3] INFO  RequestContext - URL: '/test/sc/system/reference/skin/images/server_client_exchange.png', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2': Moz (Gecko) with Accept-Encoding header
                  === 2012-09-19 00:36:19,034 [80-3] INFO  Download - File C:/Projekte/test/smartgwtee-3.0p/samples/test/out/artifacts/test_war_exploded/test/sc/system/reference/skin/images/server_client_exchange.png not found, sending 404

                  Comment


                    #10
                    Yeah, we agree this should probably be automatic. For now, you can set the operatorId to use via FormItem.setOperator() and ListGridField.setFilterEditorType().

                    Comment


                      #11
                      Andreas,

                      I've just committed changes. Now textMatchStyle is ignored in criteria for relation fields. You can test it with next nightly build.

                      Regards,
                      Alius

                      Comment

                      Working...
                      X