锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品老司机在线观看,亚洲中文字幕乱码熟女在线,亚洲成A∨人片天堂网无码http://www.tkk7.com/sakis/archive/2006/07/13/58063.htmlDuran's technical lifeDuran's technical lifeThu, 13 Jul 2006 14:17:00 GMThttp://www.tkk7.com/sakis/archive/2006/07/13/58063.htmlhttp://www.tkk7.com/sakis/comments/58063.htmlhttp://www.tkk7.com/sakis/archive/2006/07/13/58063.html#Feedback0http://www.tkk7.com/sakis/comments/commentRss/58063.htmlhttp://www.tkk7.com/sakis/services/trackbacks/58063.htmlInstalled JDK6 (Mustang) beta and Eclipse3.2 . As Sun promised , Swing library, especially the聽WindowsLookAndFeel feels much better. It鈥檚 hard to tell the difference between a Swing drawn window and a WINXP native window. Developing Java desktop applications is worth considering. Mattise, a free easy-to-use WYSIWYG Swing UI designer, is the only reason for many to use the tedious NetBeans. Recently, Genuitec provided Matisse4Eclipse, which is聽an implementation of Matisse that integrates its functionality into MyEclipse Workbench to enable the easy creation of Swing applications with Eclipse. So the only reason to use NetBeans has gone.

Duran's technical life 2006-07-13 22:17 鍙戣〃璇勮
]]>
[絎旇]浜嬪姟澶勭悊http://www.tkk7.com/sakis/archive/2005/09/09/12532.htmlDuran's technical lifeDuran's technical lifeFri, 09 Sep 2005 05:09:00 GMThttp://www.tkk7.com/sakis/archive/2005/09/09/12532.htmlhttp://www.tkk7.com/sakis/comments/12532.htmlhttp://www.tkk7.com/sakis/archive/2005/09/09/12532.html#Feedback1http://www.tkk7.com/sakis/comments/commentRss/12532.htmlhttp://www.tkk7.com/sakis/services/trackbacks/12532.html@title [絎旇]浜嬪姟澶勭悊

#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: 鑴忚錛堣剰鏁版嵁鎸囧凡鏇存柊錛岃繕娌℃彁浜ょ殑鏁版嵁錛夈備簨鍔1璇誨彇鍒頒簨鍔2涓殑鑴忔暟鎹?/FONT>

Unrepeatable Reads: 涓嶅彲閲嶅璇匯備簨鍔1媯绱㈠埌鏌愯鍚庯紝浜嬪姟T2鏇存柊騫舵彁浜や簡璇ヨ錛岃嫢浜嬪姟T2鍐嶆媯绱㈣琛岋紝鍒欎細鐪嬪埌涓嶄竴鏍風殑緇撴灉銆?/FONT>

Phantom Reads: 铏氳銆備簨鍔1媯绱㈠埌絎﹀悎鏌愭潯浠剁殑琛岄泦鍚庯紝浜嬪姟T2鎻掑叆騫舵彁浜や簡婊¤凍璇ユ潯浠剁殑鏂拌錛岃嫢浜嬪姟T2鍐嶆鎸夎鏉′歡媯绱紝鍒欎細鐪嬪埌浠ュ墠涓嶅瓨鍦ㄧ殑琛屸淧hantom鈥濄?/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
鍙浜嬪姟淇濊瘉浜嗗鏉℃煡璇QL鐨勫湪浜嬪姟綰у埆鐨勮涓鑷存с侸DBC鍜屾暟鎹簱浼氬鍙浜嬪姟鍋氫竴浜涗紭鍖栥?/FONT>

