??xml version="1.0" encoding="utf-8" standalone="yes"?>
BTWQMySql最q借着Web2.0的浪潮风头很劲啊Qtechn oratiQ好像这几天被GFW filter?jin)?j)QflickrQdel.icio.us{一批网站都是用?jin)MySql。MySqlq(sh)门在首页开?jin)一大块来炫耀?img src ="http://www.aygfsteel.com/sakis/aggbug/58242.html" width = "1" height = "1" />
#1 Transaction Propagation Behavior
Required:Excute within a current tx, create a new one if none exists.
Supports: Excute within a current tx, execute without a tx if none exsits.
Mandatory: Excute within a current tx, throw an exception if none exists.
Requires New: Create a new tx and excute within the tx, suspend the current tx if one exists.
Not Supported: Excute without a tx, suspend the current tx if none exsits.
Never: Excute without a tx, throw an exception if a tx exsits.
#2 Transaction Isolation Level[1]
#2.1 Concurrent Problem
Dirty Reads: 脏读Q脏数据指已更新Q还没提交的数据Q。事务T1dC务T2中的脏数据?/FONT>
Unrepeatable Reads: 不可重复诅R事务T1(g)索到某行后,事务T2更新q提交了(jin)该行Q若事务T2再次(g)索该行,则会(x)看到不一L(fng)l果?/FONT>
Phantom Reads: 虚读。事务T1(g)索到W合某条件的行集后,事务T2插入q提交了(jin)满该条件的新行Q若事务T2再次按该条g(g)索,则会(x)看到以前不存在的行“Phantom”?/FONT>
#2.2 Isolation Level
+---------------+-------+------------------+-----------+
|Isolation Level|Phantom|Unrepeatable Reads|Dirty Reads|
+---------------+-------+------------------+-----------+
|Read Uncommited| Y | Y | Y |
+---------------+-------+------------------+-----------+
|Read Commited | Y | Y | N |
+---------------+-------+------------------+-----------+
|Repeatable Read| Y | N | N |
+---------------+-------+------------------+-----------+
|Serializable | N | N | N |
+---------------+-------+------------------+-----------+
#3 Timeout
#4 ReadOnly Transaction
只读事务保证?jin)多条查询SQL的在事务U别的读一致性。JDBC和数据库?x)对只读事务做一些优化?/FONT>
[1] C.J.Date, An Introduction to Database Systems 7th.
#0
MXML优点Q用方便,XML代码z易?BR>~点Q事件、函数、界面描混在一赗程序规模大?jin)难于开发维护?/FONT>
#1
Cairngorm框架是iterationtwo推出的号U基于JEE Best Practice的FlexE序开发的light-weight framework??light-weightq个词还真是行?。目前最新版本ؓ(f)0.99?/FONT>
Cairngorm的结构如下:(x)
org
└─nevis
└─cairngorm
├─application
?nbsp; CairngormApplication.as
?BR> ├─business
?nbsp; Responder.as
?nbsp; ServiceLocator.as
?BR> ├─commands
?nbsp; Command.as
?nbsp; SequenceCommand.as
?BR> ├─control
?nbsp; Event.as
?nbsp; EventBroadcaster.as
?nbsp; FrontController.as
?BR> ├─model
?nbsp; ModelLocator.as
?BR> ├─view
?nbsp; ViewHelper.as
?nbsp; ViewLocator.as
?BR> └─vo
ValueObject.as
#2
下面l大家简单介lCairngorm的实现思\?/FONT>
#2.1
Command/FrontControllerEvent与Viwe分离?BR>FrontController实现Singleton模式(以下写ؓ(f)SP)。所有自定义的Command在要在FrontController构造函C实例化ƈ以关联数l的方式注册FrontController#addCommand(eventType:String, commandInstance:Command)。EventBroadcaster实现SP。Eventcȝl构为{type:eventType, data:eventData}。我们通过EventBroadcaster#broadcastEvent(eventType:String, eventData:Object)发布Event。Event发布?与eventType对应的command instance执行Command#execute(event:Event)?/FONT>
BTWQ在Cairngorm的源码中QeventType、commandName、eventNameL(fng)Q我l一用eventType?/FONT>
#2.2
ServiceLocatorRemote Service声明与View分离?BR>ServiceLocator实现SP。在Cairngorm的demo中,又通过Delegate对象解除Command/Responder和ServiceLocator之间的依赖。这个Delegate做的事情其实意义不大Q就是调用ServiceLocator中的MethodQ设|莫个Responder为相应远E方法的handler。个得无谓地增加?jin)代码量Q而且Delegate对象也没实现SPQ也是说我们每ơ调用一ơRemote Service中的MethodQ都要new一个Delegate对象Q实在浪贏V?/FONT>
#2.3
ViewLocator/ViewHelperViewQMXMLQ中Ҏ(gu)的function与View分离?BR>ViewHelper有点意思,当一个ViewHelper在某个MXML面中声明时Q如<view:LoginViewHelper id="loginViewHelper" />
#2.4
ModelLocator是一个marker interfaceQ程序中Model可以攑֜某个ModelLocator方便调用?/FONT>
#2.5
ValueObject也是一个marker interface, 基本不需要?/FONT>
#3
Cairngorm.99l我们开发FlexE序提供?jin)很不错的架构模?M/V/C/Remote之间可以做到完全解构。但在实际开发时没有必要L,代码l构清晰有活力就好?/FONT>
#0
书和文档上写的都不是Ҏ(gu)楚的。自p下来?/FONT>
#1 Using a PK association
#1.1 POJO with XDolclet annotation
public class Customer {
/**
* @return Returns the shoppingCart.
* @hibernate.many-to-one cascade="delete" column="shopping_cart_id"
* unique="true" foreign-key="FK_SHOPPING_CART__CUSTOMER"
*/
public ShoppingCart getShoppingCart() {
return shoppingCart;
}
}
public class ShoppingCart {
/**
* @return Returns the customer.
* @hibernate.one-to-one property-ref="shoppingCart"
*/
public Customer getCustomer() {
return customer;
}
}
property-ref="shoppingCart" 告诉Hibernate ShoppingCart#customer和Customer#shoppingCart是反向的关系。所以Hibernate知道如何从ShoppingCart#getCustomer中检索到相应的customer对象。取出某个Customer对象ӞHibernate?x)生成DEBUG SQL:324 - 3中的SQL语句?/FONT>
#1.2 HBM
Customer.hbm.xml
<many-to-one
name="shoppingCart"
class="ShoppingCart"
cascade="delete"
outer-join="auto"
foreign-key="FK_SHOPPING_CART__CUSTOMER"
column="shopping_cart_id"
/>
ShoppingCart.hbm.xml
<one-to-one
name="customer"
class="Customer"
cascade="none"
outer-join="auto"
constrained="false"
property-ref="shoppingCart"
/>
#1.3 SCHEMA SQL
create table CUSTOMER (
ID bigint generated by default as identity (start with 1),
SHOPPING_CART_ID bigint,
primary key (ID)
)
create table SHOPPING_CART (
ID bigint generated by default as identity (start with 1)
primary key (ID)
)
alter table CUSTOMER
add constraint FK_SHOPPING_CART__CUSTOMER
foreign key (SHOPPING_CART_ID)
references SHOPPING_CART
#1.4 Query SQL
DEBUG SQL:324 - 1
select customer0_.ID as ID, customer0_.SHOPPING_CART_ID as SHOPPING2_3_, customer0_.USERNAME as USERNAME3_, customer0_.PWD as PWD3_
from CUSTOMER customer0_
where customer0_.USERNAME=? and customer0_.PWD=?
DEBUG SQL:324 - 2
select shoppingca0_.ID as ID0_, shoppingca0_.TOTAL as TOTAL8_0_
from SHOPPING_CART shoppingca0_
where shoppingca0_.ID=?
DEBUG SQL:324 - 3
select customer0_.ID as ID1_, customer0_.SHOPPING_CART_ID as SHOPPING2_3_1_, customer0_.USERNAME as USERNAME3_1_, customer0_.PWD as PWD3_1_, shoppingca1_.ID as ID0_, shoppingca1_.TOTAL as TOTAL8_0_
from
CUSTOMER customer0_
left outer join
SHOPPING_CART shoppingca1_
on customer0_.SHOPPING_CART_ID=shoppingca1_.ID
where customer0_.SHOPPING_CART_ID=?
#2 Using a FK association
#2.1 POJO with XDolclet annotation
public class Customer {
/**
* @return Returns the shoppingCart.
* @hibernate.one-to-one cascade="delete"
*/
public ShoppingCart getShoppingCart() {
return shoppingCart;
}
}
public class ShoppingCart {
/**
* @return Returns the id.
* @hibernate.id generator-class="foreign"
* @hibernate.generator-param name="property" value="customer"
*/
public Long getId() {
return id();
}
/**
* @return Returns the customer.
* @hibernate.one-to-one constrained="true" foreign-key="FK_CUSTOMER__SHOPPING_CART"
*/
public Customer getCustomer() {
return customer;
}
}
constrained="true" 告诉Hibernate ShoppingCart的PKq应该是一个FKQ这个FK引用Customer的PK。还需要多做一点工作,声明ShoppingCart的PK生成{略是foreignQ对应ShoppingCart#customer。这和上面一句话不是一个意思嘛QFT~~
#2.2 HBM
Customer.hbm.xml
<one-to-one
name="shoppingCart"
class="ShoppingCart"
cascade="delete"
outer-join="auto"
constrained="false"
/>
ShoppingCart.hbm.xml
<id
name="id"
column="id"
type="java.lang.Long"
>
<generator class="foreign">
<param name="property">customer</param>
</generator>
</id>
<one-to-one
name="customer"
class="Customer"
cascade="none"
outer-join="auto"
constrained="true"
/>
#2.3 SCHEMA SQL
create table CUSTOMER (
ID bigint generated by default as identity (start with 1),
primary key (ID)
)
create table SHOPPING_CART (
ID bigint not null,
TOTAL integer,
primary key (ID)
)
alter table SHOPPING_CART
add constraint FK_CUSTOMER__SHOPPING_CART
foreign key (ID)
references CUSTOMER
#2.4 Query SQL
DEBUG SQL:324 -
select customer0_.ID as ID, customer0_.USERNAME as USERNAME3_, customer0_.PWD as PWD3_
from CUSTOMER customer0_
where customer0_.USERNAME=? and customer0_.PWD=?
DEBUG SQL:324 -
select shoppingca0_.ID as ID0_, shoppingca0_.TOTAL as TOTAL8_0_
from SHOPPING_CART shoppingca0_
where shoppingca0_.ID=?
q个“真正”的one-to-one的好处是条兌SQL语句Q看C(jin)吗?
Welcome to the ACM "Hello World" project. Everyone has seen the Hello World program used as a first exposure to a new language or environment. We are attempting to collect examples for as many languages and related programming environments (shells etc.) as possible.
Aproximate number of examples:204 <----wow~~~
This page has been accessed 33274 times.
Last updated: January 20, 2005
看看C的,l典HelloWorld
#include <stdio.h>
main()
{
for(;;)
{
printf ("Hello World!\n");
}
}
q也是HelloWolrdQ!
a 1986 entry from Bruce Holloway:
#include "stdio.h"
#define e 3
#define g (e/e)
#define h ((g+e)/2)
#define f (e-g-h)
#define j (e*e-g)
#define k (j-h)
#define l(x) tab2[x]/h
#define m(n,a) ((n&(a))==(a))
long tab1[]={ 989L,5L,26L,0L,88319L,123L,0L,9367L };
int tab2[]={ 4,6,10,14,22,26,34,38,46,58,62,74,82,86 };
main(m1,s) char *s; {
int a,b,c,d,o[k],n=(int)s;
if(m1==1){ char b[2*j+f-g]; main(l(h+e)+h+e,b); printf(b); }
else switch(m1-=h){
case f:
a=(b=(c=(d=g)<<g)<'<g)<<g;
return(m(n,a|c)|m(n,b)|m(n,a|d)|m(n,c|d));
case h:
for(a=f;a
return(o[b-g]%n+k-h);
default:
if(m1-=e) main(m1-g+e+h,s+g); else *(s+g)=f;
for(*s=a=f;a<e;) *s=(*s<<e)|main(h+a++,(char *)m1);
}
}
曄最短的HelloWorldQ?A href="mailto:Jari.Arkko@lmf.eua.ericsson.se">Jari.Arkko@lmf.eua.ericsson.seQ?BR>jar.1.c
char*_="Hello world.\n";
ln -s /dev/tty jar.1.o
cc -c jar.1.c
现在最短的HelloWorld QJyrki HolopainenQ?BR>";main(){puts("Hello World!");}char*C=".c
char*_=__FILE__;
q是一个v名“周星星”的同学对原文的评论?BR>周星?发表?005-06-16 5:01 PM
“很明显QC++的编译器不如java的JIT和HotSpot~译器,因ؓ(f)JIT和HotSpot~译器能针对CPU指o(h)集进行h优化、能在运行时Ҏ(gu)使用频率对methodq行内联和优化。而C++的静(rn)态编译器永远也做不到q些?
--- 无知?jin)吧Q现存(sh)世的C++~译器,无论是VC++Q还是Intel C++Q还是g++Q都能针对特定CPUq行优化Q而Java的所谓动态优化只是做?jin)部分(不是全部QC++?rn)态优化的工作Q事实上Q真正的动态优化不是Q何一个高U语a所能做到的QC++不能QC不能QJava更不能,必须内嵌汇编才能做到q一炏V?
“JDK1.0Ӟjava的速度是C++?0?0分之一。而到?jin)jdk1.4Ӟjava的性能则是C++的三分之一?倍(通常C++是java?.2倍到1.5倍)(j)。可惜这分报告没有jdk1.4以后的数据,而后面的报告我们看到在jdk1.4.2Ӟjava性能全面过C++。?
--- 有个10岁的孩子对?0母亲_(d)(x)?q前我的q龄是妳?/21Q我现在的年龄是妳的1/3Q随着q种势的发展,在未来我的年龄就可以过妟뀂?
Java的速度也许可以接近C++Q但永远不可能达到C++一样快Q更不可能超qC++Q因释程序必要求原生程序来解释执行Q所以永q达不到一L(fng)速度?
“Java写的数据库的性能是C++写的数据库性能的近600倍!?
--- 天方夜KQ如果真的这PMS SQLZ么不用Java来编写,OracleZ么不用Java来编写,MySQLZ么不用Java来编写?
“伯克利大学和Lawrence伯克利国家实验室的一份报告证明:(x)IBM的JDK比GCC更快?
--- 伯克利大学真的有q个报告吗?真是h伯克利的威名Q把JDK和GCC攑֜一hQ如同把“长度”和“重量”这两种不同性质的东西放在一h?
“用Ujava写的JDK底层要比用C++写JDK底层要快?
--- 晕,“纯java写的JDK”,教你Java的老师被你气蟩g(jin)?/P>