{"id":3995,"date":"2011-08-19T00:53:31","date_gmt":"2011-08-18T19:23:31","guid":{"rendered":"https:\/\/2thenew.today\/blog\/?p=3995"},"modified":"2016-12-19T15:16:39","modified_gmt":"2016-12-19T09:46:39","slug":"grails-get-table-name-mapped-to-a-domain","status":"publish","type":"post","link":"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/","title":{"rendered":"Grails: Get table name mapped to a domain"},"content":{"rendered":"<p>Hi guys,<\/p>\n<p>Recently while working on a project, I needed to get the table names associated with a particular domain as I needed to perform complex join operations on a particular table. The <a title=\"Grails Developers\" href=\"https:\/\/2thenew.today\/grails-application-development\">database that my team was working<\/a> on was a legacy database. The domains that were created were mapped to particular tables to provide backward compatibility with the existing system&#8217;s database and, hence the table names were specified in the mapping closure. Now I needed a way to get the names of the tables that were associated with a particular domain.<\/p>\n<p>The <i>SessionFactoryProxy<\/i> can be directly used to get the table name associated with the domain. So the code is as follows:<\/p>\n<p>[code]<br \/>\nimport org.hibernate.metadata.ClassMetadata<br \/>\nimport org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder<br \/>\nimport org.codehaus.groovy.grails.commons.ApplicationHolder<\/p>\n<p>Class clazz = Class.forName(&amp;quot;com.intelligrape.domain.Album&amp;quot;, true, Thread.currentThread().getContextClassLoader())<\/p>\n<p>String mappedTable <\/p>\n<p>def sessionFactory = ApplicationHolder.application.mainContext.getBean(&amp;quot;sessionFactory&amp;quot;)<br \/>\nClassMetadata hibernateMetaClass = sessionFactory.getClassMetadata(clazz)<br \/>\nmappedTable = hibernateMetaClass.getTableName()<\/p>\n<p>println &amp;quot;Mapped table name: &amp;quot; + mappedTable<br \/>\n[\/code]<\/p>\n<p>Now the above modified code returns the table name associated with a domain.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi guys, Recently while working on a project, I needed to get the table names associated with a particular domain as I needed to perform complex join operations on a particular table. The database that my team was working on was a legacy database. The domains that were created were mapped to particular tables to [&hellip;]<\/p>\n","protected":false},"author":33,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":9,"footnotes":""},"categories":[7],"tags":[620,4840,382,265,621],"class_list":["post-3995","post","type-post","status-publish","format-standard","hentry","category-grails","tag-domain-binder","tag-grails","tag-grails-domain-mapping","tag-hibernate","tag-table-name-mapped-to-a-domain"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Hi guys, Recently while working on a project, I needed to get the table names associated with a particular domain as I needed to perform complex join operations on a particular table. The database that my team was working on was a legacy database. The domains that were created were mapped to particular tables to\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Roni C Thomas\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Grails: Get table name mapped to a domain | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"Hi guys, Recently while working on a project, I needed to get the table names associated with a particular domain as I needed to perform complex join operations on a particular table. The database that my team was working on was a legacy database. The domains that were created were mapped to particular tables to\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"article:tag\" content=\"grails\" \/>\n\t\t<meta property=\"article:tag\" content=\"domain binder\" \/>\n\t\t<meta property=\"article:tag\" content=\"grails domain mapping\" \/>\n\t\t<meta property=\"article:tag\" content=\"hibernate\" \/>\n\t\t<meta property=\"article:tag\" content=\"table name mapped to a domain\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2011-08-18T19:23:31+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2016-12-19T09:46:39+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Grails: Get table name mapped to a domain | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Hi guys, Recently while working on a project, I needed to get the table names associated with a particular domain as I needed to perform complex join operations on a particular table. The database that my team was working on was a legacy database. The domains that were created were mapped to particular tables to\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-get-table-name-mapped-to-a-domain\\\/#article\",\"name\":\"Grails: Get table name mapped to a domain | TO THE NEW Blog\",\"headline\":\"Grails: Get table name mapped to a domain\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/roni\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2011-08-19T00:53:31+05:30\",\"dateModified\":\"2016-12-19T15:16:39+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-get-table-name-mapped-to-a-domain\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-get-table-name-mapped-to-a-domain\\\/#webpage\"},\"articleSection\":\"Grails, domain binder, Grails, grails domain mapping, hibernate, table name mapped to a domain\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-get-table-name-mapped-to-a-domain\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"name\":\"Grails\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"position\":2,\"name\":\"Grails\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-get-table-name-mapped-to-a-domain\\\/#listItem\",\"name\":\"Grails: Get table name mapped to a domain\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-get-table-name-mapped-to-a-domain\\\/#listItem\",\"position\":3,\"name\":\"Grails: Get table name mapped to a domain\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"name\":\"Grails\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/roni\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/roni\\\/\",\"name\":\"Roni C Thomas\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-get-table-name-mapped-to-a-domain\\\/#authorImage\",\"url\":\"https:\\\/\\\/newersworld-sf-static.tothenew.net\\\/prod\\\/profilePicFolder\\\/7919dc04-af55-404b-bae5-eee87d6a016f_132-Roni-C-Thomas-PROFILEPICTURE.jpeg\",\"width\":96,\"height\":96,\"caption\":\"Roni C Thomas\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-get-table-name-mapped-to-a-domain\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-get-table-name-mapped-to-a-domain\\\/\",\"name\":\"Grails: Get table name mapped to a domain | TO THE NEW Blog\",\"description\":\"Hi guys, Recently while working on a project, I needed to get the table names associated with a particular domain as I needed to perform complex join operations on a particular table. The database that my team was working on was a legacy database. The domains that were created were mapped to particular tables to\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-get-table-name-mapped-to-a-domain\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/roni\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/roni\\\/#author\"},\"datePublished\":\"2011-08-19T00:53:31+05:30\",\"dateModified\":\"2016-12-19T15:16:39+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Grails: Get table name mapped to a domain | TO THE NEW Blog","description":"Hi guys, Recently while working on a project, I needed to get the table names associated with a particular domain as I needed to perform complex join operations on a particular table. The database that my team was working on was a legacy database. The domains that were created were mapped to particular tables to","canonical_url":"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/#article","name":"Grails: Get table name mapped to a domain | TO THE NEW Blog","headline":"Grails: Get table name mapped to a domain","author":{"@id":"https:\/\/2thenew.today\/blog\/author\/roni\/#author"},"publisher":{"@id":"https:\/\/2thenew.today\/blog\/#organization"},"datePublished":"2011-08-19T00:53:31+05:30","dateModified":"2016-12-19T15:16:39+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/#webpage"},"isPartOf":{"@id":"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/#webpage"},"articleSection":"Grails, domain binder, Grails, grails domain mapping, hibernate, table name mapped to a domain"},{"@type":"BreadcrumbList","@id":"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog#listItem","position":1,"name":"Home","item":"https:\/\/2thenew.today\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog\/category\/grails\/#listItem","name":"Grails"}},{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog\/category\/grails\/#listItem","position":2,"name":"Grails","item":"https:\/\/2thenew.today\/blog\/category\/grails\/","nextItem":{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/#listItem","name":"Grails: Get table name mapped to a domain"},"previousItem":{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/#listItem","position":3,"name":"Grails: Get table name mapped to a domain","previousItem":{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog\/category\/grails\/#listItem","name":"Grails"}}]},{"@type":"Organization","@id":"https:\/\/2thenew.today\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/2thenew.today\/blog\/"},{"@type":"Person","@id":"https:\/\/2thenew.today\/blog\/author\/roni\/#author","url":"https:\/\/2thenew.today\/blog\/author\/roni\/","name":"Roni C Thomas","image":{"@type":"ImageObject","@id":"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/#authorImage","url":"https:\/\/newersworld-sf-static.tothenew.net\/prod\/profilePicFolder\/7919dc04-af55-404b-bae5-eee87d6a016f_132-Roni-C-Thomas-PROFILEPICTURE.jpeg","width":96,"height":96,"caption":"Roni C Thomas"}},{"@type":"WebPage","@id":"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/#webpage","url":"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/","name":"Grails: Get table name mapped to a domain | TO THE NEW Blog","description":"Hi guys, Recently while working on a project, I needed to get the table names associated with a particular domain as I needed to perform complex join operations on a particular table. The database that my team was working on was a legacy database. The domains that were created were mapped to particular tables to","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/2thenew.today\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/#breadcrumblist"},"author":{"@id":"https:\/\/2thenew.today\/blog\/author\/roni\/#author"},"creator":{"@id":"https:\/\/2thenew.today\/blog\/author\/roni\/#author"},"datePublished":"2011-08-19T00:53:31+05:30","dateModified":"2016-12-19T15:16:39+05:30"},{"@type":"WebSite","@id":"https:\/\/2thenew.today\/blog\/#website","url":"https:\/\/2thenew.today\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/2thenew.today\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"article","og:title":"Grails: Get table name mapped to a domain | TO THE NEW Blog","og:description":"Hi guys, Recently while working on a project, I needed to get the table names associated with a particular domain as I needed to perform complex join operations on a particular table. The database that my team was working on was a legacy database. The domains that were created were mapped to particular tables to","og:url":"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/","og:image":"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","article:tag":{"0":"grails","1":"domain binder","3":"grails domain mapping","4":"hibernate","5":"table name mapped to a domain"},"article:published_time":"2011-08-18T19:23:31+00:00","article:modified_time":"2016-12-19T09:46:39+00:00","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Grails: Get table name mapped to a domain | TO THE NEW Blog","twitter:description":"Hi guys, Recently while working on a project, I needed to get the table names associated with a particular domain as I needed to perform complex join operations on a particular table. The database that my team was working on was a legacy database. The domains that were created were mapped to particular tables to","twitter:image":"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"3995","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":"","og_description":"","og_object_type":"article","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":"","og_article_tags":"","twitter_use_og":false,"twitter_card":"summary","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-30 08:14:01","updated":"2024-02-29 10:58:21","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/2thenew.today\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/2thenew.today\/blog\/category\/grails\/\" title=\"Grails\">Grails<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tGrails: Get table name mapped to a domain\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/2thenew.today\/blog"},{"label":"Grails","link":"https:\/\/2thenew.today\/blog\/category\/grails\/"},{"label":"Grails: Get table name mapped to a domain","link":"https:\/\/2thenew.today\/blog\/grails-get-table-name-mapped-to-a-domain\/"}],"_links":{"self":[{"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/posts\/3995","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/comments?post=3995"}],"version-history":[{"count":0,"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/posts\/3995\/revisions"}],"wp:attachment":[{"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/media?parent=3995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/categories?post=3995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/tags?post=3995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}