Hibernate框架

论坛 期权论坛     
选择匿名的用户   2021-5-22 18:27   91   0
<h1 style="text-align:center"><strong>Hibernate框架</strong></h1>
<h1 align="left">1 hibernate是什么?</h1>
<p>     hibernate是一个框架。</p>
<p>     hibernate是一个持久化框架。</p>
<p>     hibernate是一个封装了JDBC的持久化框架。</p>
<p>          以后使用hibernate不用写jdbc了,select ,insert , delete , update</p>
<p>     <span style="color:red">Hibernate</span><span style="color:red">是一个基于</span><span style="color:red">ORM</span><span style="color:red">的封装</span><span style="color:red">JDBC</span><span style="color:red">的持久化框架。</span></p>
<h1>2 持久化?</h1>
<p>     化--过程。</p>
<p>     程序中的数据是临时。</p>
<p>     将程序中临时性的数据持久的保存起来的过程。叫持久化。</p>
<p>     1数据库---jdbc </p>
<p>     2文件操作---io</p>
<h1>3 ORM?</h1>
<p>     对象关系<span style="color:red">映射</span>。</p>
<p>     对象:java程序中类</p>
<p>     关系:关系型数据库中的表</p>
<p>O;</p>
<table border="1" cellpadding="0" cellspacing="0"><tbody><tr><td> <p><span style="color:#7F0055">public</span> <span style="color:#7F0055">class</span> Goods <span style="color:#7F0055">implements</span> java.io.Serializable {<!-- --></p> <p>     <span style="color:#3F7F5F">// Fields</span></p> <p>     <span style="color:#7F0055">private</span> Integer goodsId;</p> <p>     <span style="color:#7F0055">private</span> String <span style="color:#0000C0"> goodsName</span>;</p> <p>     <span style="color:#7F0055">private</span> Double <span style="color:#0000C0"> goodsPrice</span>;</p> <p>     <span style="color:#7F0055">private</span> Integer <span style="color:#0000C0"> goodsNum</span>;</p> </td></tr></tbody></table>
<p>R:</p>
<table border="1" cellpadding="0" cellspacing="0"><tbody><tr><td> <p>CREATE TABLE goods (</p> <p>  goods_id int(11) NOT NULL auto_increment,</p> <p>  goods_name varchar(200) default NULL,</p> <p>  goods_price double default NULL,</p> <p>  goods_num int(11) default NULL,</p> <p>  PRIMARY KEY  (&#39;goods_id&#39;)</p> <p>)</p> </td></tr></tbody></table>
<p>M:Goods.hbm.xml文件,ORM文件</p>
<table border="1" cellpadding="0" cellspacing="0"><tbody><tr><td> <p><span style="color:teal">&lt;</span>hibernate-mapping<span style="color:teal">&gt;</span></p> <p>    <span style="color:teal">&lt;</span>class <span style="color:#7F007F">name</span>&#61;<span style="color:#2A00FF">&#34;com.no8.domain.Goods&#34;</span> <span style="color:#7F007F">table</span>&#61;<span style="color:#2A00FF">&#34;goods&#34;</span> <span style="color:#7F007F">catalog</span>&#61;<span style="color:#2A00FF">&#34;hibernate&#34;</span><span style="color:teal">&gt;</span></p> <p>        <span style="color:teal">&lt;</span>id <span style="color:#7F007F">name</span>&#61;<span style="color:#2A00FF">&#34;goodsId&#34;</span> <span style="color:#7F007F">type</span>&#61;<span style="color:#2A00FF">&#34;java.lang.Integer&#34;</span><span style="color:teal">&gt;</span></p> <p>            <span style="color:teal">&lt;</span>column <span style="color:#7F007F"> name</span>&#61;<span style="color:#2A00FF">&#34;goods_id&#34;</span> <span style="color:teal"> /&gt;</span></p> <p>            <span style="color:teal">&lt;</span>generator <span style="color:#7F007F"> class</span>&#61;<span style="color:#2A00FF">&#34;identity&#34;</span><span style="color:teal">&gt;&lt;/</span>generator<span style="color:teal">&gt;</span></p> <p>        <span style="color:teal">&lt;/</span>id<span style="color:teal">&gt;</span></p> <p>        <span style="color:teal">&lt;</span>property <span style="color:#7F007F"> name</span>&#61;<span style="color:#2A00FF">&#34;goodsName&#34;</span> <span style="color:#7F007F"> type</span>&#61;<span style="color:#2A00FF">&#34;java.lang.String&#34;</span><span style="color:teal">&gt;</span></p> <p>            <span style="color:teal">&lt;</span>column <span style="color:#7F007F"> name</span>&#61;<span style="color:#2A00FF">&#34;goods_name&#34;</span> <span style="color:#7F007F"> length</span>&#61;<span style="color:#2A00FF">&#34;200&#34;</span> <span style="color:teal">/&gt;</span></p> <p>        <span style="color:teal">&lt;/</span>property<span style="color:teal">&gt;</span></p> <p>        <span style="color:teal">&lt;</span>property <span style="color:#7F007F"> name</span>&#61;<span style="color:#2A00FF">&#34;goodsPrice&#34;</span> <span style="color:#7F007F"> type</span>&#61;<span style="color:#2A00FF">&#34;java.lang.Double&#34;</span><span style="color:teal">&gt;</span></p> <p>            <span style="color:teal">&lt;</span>column <span style="color:#7F007F"> name</span>&#61;<span style="color:#2A00FF">&#34;goods_price&#34;</span> <span style="color:#7F007F"> precision</span>&#61;<span style="color:#2A00FF">&#34;22&#34;</span> <span style="color:#7F007F"> scale</span>&#61;<span style="color:#2A00FF">&#34;0&#34;</span> <span style="color:teal">/&gt;</span></p> <p>        <span style="color:teal">&lt;/</span>property<span style="color:teal">&gt;</span></p> <p>        <span style="color:teal">&lt;</span>property <span style="color:#7F007F"> name</span>&#61;<span style="color:#2A00FF">&#34;goodsNum&#34;</span> <span style="color:#7F007F"> type</span>&#61;<span style="color:#2A00FF">&#34;java.lang.Integer&#34;</span><span style="color:teal">&gt;</span></p> <p>            <span style="color:teal">&lt;</span>column <span style="color:#7F0
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP