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

📄 session.html

📁 非常好的 Hibernate中文API ,供各位开发参考
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.4.2_11) on Thu Nov 16 16:41:07 CST 2006 -->
<TITLE>
Session (Hibernate API Documentation)
</TITLE>

<META NAME="keywords" CONTENT="org.hibernate.Session interface">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../jdstyle.css" TITLE="Style">

<SCRIPT type="text/javascript">
function windowTitle()
{
    parent.document.title="Session (Hibernate API Documentation)";
}
</SCRIPT>

</HEAD>

<BODY BGCOLOR="white" onload="windowTitle();">

<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Session.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../org/hibernate/ScrollableResults.html" title="interface in org.hibernate"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../org/hibernate/SessionFactory.html" title="interface in org.hibernate"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../index.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="Session.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.hibernate</FONT>
<BR>
Interface Session</H2>
<DL>
<DT><B>All Superinterfaces:</B> <DD><A HREF="http://java.sun.com/j2se/1.3/docs/api/java/io/Serializable.html" title="class or interface in java.io">Serializable</A></DD>
</DL>
<DL>
<DT><B>All Known Subinterfaces:</B> <DD><A HREF="../../org/hibernate/event/EventSource.html" title="interface in org.hibernate.event">EventSource</A>, <A HREF="../../org/hibernate/classic/Session.html" title="interface in org.hibernate.classic">Session</A></DD>
</DL>
<DL>
<DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../org/hibernate/impl/SessionImpl.html" title="class in org.hibernate.impl">SessionImpl</A></DD>
</DL>
<HR>
<DL>
<DT>public interface <B>Session</B><DT>extends <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/io/Serializable.html" title="class or interface in java.io">Serializable</A></DL>

<P>
The main runtime interface between a Java application and Hibernate. This is the central API class abstracting the notion of a persistence service.<br> <br> The lifecycle of a <tt>Session</tt> is bounded by the beginning and end of a logical transaction. (Long transactions might span several database transactions.)<br> <br> The main function of the <tt>Session</tt> is to offer create, read and delete operations for instances of mapped entity classes. Instances may exist in one of three states:<br> <br> <i>transient:</i> never persistent, not associated with any <tt>Session</tt><br> <i>persistent:</i> associated with a unique <tt>Session</tt><br> <i>detached:</i> previously persistent, not associated with any <tt>Session</tt><br> <br> Transient instances may be made persistent by calling <tt>save()</tt>, <tt>persist()</tt> or <tt>saveOrUpdate()</tt>. Persistent instances may be made transient by calling<tt> delete()</tt>. Any instance returned by a <tt>get()</tt> or <tt>load()</tt> method is persistent. Detached instances may be made persistent by calling <tt>update()</tt>, <tt>saveOrUpdate()</tt>, <tt>lock()</tt> or <tt>replicate()</tt>.  The state of a transient or detached instance may also be made persistent as a new persistent instance by calling <tt>merge()</tt>.<br> <br> <tt>save()</tt> and <tt>persist()</tt> result in an SQL <tt>INSERT</tt>, <tt>delete()</tt> in an SQL <tt>DELETE</tt> and <tt>update()</tt> or <tt>merge()</tt> in an SQL <tt>UPDATE</tt>.  Changes to <i>persistent</i> instances are detected at flush time and also result in an SQL <tt>UPDATE</tt>. <tt>saveOrUpdate()</tt> and <tt>replicate()</tt> result in either an <tt>INSERT</tt> or an <tt>UPDATE</tt>.<br> <br> It is not intended that implementors be threadsafe. Instead each thread/transaction should obtain its own instance from a <tt>SessionFactory</tt>.<br> <br> A <tt>Session</tt> instance is serializable if its persistent classes are serializable.<br> <br> A typical transaction should use the following idiom: <pre> Session sess = factory.openSession(); Transaction tx; try {     tx = sess.beginTransaction();     //do some work     ...     tx.commit(); } catch (Exception e) {     if (tx!=null) tx.rollback();     throw e; } finally {     sess.close(); } </pre> <br> If the <tt>Session</tt> throws an exception, the transaction must be rolled back and the session discarded. The internal state of the <tt>Session</tt> might not be consistent with the database after the exception occurs.
<P>

<P>
<DL>
<DT><B>Author:</B></DT>  <DD>Gavin King</DD><DT><B>See Also:</B><DD><A HREF="../../org/hibernate/SessionFactory.html" title="interface in org.hibernate"><CODE>SessionFactory</CODE></A></DL>
<HR>

<P>
<!-- ======== NESTED CLASS SUMMARY ======== -->


<!-- =========== FIELD SUMMARY =========== -->


<!-- ======== CONSTRUCTOR SUMMARY ======== -->


<!-- ========== METHOD SUMMARY =========== -->

<A NAME="method_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../org/hibernate/Transaction.html" title="interface in org.hibernate">Transaction</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/Session.html#beginTransaction()">beginTransaction</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Begin a unit of work and return the associated <tt>Transaction</tt> object.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/Session.html#cancelQuery()">cancelQuery</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cancel execution of the current query.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/Session.html#clear()">clear</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Completely clear the session.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/sql/Connection.html" title="class or interface in java.sql">Connection</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/Session.html#close()">close</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End the <tt>Session</tt> by disconnecting from the JDBC connection and cleaning up.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/sql/Connection.html" title="class or interface in java.sql">Connection</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/Session.html#connection()">connection</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get the JDBC connection of this Session.<br> <br>  If the session is using aggressive collection release (as in a CMT environment), it is the application's responsibility to close the connection returned by this call.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/Session.html#contains(java.lang.Object)">contains</A></B>(<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A>&nbsp;object)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Check if this instance is associated with this <tt>Session</tt>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../org/hibernate/Criteria.html" title="interface in org.hibernate">Criteria</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/Session.html#createCriteria(java.lang.Class)">createCriteria</A></B>(<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A>&nbsp;persistentClass)</CODE>

<BR>

⌨️ 快捷键说明

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