Ограничить выполнение одного и того же объекта GORM в Groovy - PullRequest
0 голосов
/ 04 июля 2018

Я новичок в groovy. В моем проекте я получаю данные из базы данных, используя объект GORM. Когда я когда-либо вызываю объект для данных, он выполняется несколько раз. Я понятия не имею, почему он выполняется. После получения данных с использованием одного и того же объекта, когда я вижу журнал гибернации, происходит больше, чем выполнение того же объекта.

например:

Country country = Country.findByCountryCode('all');

если я вызову вышеуказанный объект, получим следующий журнал в спящем режиме

    Hibernate: select * from ( select this_.id as id1_79_0_, this_.version as version2_79_0_, this_.admin_instructions_for_use_id as admin_instructions3_79_0_, this_.admin_faq_id as admin_faq_id4_79_0_, this_.contact as contact5_79_0_, this_.country_id as country_id6_79_0_, this_.date_display_format as date_display_forma7_79_0_, this_.default_language as default_language8_79_0_, this_.distributors_id as distributors_id9_79_0_, this_.ecko_faq_id as ecko_faq_id10_79_0_, this_.ecos_faq_id as ecos_faq_id11_79_0_, this_.features_id as features_id12_79_0_, this_.footer_logo_left_id as footer_logo_left_13_79_0_, this_.footer_logo_right_id as footer_logo_right14_79_0_, this_.instructions_for_use_id as instructions_for_15_79_0_, this_.language_id as language_id16_79_0_, this_.license_agreement_id as license_agreement17_79_0_, this_.name_display_format as name_display_form18_79_0_, this_.participate as participate19_79_0_, this_.terms_of_use_id as terms_of_use_id20_79_0_, this_.use_default_format as use_default_forma21_79_0_, this_.user_guide_id as user_guide_id22_79_0_ from country_configuration this_ where this_.country_id=? and this_.language_id=? ) where rownum <= ?
    Hibernate: select * from ( select this_.id as id1_79_0_, this_.version as version2_79_0_, this_.admin_instructions_for_use_id as admin_instructions3_79_0_, this_.admin_faq_id as admin_faq_id4_79_0_, this_.contact as contact5_79_0_, this_.country_id as country_id6_79_0_, this_.date_display_format as date_display_forma7_79_0_, this_.default_language as default_language8_79_0_, this_.distributors_id as distributors_id9_79_0_, this_.ecko_faq_id as ecko_faq_id10_79_0_, this_.ecos_faq_id as ecos_faq_id11_79_0_, this_.features_id as features_id12_79_0_, this_.footer_logo_left_id as footer_logo_left_13_79_0_, this_.footer_logo_right_id as footer_logo_right14_79_0_, this_.instructions_for_use_id as instructions_for_15_79_0_, this_.language_id as language_id16_79_0_, this_.license_agreement_id as license_agreement17_79_0_, this_.name_display_format as name_display_form18_79_0_, this_.participate as participate19_79_0_, this_.terms_of_use_id as terms_of_use_id20_79_0_, this_.use_default_format as use_default_forma21_79_0_, this_.user_guide_id as user_guide_id22_79_0_ from country_configuration this_ where this_.country_id=? and this_.language_id=? ) where rownum <= ?
    Hibernate: select * from ( select this_.id as id1_79_0_, this_.version as version2_79_0_, this_.admin_instructions_for_use_id as admin_instructions3_79_0_, this_.admin_faq_id as admin_faq_id4_79_0_, this_.contact as contact5_79_0_, this_.country_id as country_id6_79_0_, this_.date_display_format as date_display_forma7_79_0_, this_.default_language as default_language8_79_0_, this_.distributors_id as distributors_id9_79_0_, this_.ecko_faq_id as ecko_faq_id10_79_0_, this_.ecos_faq_id as ecos_faq_id11_79_0_, this_.features_id as features_id12_79_0_, this_.footer_logo_left_id as footer_logo_left_13_79_0_, this_.footer_logo_right_id as footer_logo_right14_79_0_, this_.instructions_for_use_id as instructions_for_15_79_0_, this_.language_id as language_id16_79_0_, this_.license_agreement_id as license_agreement17_79_0_, this_.name_display_format as name_display_form18_79_0_, this_.participate as participate19_79_0_, this_.terms_of_use_id as terms_of_use_id20_79_0_, this_.use_default_format as use_default_forma21_79_0_, this_.user_guide_id as user_guide_id22_79_0_ from country_configuration this_ where this_.country_id=? and this_.language_id=? ) where rownum <= ?
    Hibernate: select * from ( select this_.id as id1_79_0_, this_.version as version2_79_0_, this_.admin_instructions_for_use_id as admin_instructions3_79_0_, this_.admin_faq_id as admin_faq_id4_79_0_, this_.contact as contact5_79_0_, this_.country_id as country_id6_79_0_, this_.date_display_format as date_display_forma7_79_0_, this_.default_language as default_language8_79_0_, this_.distributors_id as distributors_id9_79_0_, this_.ecko_faq_id as ecko_faq_id10_79_0_, this_.ecos_faq_id as ecos_faq_id11_79_0_, this_.features_id as features_id12_79_0_, this_.footer_logo_left_id as footer_logo_left_13_79_0_, this_.footer_logo_right_id as footer_logo_right14_79_0_, this_.instructions_for_use_id as instructions_for_15_79_0_, this_.language_id as language_id16_79_0_, this_.license_agreement_id as license_agreement17_79_0_, this_.name_display_format as name_display_form18_79_0_, this_.participate as participate19_79_0_, this_.terms_of_use_id as terms_of_use_id20_79_0_, this_.use_default_format as use_default_forma21_79_0_, this_.user_guide_id as user_guide_id22_79_0_ from country_configuration this_ where this_.country_id=? and this_.language_id=? ) where rownum <= ?
