{"id":203,"date":"2015-11-26T14:49:43","date_gmt":"2015-11-26T14:49:43","guid":{"rendered":"https:\/\/maximoconcepts.wordpress.com\/?p=203"},"modified":"2015-11-26T14:49:43","modified_gmt":"2015-11-26T14:49:43","slug":"when-using-mxserver-for-fetching-mboset","status":"publish","type":"post","link":"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/","title":{"rendered":"When using MXServer for fetching MboSet"},"content":{"rendered":"

There are two ways of fetching a MboSet in java code, either using a relationship or through MXserver. There are different benefits for using either of these and different scenarios may need one of these ways to be used. For now, we are going to talk about MboSet fetched from MXServer.<\/p>\n

When fetching a MboSet from MXServer, there are a few things that one needs to be careful about. Poor knowledge of these may result in performance issues, poor memory management and undesirable outcomes.<\/p>\n

There are six simple rules to keep in mind when fetching MboSet from MXserver. These rules are as follows \u2013<\/p>\n

    \n
  1. Always use setWhere() and reset() on the set fetched from MXServer. The where clause that you give in the setWhere will reduce the no. of MBOs fetched in the set. The reset will get the data from the database using the where clause. If the setWhere is not used, the entire set is fetched from the database which means the entire table is fetched into the memory.<\/li>\n<\/ol>\n
    \n
    MboSetRemote assetSet = MXServer.getMXServer().getMboSet(\"ASSET\", getUserInfo());\n<\/em>assetSet.setWhere(\"LOCATION = 'BEDFORD'\");\n<\/em>assetSet.reset();<\/em><\/pre>\n<\/blockquote>\n
      \n
    1. If the set is being fetched just to add new MBOs and not for traversing then use 1=0 as where clause in the setWhere. This will fetch an empty set.<\/li>\n<\/ol>\n
      \n
      assetSet.setWhere(\"1=0\");\n<\/em>assetSet.reset();<\/em><\/pre>\n<\/blockquote>\n
        \n
      1. If the set is being fetched just for traversing and not for any addition or updates set DISCARDABLE flag as true on the MboSet. Discardable MboSets are not cached in memory, they can only be traversed in forward direction and cannot be saved.<\/li>\n<\/ol>\n
        \n
        assetSet.setFlag(DISCARDABLE, true);<\/em><\/pre>\n<\/blockquote>\n
          \n
        1. If MboSet is fetched for readonly purpose, set NOSAVE flag as true. This way the MboSet won\u2019t be added to the MXTransaction which would shortens the looping time of the transaction.<\/li>\n<\/ol>\n
          \n
          assetSet.setFlag(NOSAVE, true);<\/em><\/pre>\n<\/blockquote>\n
            \n
          1. If an add or update transaction is being performed on an MboSet, do not forget to call save(). Contrary to popular belief that save shouldn\u2019t be called explicitly in java code, MboSet fetched from MXServer must be saved before the set is closed otherwise the changes would be lost. MboSets fetched from relationship do not require a save to be called explicitly because their save is called when their parent is saved. Hence the belief.<\/li>\n<\/ol>\n
              \n
            1. Always call clear() and close() on the MboSet fetched from MXServer once it is certain that it is not required anymore. This releases the memory and the database resources. If the set is not closed, it will remain in memory till it is collected by the garbage collector which could be a long time.<\/li>\n<\/ol>\n
              \n
              assetSet.clear();\n<\/em>assetSet.close();<\/em>\u00a0<\/em><\/pre>\n<\/blockquote>\n

              clear and close shouldn\u2019t be called on an MBOSet fetched from a relationship. This will give undesirable results.<\/p>\n

              So keep in mind these simple rules next time when you are fetching a set from MXServer.<\/p>\n

              In my next post I will try to explain you the difference between clear(), cleanup() & close(). Stay tuned.. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"

              There are two ways of fetching a MboSet in java code, either using a relationship or through MXserver. There are different benefits for using either of these and different scenarios may need one of these ways to be used. For now, we are going to talk about MboSet fetched from MXServer. When fetching a MboSet … Continue reading When using MXServer for fetching MboSet<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[13,5],"tags":[],"yoast_head":"\nWhen using MXServer for fetching MboSet - Maximo Concepts<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"When using MXServer for fetching MboSet - Maximo Concepts\" \/>\n<meta property=\"og:description\" content=\"There are two ways of fetching a MboSet in java code, either using a relationship or through MXserver. There are different benefits for using either of these and different scenarios may need one of these ways to be used. For now, we are going to talk about MboSet fetched from MXServer. When fetching a MboSet … Continue reading When using MXServer for fetching MboSet\" \/>\n<meta property=\"og:url\" content=\"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/\" \/>\n<meta property=\"og:site_name\" content=\"Maximo Concepts\" \/>\n<meta property=\"article:published_time\" content=\"2015-11-26T14:49:43+00:00\" \/>\n<meta name=\"author\" content=\"Pranjal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pranjal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/\"},\"author\":{\"name\":\"Pranjal\",\"@id\":\"https:\/\/maximoconcepts.com\/#\/schema\/person\/2a0ce61af426d0c4038aeaa51cb0f98b\"},\"headline\":\"When using MXServer for fetching MboSet\",\"datePublished\":\"2015-11-26T14:49:43+00:00\",\"dateModified\":\"2015-11-26T14:49:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/\"},\"wordCount\":465,\"commentCount\":13,\"publisher\":{\"@id\":\"https:\/\/maximoconcepts.com\/#\/schema\/person\/2a0ce61af426d0c4038aeaa51cb0f98b\"},\"articleSection\":[\"Customization\",\"Technical\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/\",\"url\":\"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/\",\"name\":\"When using MXServer for fetching MboSet - Maximo Concepts\",\"isPartOf\":{\"@id\":\"https:\/\/maximoconcepts.com\/#website\"},\"datePublished\":\"2015-11-26T14:49:43+00:00\",\"dateModified\":\"2015-11-26T14:49:43+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/maximoconcepts.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"When using MXServer for fetching MboSet\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/maximoconcepts.com\/#website\",\"url\":\"https:\/\/maximoconcepts.com\/\",\"name\":\"Maximo Concepts\",\"description\":\"Concepts Simplified.\",\"publisher\":{\"@id\":\"https:\/\/maximoconcepts.com\/#\/schema\/person\/2a0ce61af426d0c4038aeaa51cb0f98b\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/maximoconcepts.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/maximoconcepts.com\/#\/schema\/person\/2a0ce61af426d0c4038aeaa51cb0f98b\",\"name\":\"Pranjal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/maximoconcepts.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/i0.wp.com\/maximoconcepts.com\/wp-content\/uploads\/2015\/08\/dscn4443-2.jpg?fit=516%2C520&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/maximoconcepts.com\/wp-content\/uploads\/2015\/08\/dscn4443-2.jpg?fit=516%2C520&ssl=1\",\"width\":516,\"height\":520,\"caption\":\"Pranjal\"},\"logo\":{\"@id\":\"https:\/\/maximoconcepts.com\/#\/schema\/person\/image\/\"},\"url\":\"https:\/\/maximoconcepts.com\/author\/pranjal\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"When using MXServer for fetching MboSet - Maximo Concepts","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/","og_locale":"en_GB","og_type":"article","og_title":"When using MXServer for fetching MboSet - Maximo Concepts","og_description":"There are two ways of fetching a MboSet in java code, either using a relationship or through MXserver. There are different benefits for using either of these and different scenarios may need one of these ways to be used. For now, we are going to talk about MboSet fetched from MXServer. When fetching a MboSet … Continue reading When using MXServer for fetching MboSet","og_url":"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/","og_site_name":"Maximo Concepts","article_published_time":"2015-11-26T14:49:43+00:00","author":"Pranjal","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Pranjal","Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/#article","isPartOf":{"@id":"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/"},"author":{"name":"Pranjal","@id":"https:\/\/maximoconcepts.com\/#\/schema\/person\/2a0ce61af426d0c4038aeaa51cb0f98b"},"headline":"When using MXServer for fetching MboSet","datePublished":"2015-11-26T14:49:43+00:00","dateModified":"2015-11-26T14:49:43+00:00","mainEntityOfPage":{"@id":"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/"},"wordCount":465,"commentCount":13,"publisher":{"@id":"https:\/\/maximoconcepts.com\/#\/schema\/person\/2a0ce61af426d0c4038aeaa51cb0f98b"},"articleSection":["Customization","Technical"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/","url":"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/","name":"When using MXServer for fetching MboSet - Maximo Concepts","isPartOf":{"@id":"https:\/\/maximoconcepts.com\/#website"},"datePublished":"2015-11-26T14:49:43+00:00","dateModified":"2015-11-26T14:49:43+00:00","breadcrumb":{"@id":"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/maximoconcepts.com\/2015\/11\/26\/when-using-mxserver-for-fetching-mboset\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/maximoconcepts.com\/"},{"@type":"ListItem","position":2,"name":"When using MXServer for fetching MboSet"}]},{"@type":"WebSite","@id":"https:\/\/maximoconcepts.com\/#website","url":"https:\/\/maximoconcepts.com\/","name":"Maximo Concepts","description":"Concepts Simplified.","publisher":{"@id":"https:\/\/maximoconcepts.com\/#\/schema\/person\/2a0ce61af426d0c4038aeaa51cb0f98b"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/maximoconcepts.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":["Person","Organization"],"@id":"https:\/\/maximoconcepts.com\/#\/schema\/person\/2a0ce61af426d0c4038aeaa51cb0f98b","name":"Pranjal","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/maximoconcepts.com\/#\/schema\/person\/image\/","url":"https:\/\/i0.wp.com\/maximoconcepts.com\/wp-content\/uploads\/2015\/08\/dscn4443-2.jpg?fit=516%2C520&ssl=1","contentUrl":"https:\/\/i0.wp.com\/maximoconcepts.com\/wp-content\/uploads\/2015\/08\/dscn4443-2.jpg?fit=516%2C520&ssl=1","width":516,"height":520,"caption":"Pranjal"},"logo":{"@id":"https:\/\/maximoconcepts.com\/#\/schema\/person\/image\/"},"url":"https:\/\/maximoconcepts.com\/author\/pranjal\/"}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/maximoconcepts.com\/wp-json\/wp\/v2\/posts\/203"}],"collection":[{"href":"https:\/\/maximoconcepts.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/maximoconcepts.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/maximoconcepts.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/maximoconcepts.com\/wp-json\/wp\/v2\/comments?post=203"}],"version-history":[{"count":0,"href":"https:\/\/maximoconcepts.com\/wp-json\/wp\/v2\/posts\/203\/revisions"}],"wp:attachment":[{"href":"https:\/\/maximoconcepts.com\/wp-json\/wp\/v2\/media?parent=203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/maximoconcepts.com\/wp-json\/wp\/v2\/categories?post=203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/maximoconcepts.com\/wp-json\/wp\/v2\/tags?post=203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}