⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 struts+hibernate(dao)+filter的例子.mht

📁 hibernate(java 相关)书籍
💻 MHT
📖 第 1 页 / 共 5 页
字号:
#6666ff">//hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"&gt;</SPAN=
>=20
                        <BR><BR>&lt;hibernate-mapping&gt; <BR>&nbsp; =
&nbsp;=20
                        &lt;<SPAN style=3D"FONT-WEIGHT: bold; COLOR: =
#990066"=20
                        ?>class</SPAN> name=3D"com.<SPAN=20
                        style=3D"COLOR: #000000">foxconn</SPAN>.<SPAN=20
                        style=3D"COLOR: #000000">hibernate</SPAN>.<SPAN=20
                        style=3D"COLOR: #000000">po</SPAN>.<SPAN=20
                        style=3D"COLOR: #000000">Company</SPAN>" =
table=3D"company"=20
                        dynamic-update=3D"<SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>false</SPAN>"&gt; <BR>&nbsp; &nbsp; &nbsp; =
&nbsp;=20
                        &lt;id name=3D"id" column=3D"id" type=3D"string" =

                        unsaved-value=3D"any" &gt; <BR>&nbsp; &nbsp; =
&nbsp; &nbsp;=20
                        &nbsp; &nbsp; &lt;generator <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>class</SPAN>=3D"assigned"&gt; <BR>&nbsp; =
&nbsp; &nbsp;=20
                        &nbsp; &nbsp; &nbsp; &lt;/generator&gt; =
<BR>&nbsp;=20
                        &nbsp; &nbsp; &nbsp; &lt;/id&gt; <BR>&nbsp; =
&nbsp;=20
                        &nbsp; &nbsp; &lt;property name=3D"companyname"=20
                        type=3D"string" update=3D"<SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066" =
?>true</SPAN>"=20
                        insert=3D"<SPAN style=3D"FONT-WEIGHT: bold; =
COLOR: #990066"=20
                        ?>true</SPAN>" column=3D"company_name"/&gt; =
<BR>&nbsp;=20
                        &nbsp; &lt;/<SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>class</SPAN>&gt;=20
                        =
<BR>&lt;/hibernate-mapping&gt;</DIV><BR></TD></TR></TBODY></TABLE><SPAN=20
                  =
class=3Dpostbody><BR><BR>=C5=E4=D6=C3=CE=C4=BC=FEhibernate.cfg.xml =
<BR></SPAN>
                  <TABLE cellSpacing=3D1 cellPadding=3D3 width=3D"90%" =
align=3Dcenter=20
                  border=3D0>
                    <TBODY>
                    <TR>
                      <TD><SPAN =
class=3Dgenmed><B>java=B4=FA=C2=EB:&nbsp;</B></SPAN></TD></TR>
                    <TR>
                      <TD class=3Dcode>
                        <DIV=20
                        style=3D"FONT-FAMILY: 'Courier New', Courier, =
monospace"><BR>&lt;!DOCTYPE=20
                        hibernate-configuration <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>PUBLIC</SPAN> "-<SPAN=20
                        style=3D"COLOR: #6666ff">//Hibernate/Hibernate=20
                        Configuration D</SPAN> <BR><BR>TD<SPAN=20
                        style=3D"COLOR: #6666ff">//EN"=20
                        =
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd"&gt;</S=
PAN>=20
                        <BR><BR>&lt;hibernate-configuration&gt;=20
                        <BR><BR>&lt;session-factory&gt; =
<BR><BR>&lt;property=20
                        name=3D"connection.<SPAN=20
                        style=3D"COLOR: =
#000000">datasource</SPAN>"&gt;java:comp/env/jdbc/fox221&lt;/property&gt;=
=20
                        <BR><BR>&lt;property name=3D"show_sql"&gt;<SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>false</SPAN>&lt;/property&gt; =
<BR><BR>&lt;property=20
                        name=3D"dialect"&gt;net.<SPAN=20
                        style=3D"COLOR: #000000">sf</SPAN>.<SPAN=20
                        style=3D"COLOR: #000000">hibernate</SPAN>.<SPAN=20
                        style=3D"COLOR: #000000">dialect</SPAN>.<SPAN=20
                        style=3D"COLOR: =
#000000">OracleDialect</SPAN>&lt;/property&gt;=20
                        <BR><BR>&lt;property name=3D"jdbc.<SPAN=20
                        style=3D"COLOR: =
#000000">fetch_size</SPAN>"&gt;<SPAN=20
                        style=3D"COLOR: #000000" =