Hibernate: select * from ( select this_.id as id1_79_0_, this_.version as version2_79_0_, this_.admin_instructions_for_use_id as admin_instructions3_79_0_, this_.admin_faq_id as admin_faq_id4_79_0_, this_.contact as contact5_79_0_, this_.country_id as country_id6_79_0_, this_.date_display_format as date_display_forma7_79_0_, this_.default_language as default_language8_79_0_, this_.distributors_id as distributors_id9_79_0_, this_.ecko_faq_id as ecko_faq_id10_79_0_, this_.ecos_faq_id as ecos_faq_id11_79_0_, this_.features_id as features_id12_79_0_, this_.footer_logo_left_id as footer_logo_left_13_79_0_, this_.footer_logo_right_id as footer_logo_right14_79_0_, this_.instructions_for_use_id as instructions_for_15_79_0_, this_.language_id as language_id16_79_0_, this_.license_agreement_id as license_agreement17_79_0_, this_.name_display_format as name_display_form18_79_0_, this_.participate as participate19_79_0_, this_.terms_of_use_id as terms_of_use_id20_79_0_, this_.use_default_format as use_default_forma21_79_0_, this_.user_guide_id as user_guide_id22_79_0_ from country_configuration this_ where this_.country_id=? and this_.language_id=? ) where rownum <= ?
    Hibernate: select * from ( select this_.id as id1_79_0_, this_.version as version2_79_0_, this_.admin_instructions_for_use_id as admin_instructions3_79_0_, this_.admin_faq_id as admin_faq_id4_79_0_, this_.contact as contact5_79_0_, this_.country_id as country_id6_79_0_, this_.date_display_format as date_display_forma7_79_0_, this_.default_language as default_language8_79_0_, this_.distributors_id as distributors_id9_79_0_, this_.ecko_faq_id as ecko_faq_id10_79_0_, this_.ecos_faq_id as ecos_faq_id11_79_0_, this_.features_id as features_id12_79_0_, this_.footer_logo_left_id as footer_logo_left_13_79_0_, this_.footer_logo_right_id as footer_logo_right14_79_0_, this_.instructions_for_use_id as instructions_for_15_79_0_, this_.language_id as language_id16_79_0_, this_.license_agreement_id as license_agreement17_79_0_, this_.name_display_format as name_display_form18_79_0_, this_.participate as participate19_79_0_, this_.terms_of_use_id as terms_of_use_id20_79_0_, this_.use_default_format as use_default_forma21_79_0_, this_.user_guide_id as user_guide_id22_79_0_ from country_configuration this_ where this_.country_id=? and this_.language_id=? ) where rownum <= ?

Пожалуйста, помогите мне исправить это. Спасибо заранее.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...