`
PeakLui
  • 浏览: 44727 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

初步使用Hibernate

阅读更多

1.       <!-- [endif]-->配置 Hibernate.cfg.xml

<!-- [if !supportLists]-->2.       <!-- [endif]-->定义 HibernateUtil , 里面最主要的就是一个 sessionFactory

<!-- [if !supportLists]-->3.       <!-- [endif]-->配置实体类   @.....

<!-- [if !supportLists]-->4.       <!-- [endif]-->配置 session, 提交事务

<!-- [if !supportLists]-->5.       <!-- [endif]-->关闭 session, 关闭 SessionFactory

 

<!-- [if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!-- [if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--> <!-- [if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!-- [if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--> <!-- [if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->

AnnotationConfiguration ->

<!-- [if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!-- [if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--> <!-- [if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->

<!-- [if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!-- [if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--> <!-- [if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->

SessionFactory ->

<!-- [if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->

Session ->

<!-- [if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!-- [if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--> <!-- [if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->

Transaction

 

 

 

 

 

 

 

 

<!-- [if mso & !supportInlineShapes & supportFields]><span lang=EN-US><span style="mso-element:field-begin;mso-field-lock:yes" mce_style="mso-element:field-begin;mso-field-lock:yes"></span><span style='mso-spacerun:yes'> </span>SHAPE<span style="mso-spacerun:yes" mce_style="mso-spacerun:yes">  </span>\* MERGEFORMAT <span style="mso-element:field-separator" mce_style="mso-element:field-separator"></span></span><![endif]--><!-- [if gte vml 1]><v:group id="_x0000_s1026" editas="canvas" style="width:414pt;height:241.8pt;mso-position-horizontal-relative:char; mso-position-vertical-relative:line" mce_style="width:414pt;height:241.8pt;mso-position-horizontal-relative:char; mso-position-vertical-relative:line" coordorigin="2362,2800" coordsize="7200,4212"> <o:lock v:ext="edit" aspectratio="t"/> <v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"/> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"/> <v:f eqn="sum @0 1 0"/> <v:f eqn="sum 0 0 @1"/> <v:f eqn="prod @2 1 2"/> <v:f eqn="prod @3 21600 pixelWidth"/> <v:f eqn="prod @3 21600 pixelHeight"/> <v:f eqn="sum @0 0 1"/> <v:f eqn="prod @6 1 2"/> <v:f eqn="prod @7 21600 pixelWidth"/> <v:f eqn="sum @8 21600 0"/> <v:f eqn="prod @7 21600 pixelHeight"/> <v:f eqn="sum @10 21600 0"/> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/> <o:lock v:ext="edit" aspectratio="t"/> </v:shapetype><v:shape id="_x0000_s1027" type="#_x0000_t75" style="position:absolute; left:2362;top:2800;width:7200;height:4212" mce_style="position:absolute; left:2362;top:2800;width:7200;height:4212" o:preferrelative="f"> <v:fill o:detectmouseclick="t"/> <v:path o:extrusionok="t" o:connecttype="none"/> <o:lock v:ext="edit" text="t"/> </v:shape><v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe"> <v:stroke joinstyle="miter"/> <v:path gradientshapeok="t" o:connecttype="rect"/> </v:shapetype><v:shape id="_x0000_s1028" type="#_x0000_t202" style="position:absolute; left:3145;top:6469;width:2347;height:408" mce_style="position:absolute; left:3145;top:6469;width:2347;height:408"> <v:textbox> <![if !mso]> <table cellpadding=0 cellspacing=0 width="100%"> <tr> <td><![endif]> <div> <p class=MsoNormal><span lang=EN-US>AnnotationConfiguration</span></p> </div> <![if !mso]></td> </tr> </table> <![endif]></v:textbox> </v:shape><v:shape id="_x0000_s1029" type="#_x0000_t202" style="position:absolute; left:3145;top:5789;width:2347;height:408" mce_style="position:absolute; left:3145;top:5789;width:2347;height:408"> <v:textbox> <![if !mso]> <table cellpadding=0 cellspacing=0 width="100%"> <tr> <td><![endif]> <div> <p class=MsoNormal><span lang=EN-US>SessionFactory</span></p> <p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p> </div> <![if !mso]></td> </tr> </table> <![endif]></v:textbox> </v:shape><v:shape id="_x0000_s1030" type="#_x0000_t202" style="position:absolute; left:3145;top:4974;width:2347;height:408" mce_style="position:absolute; left:3145;top:4974;width:2347;height:408"> <v:textbox> <![if !mso]> <table cellpadding=0 cellspacing=0 width="100%"> <tr> <td><![endif]> <div> <p class=MsoNormal><span lang=EN-US>Session</span></p> <p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p> </div> <![if !mso]></td> </tr> </table> <![endif]></v:textbox> </v:shape><v:shape id="_x0000_s1031" type="#_x0000_t202" style="position:absolute; left:3145;top:4295;width:2347;height:408" mce_style="position:absolute; left:3145;top:4295;width:2347;height:408"> <v:textbox> <![if !mso]> <table cellpadding=0 cellspacing=0 width="100%"> <tr> <td><![endif]> <div> <p class=MsoNormal><span lang=EN-US>Transaction</span></p> <p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p> </div> <![if !mso]></td> </tr> </table> <![endif]></v:textbox> </v:shape><w:wrap type="none"/> <w:anchorlock/> </v:group><![endif]--><!-- [if !vml]--><!-- [endif]--> <!-- [if mso & !supportInlineShapes & supportFields]><span lang=EN-US><v:shape id="_x0000_i1025" type="#_x0000_t75" style="width:414pt; height:241.8pt" mce_style="width:414pt; height:241.8pt"> <v:imagedata croptop="-65520f" cropbottom="65520f"/> </v:shape><span style="mso-element:field-end" mce_style="mso-element:field-end"></span></span><![endif]-->

 

分享到:
评论

相关推荐

    web小项目初步整合hibernate

    在IT行业中,Web小项目...总之,"web小项目初步整合hibernate"是一个典型的Java Web开发任务,涵盖了数据库操作、ORM框架使用、Servlet编程等多个方面。通过这样的整合,开发者可以构建出更高效、更易于维护的Web应用。

    hibernate的初步知识

    **Hibernate 概述** Hibernate 是一个开放源代码...然而,使用 Hibernate 时也要注意性能优化,如适当使用缓存、避免 N+1 查询等问题。在实际开发中,结合其他框架和最佳实践,可以构建出更加健壮和高效的 Java 应用。

    Hibernate-Annotation初步.rar

    在【压缩包子文件的文件名称列表】中的“Hibernate-Annotation初步.doc”,很可能是提供了一份详细的指南或者教程,涵盖了如何在Hibernate中使用注解进行数据库操作的基本步骤,包括设置环境、创建实体类、配置...

    Hibernate 进阶教程

    《Hibernate 进阶教程》是一本专为对Hibernate有初步了解并希望深入学习的开发者准备的手册。Hibernate作为Java领域中最流行的持久化框架之一,它极大地简化了数据库操作,使得开发者能够更专注于业务逻辑,而非繁琐...

    hibernate开发流程 入门

    通过以上步骤,你就成功地完成了使用Hibernate进行数据库操作的初步开发。在实际项目中,你可能需要进一步学习和掌握更多的Hibernate特性,如懒加载、级联操作、事务管理等,以便更高效、灵活地管理数据。同时,理解...

    Hibernate4的一些总结

    【标题】:“Hibernate4的...以上内容只是对Hibernate4框架的初步介绍,真正的精通还需要结合实际项目进行深入学习和实践。对于源码的探索,可以帮助开发者更深入地理解其内部工作原理,从而更好地利用这个强大的工具。

    hibernate in action 中文版书籍

    10. **最佳实践与实战经验**:分享作者在实际项目中积累的Hibernate使用经验和最佳实践,帮助读者避免常见错误,提高代码质量。 通过阅读《Hibernate in Action》中文版,Java开发者不仅可以掌握Hibernate的使用...

    Hibernate学习笔记特别详细

    这篇笔记将深入探讨Hibernate的核心概念和使用方法。 001---Hibernate简介 Hibernate是一个Java库,它允许开发人员在Java对象和关系数据库之间进行映射。ORM框架的目标是消除传统的JDBC代码,通过提供一种抽象层来...

    Hibernate初步配置

    - Hibernate使用JDBC事务管理,通过Session的beginTransaction()和transaction.commit()控制事务。 5. **持久化操作** - 插入数据:`session.save()`或`session.persist()`。 - 更新数据:`session.update()`。 ...

    hibernate入门数据简单插入

    这个文件可能包含了关于Hibernate入门的初步讲解,包括基本概念、环境配置、简单数据插入的示例代码等。 **总结** Hibernate作为Java的ORM框架,简化了数据库操作,使得开发者可以更加专注于业务逻辑而不是底层...

    hibernate2.1

    在"chapter1"这个子目录中,你可能找到关于Hibernate 2.1的初步教程或示例,这将帮助你了解如何配置项目、创建实体类、设置映射关系、执行基本的CRUD操作等。通过对这些内容的学习,你可以掌握Hibernate的基本用法,...

    hibernate3入门

    通过上述内容的学习,我们对Hibernate 3 的基础知识有了初步的认识,了解了它的历史背景、基本配置方法以及简单的O/R映射示例。随着深入学习,我们将探索更多高级特性,如缓存管理、事务处理以及更复杂的查询功能。...

    Hibernate使用——入门

    **Hibernate使用——入门** Hibernate 是一个强大的开源对象关系映射(ORM)框架,它简化了Java应用程序与数据库之间的交互。这篇博文将引导你入门Hibernate,理解其基本概念和使用方法。 **1. Hibernate概述** ...

    Hibernate 4——Hello World

    在本文中,我们将深入探讨如何使用Hibernate 4框架进行初步的“Hello World”实践。Hibernate是一个流行的开源对象关系映射(ORM)框架,它简化了Java应用程序与数据库之间的交互。通过将Java对象与数据库表之间的...

    26. 尚硅谷_佟刚_Hibernate 课件及源代码

    3. "hibernate-1" - 这是源代码的第一部分,可能包含Hibernate的初步设置、基本的CRUD操作等入门内容,适合初学者上手。 4. "hibernate-4" - 可能涉及到Hibernate的第四部分,涵盖了一些高级主题,如HQL(Hibernate ...

    spring整合hibernate示例代码

    "FirstSSH"可能是项目或者文件夹的名称,暗示着这是对SSH整合的初步尝试或入门教程。在这个"FirstSSH"中,我们可能找到一个简单的Web应用程序,包含了Controller(可能是基于Struts的Action),Service,DAO,以及...

    ssh框架用struts2 hibernate实现图片的上传源码

    本项目涉及的核心知识点是使用Struts2处理表单提交,Hibernate进行数据持久化,以及图片上传的相关技术。下面将详细介绍这些内容。 1. **Struts2**:Struts2是一个基于MVC设计模式的Web应用框架,它通过拦截器模型...

Global site tag (gtag.js) - Google Analytics