[1] C.J.Date, An Introduction to Database Systems 7th.



]]>
iteration::two Cairngorm 0.99 寮鍙戞寚鍗?/title><link>http://www.tkk7.com/sakis/archive/2005/09/07/12342.html</link><dc:creator>Duran's technical life</dc:creator><author>Duran's technical life</author><pubDate>Wed, 07 Sep 2005 13:49:00 GMT</pubDate><guid>http://www.tkk7.com/sakis/archive/2005/09/07/12342.html</guid><wfw:comment>http://www.tkk7.com/sakis/comments/12342.html</wfw:comment><comments>http://www.tkk7.com/sakis/archive/2005/09/07/12342.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/sakis/comments/commentRss/12342.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/sakis/services/trackbacks/12342.html</trackback:ping><description><![CDATA[<P><FONT face="Courier New" size=2>iteration::two Cairngorm 0.99 寮鍙戞寚鍗?BR>@author <A href="mailto:notifyAll@hotmail.com">sakis</A><BR>@version 0.1</FONT></P> <P><FONT face="Courier New" size=2>#0<BR>MXML浼樼偣錛氫嬌鐢ㄦ柟渚匡紝XML浠g爜綆媧佹槗鎳?BR>緙虹偣錛氫簨浠躲佸嚱鏁般佺晫闈㈡弿娣峰湪涓璧楓傜▼搴忚妯″ぇ浜嗛毦浜庡紑鍙戠淮鎶ゃ?/FONT></P> <P><FONT face="Courier New" size=2>#1<BR>Cairngorm妗嗘灦鏄痠terationtwo鎺ㄥ嚭鐨勫彿縐板熀浜嶫EE Best Practice鐨凢lex紼嬪簭寮鍙戠殑light-weight framework銆?鎭?light-weight榪欎釜璇嶈繕鐪熸槸嫻佽鍛?銆傜洰鍓嶆渶鏂扮増鏈負0.99銆?/FONT></P> <P><FONT face="Courier New" size=2>Cairngorm鐨勭粨鏋勫涓嬶細<BR>org<BR>鈹斺攢nevis<BR>    鈹斺攢cairngorm<BR>        鈹溾攢application<BR>        鈹?nbsp;     CairngormApplication.as<BR>        鈹?BR>        鈹溾攢business<BR>        鈹?nbsp;     Responder.as<BR>        鈹?nbsp;     ServiceLocator.as<BR>        鈹?BR>        鈹溾攢commands<BR>        鈹?nbsp;     Command.as<BR>        鈹?nbsp;     SequenceCommand.as<BR>        鈹?BR>        鈹溾攢control<BR>        鈹?nbsp;     Event.as<BR>        鈹?nbsp;     EventBroadcaster.as<BR>        鈹?nbsp;     FrontController.as<BR>        鈹?BR>        鈹溾攢model<BR>        鈹?nbsp;     ModelLocator.as<BR>        鈹?BR>        鈹溾攢view<BR>        鈹?nbsp;     ViewHelper.as<BR>        鈹?nbsp;     ViewLocator.as<BR>        鈹?BR>        鈹斺攢vo<BR>                ValueObject.as</FONT></P> <P><BR><FONT face="Courier New" size=2>#2<BR>涓嬮潰緇欏ぇ瀹剁畝鍗曚粙緇岰airngorm鐨勫疄鐜版濊礬銆?/FONT></P> <P><FONT face="Courier New" size=2>#2.1<BR>Command/FrontController灝咵vent涓嶸iwe鍒嗙銆?BR>FrontController瀹炵幇Singleton妯″紡(浠ヤ笅綆鍐欎負SP)銆傛墍鏈夎嚜瀹氫箟鐨凜ommand鍦ㄨ鍦‵rontController鏋勯犲嚱鏁頒腑瀹炰緥鍖栧茍浠ュ叧鑱旀暟緇勭殑鏂瑰紡娉ㄥ唽FrontController#addCommand(eventType:String, commandInstance:Command)銆侲ventBroadcaster瀹炵幇SP銆侲vent綾葷殑緇撴瀯涓簕type:eventType, data:eventData}銆傛垜浠氳繃EventBroadcaster#broadcastEvent(eventType:String, eventData:Object)鍙戝竷Event銆侲vent鍙戝竷鍚?涓巈ventType瀵瑰簲鐨刢ommand instance鎵цCommand#execute(event:Event)銆?/FONT></P> <P><FONT face="Courier New" size=2>BTW錛氬湪Cairngorm鐨勬簮鐮佷腑錛宔ventType銆乧ommandName銆乪ventName娣風敤錛屾垜緇熶竴鐢╡ventType銆?/FONT></P> <P><FONT face="Courier New" size=2>#2.2<BR>ServiceLocator灝哛emote Service澹版槑涓嶸iew鍒嗙銆?BR>ServiceLocator瀹炵幇SP銆傚湪Cairngorm鐨刣emo涓紝鍙堥氳繃Delegate瀵硅薄瑙i櫎Command/Responder鍜孲erviceLocator涔嬮棿鐨勪緷璧栥傝繖涓狣elegate鍋氱殑浜嬫儏鍏跺疄鎰忎箟涓嶅ぇ錛屽氨鏄皟鐢⊿erviceLocator涓殑Method錛岃緗帿涓猂esponder涓虹浉搴旇繙紼嬫柟娉曠殑handler銆備釜浜鴻寰楁棤璋撳湴澧炲姞浜嗕唬鐮侀噺錛岃屼笖Delegate瀵硅薄涔熸病瀹炵幇SP錛屼篃灝辨槸璇存垜浠瘡嬈¤皟鐢ㄤ竴嬈emote Service涓殑Method錛岄兘瑕乶ew涓涓狣elegate瀵硅薄錛屽疄鍦ㄦ氮璐廣?/FONT></P> <P><FONT face="Courier New" size=2>#2.3<BR>ViewLocator/ViewHelper灝哣iew錛圡XML錛変腑澶規潅鐨刦unction涓嶸iew鍒嗙銆?BR>ViewHelper鏈夌偣鎰忔濓紝褰撲竴涓猇iewHelper鍦ㄦ煇涓狹XML欏甸潰涓0鏄庢椂錛屽<view:LoginViewHelper id="loginViewHelper" /><?xml:namespace prefix = view /><view:LoginViewHelper id=loginViewHelper></view:LoginViewHelper>銆俈iewHelper鑳借嚜鍔ㄥ彇寰楁墍鍦∕XML瀵硅薄鐨勫紩鐢紝騫墮氳繃ViewLocator#register(id, this:ViewHelper)灝嗚嚜韜敞鍐屽埌ViewLocator涓俈iewLocator瀹炵幇SP銆傚熷姪ViewLocator/ViewHelper,鎴戜滑灝卞彲浠ユ柟渚跨殑璋冪敤涓嶅悓MXML欏甸潰涓殑鏂規硶銆?/FONT></P> <P><FONT face="Courier New" size=2>#2.4<BR>ModelLocator鏄竴涓猰arker interface錛岀▼搴忎腑Model鍙互鏀懼湪鏌愪釜ModelLocator鏂逛究璋冪敤銆?/FONT></P> <P><FONT face="Courier New" size=2>#2.5<BR>ValueObject涔熸槸涓涓猰arker interface, 鍩烘湰涓嶉渶瑕併?/FONT></P> <P><FONT face="Courier New" size=2>#3<BR>Cairngorm.99緇欐垜浠紑鍙慒lex紼嬪簭鎻愪緵浜嗗緢涓嶉敊鐨勬灦鏋勬ā寮?M/V/C/Remote涔嬮棿鍙互鍋氬埌瀹屽叏瑙f瀯銆備絾鍦ㄥ疄闄呭紑鍙戞椂娌℃湁蹇呰姝繪墸,浠g爜緇撴瀯娓呮櫚鏈夋椿鍔涘氨濂姐?/FONT></P><img src ="http://www.tkk7.com/sakis/aggbug/12342.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/sakis/" target="_blank">Duran's technical life</a> 2005-09-07 21:49 <a href="http://www.tkk7.com/sakis/archive/2005/09/07/12342.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Hibernate涓瀵逛竴鍏寵仈瀹炵敤浠嬬粛http://www.tkk7.com/sakis/archive/2005/09/06/12200.htmlDuran's technical lifeDuran's technical lifeTue, 06 Sep 2005 05:16:00 GMThttp://www.tkk7.com/sakis/archive/2005/09/06/12200.htmlhttp://www.tkk7.com/sakis/comments/12200.htmlhttp://www.tkk7.com/sakis/archive/2005/09/06/12200.html#Feedback2http://www.tkk7.com/sakis/comments/commentRss/12200.htmlhttp://www.tkk7.com/sakis/services/trackbacks/12200.htmlHibernate涓瀵逛竴鍏寵仈瀹炵敤浠嬬粛

