📄 sessionfactory.html
字号:
<!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>
SessionFactory (Hibernate API Documentation)
</TITLE>
<META NAME="keywords" CONTENT="org.hibernate.SessionFactory interface">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../jdstyle.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
parent.document.title="SessionFactory (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> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/SessionFactory.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../org/hibernate/Session.html" title="interface in org.hibernate"><B>PREV CLASS</B></A>
<A HREF="../../org/hibernate/SQLQuery.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>
<A HREF="SessionFactory.html" target="_top"><B>NO FRAMES</B></A>
<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: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | CONSTR | <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 SessionFactory</H2>
<DL>
<DT><B>All Superinterfaces:</B> <DD><A HREF="http://java.sun.com/j2se/1.3/docs/api/javax/naming/Referenceable.html" title="class or interface in javax.naming">Referenceable</A>, <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/engine/SessionFactoryImplementor.html" title="interface in org.hibernate.engine">SessionFactoryImplementor</A></DD>
</DL>
<DL>
<DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../org/hibernate/impl/SessionFactoryImpl.html" title="class in org.hibernate.impl">SessionFactoryImpl</A>, <A HREF="../../org/hibernate/jmx/SessionFactoryStub.html" title="class in org.hibernate.jmx">SessionFactoryStub</A></DD>
</DL>
<HR>
<DL>
<DT>public interface <B>SessionFactory</B><DT>extends <A HREF="http://java.sun.com/j2se/1.3/docs/api/javax/naming/Referenceable.html" title="class or interface in javax.naming">Referenceable</A>, <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>
Creates <tt>Session</tt>s. Usually an application has a single <tt>SessionFactory</tt>. Threads servicing client requests obtain <tt>Session</tt>s from the factory.<br> <br> Implementors must be threadsafe.<br> <br> <tt>SessionFactory</tt>s are immutable. The behaviour of a <tt>SessionFactory</tt> is controlled by properties supplied at configuration time. These properties are defined on <tt>Environment</tt>.
<P>
<P>
<DL>
<DT><B>Author:</B></DT> <DD>Gavin King</DD><DT><B>See Also:</B><DD><A HREF="../../org/hibernate/Session.html" title="interface in org.hibernate"><CODE>Session</CODE></A>, <A HREF="../../org/hibernate/cfg/Environment.html" title="class in org.hibernate.cfg"><CODE>Environment</CODE></A>, <A HREF="../../org/hibernate/cfg/Configuration.html" title="class in org.hibernate.cfg"><CODE>Configuration</CODE></A>, <A HREF="../../org/hibernate/connection/ConnectionProvider.html" title="interface in org.hibernate.connection"><CODE>ConnectionProvider</CODE></A>, <A HREF="../../org/hibernate/transaction/TransactionFactory.html" title="interface in org.hibernate.transaction"><CODE>TransactionFactory</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> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#close()">close</A></B>()</CODE>
<BR>
Destroy this <tt>SessionFactory</tt> and release all resources (caches, connection pools, etc).</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#evict(java.lang.Class)">evict</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> persistentClass)</CODE>
<BR>
Evict all entries from the second-level cache.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#evict(java.lang.Class, java.io.Serializable)">evict</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> persistentClass, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/io/Serializable.html" title="class or interface in java.io">Serializable</A> id)</CODE>
<BR>
Evict an entry from the second-level cache.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#evictCollection(java.lang.String)">evictCollection</A></B>(<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> roleName)</CODE>
<BR>
Evict all entries from the second-level cache.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#evictCollection(java.lang.String, java.io.Serializable)">evictCollection</A></B>(<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> roleName, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/io/Serializable.html" title="class or interface in java.io">Serializable</A> id)</CODE>
<BR>
Evict an entry from the second-level cache.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#evictEntity(java.lang.String)">evictEntity</A></B>(<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> entityName)</CODE>
<BR>
Evict all entries from the second-level cache.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#evictEntity(java.lang.String, java.io.Serializable)">evictEntity</A></B>(<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> entityName, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/io/Serializable.html" title="class or interface in java.io">Serializable</A> id)</CODE>
<BR>
Evict an entry from the second-level cache.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#evictQueries()">evictQueries</A></B>()</CODE>
<BR>
Evict any query result sets cached in the default query cache region.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#evictQueries(java.lang.String)">evictQueries</A></B>(<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> cacheRegion)</CODE>
<BR>
Evict any query result sets cached in the named query cache region.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/Map.html" title="class or interface in java.util">Map</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#getAllClassMetadata()">getAllClassMetadata</A></B>()</CODE>
<BR>
Get all <tt>ClassMetadata</tt> as a <tt>Map</tt> from entityname <tt>String</tt> to metadata object</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/Map.html" title="class or interface in java.util">Map</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#getAllCollectionMetadata()">getAllCollectionMetadata</A></B>()</CODE>
<BR>
Get all <tt>CollectionMetadata</tt> as a <tt>Map</tt> from role name to metadata object</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../org/hibernate/metadata/ClassMetadata.html" title="interface in org.hibernate.metadata">ClassMetadata</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#getClassMetadata(java.lang.Class)">getClassMetadata</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> persistentClass)</CODE>
<BR>
Get the <tt>ClassMetadata</tt> associated with the given entity class</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../org/hibernate/metadata/ClassMetadata.html" title="interface in org.hibernate.metadata">ClassMetadata</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#getClassMetadata(java.lang.String)">getClassMetadata</A></B>(<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> entityName)</CODE>
<BR>
Get the <tt>ClassMetadata</tt> associated with the given entity name</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../org/hibernate/metadata/CollectionMetadata.html" title="interface in org.hibernate.metadata">CollectionMetadata</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#getCollectionMetadata(java.lang.String)">getCollectionMetadata</A></B>(<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> roleName)</CODE>
<BR>
Get the <tt>CollectionMetadata</tt> associated with the named collection role</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../org/hibernate/classic/Session.html" title="interface in org.hibernate.classic">Session</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#getCurrentSession()">getCurrentSession</A></B>()</CODE>
<BR>
Obtains the current session.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/Set.html" title="class or interface in java.util">Set</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#getDefinedFilterNames()">getDefinedFilterNames</A></B>()</CODE>
<BR>
Obtain a set of the names of all filters defined on this SessionFactory.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../org/hibernate/engine/FilterDefinition.html" title="class in org.hibernate.engine">FilterDefinition</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#getFilterDefinition(java.lang.String)">getFilterDefinition</A></B>(<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> filterName)</CODE>
<BR>
Obtain the definition of a filter by name.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../org/hibernate/stat/Statistics.html" title="interface in org.hibernate.stat">Statistics</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#getStatistics()">getStatistics</A></B>()</CODE>
<BR>
Get the statistics for this session factory</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#isClosed()">isClosed</A></B>()</CODE>
<BR>
Was this <tt>SessionFactory</tt> already closed?</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../org/hibernate/classic/Session.html" title="interface in org.hibernate.classic">Session</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#openSession()">openSession</A></B>()</CODE>
<BR>
Create database connection and open a <tt>Session</tt> on it.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../org/hibernate/classic/Session.html" title="interface in org.hibernate.classic">Session</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../org/hibernate/SessionFactory.html#openSession(java.sql.Connection)">openSession</A></B>(<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/sql/Connection.html" title="class or interface in java.sql">Connection</A> connection)</CODE>
<BR>
Open a <tt>Session</tt> on the given connection.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -