²Â²Â¿´£¬Hibernate»áÖ´Ðм¸¾äSQL(Ò»)
POEAAÖнéÉÜÁËORMÖÐ×îÖØÒªµÄģʽ֮һ£ºUnit Of Work¡£¿´ËƼòµ¥£¬ÊµÏÖÆðÀ´È´·Ç³£¸´ÔÓ¡£
HibernateÍêÃÀµÄʵÏÖÁËÕâ¸öģʽ¡£ÒÔÏÂÎÒÓÃһϵÁеÄÀý×ÓÀ´·ÖÎöHibernateµÄ´¦Àí»úÖÆ
ÏÂÃæÓÐÈý¸öÀý×Ó£¬²Â²Â¿´Hibernate»áÖ´Ðм¸¾äSQL(Ê¡ÂÔÊÂÎñ´¦Àí´úÂ룬ʵÌå¶ÔÏó½ÐUser£¬¼ÙÉèÖ÷¼üÊÇ×ÔÔöÐ͵Ä)
Àý1:
User user = new User();
user.setName("KENT");
session.save(user);
session.save(user);
Àý2:
User user = new User();
user.setName("KENT");
session.save(user);
user.setName("JACK");
session.save(user);
Àý3:
User user = new User();
user.setName("KENT");
session.save(user);
user.setName("JACK");
session.save(user);
user.setName("TOM");
session.save(user);
ÈÃÎÒÃÇ¿´¿´´ð°¸
Àý1:Á½´Îsave£¬½ö½öÖ´ÐÐinsertÓï¾äÒ»´Î£¬Ã»ÓÐÖ´ÐÐupdate
Àý2:Ö´ÐÐinsertÓï¾äÒ»´Î£¬ÏÈinsert³ÉKENT£¬È»ºóÖ´ÐÐupdate£¬È»ºóupdate³ÉJACK
Àý3:Ö´ÐÐinsertÓï¾äÒ»´Î£¬ÏÈinsert³ÉKENT£¬È»ºóÖ´ÐÐupdate£¬È»ºóupdate³ÉTOM£¬Ã»ÓÐupdate³ÉJACKµÄ¹ý³Ì
Äã²Â¶ÔÁËÂð£¿
ÎÒÃÇ¿´HibernateÔ´Â룬¿´µ½UnitOfWork´óÖÂÔÀíÊÇÕâÑùµÄ£º
Hibernate²¢²»ÊÇsave()Á˾ÍÖ±½ÓÖ´ÐÐsql£¬¶øÊÇʹÓÃÑÓʱִÐеķ½Ê½¡£Ö±µ½flushʱ²Å»áÒ»´ÎÐÔÖ´Ðжà¾äsql
HibernateʹÓÃAction½Ó¿Ú±íʾÿ´ÎÔöɾ¸ÄµÄÐÐΪ£¬ËùÓеÄÐÐΪ¶¼Ê¹ÓÃActionQueueÅÅÐò
µ±Ö´ÐÐÒ»´Îsave()·½·¨£¬Hibernate»áÅжϴ˶ÔÏóµÄ״̬¡£Èç¹ûÊÇTransient¾ÍÔÚActionQueueÖÐÔö¼ÓÒ»¸öInsertAction£¬²¢Éú³É´Ë¶ÔÏóµÄÖ÷¼ü£¬°Ñ´Ë¶ÔÏó±ê¼ÇΪPersistent¡£Í¬Ê±£¬»á°ÑËùÓÐÊôÐÔµÄ״̬±£´æµ½Ò»¸öÊý×éÖС£
ÔÙ´ÎÖ´ÐÐsave()·½·¨Ê±£¬Èç¹ûÊÇPersistent£¬²¢²»»áÖ±½Ó²úÉúupdateAction
µ±Êý¾Ýcommit֮ǰ£¬Ò»¶¨»áÖ´ÐÐflush()£¬¸ù¾Ý±£´æµÄËùÓÐÊôÐÔµÄ״̬£¬Åжϵ±Ç°¶ÔÏóµÄ×Ö¶ÎÊÇ·ñ±»¸üйý£¬Èç¹û±»¸üйý£¬Ôò»áÔÚActionQueueÖÐÔö¼ÓÒ»¸öUpdateAction
ËùÒÔ
Àý1»á²úÉúInsertAction
Àý2»á²úÉúInsertAction¡¢UpdateAction
Àý3»á²úÉúInsertAction¡¢UpdateAction
´ËÀýÖÐÖ»ÊÇÐÂÔö»òÐ޸ģ¬Èç¹ûÓÐɾ³ýºÍ²éѯ£¬HibernateÓÖ»áÈçºÎ´¦ÀíÄØ£¿
Çë¿´ºóÎÄ......
Ïà¹ØÎĵµ£º
SQL Server Êý¾Ý¿âµÄÕûÀíÓÅ»¯µÄ»ù±¾¹ý³Ì£¨Ò»£©
¸ß½¨¸Õ
×÷ΪϵͳµÄÖØÒªÒ»¸ö²¿·Ö£¬Êý¾Ý¿âµÄÐÔÄÜÔÚϵͳµÄÔËÐйý³ÌÖÐÆðµ½Á˷dz£¹Ø¼üµÄ×÷Óã¬ÏµÍ³µÄÔËÐйý³ÌÖУ¬ÎÒÃǾ³£Óöµ½¿Í»§±§Ô¹ÏµÍ³ÔËÐеÄÌ«Âý£¬Í³¼ÆÒ»¸öÔµı¨±í¾³£»á³öÏÖ³¬Ê±µÄÇé¿ö£¬Ãæ¶ÔÕâЩÎÊÌ⣬ÎÒÃÇÓ¦¸ÃÈçºÎ´¦ÀíÄÄ£¿³ÌÐòÓÅ»¯ºÍÊý¾Ý¿âÓÅ»¯ÒªÍ¬²½½øÐУ¬³ÌÐò·½ÃæÓ ......
<!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:ËÎÌå;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"Cambria Mat ......
Ê×ÏÈ£¬ÓÃwindows Éí·ÝÑéÖ¤ µÇ½ sql server 2005
ÒÀ´ÎÕ¹¿ª
°²È«ÐÔ->µÇ¼Ãû
Ñ¡ÖÐ sa ÓÒ¼üµ¥»÷
Ñ¡ÖÐ ÊôÐÔ
µ¯³ö sa µÄÊôÐÔ¶Ô»°¿ò
¾ÍÔÚÃÜÂë´¦ ¸Ä ÃÜÂë ÐÐÁË
¸ÄÁËÃÜÂëºó Óà sa ºÍ Äã¸ÄµÄÃÜÂëµÇ½
Èç¹û»¹µÇ½²»ÉÏ
¾ÍÊÇÄãû´ò¿ª sql serverºÍ windowsÉí·ÝÑéÖ¤
ºÍûÊÚÓè sa µÇ½ȨÏÞ
½â¾ö°ì·¨ÈçÏÂ
£º£º£º£º ......
¡¡¡¡Ò»¡¢Ê²Ã´ÊÇSQL×¢Èëʽ¹¥»÷?
¡¡¡¡ËùνSQL×¢Èëʽ¹¥»÷£¬¾ÍÊǹ¥»÷Õß°ÑSQLÃüÁî²åÈëµ½Web±íµ¥µÄÊäÈëÓò»òÒ³ÃæÇëÇóµÄ²éѯ×Ö·û´®£¬ÆÛÆ·þÎñÆ÷Ö´ÐжñÒâµÄSQLÃüÁî¡£ÔÚijЩ±íµ¥ÖУ¬Óû§ÊäÈëµÄÄÚÈÝÖ±½ÓÓÃÀ´¹¹Ôì(»òÕßÓ°Ïì)¶¯Ì¬SQLÃüÁ»ò×÷Ϊ´æ´¢¹ý³ÌµÄÊäÈë²ÎÊý£¬ÕâÀà±íµ¥ÌرðÈÝÒ×Êܵ½SQL×¢Èëʽ¹¥»÷¡£³£¼ûµÄSQL×¢Èëʽ¹¥»÷¹ý³ÌÀàÈ磺 ......
ÊÂÎñ¾ÍÊǸºÔð°ÑһϵÁвÙ×÷¿´×öÒ»¸ö¶ÀÁ¢µÄÂß¼µ¥Ôª£¬ÕâЩ²Ù×÷Ҫôͬʱ³É¹¦£¬ÒªÃ´Í¬Ê±Ê§°Ü¡£ÏÂÃæÊÇÒ»¸ö¾µäµÄÀý×Ó£º
create procedure TransferMoeny
(
@fromAccountNo varchar(50),-- ת³öÕ˺Å
@ToAccountNo varchar(50),--תÈëÕ˺Å
& ......