#0
涔﹀拰鏂囨。涓婂啓鐨勯兘涓嶆槸鐗規竻妤氱殑銆傝嚜宸辮涓嬫潵銆?/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鍜孋ustomer#shoppingCart鏄弽鍚戠殑鍏崇郴銆傛墍浠ibernate鐭ラ亾濡備綍浠嶴hoppingCart#getCustomer涓绱㈠埌鐩稿簲鐨刢ustomer瀵硅薄銆傚彇鍑烘煇涓狢ustomer瀵硅薄鏃訛紝Hibernate浼氱敓鎴怐EBUG 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鐨凱K榪樺簲璇ユ槸涓涓狥K錛岃繖涓狥K寮曠敤Customer鐨凱K銆傝繕闇瑕佸鍋氫竴鐐瑰伐浣滐紝澹版槑ShoppingCart鐨凱K鐢熸垚絳栫暐鏄痜oreign錛屽搴擲hoppingCart#customer銆傝繖鍜屼笂闈竴鍙ヨ瘽涓嶆槸涓涓剰鎬濆槢錛孎T~~

#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=?

榪欎釜鈥滅湡姝b濈殑one-to-one鐨勫ソ澶勬槸灝戞潯鍏寵仈SQL璇彞錛岀湅鍒頒簡鍚楋紵



]]>
Avoid tomcat "out of memory" errorhttp://www.tkk7.com/sakis/archive/2005/08/12/9982.htmlDuran's technical lifeDuran's technical lifeFri, 12 Aug 2005 09:38:00 GMThttp://www.tkk7.com/sakis/archive/2005/08/12/9982.htmlhttp://www.tkk7.com/sakis/comments/9982.htmlhttp://www.tkk7.com/sakis/archive/2005/08/12/9982.html#Feedback0http://www.tkk7.com/sakis/comments/commentRss/9982.htmlhttp://www.tkk7.com/sakis/services/trackbacks/9982.html2  In \Program Files\Apache software Foundation\Tomcat 5.0\bin\catalina.bat, in the last section immediately after "rem Execute Java with the applicable properties", insert this line, set CATALINA_OPTS=-mx1024m. Save the file.

]]>
HelloWorldhttp://www.tkk7.com/sakis/archive/2005/08/09/9631.htmlDuran's technical lifeDuran's technical lifeTue, 09 Aug 2005 01:38:00 GMThttp://www.tkk7.com/sakis/archive/2005/08/09/9631.htmlhttp://www.tkk7.com/sakis/comments/9631.htmlhttp://www.tkk7.com/sakis/archive/2005/08/09/9631.html#Feedback0http://www.tkk7.com/sakis/comments/commentRss/9631.htmlhttp://www.tkk7.com/sakis/services/trackbacks/9631.html鍦╣oogle閲屾暡浜嗏淗elloWolrd鈥濓紝鍐嶇偣鈥滄墜姘斾笉閿欌濓紝鍑烘潵浜嗚繖鏍蜂竴涓〉闈細http://www2.latech.edu/~acm/HelloWorld.shtml