?>50</SPAN>&lt;/property&gt;=20
                        <BR><BR>&lt;property name=3D"jdbc.<SPAN=20
                        style=3D"COLOR: =
#000000">batch_size</SPAN>"&gt;<SPAN=20
                        style=3D"COLOR: #000000" =
?>30</SPAN>&lt;/property&gt;=20
                        <BR><BR>&lt;!-- Mapping files --&gt; =
<BR><BR>&lt;mapping=20
                        resource=3D"/hbm/Company.<SPAN=20
                        style=3D"COLOR: #000000">hbm</SPAN>.<SPAN=20
                        style=3D"COLOR: #000000">xml</SPAN>"/&gt;=20
                        <BR><BR>&lt;/session-factory&gt;=20
                        =
<BR><BR>&lt;/hibernate-configuration&gt;</DIV><BR></TD></TR></TBODY></TAB=
LE><SPAN=20
                  =
class=3Dpostbody><BR><BR>=CC=E1=B9=A9session=B5=C4=C0=E0HebernateSessionF=
actory(=C0=FB=D3=C3Thread=B9=DC=C0=EDsession)=20
                  <BR><BR></SPAN>
                  <TABLE cellSpacing=3D1 cellPadding=3D3 width=3D"90%" =
align=3Dcenter=20
                  border=3D0>
                    <TBODY>
                    <TR>
                      <TD><SPAN =
class=3Dgenmed><B>java=B4=FA=C2=EB:&nbsp;</B></SPAN></TD></TR>
                    <TR>
                      <TD class=3Dcode>
                        <DIV=20
                        style=3D"FONT-FAMILY: 'Courier New', Courier, =
