Skip to content


Funcionamento do Lazy Load no Ibatis

A documentação do Ibatis não explica adequadamente como funciona o mecanismo de Lazy Load do framework, e como este conhecimento é importante e útil, resolvi explicar brevemente por aqui.

Para habilitar o mecanismo de lazy load, é necessário declarar o elemento settings no sql-map-config, como o exemplo a seguir:

<sqlMapConfig>
	<settings
		cacheModelsEnabled="true"
		enhancementEnabled="true"
		lazyLoadingEnabled="true"
		maxRequests="128"
		maxSessions="10"
		maxTransactions="5"
		useStatementNamespaces="false"
		defaultStatementTimeout="5"	/>
</sqlMapConfig>

Nestas configurações, dois elementos são importantes. O parâmetro lazyLoadingEnabled habilita globalmente o uso de lazy loading no framework. Sem declarar esse parâmetro, todas as buscas serão eager, possivelmente gerando uma grande quantidade de acessos ao banco, dependendo da estrutura de classes.

O outro parâmetro importante é o enhancementEnabled. Com ele habilitado, o Ibatis usa proxies cglib no mecanismo de carregamento das classes, e ele aumenta o escopo do carregamento lazy.

Com o enhancement desligado, serão carregadas de forma lazy apenas as coleções de um objeto, como a lista de produtos de um pedido. Com o enhancement ligado, é feito também o carregamento lazy de atributos complexos de um objeto, como o endereço de entrega do pedido.

Este mecanismo é bem simples de utilizar, e ajuda bastante, pois não precisamos tratar disso no código da aplicação.

Posted in java, open source, posts em português.

Tagged with , , , .


5 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Alex Rios says

    Legal a dica Bruno, já conhecia mas valeu por apresentar é bastante obscuro essa parte sobre o lazy model na documentação.

  2. Emerson Macedo says

    Essa do enhancementEnabled eu não conhecia. valeu pela dica ;)

  3. blpsilva says

    É, o Ibatis não é nenhuma novidade, mas é muito bom para alguns projetos e tem alguns recursos simples que faciltam bastante a vida.

  4. Rodrigo Figueira says

    Imagine o seguinte ambiente:

    (Modulo Financeiro) tenho o Projeto1: contém a interface do usuário , etc…. O projeto tem uma referência para outro projeto de Domínio para gerenciar código do Negócio. E por fim este referência o projeto de Repositório para gerenciar acesso aos Dados. (aqui está a referência a um outro componente Genérico de Infraestrutura que aí sim contém o Ibatis.net)

    (Módulo RH) tenho o Projeto2: com a mesma estrutura de componentes do Projeto1.

    Tenho um Projeto de Login e Menu genéricos. Estes é que irão abrir a conexão com o Banco de Dados. (Uma observação importante é que um determinado cliente pode ter comprado apenas 1 dos módulos!)

    A minha pergunta é o seguinte:

    Onde ficaria o arquivo de mapas ?
    Como vou repassar a mesma conexão entre os diferentes módulos/componentes?
    Será que o ideal seria talvez eu ter o arquivo de mapas (sqlmaps) em cada projeto de interface?

    Agradeceria se pudesse me auxiliar nestas dúvidas!

Continuing the Discussion

  1. cardinalidade.net - Bruno Pereira » Blog Archive » Funcionamento do Lazy Load no Ibatis linked to this post on 16/02/2009

    [...] cardinalidade.net – Bruno Pereira » Blog Archive » Precisamos de um … Veja o post completo clicando aqui. Post indexado de: [...]



Some HTML is OK