Hello World!

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鐨勶紝緇忓吀HelloWorld
#include <stdio.h>
main()
{
  for(;;)
      {
          printf ("Hello World!\n");
      }
}


榪欎篃鏄疕elloWolrd錛燂紒
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=e)for(b=g<<g;b<n;++b)o[b]=o[b-h]+o[b-g]+c;
            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);
        }
}

鏇劇粡鏈鐭殑HelloWorld錛?A href="mailto:Jari.Arkko@lmf.eua.ericsson.se">Jari.Arkko@lmf.eua.ericsson.se錛?BR>jar.1.c
char*_="Hello world.\n";

ln -s /dev/tty jar.1.o
cc -c jar.1.c



鐜板湪鏈鐭殑HelloWorld 錛圝yrki Holopainen錛?BR>";main(){puts("Hello World!");}char*C=".c  
char*_=__FILE__;



]]>
Hibernate MySQL 涓枃涔辯爜闂http://www.tkk7.com/sakis/archive/2005/06/10/5894.htmlDuran's technical lifeDuran's technical lifeFri, 10 Jun 2005 13:35:00 GMThttp://www.tkk7.com/sakis/archive/2005/06/10/5894.htmlhttp://www.tkk7.com/sakis/comments/5894.htmlhttp://www.tkk7.com/sakis/archive/2005/06/10/5894.html#Feedback6http://www.tkk7.com/sakis/comments/commentRss/5894.htmlhttp://www.tkk7.com/sakis/services/trackbacks/5894.html鐜錛欻ibernate 2.1.7 + MySQL4.1錛圡ySQL鐨勭紪鐮佸凡璁劇疆涓簎tf8錛?BR>闂錛氶氳繃Hibernate鍚慚ySQL鍐欏叆涓枃鍚庯紝閫氳繃Hibernate鍙栧洖鏁版嵁錛屽湪console涓墦鍗癹ava瀵硅薄鏄劇ず姝e父銆備絾鍦∕ySQL Query Browser涓湅鍒扮殑鏄貢鐮侊紝浼犵粰鍓嶇鐨凢lex涔熸槸涔辯爜銆?BR>鍘熷洜錛欻ibernate鐨勫熀紜榪樻槸JDBC錛屾墍浠ヤ竴鏍烽渶瑕佽緗甤haracterEncoding錛?BR>瑙e喅鏂規硶錛?BR>鍦╤ibernate.cfg.xml涓簲璇ヨ繖鏍峰啓

