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

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

flustar 2007-12-26 01:11 鍙戣〃璇勮
]]>
涓涓敤myeclipse寮鍙慼ibernate鐨勫叆闂ㄤ緥瀛?/title><link>http://www.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://www.tkk7.com/flustar/archive/2007/04/19/111958.html</guid><wfw:comment>http://www.tkk7.com/flustar/comments/111958.html</wfw:comment><comments>http://www.tkk7.com/flustar/archive/2007/04/19/111958.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.tkk7.com/flustar/comments/commentRss/111958.html</wfw:commentRss><trackback:ping>http://www.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://www.tkk7.com/flustar/aggbug/111958.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/flustar/" target="_blank">flustar</a> 2007-04-19 15:45 <a href="http://www.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://www.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://jxszzhzs.com" target="_blank">亚洲国产日韩在线一区</a>| <a href="http://wwby66636.com" target="_blank">亚洲国产成人一区二区三区</a>| <a href="http://828556.com" target="_blank">亚洲免费在线视频播放</a>| <a href="http://8k91.com" target="_blank">69视频在线观看免费</a>| <a href="http://818812.com" target="_blank">亚洲AV成人片色在线观看高潮 </a>| <a href="http://xabcjzx.com" target="_blank">亚洲人精品午夜射精日韩</a>| <a href="http://41xjj.com" target="_blank">一区二区免费在线观看</a>| <a href="http://5656ys.com" target="_blank">亚洲精品无码永久在线观看</a>| <a href="http://7299jj.com" target="_blank">一区二区三区视频免费观看</a>| <a href="http://meijibear.com" target="_blank">亚洲国产人成中文幕一级二级</a>| <a href="http://txa6.com" target="_blank">深夜免费在线视频</a>| <a href="http://33sse.com" target="_blank">337p日本欧洲亚洲大胆裸体艺术 </a>| <a href="http://dukane1688.com" target="_blank">精品视频一区二区三区免费</a>| <a href="http://onisterwines.com" target="_blank">亚洲精品无码久久久久</a>| <a href="http://yiuuu.com" target="_blank">毛片在线播放免费观看</a>| <a href="http://jiuse54.com" target="_blank">久久久亚洲裙底偷窥综合</a>| <a href="http://zisewang.com" target="_blank">7723日本高清完整版免费</a>| <a href="http://wwwnewhtbook.com" target="_blank">亚洲一级特黄特黄的大片</a>| <a href="http://caocl1024liu.com" target="_blank">精品久久洲久久久久护士免费</a>| <a href="http://wwwaa875.com" target="_blank">日本亚洲欧美色视频在线播放</a>| <a href="http://180xiu.com" target="_blank">国产免费变态视频网址网站</a>| <a href="http://pengkaimjg.com" target="_blank">特级毛片免费播放</a>| <a href="http://470577.com" target="_blank">亚洲AV无码专区亚洲AV伊甸园</a>| <a href="http://www5g9.com" target="_blank">曰批全过程免费视频网址</a>| <a href="http://qu41.com" target="_blank">亚洲色丰满少妇高潮18p</a>| <a href="http://dzhankong.com" target="_blank">免费人成年激情视频在线观看</a>| <a href="http://68996500.com" target="_blank">国产精品免费看久久久香蕉 </a>| <a href="http://avdian126.com" target="_blank">亚洲综合中文字幕无线码</a>| <a href="http://okgou58.com" target="_blank">麻豆精品国产免费观看</a>| <a href="http://fphs666.com" target="_blank">一级特黄a免费大片</a>| <a href="http://tyfinland.com" target="_blank">亚洲gv猛男gv无码男同短文</a>| <a href="http://kssijia.com" target="_blank">91久久成人免费</a>| <a href="http://xjdz8.com" target="_blank">亚洲hairy多毛pics大全</a>| <a href="http://xx16xx.com" target="_blank">亚洲熟妇av一区二区三区</a>| <a href="http://www-887234.com" target="_blank">2015日韩永久免费视频播放</a>| <a href="http://wwwfac37.com" target="_blank">亚洲精品无码久久久久APP</a>| <a href="http://liexion.com" target="_blank">精品亚洲成α人无码成α在线观看 </a>| <a href="http://998wc.com" target="_blank">国产成人免费一区二区三区</a>| <a href="http://8833081.com" target="_blank">中国毛片免费观看</a>| <a href="http://126cm.com" target="_blank">一本天堂ⅴ无码亚洲道久久</a>| <a href="http://gycat.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>