Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv22330/reference/src Modified Files: advanced_or_mapping.xml basic_or_mapping.xml persistent_classes.xml session_configuration.xml Log Message: updated to cover latest features Index: advanced_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/advanced_or_mapping.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** advanced_or_mapping.xml 27 Mar 2003 11:29:38 -0000 1.11 --- advanced_or_mapping.xml 29 Mar 2003 09:51:27 -0000 1.12 *************** *** 1170,1173 **** --- 1170,1186 ---- </para> + <para> + Sometimes we need to ensure that a proxy or collection is initialized before closing the + <literal>Session</literal>. Of course, we can alway force initialization by calling + <literal>cat.getSex()</literal> or <literal>cat.getKittens().size()</literal>, for example. + But that is confusing to readers of the code and is not convenient for generic code. + The static methods <literal>Hibernate.initialize()</literal> and <literal>Hibernate.isInitialized()</literal> + provide the application with a convenient way of working with lazyily initialized collections or + proxies. <literal>Hibernate.initialize(cat)</literal> will force the initialization of a proxy, + <literal>cat</literal>, as long as its <literal>Session</literal> is still open. + <literal>Hibernate.initialize( cat.getKittens() )</literal> has a similar effect for the collection + of kittens. + </para> + </sect1> Index: basic_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/basic_or_mapping.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** basic_or_mapping.xml 23 Feb 2003 13:53:24 -0000 1.9 --- basic_or_mapping.xml 29 Mar 2003 09:51:27 -0000 1.10 *************** *** 28,32 **** <property name="birthdate" type="date"/> <property name="color" not-null="true"/> ! <property name="sex" not-null="true"/> <property name="weight"/> <many-to-one name="mate" column="mate_id"/> --- 28,32 ---- <property name="birthdate" type="date"/> <property name="color" not-null="true"/> ! <property name="sex" not-null="true" update="false"/> <property name="weight"/> <many-to-one name="mate" column="mate_id"/> *************** *** 71,83 **** <para> ! This element has just two optional attributes. The <literal>schema</literal> attribute specifies that tables referred to by this mapping belong to the named schema. If specified, tablenames will be qualified by the given schema name. If missing, tablenames will be unqualified. The <literal>default-cascade</literal> attribute specifies what cascade style should be assumed for properties and collections which do not specify a ! <literal>cascade</literal> attribute. If missing, the default is <literal>none</literal> ! (see below). </para> ! </sect2> <sect2 id="or-mapping-s1-3"> --- 71,118 ---- <para> ! This element has three optional attributes. The <literal>schema</literal> attribute specifies that tables referred to by this mapping belong to the named schema. If specified, tablenames will be qualified by the given schema name. If missing, tablenames will be unqualified. The <literal>default-cascade</literal> attribute specifies what cascade style should be assumed for properties and collections which do not specify a ! <literal>cascade</literal> attribute. The <literal>auto-import</literal> attribute lets us ! use unqualified class names in the query language, by default. </para> ! ! <programlistingco> ! <areaspec> ! <area id="hm1" coords="2 55"/> ! <area id="hm2" coords="3 55" /> ! <area id="hm3" coords="4 55"/> ! </areaspec> ! <programlisting><![CDATA[<class ! schema="schemaName" ! default-cascade="none|save-update" ! auto-import="true|false" ! />]]></programlisting> ! <calloutlist> ! <callout arearefs="hm1"> ! <para> ! <literal>schema</literal> (optional): The name of a database schema. ! </para> ! </callout> ! <callout arearefs="hm2"> ! <para> ! <literal>default-cascade</literal> (optional - defaults to <literal>none</literal>): ! A default cascade style. ! </para> ! </callout> ! <callout arearefs="hm3"> ! <para> ! <literal>auto-import</literal> (optional - defaults to <literal>true</literal>): ! Specifies whether we can use unqualified class names (of classes in this mapping) ! in the query language. ! </para> ! </callout> ! </calloutlist> ! </programlistingco> ! ! ! </sect2> <sect2 id="or-mapping-s1-3"> *************** *** 1100,1103 **** --- 1135,1175 ---- </sect2> + <sect2 id="or-mapping-s1-13"> + <title>import</title> + + <para> + Suppose your application has two persistent classes with the same name, and you don't want to + specify the fully qualified (package) name in Hibernate queries. Classes may be "imported" + explicitly, rather than relying upon <literal>auto-import="true"</literal>. You may even import classes + and interfaces that are not explicitly mapped. + </para> + + <programlisting><![CDATA[<import class="java.lang.Object" rename="Universe"/>]]></programlisting> + + <programlistingco> + <areaspec> + <area id="import1" coords="2 55"/> + <area id="import2" coords="3 55"/> + </areaspec> + <programlisting><![CDATA[<import + class="ClassName" + rename="ShortName" + />]]></programlisting> + <calloutlist> + <callout arearefs="import1"> + <para> + <literal>class</literal>: The fully qualified class name of of any Java class. + </para> + </callout> + <callout arearefs="import2"> + <para> + <literal>rename</literal> (optional - defaults to the unqualified class name): + A name that may be used in the query language. + </para> + </callout> + </calloutlist> + </programlistingco> + + </sect2> </sect1> *************** *** 1355,1373 **** <sect2 id="or-mapping-s2-5"> ! <title>The object type</title> <para> ! There is one further type allowed for a property mapping. The <literal>object</literal> ! type maps entities to two columns. The first column holds the class name. The second holds ! the serialized identifier. This type is intended to allow heterogeneous collections and ! properties of type <literal>java.lang.Object</literal> whose values might come from ! different tables. It is most certainly not meant as the usual way of mapping (polymorphic) ! associations. You should use this only in very special cases. </para> ! <programlisting><![CDATA[<property name="anyEntity" type="object"> <column name="class_name"/> <column name="id"/> ! </property>]]></programlisting> </sect2> --- 1427,1451 ---- <sect2 id="or-mapping-s2-5"> ! <title>Any type mappings</title> <para> ! There is one further type of property mapping. The <literal><any></literal> mapping element ! defines a polymorphic association to classes from multiple tables. This type of mapping always ! requires more than one column. The first column holds the class name of the associated entity. ! The remaining columns hold the identifier. It is impossible to specify a foreign key constraint ! for this kind of association, so this is most certainly not meant as the usual way of mapping ! (polymorphic) associations. You should use this only in very special cases (eg. audit logs, ! user session data, etc). </para> ! <programlisting><![CDATA[<any name="anyEntity" id-type="long"> <column name="class_name"/> <column name="id"/> ! </any>]]></programlisting> ! ! <para> ! The old <literal>object</literal> type from Hibernate 1.2 is still supported, but is ! semi-deprecated. ! </para> </sect2> Index: persistent_classes.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/persistent_classes.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** persistent_classes.xml 29 Mar 2003 04:22:48 -0000 1.3 --- persistent_classes.xml 29 Mar 2003 09:51:27 -0000 1.4 *************** *** 283,286 **** --- 283,404 ---- </para> </sect1> + + <sect1 id="persistent-classes-s5"> + <title>XDoclet Example</title> + <para> + In the next section we will show how Hibernate mappings may be expressed using + a simple, readable XML format. Many Hibernate users prefer to embed mapping + information directly in sourcecode using XDoclet <literal>@hibernate.tags</literal>. + We will not cover this approach in this document, since strictly it is considered + part of XDoclet. However, we include the following example of the <literal>Cat</literal> + class with XDoclet mappings. + </para> + + <programlisting><![CDATA[package eg; + import java.util.Set; + import java.util.Date; + + /** + * @hibernate.class + * table="CATS" + */ + public class Cat { + private Long id; // identifier + private Date birthdate; + private Cat mate; + private Set kittens + private Color color; + private char sex; + private float weight; + + /** + * @hibernate.id + * generator-class="native" + * column="CAT_ID" + */ + public Long getId() { + return id; + } + private void setId(Long id) { + this.id=id; + } + + /** + * @hibernate.many-to-one + * column="MATE_ID" + */ + public Cat getMate() { + return mate; + } + void setMate(Cat mate) { + this.mate = mate; + } + + /** + * @hibernate.property + * column="BIRTH_DATE" + */ + public Date getBirthdate() { + return birthdate; + } + void setBirthdate(Date date) { + birthdate = date; + } + /** + * @hibernate.property + * column="WEIGHT" + */ + public float getWeight() { + return weight; + } + void setWeight(float weight) { + this.weight = weight; + } + + /** + * @hibernate.property + * column="COLOR" + * not-null="true" + */ + public Color getColor() { + return color; + } + void setColor(Color color) { + this.color = color; + } + /** + * @hibernate.set + * lazy="true" + * order-by="BIRTH_DATE" + * @hibernate.collection-key + * column="PARENT_ID" + * @hibernate.collection-one-to-many + */ + public Set getKittens() { + return kittens; + } + void setKittens(Set kittens) { + this.kittens = kittens; + } + // addKitten not needed by Hibernate + public void addKitten(Cat kitten) { + kittens.add(kitten); + } + + /** + * @hibernate.property + * column="SEX" + * not-null="true" + * update="false" + */ + public char getSex() { + return sex; + } + void setSex(char sex) { + this.sex=sex; + } + }]]></programlisting> + + </sect1> </chapter> Index: session_configuration.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/session_configuration.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** session_configuration.xml 23 Feb 2003 13:53:24 -0000 1.7 --- session_configuration.xml 29 Mar 2003 09:51:27 -0000 1.8 *************** *** 2,5 **** --- 2,12 ---- <title>SessionFactory Configuration</title> + + <para> + Because Hibernate is designed to operate in many different environments, there + are a large number of configuration parameters. Fortunately, most have sensible + default values and Hibernate is distributed with an example + <literal>hibernate.properties</literal> file that shows the various options. + </para> <sect1 id="session-configuration-s1"> *************** *** 460,478 **** <row> <entry> - <literal>hibernate.query.imports</literal> - </entry> - <entry> - A list of packages containing persistent classes. If the package is - listed here, your Hibernate queries need not specify the full class name of a - persistent class. (You can use <literal>from foo in class Foo</literal> as an - alternative to <literal>from foo in class eg.foo.Foo</literal>.) - <para> - <emphasis role="strong">Value:</emphasis> - <literal>package.name, other.package.name</literal> - </para> - </entry> - </row> - <row> - <entry> <literal>hibernate.query.substitutions</literal> </entry> --- 467,470 ---- *************** *** 502,506 **** </tgroup> </table> ! <para> You should always set the <literal>hibernate.dialect</literal> property to the correct --- 494,501 ---- </tgroup> </table> ! ! <sect2 id="session-configuration-s5-1"> ! <title>SQL Dialects</title> ! <para> You should always set the <literal>hibernate.dialect</literal> property to the correct *************** *** 564,571 **** --- 559,576 ---- <entry>Microsoft SQL Server</entry> <entry><literal>net.sf.hibernate.dialect.SybaseDialect</literal></entry> </row> + <row> + <entry>Ingres</entry> <entry><literal>net.sf.hibernate.dialect.IngresDialect</literal></entry> + </row> + <row> + <entry>FrontBase</entry> <entry><literal>net.sf.hibernate.dialect.FrontbaseDialect</literal></entry> + </row> </tbody> </tgroup> </table> + </sect2> + <sect2 id="session-configuration-s5-2"> + <title>Outer Join Fetching</title> + <para> If your database supports ANSI or Oracle style outerjoins, <emphasis>outer join *************** *** 578,582 **** by setting <literal>outer-join="false"</literal>. </para> ! <para> Oracle limits the size of <literal>byte</literal> arrays that may --- 583,592 ---- by setting <literal>outer-join="false"</literal>. </para> ! ! </sect2> ! ! <sect2 id="session-configuration-s5-3"> ! <title>Binary Streams</title> ! <para> Oracle limits the size of <literal>byte</literal> arrays that may *************** *** 586,595 **** --- 596,613 ---- <emphasis>This is a JVM-level setting only.</emphasis> </para> + </sect2> + <sect2 id="session-configuration-s5-4"> + <title>SQL Logging to Console</title> + <para> <literal>hibernate.show_sql</literal> forces Hibernate to write SQL statements to the console. This is provided as an easy alternative to enabling logging. </para> + </sect2> + <sect2 id="session-configuration-s5-5"> + <title>Custom <literal>ConnectionProvider</literal></title> + <para> You may define your own plugin strategy for obtaining JDBC connections by *************** *** 599,603 **** --- 617,625 ---- <literal>hibernate.connection.provider_class</literal>. </para> + </sect2> + <sect2 id="session-configuration-s5-6"> + <title>Transaction Strategy</title> + <para> If you wish to use the Hibernate <literal>Transaction</literal> API, you must *************** *** 623,627 **** <para> ! You may also define your own. </para> --- 645,650 ---- <para> ! You may also define your own transaction strategies (for a CORBA transaction service, ! for example). </para> *************** *** 663,670 **** <entry align="center">Resin</entry> </row> </tbody> </tgroup> </table> ! <para> If you wish to have the <literal>SessionFactory</literal> bound to a JNDI namespace, specify --- 686,702 ---- <entry align="center">Resin</entry> </row> + <row> + <entry><literal>net.sf.hibernate.transaction.JRun4TransactionManagerLookup</literal></entry> + <entry align="center">JRun4</entry> + </row> </tbody> </tgroup> </table> ! </sect2> ! ! <sect2 id="session-configuration-s5-7"> ! <title>JNDI-bound <literal>SessionFactory</literal></title> ! ! <para> If you wish to have the <literal>SessionFactory</literal> bound to a JNDI namespace, specify *************** *** 675,679 **** an initial context. </para> ! <para> You may define new Hibernate query tokens using <literal>hibernate.query.substitutions</literal>. --- 707,715 ---- an initial context. </para> ! </sect2> ! ! <sect2 id="session-configuration-s5-8"> ! <title>Query Language Substitution</title> ! <para> You may define new Hibernate query tokens using <literal>hibernate.query.substitutions</literal>. *************** *** 690,695 **** <para> ! would allow you to rename the SQL <literal>lower</literal> function. </para> </sect1> --- 726,733 ---- <para> ! would allow you to rename the SQL <literal>LOWER</literal> function. </para> + + </sect2> </sect1> *************** *** 702,706 **** An alternative approach is to specify a full configuration in a file named <literal>hibernate.cfg.xml</literal>. The configuration file is expected to ! be in the root of your CLASSPATH. </para> --- 740,744 ---- An alternative approach is to specify a full configuration in a file named <literal>hibernate.cfg.xml</literal>. The configuration file is expected to ! be in the root of your <literal>CLASSPATH</literal>. </para> |