<property name="connection.url">jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=UTF-8</property>
濡傛灉鐢╤ibernate.properties
#hibernate.connection.url jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8

ps錛氬鐞嗕腑鏂囩殑璇濓紝characterEncoding鐢℅BK涓鏍峰彲浠ャ?BR>浣嗗瓧鑺傜紪鐮侀棶棰樻渶濂界殑瑙e喅鏂規硶榪樻槸緇熶竴浣跨敤UTF-8錛侊紒錛?/FONT>

]]>
[OS]Reader-Writer Problem鐨勪笁縐嶅疄鐜?/title><link>http://www.tkk7.com/sakis/archive/2005/05/19/4844.html</link><dc:creator>Duran's technical life</dc:creator><author>Duran's technical life</author><pubDate>Thu, 19 May 2005 01:54:00 GMT</pubDate><guid>http://www.tkk7.com/sakis/archive/2005/05/19/4844.html</guid><wfw:comment>http://www.tkk7.com/sakis/comments/4844.html</wfw:comment><comments>http://www.tkk7.com/sakis/archive/2005/05/19/4844.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/sakis/comments/commentRss/4844.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/sakis/services/trackbacks/4844.html</trackback:ping><description><![CDATA[     鎽樿: 鍙傝僷ackage EDU.oswego.cs.dl.util.concurrent 1public interface Sync {2    public void acquire();3    public void release();4...  <a href='http://www.tkk7.com/sakis/archive/2005/05/19/4844.html'>闃呰鍏ㄦ枃</a><img src ="http://www.tkk7.com/sakis/aggbug/4844.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/sakis/" target="_blank">Duran's technical life</a> 2005-05-19 09:54 <a href="http://www.tkk7.com/sakis/archive/2005/05/19/4844.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>[絎旇]Hibernate - Parent/Child relationship & inverse usagehttp://www.tkk7.com/sakis/archive/2005/05/19/4838.htmlDuran's technical lifeDuran's technical lifeThu, 19 May 2005 01:28:00 GMThttp://www.tkk7.com/sakis/archive/2005/05/19/4838.htmlhttp://www.tkk7.com/sakis/comments/4838.htmlhttp://www.tkk7.com/sakis/archive/2005/05/19/4838.html#Feedback0http://www.tkk7.com/sakis/comments/commentRss/4838.htmlhttp://www.tkk7.com/sakis/services/trackbacks/4838.htmlSuppose we start with a simple <one-to-many> association from Parent to Child.
 1<hibernate-mapping package="org.hibernate.auction.model">
 2 <class name="Parent" table="PARENT">
 3  <id name="id" column="PARENT_ID" type="long">
 4   <generator class="native"></generator>
 5  </id>
 6  <set name="children">
 7   <key column="MY_PARENT_ID" />
 8   <one-to-many class="org.hibernate.auction.model.Child" />
 9  </set>