monospace"><BR><SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>public</SPAN> <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066" =
?>class</SPAN>=20
                        HibernateSessionFactory <SPAN=20
                        style=3D"COLOR: #000000">{</SPAN> <BR>&nbsp; =
&nbsp; <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>public</SPAN> <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>static</SPAN> <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066" =
?>final</SPAN>=20
                        <SPAN style=3D"COLOR: #aaaadd" =
?>ThreadLocal</SPAN>=20
                        session =3D <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066" =
?>new</SPAN>=20
                        <SPAN style=3D"COLOR: #aaaadd" =
?>ThreadLocal</SPAN><SPAN=20
                        style=3D"COLOR: #000000">(</SPAN><SPAN=20
                        style=3D"COLOR: #000000">)</SPAN>; <BR>&nbsp; =
&nbsp; <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>private</SPAN> <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>static</SPAN> SessionFactory sessionFactory;=20
                        <BR><BR>&nbsp; &nbsp; &nbsp;<SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>static</SPAN> <SPAN style=3D"COLOR: =
#000000">{</SPAN>=20
                        <BR>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066" =
?>try</SPAN>=20
                        <SPAN style=3D"COLOR: #000000">{</SPAN> =
<BR>&nbsp; &nbsp;=20
                        &nbsp; &nbsp; &nbsp; &nbsp; sessionFactory =3D =
<BR>&nbsp;=20
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;=20
                        &nbsp; <SPAN style=3D"FONT-WEIGHT: bold; COLOR: =
#990066"=20
                        ?>new</SPAN> Configuration<SPAN=20
                        style=3D"COLOR: #000000">(</SPAN><SPAN=20
                        style=3D"COLOR: #000000">)</SPAN>.<SPAN=20
                        style=3D"COLOR: #000000">configure</SPAN><SPAN=20
                        style=3D"COLOR: #000000">(</SPAN><SPAN=20
                        style=3D"COLOR: #000000">)</SPAN>.<SPAN=20
                        style=3D"COLOR: =
#000000">buildSessionFactory</SPAN><SPAN=20
                        style=3D"COLOR: #000000">(</SPAN><SPAN=20
                        style=3D"COLOR: #000000">)</SPAN>; <BR>&nbsp; =
&nbsp;=20
                        &nbsp; &nbsp; <SPAN style=3D"COLOR: =
#000000">}</SPAN>=20
                        <SPAN style=3D"FONT-WEIGHT: bold; COLOR: =
#990066"=20
                        ?>catch</SPAN> <SPAN=20
                        style=3D"COLOR: =
#000000">(</SPAN>HibernateException=20
                        ex<SPAN style=3D"COLOR: #000000">)</SPAN> <SPAN=20
                        style=3D"COLOR: #000000">{</SPAN> <BR>&nbsp; =
&nbsp; &nbsp;=20
                        &nbsp; &nbsp; &nbsp; throw <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066" =
?>new</SPAN>=20
                        <SPAN style=3D"COLOR: #aaaadd"=20
                        ?>RuntimeException</SPAN><SPAN=20
                        style=3D"COLOR: #000000">(</SPAN> <BR>&nbsp; =
&nbsp; &nbsp;=20
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
"<SPAN=20
                        style=3D"COLOR: #aaaadd" ?>Exception</SPAN> =
building=20
                        SessionFactory: " + ex.<SPAN=20
                        style=3D"COLOR: #000000">getMessage</SPAN><SPAN=20
                        style=3D"COLOR: #000000">(</SPAN><SPAN=20
                        style=3D"COLOR: #000000">)</SPAN>,ex<SPAN=20
                        style=3D"COLOR: #000000">)</SPAN>; <BR>&nbsp; =
&nbsp;=20
                        &nbsp; &nbsp; <SPAN style=3D"COLOR: =
#000000">}</SPAN>=20
                        <BR>&nbsp; &nbsp; <SPAN style=3D"COLOR: =
#000000">}</SPAN>=20
                        <BR><BR>&nbsp; &nbsp; <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>public</SPAN> <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>static</SPAN> Session currentSession<SPAN=20
                        style=3D"COLOR: #000000">(</SPAN><SPAN=20
                        style=3D"COLOR: #000000">)</SPAN> <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>throws</SPAN> HibernateException<SPAN=20
                        style=3D"COLOR: #000000">{</SPAN> <BR>&nbsp; =
&nbsp; &nbsp;=20
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Session s =3D =
<SPAN=20
                        style=3D"COLOR: #000000">(</SPAN>Session<SPAN=20
                        style=3D"COLOR: #000000">)</SPAN> session.<SPAN=20
                        style=3D"COLOR: #000000">get</SPAN><SPAN=20
                        style=3D"COLOR: #000000">(</SPAN><SPAN=20
                        style=3D"COLOR: #000000">)</SPAN>; <BR>&nbsp; =
&nbsp;=20
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066" =
?>if</SPAN>=20
                        <SPAN style=3D"COLOR: #000000">(</SPAN>s =3D=3D =
<SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>null</SPAN><SPAN style=3D"COLOR: =
#000000">)</SPAN> <SPAN=20
                        style=3D"COLOR: #000000">{</SPAN> <BR>&nbsp; =
&nbsp; &nbsp;=20
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
s=20
                        =3D&nbsp; sessionFactory.<SPAN=20
                        style=3D"COLOR: #000000">openSession</SPAN><SPAN =

                        style=3D"COLOR: #000000">(</SPAN><SPAN=20
                        style=3D"COLOR: #000000">)</SPAN>; <BR>&nbsp; =
&nbsp;=20
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;=20
                        session.<SPAN style=3D"COLOR: =
#000000">set</SPAN><SPAN=20
                        style=3D"COLOR: #000000">(</SPAN>s<SPAN=20
                        style=3D"COLOR: #000000">)</SPAN>; <BR>&nbsp; =
&nbsp;=20
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN=20
                        style=3D"COLOR: #000000">}</SPAN> <BR>&nbsp; =
&nbsp; &nbsp;=20
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>return</SPAN> s; <BR>&nbsp; &nbsp; <SPAN=20
                        style=3D"COLOR: #000000">}</SPAN> <BR>&nbsp; =
&nbsp; <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>public</SPAN> <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>static</SPAN> <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066" =
?>void</SPAN>=20
                        closeSession<SPAN style=3D"COLOR: =
#000000">(</SPAN><SPAN=20
                        style=3D"COLOR: #000000">)</SPAN> <SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20
                        ?>throws</SPAN> HibernateException<SPAN=20
                        style=3D"COLOR: #000000">{</SPAN> <BR>&nbsp; =
&nbsp; &nbsp;=20
                        &nbsp; Session s =3D <SPAN=20
                        style=3D"COLOR: #000000">(</SPAN>Session<SPAN=20
                        style=3D"COLOR: #000000">)</SPAN> session.<SPAN=20
                        style=3D"COLOR: #000000">get</SPAN><SPAN=20
                        style=3D"COLOR: #000000">(</SPAN><SPAN=20
                        style=3D"COLOR: #000000">)</SPAN>; <BR>&nbsp; =
&nbsp;=20
                        &nbsp; &nbsp; session.<SPAN=20
                        style=3D"COLOR: #000000">set</SPAN><SPAN=20
                        style=3D"COLOR: #000000">(</SPAN><SPAN=20
                        style=3D"FONT-WEIGHT: bold; COLOR: #990066"=20

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -