è”åˆä¸¤äh的知识去对付一个难题ã€?span lang="EN-US">
çŸ¥è¯†äº’ç›¸ä¼ é€’ã€?span lang="EN-US">
æ›´æœ‰æ•ˆçš„æŸ¥é”™è·Ÿçº é”™ã€?span lang="EN-US">
½E‹åºå‘˜éƒ½å¾ˆå¼€å¿ƒã€?span lang="EN-US">
å‡å°‘员工¼›»èŒçš„æŸå¤±ã€?span lang="EN-US">
¾l“对¾~–程需è¦çš„一些技能:
用代ç 解释已有的设计¾l“æž„ã€?span lang="EN-US">
ç”¨ä¾‹åæ¥è§£é‡Šã€?span lang="EN-US">
用图表æ¥è§£é‡Šè®¾è®¡æ€èµ\ã€?span lang="EN-US">
å¦‚æžœä½ æ— æ³•æŠŠä½ çš„è®¾è®¡æ€èµ\表达清楚åQŒæŠŠä»£ç 写出æ¥ã€?span lang="EN-US">
è®©æ¯”è¾ƒè¿·æƒ‘çš„ææ¡£æ¥å†™ä»£ç åQŒè¿™æ ·ä»–ž®±å¯ä»¥è¾ƒå¥½çš„èžå…¥ä½ 的概念ã€?span lang="EN-US">
¾l常的休æ¯ã€?span lang="EN-US">
¾lå¸¸çš„æ›´æ¢ææ¡£ã€?span lang="EN-US">
å› äØ“åœ¨è¿™äº›å¡é‡Œé¢åQŒæˆ‘们写上了¾cÕdåQŒå®ƒçš„èŒè´£ï¼Œä»¥åŠå®ƒçš„å作关系åQŒæˆ‘们管˜q™æ ·çš„å¡ç‰‡å«â€?span lang="EN-US">CRCå¡â€ã€?span lang="EN-US">CRCž®±æ˜¯ClassåQ?span lang="EN-US">Responsibilityå’?span lang="EN-US">Collaboration的简¿U°ã€?span lang="EN-US">
CRC
å¡çš„典型应用 
ä¸ÞZ»€ä¹ˆç”¨CRCå¡ï¼Œè€Œä¸ç”¨æ–‡æ¡£æˆ–者更先进çš?span lang="EN-US">UML工具åQ?span lang="EN-US">
1.
å¡ç‰‡ä¸Šé¢çš„空间很ž®ï¼Œ˜q™æ ·ž®±å¯ä»¥é˜²æ¢æˆ‘们给˜q™ä¸ª¾cÕd¤ªå¤šçš„èŒè´£ã€‚如果一个类的èŒè´£å¤ªå¤šçš„è¯ï¼ˆæ¯”如åQŒè¶…˜q?span lang="EN-US">4个)åQŒå°è¯•以更抽象的方å¼åŽ»è€ƒè™‘ä¸€ä¸‹ï¼Œž®†èŒè´£åˆ’分ã€?span lang="EN-US">
2.CRC
å¡ä¸»è¦æ˜¯ç”¨åœ¨æŽ¢çƒ¦æˆ–者讨论类的设计的阶段。如果我们觉得这个设计ä¸è¡Œçš„è¯ï¼Œæˆ‘们既ä¸ç”¨ä¿®æ”ÒŽ–‡æ¡£ï¼Œä¹Ÿä¸ç”¨ä¿®æ”¹ç±»å›¾ï¼Œåªè¦æŠŠå¡ç‰‡ä¸¢äº†å°±è¡Œäº†ã€‚æ¤å¤–,一旦设计完æˆï¼Œæˆ‘们ž®±å¯ä»¥æŠŠæ‰€æœ‰çš„å¡ä¸¢äº†ã€‚å®ƒä»¬ä¸æ˜¯ç”¨æ¥åšæ–‡æ¡£çš„ã€?span lang="EN-US">
  3. 如果我们觉得现在的å¡ç‰‡ä¸åˆé€‚,之å‰è®¾è®¡çš„æ¯”较好åQŒæˆ‘们åªè¦ç®€å•的把之å‰çš„å¡ç‰‡æ‹¿å‡ºæ¥ç»„åˆå°±è¡Œäº†ã€?/span>
ç„¶åŽåœ¨è¦éªŒè¯çš„Form里é¢åŠ ä¸ªå±žæ€§validatable=true,如下åQ?br />
注æ„åQŒè¿™è¾¹ä¸è¦åŠ onsubmitæ–ÒŽ³•
接下æ¥ï¼Œž®±å¥½äº†ï¼Œæ¯”如说有个输入框åQ?br /><ww:textfield name="name" id="name"/>
我想验è¯åQŒè®©å®ƒå¿…填,如下ž®±å¯ä»¥äº†åQ?br /><label for="name" validate="required">请填写å¿U?lt;/label> å…¶ä¸ for属性里é¢å¡«çš„è¦æ˜¯éªŒè¯çš„输入框idåQŒvalidateå¡«çš„æ˜¯éªŒè¯æ–¹æ³?;label里é¢çš„æ–‡æœ¬å°±æ˜¯éªŒè¯ä¸˜q‡çš„æ—¶å€™è¦æ˜„¡¤ºçš„ä¿¡æ¯ã€?br />如果我想验è¯ä¸€ä¸ªè¾“入框的输入值长度怎么办,˜q™æ ·å就行了
åŽé¢çš„傿•°ç”¨åQ›å·éš”å¼€åQŒéªŒè¯çš„æ–ÒŽ³•åè·Ÿå‚æ•°ç”? 隔开ã€?br />wingel.js里é¢å·²ç»åŒ…æ‹¬äº†ä¸€äº›å¸¸ç”¨çš„éªŒè¯æ–ÒŽ³•åQŒçŽ°åœ¨é—®é¢˜æ¥äº†ï¼Œå¦‚æžœè¦è‡ªå®šä¹‰éªŒè¯æ–ÒŽ³•怎么办,如下办:
æ¯”å¦‚ä½ æƒ³åŠ ä¸ªéªŒè¯æ–ÒŽ³•是hello
则label里é¢çš„validate属性写æˆhello,
ç„¶åŽåŠ ä¸€ä¸ªJavaScriptæ–ÒŽ³•åQ?br />
里é¢ä¸‰ä¸ªå‚æ•°,shit , couldn't input Chinese. now English will be used.
The first parameter is the value of the input element you want to validate,the second one is the validated element, the third one, is the parameters you add in validate label, the last one, is a utility class, you can invoke its method to make your code easier.
PROPAGATION_MANDATORY:
Indicates that the method must run within a transaction. If no
existing transaction is in progress, an exception will be thrown.
PROPAGATION_NESTED:
Indicates that the method should be run within a nested transaction
if an existing transaction is in progress. The nested transaction
can be committed and rolled back individually from the enclosing
transaction. If no enclosing transaction exists, behaves like
PROPAGATION_REQUIRED:
Beware that vendor support for this propagation behavior is spotty at best.
Consult the documentation for your resource manager to determine if nested
transactions are supported.
PROPAGATION_NEVER:
Indicates that the current method should not run within a transactional
context. If there is an existing transaction in progress, an
exception will be thrown.
PROPAGATION_NOT_SUPPORTED:
Indicates that the method should not run within a transaction. If an
existing transaction is in progress, it will be suspended for the
duration of the method. If using JTATransactionManager,
access to TransactionManager is required.
PROPAGATION_REQUIRED:
Indicates that the current method must run within a transaction. If
an existing transaction is in progress, the method will run within
that transaction. Otherwise, a new transaction will be started.
PROPAGATION_REQUIRES_NEW:
Indicates that the current method must run within its own transaction.
A new transaction is started and if an existing transaction is in
progress, it will be suspended for the duration of the method. If
using JTATransactionManager, access to Transaction-
Manager is required.
PROPAGATION_SUPPORTS:
Indicates that the current method does not require a transactional
context, but may run within a transaction if one is already in
progress.
Isolation levels:
In a typical application, multiple transactions run concurrently, often working
with the same data to get their job done. Concurrency, while necessary, can lead
to the following problems:
â–?Dirty read—Dirty reads occur when one transaction reads data that has
been written but not yet committed by another transaction. If the
changes are later rolled back, the data obtained by the first transaction
will be invalid.
â–?Nonrepeatable read—Nonrepeatable reads happen when a transaction performs
the same query two or more times and each time the data is different.
This is usually due to another concurrent transaction updating the
data between the queries.
â–?Phantom reads—Phantom reads are similar to nonrepeatable reads. These
occur when a transaction (T1) reads several rows, then a concurrent transaction
(T2) inserts rows. Upon subsequent queries, the first transaction
(T1) finds additional rows that were not there before.
Isolation level:
ISOLATION_DEFAULT:
Use the default isolation level of the underlying datastore.
ISOLATION_READ_UNCOMMITTED:
Allows you to read changes that have not yet been committed. May
result in dirty reads, phantom reads, and nonrepeatable reads.
ISOLATION_READ_COMMITTED:
Allows reads from concurrent transactions that have been committed.
Dirty reads are prevented, but phantom and nonrepeatable
reads may still occur.
ISOLATION_REPEATABLE_READ:
Multiple reads of the same field will yield the same results, unless
changed by the transaction itself. Dirty reads and nonrepeatable
reads are prevented by phantom reads may still occur.
ISOLATION_SERIALIZABLE:
This fully ACID-compliant isolation level ensures that dirty reads,
nonrepeatable reads, and phantom reads are all prevented. This is
the slowest of all isolation levels because it is typically accomplished
by doing full table locks on the tables involved in the transaction.
åšç€åšç€çš„æ—¶å€™ï¼Œå‘现åQŒå’¦åQŒå¥½åƒè¿™è¡¨å¾—å¢žåŠ ä¸€ä¸ªå—ŒD‰|‰è¡Œï¼Œå¢žåŠ äº†ï¼Œç„¶åŽæ‰€æœ‰æŸ¥è¯¢çš„SQLè¯å¥åŠ ä¸€ä¸‹ï¼Œæ‰€æœ‰insertè·Ÿupdate的代ç 修改一下,™åµé¢ä¿®æ”¹ä¸€ä¸‹ï¼Œå—¯ï¼ŒçŽ°åœ¨åº”è¯¥æ£å¸¸äº†ï¼Œçœ‹è“væ¥å€’是没什么问题,咦,报表好åƒä¸æ€Žä¹ˆå¯¹å•ŠåQŒé åQŒè¿™è¾¹è¿˜æœ‰è°ƒç”¨è¿™ä¸ªè¡¨çš„代ç ,妈的åQŒæ”¹å§æ”¹å§ã€‚磨íyäº†å¥½å‡ ä¸ªå°æ—Óž¼ˆå½“ç„¶åQŒç†Ÿ¾lƒçš„è¯ï¼Œòq¶ä¸ç”¨å‡ ä¸ªå°æ—Óž¼‰åQŒæ€È®—看è“væ¥éƒ½æ£å¸¸äº†ã€?/p>
˜q™ä¸€å›žï¼Œ˜q™ä¸ªåŠŸèƒ½ä¸æœ‰ä¸€‹Æ¡ç”¨æˆ¯‚¯·æ±‚,讉K—®äº†å¥½å‡ 次数æ®åº“,ä¸è¡ŒåQŒè¿™é‡Œåº”该用个cacheåQŒå¦åˆ™æ€§èƒ½ä¸Šä¼šæœ‰é—®é¢˜å•ŠåQŒç®—了,用算法解决一下,ž®½é‡ž®‘访问数æ®åº“好了åQŒæˆ‘对cache˜q˜ä¸ç†Ÿå‘¢ã€‚(写啊写啊åQŒBatch SizeåQŒè¿™æ ·å¤šåQŒé‚£æ ·å¤šåQŒFetch Size。。。,¾lˆäºŽåQŒçœ‹èµäh¥æ£å¸¸ä¸€äº›äº†åQ‰ã€‚过了一ŒD‰|—¶é—ß_¼Œé ,˜q™è¾¹åˆè¦è®‰K—®å¥½å‡ ‹Æ¡æ•°æ®åº“åQŒYaçš„å—ä¸é¸Ÿäº†ï¼Œæ€§èƒ½çˆ±å’‹çš„å’‹çš„ï¼Œåæ£ä¸€ä¸ªåœ°æ–ÒŽ…¢åˆä¸è¦ç´§ã€‚Oh shit!!!˜q™è¾¹ä¹Ÿæ˜¯å¥½å‡ ‹Æ¡ï¼Œ˜q™è¾¹åˆæ˜¯å¥½å‡ ‹Æ¡ï¼Œé‚£è¾¹åˆæ˜¯å¥½å‡ ‹Æ¡ã€‚ä¸è¡Œäº†åQŒæˆ‘è€è€å®žå®žå†™ä¸ªcache支æŒå§ï¼ŒäºŽæ˜¯åˆå®å®å½“å½“äº†å¥½å‡ å¤©ï¼Œ¾lˆäºŽåQŒæœ‰ä¸ªç²—¾p™çš„cache出æ¥äº†ï¼Œ¾lˆäºŽé€Ÿåº¦å¯ä»¥çœ‹ä¸€äº›äº†ã€‚åŽæ¥æ”¹˜q›åˆæ”¹è¿›åQŒæµ‹è¯•刋¹‹è¯•åQŒç¯æÖMº†åQŒè€å好ä¸çˆ½å•Šã€?/p>
好åƒå¤©ä¸‹æœ‰ç‚¹å¤ªåã^äº†ï¼Œå•Šï¼Œä½ è¯´æˆ‘è¿™ä¸ªåœ°æ–¹å¿˜è®°æ›´æ–îC½ å¢žåŠ çš„é‚£ä¸ªå表啊åQŒç®—了,没关¾p»ï¼Œæˆ‘明天看一下代ç ,˜q™ä¸ªå®ÒŽ˜“解决ç‚V€‚å—¯åQŒæˆ‘改了那边的代ç 了åQŒä¼šæ›´æ–°å表信æ¯äº†ã€‚ä»€ä¹ˆï¼Ÿä½ è¯´å–主表的记录跟相应的å表记录列表éºÈƒ¦å•Šï¼Œæ²¡å…³¾p»ï¼Œæˆ‘æ›´æ–îC¸€ä¸‹å¤„ç†resultset的公共模å—,明天å†è¯´ã€?br /> Oh shit......å¯¹è¿™æ ·å夿‚的查询好åƒçŽ°åœ¨çš„å…¬å…±æ¨¡å—æ”¯æŒä¸äº†å•Šï¼Œ½Ž—了åQŒè¿™æ ·å的查询ä¸è¦ç”¨˜q™ä¸ªå…¬å…±æ¨¡å—åQŒæˆ‘们手动写一些代ç 好啊,别跟我讲˜q™æ ·ä»£ç ¾l“æž„å¾ˆéš¾çœ‹ï¼Œä½ ä»¥ä¸ºæˆ‘ä¸çŸ¥é“啊åQŒTMDã€?/p>
TMD的,怎么˜q™è¾¹çš„SQLè€æ˜¯˜q行ä¸äº†å•Šï¼Œä¸ä¼šæ˜¯åˆ†™åµåº•层模å—的问题å§ï¼Œé ï¼Œæ€Žä¹ˆä½ çš„SQLè¯å¥æœ‰è¿™ä¹ˆå¤šorder,group byåQŒé åQŒè¿˜æœ‰top啊,˜q™å½“然过ä¸äº†äº†ï¼Œä¸è¦åµäº†åQŒçŽ°åœ¨æ—¶é—´æ”¹åQŒä¸ç†å®ƒåQŒç›´æŽ¥ç”¨ä¸ªå‡åˆ†é¡µž®Þp¡Œäº†ã€‚ä½ åˆè¯´ä»£ç ¾l“构隄¡œ‹åQŒå°å¿ƒæˆ‘æŠ½ä½ å“¦ã€?/p>
公叿–°æ¥ä¸€ä¸ªç¨‹åºå‘˜åQŒçœ‹äº†å‡ 天代ç ,ä¸åœçš„æŠ±æ€¨è¯´åQŒè¿™ä»£ç 写得真差啊。。。。。ã€?nbsp;
PROPAGATION_MANDATORY:
Indicates that the method must run within a transaction. If no
existing transaction is in progress, an exception will be thrown.
PROPAGATION_NESTED:
Indicates that the method should be run within a nested transaction
if an existing transaction is in progress. The nested transaction
can be committed and rolled back individually from the enclosing
transaction. If no enclosing transaction exists, behaves like
PROPAGATION_REQUIRED:
Beware that vendor support for this propagation behavior is spotty at best.
Consult the documentation for your resource manager to determine if nested
transactions are supported.
PROPAGATION_NEVER:
Indicates that the current method should not run within a transactional
context. If there is an existing transaction in progress, an
exception will be thrown.
PROPAGATION_NOT_SUPPORTED:
Indicates that the method should not run within a transaction. If an
existing transaction is in progress, it will be suspended for the
duration of the method. If using JTATransactionManager,
access to TransactionManager is required.
PROPAGATION_REQUIRED:
Indicates that the current method must run within a transaction. If
an existing transaction is in progress, the method will run within
that transaction. Otherwise, a new transaction will be started.
PROPAGATION_REQUIRES_NEW:
Indicates that the current method must run within its own transaction.
A new transaction is started and if an existing transaction is in
progress, it will be suspended for the duration of the method. If
using JTATransactionManager, access to Transaction-
Manager is required.
PROPAGATION_SUPPORTS:
Indicates that the current method does not require a transactional
context, but may run within a transaction if one is already in
progress.
Isolation levels:
In a typical application, multiple transactions run concurrently, often working
with the same data to get their job done. Concurrency, while necessary, can lead
to the following problems:
â–?Dirty read—Dirty reads occur when one transaction reads data that has
been written but not yet committed by another transaction. If the
changes are later rolled back, the data obtained by the first transaction
will be invalid.
â–?Nonrepeatable read—Nonrepeatable reads happen when a transaction performs
the same query two or more times and each time the data is different.
This is usually due to another concurrent transaction updating the
data between the queries.
â–?Phantom reads—Phantom reads are similar to nonrepeatable reads. These
occur when a transaction (T1) reads several rows, then a concurrent transaction
(T2) inserts rows. Upon subsequent queries, the first transaction
(T1) finds additional rows that were not there before.
Isolation level:
ISOLATION_DEFAULT:
Use the default isolation level of the underlying datastore.
ISOLATION_READ_UNCOMMITTED:
Allows you to read changes that have not yet been committed. May
result in dirty reads, phantom reads, and nonrepeatable reads.
ISOLATION_READ_COMMITTED:
Allows reads from concurrent transactions that have been committed.
Dirty reads are prevented, but phantom and nonrepeatable
reads may still occur.
ISOLATION_REPEATABLE_READ:
Multiple reads of the same field will yield the same results, unless
changed by the transaction itself. Dirty reads and nonrepeatable
reads are prevented by phantom reads may still occur.
ISOLATION_SERIALIZABLE:
This fully ACID-compliant isolation level ensures that dirty reads,
nonrepeatable reads, and phantom reads are all prevented. This is
the slowest of all isolation levels because it is typically accomplished
by doing full table locks on the tables involved in the transaction.
那么在事务Aä¸ï¼Œquery1è·Ÿquery2查询出æ¥çš„结果是å¦ä¸€æ ·å‘¢åQŸè¿™ž®Þp·Ÿäº‹åŠ¡éš”ç¦»¾U§åˆ«æœ‰å…³äº†ã€?br />SQLçš„æ ‡å‡†å®šä¹‰é‡Œé¢ï¼Œä¸€å…±æœ‰å››ç§¾U§åˆ«åQ?br />read uncommitedè¯Õd–未æäº¤çš„æ•°æ®ã€€ž®±æ˜¯å…¶ä»–事务求æäº¤çš„æ•°æ®åQŒéƒ½å¯ä»¥è¯Õd–出æ¥
read commitedè¯Õd–å·²æäº¤çš„æ•°æ®ã€€query2会跟query1è¯Õd–的数æ®ä¸ä¸€æ ?br />repeatable readå¯é‡å¤è¯»å–,å³query1è·Ÿquery2è¯Õd–çš„æ•°æ®æ˜¯ä¸€æ ïLš„
serializable åºåˆ—化,
SQL æ ‡å‡†ç”¨ä¸‰ä¸ªå¿…™åÕdœ¨òq¶è¡Œçš„事务之间é¿å…的现象定义了四个çñ”别的事务隔离ã€?˜q™äº›ä¸å¸Œæœ›å‘生的现象是:
è„读åQˆdirty readsåQ?br /> 一个事务读å–了å¦ä¸€ä¸ªæœªæäº¤çš„åÆˆè¡Œäº‹åŠ¡å†™çš„æ•°æ®ã€?
ä¸å¯é‡å¤è¯»ï¼ˆnon-repeatable readsåQ?br /> ä¸€ä¸ªäº‹åŠ¡é‡æ–°è¯»å–å‰é¢è¯»å–过的数æ®ï¼Œ å‘现该数æ®å·²¾l被å¦ä¸€ä¸ªå·²æäº¤çš„事务修改过ã€?
òq»è¯»åQˆphantom readåQ?br /> ä¸€ä¸ªäº‹åŠ¡é‡æ–°æ‰§è¡Œä¸€ä¸ªæŸ¥è¯¢ï¼Œ˜q”å›žä¸€å¥—ç¬¦åˆæŸ¥è¯¢æ¡ä»¶çš„行, å‘现˜q™äº›è¡Œå› 为其他最˜q‘æäº¤çš„事务而å‘生了改å˜ã€?
隔离¾U§åˆ«       è„读åQˆDirty ReadåQ?nbsp; ä¸å¯é‡å¤è¯»ï¼ˆNonRepeatable ReadåQ?nbsp; òq»è¯»åQˆPhantom ReadåQ?br />è¯ÀLœªæäº¤åQˆRead uncommittedåQ?nbsp;  å¯èƒ½ å¯èƒ½ å¯èƒ½
è¯Õd·²æäº¤åQˆRead committedåQ?   ä¸å¯èƒ½ã€€ å¯èƒ½ å¯èƒ½
å¯é‡å¤è¯»åQˆRepeatable readåQ?nbsp; ä¸å¯èƒ?nbsp; ä¸å¯èƒ?nbsp;  å¯èƒ½
å¯ä¸²è¡ŒåŒ–åQˆSerializable åQ?nbsp; ä¸å¯èƒ?nbsp; ä¸å¯èƒ?nbsp; ä¸å¯èƒ?/p>
SQLServer
我们首先在SQLServer上åšäº†å®žéªŒï¼ŒSQLServer一共支æŒå››¿Uéš”¼›Èñ”别,read uncommitedè·Ÿread commited我们没有实验åQŒæˆ‘们直接先实验
repeatable readåQŒå¦‚果事务A定义了如下çñ”别,那么当事务B执行到modify1˜q™æ¡è¯å¥æ—Óž¼Œå¦‚æžœmodify1是updateçš„è¯åQŒå°±è¢«é”èµäh¥åQŒä¸€ç›´ç‰
åˆîCº‹åŠ¡Aæäº¤å®Œä»¥åŽï¼Œé”æ‰ä¼šè¢«é‡Šæ”¾åQŒè€Œå¦‚果是insertçš„è¯åQŒåˆšå¯ä»¥™åºåˆ©˜q›è¡Œä¸‹åŽ»åQŒç„¶åŽåœ¨äº‹åŠ¡Aä¸ï¼Œquery2查到的数æ®ï¼Œæ˜¯å·²¾l被事务B
修改˜q‡çš„æ•°æ®åQŒå¦‚果将¾U§åˆ«å®šä¹‰åœ¨serializableçš„è¯åQŒåˆ™åœ¨modify1è¯å¥ä¸ï¼Œupdate,insert或者deleteéƒ½ä¼šè¢«é”æŽ‰ã€?br />也就是说åQŒSQLServer对这些çñ”别的支æŒåQŒæ˜¯é€šè¿‡é”æ¥åšåˆ°çš„,虽然å¯ä»¥ä¿è¯äº‹åŠ¡æ£å¸¸˜q›è¡ŒåQŒä½†æ˜¯åƈ行的性能å´å¾ˆå·®ã€?br />Oracle
oracleåªæ”¯æŒä¸¤ä¸ªçñ”别,read commitedè·ŸserializableåQŒç»“果这里就ä¸ç”¨è¯¦ç»†è¯´æ˜ŽåQŒå®žéªŒçš„¾l“果是,oracleçš„serializable是通过版本
控制æ¥å®Œæˆçš„åQŒè€Œä¸æ˜¯é€šè¿‡é”机åˆÓž¼Œ˜q™å°±ä¿è¯äº†åƈ行的性能。Oracle的默认çñ”别是read commited
MySQL
MySQLServer也支æŒå››ä¸ªçñ”别,而且MySQL也是通过版本控制而éžé”机制æ¥å®Œæˆçš„ã€?br />