10 </class>
11 <class name="Child" table="CHILD">
12  <id name="id" column="CHILD_ID" type="long">
13   <generator class="native"></generator>
14  </id>
15  <property name="name" column="NAME" type="string" />
16 </class>
17</hibernate-mapping>

If we were to execute the following code

 1Parent p = new Parent(new HashSet()); 
 2Child c1 = new Child(new String("c1"
));
 3

 4try 
{
 5    session =
 sessionFactory.openSession();            
 6    tx =
 session.beginTransaction();           
 7
    session.save(p);
 8    Long pid =
 p.getId();
 9
    tx.commit();
10
    session.close();
11
    
12    session =
 sessionFactory.openSession();
13    tx =
 session.beginTransaction();
14    Parent pp = (Parent) session.load(Parent.class
, pid); 
15
    pp.getChildren().add(c1);        
16
    session.save(c1);
17
    session.flush();
18
    tx.commit();
19

20}
 catch (HibernateException e) {
21}

Hibernate would issue two SQL statements:
- an INSERT to create the record for c
- an UPDATE to create the link from p to c

Hibernate: insert into PARENT values ( )
Hibernate: select parent0_.PARENT_ID as PARENT_ID0_ from PARENT parent0_ where parent0_.PARENT_ID=?
Hibernate: select children0_.MY_PARENT_ID as MY_PAREN3___, children0_.CHILD_ID as CHILD_ID__, children0_.CHILD_ID as CHILD_ID0_, children0_.NAME as NAME0_ from CHILD children0_ where children0_.MY_PARENT_ID=?

- Hibernate: insert into CHILD (NAME) values (?)
- Hibernate: update CHILD set MY_PARENT_ID=? where CHILD_ID=?

This is not only inefficient, but also violates any NOT NULL constraint on the
MY_PARENT_ID column.

**********1
The underlying cause is that the link (the foreign key parent_id) from p to c is not considered part of the state of the Child object and is therefore not created in the INSERT. So the solution is to make the link part of the Child mapping.
**********1

 <many-to-one name="my_parent"
  class
="org.hibernate.auction.model.Parent" column="MY_PARENT_ID"
  not-null
="true">
 
</many-to-one>

**********2
Now that the Child entity is managing the state of the link, we tell the collection not to update the link. We use the inverse attribute.
**********2

 <set name="children" inverse="true">
  
<key column="MY_PARENT_ID" />
  
<one-to-many class="org.hibernate.auction.model.Child" />
 
</set>

The following code would be used to add a new Child

1Parent pp = (Parent) session.load(Parent.class, pid); 
2
pp.getChildren().add(c1);
3c1.setMy_parent(pp); //the link is part of the Child object's state. @see***1 

4session.save(c1);

And now, only one SQL INSERT would be issued!
To tighten things up a bit, we could create an addChild() method of Parent.

1public void addChild(Child c) {
2  c.setParent(this
);
3
  children.add(c);
4}

Now, the code to add a Child looks like

1Parent p = (Parent) session.load(Parent.class, pid);
2Child c = new
 Child();
3p.addChild(c);  // 1.let both side of the association knows each other.

4session.save(c); // 2.save the non-verse side

