settings

lazyLoadingEnabled
Lazy loading is a technique in which you load only the information that is essential,
and defer the loading of other data until it is specifically requested. In other words,
you want to have the application do as little as possible until it is absolutely required.

In the previous chapter, we talked about an example where you had 1,000 customer
accounts with 1,000 orders each, and 25 items on each order. Loading all of
that data would require creating 25,000,000 objects, and keeping them in memory.
Using lazy loading we reduce that requirement to a number closer to 2,500,
which is one ten-thousandth of the original number.
The lazyLoadingEnabled setting is used to indicate whether or not you want to
use lazy loading when you have related mapped statements (which we will talk about
in section 6.2.2). Valid values are true or false, and the default value is true.
In our sample SqlMapConfig.xml file earlier, lazy loading is enabled.
cacheModelsEnabled
Caching is a performance-enhancement technique where recently used data is
kept in memory based on the assumption that it will be needed again in the
future. The cacheModelsEnabled setting is used to indicate whether or not you
want iBATIS to use caching. As with most of the values of the <settings> element,
valid values are true or false.
In our earlier example, caching is enabled, which is the default. To take advantage
of caching, you must also configure cache models for your mapped statements,
which are introduced in section 9.1.
enhancementEnabled
The enhancementEnabled setting is used to indicate whether or not you want to
use cglib optimized classes to improve performance with lazy loading. Again, valid
values are true or false, and the default value is true.

In our previous example, we are allowing enhancements, but if cglib is not on the
classpath, the enhancements will be silently disabled.

useStatementNamespaces
The useStatementNamespaces setting is used to tell iBATIS to require qualified
names for mapped statements. Valid values are true or false, and the default
value is false.
In other words, when the SQL maps are defined (see the section 4.2.1 for more
information on that), the map name is to be used to qualify the mapped statement.
iBATIS configuration continued 73
So, for example, you may have a SQL map named Account, with mapped statements
named insert, update, delete, and getAll. When you want to insert an account,
you would call the Account.insert mapped statement when namespaces are used.
You can have as many mapped statements (in other maps) named insert as
needed, and the names will not collide.
While you could accomplish the same thing using names like insertAccount,
using namespaces can be very helpful when working with large systems, because it
helps in finding statements if they are not organized logically.
maxRequests (deprecated)
A request is any SQL operation—an insert, update, delete, or a stored procedure
call. In our example, we are scaling back and only allow 32 requests to be active at
one time instead of the default value of 512.
maxSessions (deprecated)
A session is a thread-level mechanism that is used to track information about a
group of related transactions and requests. In our example, we allow only 10 sessions
at any time, instead of the default value of 128.
maxTransactions (deprecated)
A transaction is just what it appears: a database transaction. As with maxRequests, we
have reduced the number of active transactions to 5 from the default value of 32.

NOTE These settings are complicated to understand, but luckily they are deprecated.
In future versions of iBATIS, you won’t need to configure them
manually. So, for the most part, you should simply never modify them.
The default settings will work for most systems of a reasonable scale. If
you do modify the settings, always ensure that maxRequests is larger than
maxSessions, and that maxSessions is larger than maxTransactions. A
simple rule of thumb is to keep the ratios the same. Also note that none
of these settings directly impacts the number of connections in your connection
pool or any other resources that your application server is
responsible for managing.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值