or, reply to this post via trackback.



  • Buy Cheap xanax recreational use Now The Largest Internet Pharmacy. Best Online.
  • Buy Cheapest insomnia medication prescription Online Drugs, Health And Beauty. Best Internet.
  • Buy Cheapest drugs online Now Low Prices. Discount Pharmacy Online.
  • Buy Cheap pharmacies and prescriptions for pain meds Online No Prescription Needed. Best Prices.
  • Buy Cheapest buy depo medrol Online Best Prices. Internet Prices For buy depo medrol!
  • Buy Cheapest names of prescription pain medications Now Best Drugstore. Cheap Online Pharmacy.
  • Buy Cheapest cialis profestional Online Online Medical Shop. Pharmacy Store.
  • Buy Cheap buy cialis cialas Online Best Drugstore. Online Medical Shop.
  • Buy Cheap health med Now 100% Satisfaction Guaranteed. Pharmacy Store.
  • Buy Cheap on line pharmacies Online Online Prices For on line pharmacies! Best Prices.
  • Buy Cheap consumer proven weight loss medication Online Discount Online Pharmacy. Best Internet.
  • Buy Cheap drugs to treat depression Online Special Prices For drugs to treat depression! Best Online.
  • Buy Cheap medicin depression buy Online 24/Internet)(safe Pharmacy. Best Prices.
  • Buy Cheapest antidepressant purchase france Now Pharmacy At The Best Price! Best Online.
  • alprazolam overdose Online Without Prescription Free Viagra Pills! Best Prices.
  • Buy Cheapest cialis free trials Online Best Internet. WorldWide Shipping.
  • Buy Cheapest belly fat diet pill Online Best Online. Online Prices For belly fat diet pill!
  • Buy Cheapest prescription drugs on internet Online Discount Pharmacy Online. Best Online.
  • Buy Cheapest cheap overseas pharmacies Now Pharmacy At The Best Price! Best Online.
  • Buy ambien purchase Without Prescription Doctor. Pharmacy Store. Low Prices.
  • Buy Cheap spain farmacia levitra Online Online Medical Shop. Cheap Online Pharmacy.
  • Buy Cheapest what is viagra super active Now Top Online Pharmacy. Cheap Pharmacy Online.
  • Buy Cheap overdose of xanax Online Online Medical Shop. Pharmacy Store.
  • Buy Cheap impotence drugs Online Best Online. Internet Prices For impotence drugs!
  • Buy Cheap buy narcotic pain relievers Now Discount Online Pharmacy. WorldWide Shipping.
  • Buy Cheapest phentermine online without doctor orders Now Pharmacy Store. Buy Medications Online.
  • Buy Cheapest generic name viagra Now Pharmacy At The Best Price! Pharmacy Store.
  • Buy Cheapest cheap priced valium Online Guaranteed Shipping. Pharmacy Store.
  • Buy Cheapest buy sleep aids on line Online Best Prices. Discount Online Pharmacy.
  • Buy Cheap viagra drug interactions Online Guaranteed Shipping. WorldWide Shipping.
  • Buy Cheap cheap sarafem Now The Largest Internet Pharmacy. Best Online.
  • Buy Cheap phentermine 30mg Now Cheap Meds Without Prescription. Best Online.
  • Buy Cheap valium dosage Now Guaranteed Shipping. Online Prices For valium dosage!
  • Buy Cheap pain pill withdrawals Online No Prescription Needed. Best Online.
  • Buy Cheap cialis for erection Now Special Prices For cialis for erection! Best Internet.
  • Buy Cheap weight loss doctor online Now Bonus Pills And Reorder Discounts! Low Prices.
  • Buy Cheapest levitra website Online Guaranteed Shipping. Pharmacy Store.
  • Buy Cheap free samples cialis Online Best Internet. Cheap Prescription Drugs.
  • Buy Cheapest maximum fat loss Online WorldWide Shipping. Pharmacy Store.
  • Buy Cheap tadalafil jelly Online Discount Online Pharmacy. Best Prices.
  • how to buy impotence medication Online Without Prescription Best Drugstore. Low Prices.
  • Buy Cheap prescription weight loss meds online Now Guaranteed Shipping. Top Online Pharmacy.
  • Buy Cheapest cheap femara Online Pharmacy Store. No Prescription Needed.
  • Buy Cheap viagra size Online Best Online. Top Online Pharmacy Supplier.
  • Buy Cheap vardenafil hcl Online Pharmacy At The Best Price! Best Drugstore.
  • Buy Cheapest prescription for chlamydia Now Free Viagra Pills! Cheap Pharmacy Online.
  • Buy Cheapest cialis flagstaff Online Free Viagra Pills! Pharmacy Store.
  • Buy Cheapest valium generic Online Guaranteed Shipping. Best Online.
  • Buy Cheapest cheap diet pills online Now Best Online. Online Prices For cheap diet pills online!
  • Buy Cheapest weight loss medicine buy online Now We Can Offer You Visit Our Online Pharmacy.
  • Buy Cheap curing impotence Online Order Cheap Meds Without Rx. Best Online.
  • Buy Cheapest stronger pain killer Now Free Viagra Pills! No Prescription Needed.
  • Buying Cheap india pharmacy. Offshore Rx, Good Prices. Guaranteed Shipping.
  • Buy Cheapest order ampicillin Now Internet Prices For order ampicillin! Best Drugstore.
  • Buy order quality cialis Online Without Prescription. Best Online. Low Prices.
  • Buy Cheap accutane before after Now No Prescription Needed For Drugs. Best Prices.
  • Buy Cheapest side effects of ambien 10 mg Online Cheap Pharmacy Online. Low Prices.
  • Buy Cheapest original cialis Now No Prescription Needed. Free Viagra Pills!
  • Buy Cheapest xanax 2 mg no prescription Now Top Online Pharmacy. WorldWide Shipping.
  • Buy does zyban work Online Without Prescription. Pharmacy Store. Low Prices.
  • Buy Cheapest viagra alcohol Now Special Prices For viagra alcohol! Best Drugstore.
  • Buy Cheapest lexapro for anxiety Online 24/Online Pharmacy. Low Prices.
  • Buy Cheapest viagra for recreational use Now Buy Medications Online. WorldWide Shipping.
  • Buy Cheapest diazepam us pharmacy Online Drugs, Health And Beauty. Low Prices.
  • Buy Cheap how to take viagra Now 24/Online Pharmacy. WorldWide Shipping.
  • Buy Cheapest viagra canada satisfaction guarantee Online Drugs, Health And Beauty. Best Internet.
  • Buy Cheapest mexican cialis Online Drugs, Health And Beauty. Best Internet.
  • Buy Cheapest drug ambien Now Cheap Pharmacy Online. WorldWide Shipping.
  • Buy Cheapest prescribed weight loss medication Now Free Viagra Pills! Cheap Pharmacy Online.
  • Buy Cheap best price for cialis Online Internet Prices For best price for cialis! Low Prices.
  • Buy Cheapest levitra pill size Online Low Prices. Buy Medications Online.
  • Buy cvs drug stores Without Prescription Doctor. Low Prices. Best Internet.
  • Buy Cheap promethazine tablets Now Best Online. Safe And Secure Payment System.
  • Buy Cheap online consultation xanax Online Pharmacy Store. Top Online Pharmacy.
  • Buy Cheap lorazepam withdrawal symptoms Online Best Prices. Drugs, Health And Beauty.
  • Buy Cheapest ultram ultracet Online No Prescription Needed. Low Prices.
  • Buy Cheapest fast weight loss Now Best Online. 100% Satisfaction Guaranteed.
  • Buy Cheapest drugs for depression Now Best Internet. Buy Medications Online.
  • Buy Cheapest valium recreational Online Best Online. Online Prices For valium recreational!
  • Buy Cheapest cialis low dose Now Buy Medications Online. Free Viagra Pills!
  • Buy Cheapest otc treatment for scabies Now WorldWide Shipping. Online Medical Shop.
  • Buy Cheapest diazepam mylan Now Cheap Pharmacy Online. Best Drugstore.
  • Buy Cheap cheap phentermine 37.5 Now The Largest Internet Pharmacy. Best Drugstore.
  • Buy Cheapest pain pills online thailand Online Best Drugstore. Cheap Pharmacy Online.
  • Buy Cheapest prescription drug store online Online Best Internet. Discount Pharmacy Online.
  • Buy Cheap over the counter weight loss drugs Now WorldWide Shipping. Cheap Online Pharmacy.
  • Buy Cheap klonopin effects Now Top Online Pharmacy Supplier. Low Prices.
  • Buy Cheapest erectile dysfunction syndrome drugs Online Best Online. Cheap Prescription Drugs.
  • Buy Cheapest buy ambien online without prescription Online Buy %items% Online Without Prescription.
  • Buy Cheapest viagra online overnight delivery Online Best Drugstore. Online Medical Shop.
  • Buy Cheap bayer levitra cheapest price online pharmacy Now Special Prices For bayer levitra cheapest price online pharmacy! Best Online.
  • Buy Cheapest indian tadalafil Now Best Prices. Cheap Prescription Drugs.
  • Buy Cheapest accutane before after Now Best Online. Pharmacy At The Best Price!
  • Buy Cheapest reliable online pharmacy Now Pharmacy At The Best Price! Best Online.
  • Buy Cheapest finasteride tablets Online Cheap Pharmacy Online. Low Prices.
  • Buy Cheap list pain meds Online Top Online Pharmacy. WorldWide Shipping.
  • Buy Cheap tramadol medicine online Online Internet Prices For tramadol medicine online! Best Internet.
  • Buy Cheapest cialis coupons Online Best Internet. Cheap Prescription Drugs.
  • Buy Cheapest cialis professional cheap Now Cheap Prescription Drugs. Best Drugstore.
  • Buy Cheapest online canada pharmacy Online Free Viagra Pills! Best Drugstore.