=========================================================================================
CONCLUSION:
1.The non-inverse(inverse="false") side is responsible to save the in-memory representation (object) to the database .
--- you should save the child: session.save(c);
2.Changes made only to the inverse end of the association are not persisted.
--- you needn't update the parent: //session.update(p);

 1session = sessionFactory.openSession();
 2tx =
 session.beginTransaction();
 3Parent pp = (Parent) session.load(Parent.classnew Long(1
)); 
 4pp.getChildren().add(c1); //the parent(pp) now knowns about the relationship

 5c1.setMy_parent(pp); //the child(c1) now knows about the relationship
 6

 7//
 when cascade="save-update", update(p) will cause all p's
 8//
 referencing children become persistence(cascade 
 9//
 saveOrUpdate() operation to parent's all children).
10//
 So, it's same as you explicitly call session.save(c1).
11

12//
 when cascade="none"(default), update(p) will just cause
13//
 p become persistence.
14//
 And inverse="true", update(p) just persists p, but not 
15// persists the link between p and c1. @see ***2

16session.update(pp);  
17//session.save(c1);  

18session.flush();
19
tx.commit();
20


Hibernate: select parent0_.PARENT_ID as PARENT_ID0_ from PARENT parent0_ where parent0_.PARENT_ID=?
Hibernate: select children0_.MY_PARENT_ID as MY_PAREN3___, children0_.CHILD_ID as CHILD_ID__, children0_.CHILD_ID as CHILD_ID0_, children0_.NAME as NAME0_, children0_.MY_PARENT_ID as MY_PAREN3_0_ from CHILD children0_ where children0_.MY_PARENT_ID=?

 1session = sessionFactory.openSession();
 2tx =
 session.beginTransaction();
 3Parent pp = (Parent) session.load(Parent.classnew Long(1
)); 
 4
pp.getChildren().add(c1);
 5
c1.setMy_parent(pp);
 6//
session.update(pp);
 7

 8//
 when save(c1), because c1 holds a reference to its Parent
 9// (my_parent), so p become persistence too.

10session.save(c1);  //The relationship will be saved. @see ***1
11session.flush();
12
tx.commit();
13


Hibernate: select parent0_.PARENT_ID as PARENT_ID0_ from PARENT parent0_ where parent0_.PARENT_ID=?
Hibernate: select children0_.MY_PARENT_ID as MY_PAREN3___, children0_.CHILD_ID as CHILD_ID__, children0_.CHILD_ID as CHILD_ID0_, children0_.NAME as NAME0_, children0_.MY_PARENT_ID as MY_PAREN3_0_ from CHILD children0_ where children0_.MY_PARENT_ID=?
Hibernate: insert into CHILD (NAME, MY_PARENT_ID) values (?, ?)


 



]]>
主站蜘蛛池模板: 91香蕉国产线观看免费全集| 边摸边脱吃奶边高潮视频免费| 国产精品小视频免费无限app| 色吊丝最新永久免费观看网站| 中文字幕精品三区无码亚洲| 无人在线观看免费高清视频| 亚洲av无码专区青青草原| 一色屋成人免费精品网站 | 无码国产精品一区二区免费| 亚洲一级二级三级不卡| 午夜不卡久久精品无码免费| 亚洲精品免费视频| 99久热只有精品视频免费看 | 亚洲精品又粗又大又爽A片| 国产成人免费爽爽爽视频| 亚洲国产精品日韩在线| 大地资源在线观看免费高清| 亚洲AV无码男人的天堂| 亚洲国产精品狼友中文久久久| A国产一区二区免费入口| 亚洲精品无码国产| 成年网站免费视频A在线双飞| 亚洲日韩AV一区二区三区四区| 免费a级黄色毛片| 国产免费网站看v片在线| 1区1区3区4区产品亚洲| 国产精品免费看久久久无码| j8又粗又长又硬又爽免费视频 | 久久亚洲成a人片| 中文字幕无码成人免费视频| 亚洲av日韩av永久无码电影| 亚洲午夜无码AV毛片久久| 国产精品99精品久久免费| 亚洲伊人久久大香线焦| 免费一级毛片在级播放| 亚洲精品免费观看| 大桥未久亚洲无av码在线| 亚洲国产精品无码中文字| 全免费毛片在线播放| 无码精品人妻一区二区三区免费| 久久亚洲高清观看|