锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品乱码久久久久蜜桃,亚洲人成网站在线观看播放动漫,国产精品亚洲一区二区三区久久 http://m.tkk7.com/flustar/category/21761.html寮鍙戣漿浜嗛攢鍞紝榪樿兘鐢遍攢鍞仛鍥炲紑鍙戝悧錛?/description>zh-cnSun, 13 Sep 2009 15:11:30 GMTSun, 13 Sep 2009 15:11:30 GMT60Hibernate鏋勬灦搴旂敤涓父鐢ㄤ繚瀛樻柟寮忓尯鍒?杞澆)http://m.tkk7.com/flustar/archive/2008/03/13/186121.htmlflustarflustarThu, 13 Mar 2008 10:11:00 GMThttp://m.tkk7.com/flustar/archive/2008/03/13/186121.htmlhttp://m.tkk7.com/flustar/comments/186121.htmlhttp://m.tkk7.com/flustar/archive/2008/03/13/186121.html#Feedback1http://m.tkk7.com/flustar/comments/commentRss/186121.htmlhttp://m.tkk7.com/flustar/services/trackbacks/186121.html闃呰鍏ㄦ枃

flustar 2008-03-13 18:11 鍙戣〃璇勮
]]>
Struts2+spring2+hibernate3鏁村悎鏂規http://m.tkk7.com/flustar/archive/2007/12/26/ssha.htmlflustarflustarTue, 25 Dec 2007 17:11:00 GMThttp://m.tkk7.com/flustar/archive/2007/12/26/ssha.htmlhttp://m.tkk7.com/flustar/comments/170431.htmlhttp://m.tkk7.com/flustar/archive/2007/12/26/ssha.html#Feedback36http://m.tkk7.com/flustar/comments/commentRss/170431.htmlhttp://m.tkk7.com/flustar/services/trackbacks/170431.html闃呰鍏ㄦ枃

flustar 2007-12-26 01:11 鍙戣〃璇勮
]]>
涓涓敤myeclipse寮鍙慼ibernate鐨勫叆闂ㄤ緥瀛?/title><link>http://m.tkk7.com/flustar/archive/2007/04/19/111958.html</link><dc:creator>flustar</dc:creator><author>flustar</author><pubDate>Thu, 19 Apr 2007 07:45:00 GMT</pubDate><guid>http://m.tkk7.com/flustar/archive/2007/04/19/111958.html</guid><wfw:comment>http://m.tkk7.com/flustar/comments/111958.html</wfw:comment><comments>http://m.tkk7.com/flustar/archive/2007/04/19/111958.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://m.tkk7.com/flustar/comments/commentRss/111958.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/flustar/services/trackbacks/111958.html</trackback:ping><description><![CDATA[<p style="FONT-SIZE: 12pt"></p> <span style="FONT-SIZE: 12pt"> <p style="FONT-SIZE: 12pt"></p> <span style="FONT-SIZE: 14pt"> <p style="FONT-SIZE: 12pt"></p> <span style="FONT-SIZE: 14pt"><br></span> <p style="FONT-SIZE: 12pt"></p> </span> <p style="FONT-SIZE: 12pt"></p> </span> <p style="FONT-SIZE: 12pt"><br></p> <p><o:p> 涓銆佺幆澧?br><br>1.eclipse 3.2.2<br>2.myeclipse 5.1.1<br>3.jdk 1.5<br><br>浜屻佺畝瑕佽鏄?br><br>鏁版嵁搴撲負mysql<br><br> 鍦╩ysql涓緩绔嬩竴涓猼est鏁版嵁搴?寤虹珛cat琛?br>CREATE TABLE `cat` (<br>  `cat_id` varchar(32) NOT NULL,<br>  `name` varchar(16) NOT NULL,<br>  `sex` varchar(1) default NULL,<br>  `weight` float(9,3) default NULL,<br>  PRIMARY KEY  (`cat_id`)<br>)</o:p></p> <p>涓夈佹楠?o:p></o:p></p> <p>1.瀵煎叆鍖呯殑鍑嗗宸ヤ綔<br></p> <p>a.鏂板緩java project.寤虹珛鍖卐xample<br>鍦ㄥ畠涓嬮潰緙栧啓綾籆at.java<o:p></o:p></p> <p>package example;<o:p></o:p></p> <p><o:p> public class Cat  implements java.io.Serializable {</o:p></p> <o:p></o:p> <p><br>    // Fields    </p> <p>     private String catId;<br>     private String name;<br>     private String sex;<br>     private Float weight;</p> <p><br>    // Constructors</p> <p>    /** default constructor */<br>    public Cat() {<br>    }</p> <p> /** minimal constructor */<br>    public Cat(String name) {<br>        this.name = name;<br>    }<br>    <br>    /** full constructor */<br>    public Cat(String name, String sex, Float weight) {<br>        this.name = name;<br>        this.sex = sex;<br>        this.weight = weight;<br>    }</p> <p>   <br>    // Property accessors</p> <p>    public String getCatId() {<br>        return this.catId;<br>    }<br>    <br>    public void setCatId(String catId) {<br>        this.catId = catId;<br>    }</p> <p>    public String getName() {<br>        return this.name;<br>    }<br>    <br>    public void setName(String name) {<br>        this.name = name;<br>    }</p> <p>    public String getSex() {<br>        return this.sex;<br>    }<br>    <br>    public void setSex(String sex) {<br>        this.sex = sex;<br>    }</p> <p>    public Float getWeight() {<br>        return this.weight;<br>    }<br>    <br>    public void setWeight(Float weight) {<br>        this.weight = weight;<br>    }<o:p> <br>}</o:p></p> <p>鍚屾牱鍦ㄦ鍖呬笅闈㈢紪鍐機at.hbm.xml<o:p></o:p></p> <p><o:p> </o:p><o:p> <?xml version="1.0" encoding="utf-8"?><br><!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"<br>"<a ><br><!-- <br>    Mapping file autogenerated by MyEclipse - Hibernate Tools<br>--><br><hibernate-mapping><br>    <class name="example.Cat" table="cat" catalog="testhibernate"><br>        <id name="catId" type="java.lang.String"><br>            <column name="cat_id" length="32" /><br>            <generator class="uuid.hex"></generator><br>        </id><br>        <property name="name" type="java.lang.String"><br>            <column name="name" length="16" not-null="true" /><br>        </property><br>        <property name="sex" type="java.lang.String"><br>            <column name="sex" length="1" /><br>        </property><br>        <property name="weight" type="java.lang.Float"><br>            <column name="weight" precision="9" scale="3" /><br>        </property><br>    </class><br></hibernate-mapping><br></o:p><br><o:p></o:p></p> <p>b.鍦ㄥ伐紼嬬殑src閲岄潰鍔犲叆涓涓寘錛岀敤鏉ュ瓨鏀懼皢瑕佺敓鎴愮殑HibernateSessionFactory銆傚寘鍚嶅錛坋xample.util錛夈?br><o:p>瀵煎叆hibernate(鐢熸垚鐨勪唬鐮?<br>package example.util;</o:p></p> <p><o:p>import org.hibernate.HibernateException;<br>import org.hibernate.Session;<br>import org.hibernate.cfg.Configuration;</o:p></p> <p><o:p>/**<br> * Configures and provides access to Hibernate sessions, tied to the<br> * current thread of execution.  Follows the Thread Local Session<br> * pattern, see <a href="mailto:{@link">{@link</a> <a >http://hibernate.org/42.html</a> }.<br> */<br>public class HibernateSessionFactory {</o:p></p> <p><o:p>    /** <br>     * Location of hibernate.cfg.xml file.<br>     * Location should be on the classpath as Hibernate uses  <br>     * #resourceAsStream style lookup for its configuration file. <br>     * The default classpath location of the hibernate config file is <br>     * in the default package. Use #setConfigFile() to update <br>     * the location of the configuration file for the current session.   <br>     */<br>    private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";<br> private static final ThreadLocal<Session> threadLocal = new ThreadLocal<Session>();<br>    private  static Configuration configuration = new Configuration();<br>    private static org.hibernate.SessionFactory sessionFactory;<br>    private static String configFile = CONFIG_FILE_LOCATION;</o:p></p> <p><o:p>    private HibernateSessionFactory() {<br>    }<br> <br> /**<br>     * Returns the ThreadLocal Session instance.  Lazy initialize<br>     * the <code>SessionFactory</code> if needed.<br>     *<br>     *  @return Session<br>     *  @throws HibernateException<br>     */<br>    public static Session getSession() throws HibernateException {<br>        Session session = (Session) threadLocal.get();</o:p></p> <p><o:p>  if (session == null || !session.isOpen()) {<br>   if (sessionFactory == null) {<br>    rebuildSessionFactory();<br>   }<br>   session = (sessionFactory != null) ? sessionFactory.openSession()<br>     : null;<br>   threadLocal.set(session);<br>  }</o:p></p> <p><o:p>        return session;<br>    }</o:p></p> <p><o:p> /**<br>     *  Rebuild hibernate session factory<br>     *<br>     */<br> public static void rebuildSessionFactory() {<br>  try {<br>   configuration.configure(configFile);<br>   sessionFactory = configuration.buildSessionFactory();<br>  } catch (Exception e) {<br>   System.err<br>     .println("%%%% Error Creating SessionFactory %%%%");<br>   e.printStackTrace();<br>  }<br> }</o:p></p> <p><o:p> /**<br>     *  Close the single hibernate session instance.<br>     *<br>     *  @throws HibernateException<br>     */<br>    public static void closeSession() throws HibernateException {<br>        Session session = (Session) threadLocal.get();<br>        threadLocal.set(null);</o:p></p> <p><o:p>        if (session != null) {<br>            session.close();<br>        }<br>    }</o:p></p> <p><o:p> /**<br>     *  return session factory<br>     *<br>     */<br> public static org.hibernate.SessionFactory getSessionFactory() {<br>  return sessionFactory;<br> }</o:p></p> <p><o:p> /**<br>     *  return session factory<br>     *<br>     * session factory will be rebuilded in the next call<br>     */<br> public static void setConfigFile(String configFile) {<br>  HibernateSessionFactory.configFile = configFile;<br>  sessionFactory = null;<br> }</o:p></p> <p><o:p> /**<br>     *  return hibernate configuration<br>     *<br>     */<br> public static Configuration getConfiguration() {<br>  return configuration;<br> }</o:p></p> <p><o:p>}<br></o:p></p> <o:p></o:p> <p>瀵瑰伐紼嬪悕鐐歸紶鏍囧彸閿傞夋嫨myeclipse->add <o:p></o:p></p> <p><o:p></o:p></p> <p>hibernate capabicities銆?o:p></o:p></p> <p>鍦ㄥ脊鍑虹殑紿楀彛閫夋嫨涓璈ibernate 3.0 Core Libraries鍜孒ibernate 3.0 Advanced Support Libraries<o:p></o:p></p> <p>涓嬮潰閫変腑Copy checked Library Jars to project folder and add to build-path銆傜偣鍑諱笅涓姝ャ?o:p></o:p></p> <p>c.榛樿錛坔ibernate cofig file錛夛紝涓嬩竴姝ャ?o:p></o:p></p> <p>d.閫変腑User JDBC driver<br>connect url:  jdbc:mysql://localhost:3306/test<br>Driver class:  org.gjt.mm.mysql.Driver<br>username:  root<br>password: ******<br>Dialect: mysql<br></p> <p>e.鍦ㄧ涓琛屽寘閫夋嫨閲岄潰錛岄夋嫨鍦ㄥ墠闈㈢浜屽ぇ姝ュ緩鐨勫寘濡傦紙example錛夈傜偣鍑誨畬鎴愩?o:p></o:p></p> <p>f.寮瑰嚭鐨勭敾闈腑 閫夋嫨properties鐨刟dd鎸夐挳銆傚湪Property涓姞鍏how_sql錛孷alue涓姞鍏rue銆傜偣紜畾</p> <p>淇濆瓨璁劇疆銆傚湪mappings涓偣add鍔犲叆鍓嶉潰寤虹珛鐨凜at.hbm.xml銆傛渶鍚庣敓鎴愮殑hibernate.cfg.xml鏂囦歡濡備笅<br><?xml version='1.0' encoding='UTF-8'?><br><!DOCTYPE hibernate-configuration PUBLIC<br>          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"<br>          "<a ></p> <p><!-- Generated by MyEclipse Hibernate Tools.                   --><br><hibernate-configuration></p> <p><session-factory><br> <property name="connection.username">root</property><br> <property name="connection.url"><br>  jdbc:mysql://localhost:3306/testhibernate<br> </property><br> <property name="dialect"><br>  org.hibernate.dialect.MySQLDialect<br> </property><br> <property name="connection.password">123456</property><br> <property name="connection.driver_class"><br>  org.gjt.mm.mysql.Driver<br> </property><br> <property name="show_sql">true</property><br> <mapping resource="example/Cat.hbm.xml" /></p> <p></session-factory></p> <p></hibernate-configuration></p> <p><br><o:p>3.嫻嬭瘯 鏂板緩鍖卼est 鍦ㄥ叾涓緩绔嬫祴璇曟枃浠禩estHibernate.java<br>package test;</o:p></p> <p><o:p>import java.util.Iterator;<br>import java.util.List;<br>import example.*;<br>import example.util.*;<br>import org.hibernate.Session;<br>import org.hibernate.Transaction;</o:p></p> <p><o:p>public class TestHibernate {<br> Session session=null;<br> Transaction tx=null;<br>public static void main(String[] args) {<br> TestHibernate th=new TestHibernate(); <br> List cl=th.getAllCats();<br> if(cl!=null){<br>  Iterator it=cl.iterator();<br>  while(it.hasNext()){<br>   Cat cat=(Cat)it.next();<br>   System.out.println("catID:"+cat.getCatId()+"name:"+cat.getName()+"sex:"+cat.getSex());<br>  }<br> }<br>  <br>  </o:p></p> <p><o:p> }<br>public List getAllCats(){<br> session=HibernateSessionFactory.getSession();<br> List catlist=null;<br> try{<br>  tx=session.beginTransaction();<br>  catlist=session.createQuery("from Cat").list();<br>  return catlist;<br> }catch(Exception ex){<br>  System.err.println(ex.getMessage());<br>  return null;<br> }finally{<br>  HibernateSessionFactory.closeSession();<br> }<br>}</o:p></p> <p><o:p>}</o:p></p> <p><o:p> </o:p></p> <p><o:p></o:p></p> <p> </p> <img src ="http://m.tkk7.com/flustar/aggbug/111958.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/flustar/" target="_blank">flustar</a> 2007-04-19 15:45 <a href="http://m.tkk7.com/flustar/archive/2007/04/19/111958.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://m.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://2255325.com" target="_blank">亚洲精品永久www忘忧草</a>| <a href="http://lyaa60.com" target="_blank">国产在线a免费观看</a>| <a href="http://youyou8tv.com" target="_blank">日韩视频免费一区二区三区</a>| <a href="http://sewo66.com" target="_blank">伊人久久精品亚洲午夜</a>| <a href="http://djyvp32.com" target="_blank">美女裸免费观看网站</a>| <a href="http://jjesqc.com" target="_blank">成人毛片免费在线观看</a>| <a href="http://kkm55.com" target="_blank">国产91在线|亚洲</a>| <a href="http://513net.com" target="_blank">免费看国产成年无码AV片</a>| <a href="http://6711wan.com" target="_blank">精品亚洲AV无码一区二区</a>| <a href="http://sdkjkj.com" target="_blank">**实干一级毛片aa免费</a>| <a href="http://kkjk123.com" target="_blank">亚洲综合激情另类小说区</a>| <a href="http://www-kj5799.com" target="_blank">日韩中文字幕免费视频</a>| <a href="http://ju7776.com" target="_blank">亚洲午夜久久影院</a>| <a href="http://jyd56.com" target="_blank">亚洲第一网站免费视频</a>| <a href="http://www-554949.com" target="_blank">亚洲免费电影网站</a>| <a href="http://arkinbokis.com" target="_blank">午夜免费福利网站</a>| <a href="http://gepuw.com" target="_blank">在线视频亚洲一区</a>| <a href="http://123994.com" target="_blank">亚洲日韩中文在线精品第一</a>| <a href="http://jimeng-99.com" target="_blank">99在线热播精品免费99热</a>| <a href="http://js06vip.com" target="_blank">亚洲国产精品不卡在线电影</a>| <a href="http://38miao.com" target="_blank">99精品免费观看</a>| <a href="http://k8h9.com" target="_blank">亚洲精品综合在线影院</a>| <a href="http://2886868.com" target="_blank">在线观看国产情趣免费视频</a>| <a href="http://zhidianzh.com" target="_blank">曰批全过程免费视频免费看</a>| <a href="http://cqyouyongpx.com" target="_blank">a级亚洲片精品久久久久久久</a>| <a href="http://bjgelinhotel.com" target="_blank">亚洲精品黄色视频在线观看免费资源</a>| <a href="http://zz1220.com" target="_blank">日韩一卡2卡3卡4卡新区亚洲 </a>| <a href="http://yy885.com" target="_blank">91久久青青草原线免费</a>| <a href="http://ding001.com" target="_blank">亚洲免费在线视频观看</a>| <a href="http://yy885.com" target="_blank">午夜时刻免费入口</a>| <a href="http://paweax.com" target="_blank">gogo免费在线观看</a>| <a href="http://7766qq.com" target="_blank">亚洲最大福利视频网站</a>| <a href="http://www-64000.com" target="_blank">两个人的视频高清在线观看免费</a>| <a href="http://zanyoo.com" target="_blank">自拍偷自拍亚洲精品偷一</a>| <a href="http://3688008.com" target="_blank">狠狠综合久久综合88亚洲</a>| <a href="http://shaonvfushi.com" target="_blank">免费国产黄网站在线观看视频 </a>| <a href="http://paweax.com" target="_blank">免费电视剧在线观看</a>| <a href="http://65123456.com" target="_blank">国产成人亚洲综合在线</a>| <a href="http://gbn21.com" target="_blank">国产亚洲精品a在线无码</a>| <a href="http://0359jgyy.com" target="_blank">69av免费视频</a>| <a href="http://cqtjqcc.com" target="_blank">四虎国产精品成人免费久久</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>