You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(22) |
Nov
(308) |
Dec
(131) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(369) |
Feb
(171) |
Mar
(236) |
Apr
(187) |
May
(218) |
Jun
(217) |
Jul
(127) |
Aug
(448) |
Sep
(270) |
Oct
(231) |
Nov
(422) |
Dec
(255) |
2004 |
Jan
(111) |
Feb
(73) |
Mar
(338) |
Apr
(351) |
May
(349) |
Jun
(495) |
Jul
(394) |
Aug
(1048) |
Sep
(499) |
Oct
(142) |
Nov
(269) |
Dec
(638) |
2005 |
Jan
(825) |
Feb
(1272) |
Mar
(593) |
Apr
(690) |
May
(950) |
Jun
(958) |
Jul
(767) |
Aug
(839) |
Sep
(525) |
Oct
(449) |
Nov
(585) |
Dec
(455) |
2006 |
Jan
(603) |
Feb
(656) |
Mar
(195) |
Apr
(114) |
May
(136) |
Jun
(100) |
Jul
(128) |
Aug
(68) |
Sep
(7) |
Oct
(1) |
Nov
(1) |
Dec
(8) |
2007 |
Jan
(4) |
Feb
(3) |
Mar
(8) |
Apr
(16) |
May
(5) |
Jun
(4) |
Jul
(6) |
Aug
(23) |
Sep
(15) |
Oct
(5) |
Nov
(7) |
Dec
(5) |
2008 |
Jan
(5) |
Feb
(1) |
Mar
(1) |
Apr
(5) |
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
(1) |
Feb
|
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(2) |
Jun
(1) |
Jul
|
Aug
(1) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <tu...@us...> - 2002-11-26 08:15:00
|
Update of /cvsroot/hibernate/Hibernate/doc/reference/html_single In directory sc8-pr-cvs1:/tmp/cvs-serv32325/doc/reference/html_single Modified Files: index.html Log Message: Update to current and CSS quotation fix Index: index.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/reference/html_single/index.html,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** index.html 25 Nov 2002 21:01:40 -0000 1.86 --- index.html 26 Nov 2002 08:14:57 -0000 1.87 *************** *** 1,5 **** <html><head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> ! <title>Hibernate Reference Documentation</title><link rel="stylesheet" href="'../style.css'" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.49"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book"><div class="titlepage"><div><h1 class="title"><a name="d0e1"></a>Hibernate Reference Documentation</h1></div><div><h2 class="subtitle">Relational Persistence for Idiomatic Java</h2></div><div><h2 class="subtitle">http://hibernate.sourceforge.net/</h2></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>1. <a href="#architecture">Architecture</a></dt><dd><dl><dt><a href="#architecture-s1">Overview</a></dt><dt><a href="#architecture-s2">Persistent Object Identity</a></dt><dt><a href="#architecture-s3">JMX Integration</a></dt></dl></dd><dt>2. <a href="#session-configuration">SessionFactory Configuration</a></dt><dd><dl><dt><a href="#session-configuration-s1">Programmatic Datastore Configuration</a></dt><dt><a href="#session-configuration-s2">Obtaining a SessionFactory</a></dt><dt><a href="#session-configuration-s3">User provided JDBC connection</a></dt><dt><a href="#session-configuration-s4">Hibernate provided JDBC connection</a></dt><dt><a href="#session-configuration-s5">Other properties</a></dt><dt><a href="#session-configuration-s6">XML Configuration File</a></dt><dt><a href="#session-configuration-s7">Logging</a></dt></dl></dd><dt>3. <a href="#persistent-classes">Persistent Classes</a></dt><dd><dl><dt><a href="#persistent-classes-s1">Simple Example</a></dt><dd><dl><dt><a href="#persistent-classes-s1-1">Declare accessors and mutators for persistent fields</a></dt><dt><a href="#persistent-classes-s1-2">Implement a default constructor</a></dt><dt><a href="#persistent-classes-s1-3">Provide an identifier property (optional)</a></dt></dl></dd><dt><a href="#persistent-classes-s2">Inheritance</a></dt><dt><a href="#persistent-classes-s3">Persistent Lifecycle Callbacks</a></dt><dt><a href="#persistent-classes-s4">Validatable</a></dt></dl></dd><dt>4. <a href="#or-mapping">Basic O/R Mapping</a></dt><dd><dl><dt><a href="#or-mapping-s1">Mapping declaration</a></dt><dd><dl><dt><a href="#or-mapping-s1-1">Doctype</a></dt><dt><a href="#or-mapping-s1-2">hibernate-mapping</a></dt><dt><a href="#or-mapping-s1-3">class</a></dt><dt><a href="#or-mapping-s1-4">id</a></dt><dt><a href="#or-mapping-s1-4b">composite-id</a></dt><dt><a href="#or-mapping-s1-5">discriminator</a></dt><dt><a href="#or-mapping-s1-6">version (optional)</a></dt><dt><a href="#or-mapping-s1-6b">timestamp (optional)</a></dt><dt><a href="#or-mapping-s1-7">property</a></dt><dt><a href="#or-mapping-s1-8">many-to-one</a></dt><dt><a href="#or-mapping-s1-9">one-to-one</a></dt><dt><a href="#or-mapping-s1-10">component</a></dt><dt><a href="#or-mapping-s1-11">subclass</a></dt><dt><a href="#or-mapping-s1-11b">joined-subclass</a></dt><dt><a href="#or-mapping-s1-12">map, set, list, bag</a></dt></dl></dd><dt><a href="#or-mapping-s2">Hibernate Types</a></dt><dd><dl><dt><a href="#or-mapping-s2-1">Entities and values</a></dt><dt><a href="#or-mapping-s2-2">Basic value types</a></dt><dt><a href="#or-mapping-s2-3">Persistent enum types</a></dt><dt><a href="#or-mapping-s2-4">Custom value types</a></dt><dt><a href="#or-mapping-s2-5">The object type</a></dt></dl></dd></dl></dd><dt>5. <a href="#adv-or-mapping">Advanced O/R Mapping</a></dt><dd><dl><dt><a href="#adv-or-mapping-s1">Collections</a></dt><dd><dl><dt><a href="#adv-or-mapping-s1-1">Persistent Collection Styles</a></dt><dt><a href="#adv-or-mapping-s1-2">Toplevel and Nested Collections</a></dt><dt><a href="#adv-or-mapping-s1-3">Mapping a Collection</a></dt><dt><a href="#adv-or-mapping-s1-4">Mapping a Property to a Toplevel Collection</a></dt><dt><a href="#adv-or-mapping-s1-5">Collections of Values and Many To Many Associations</a></dt><dt><a href="#adv-or-mapping-s1-6">One To Many Associations</a></dt><dt><a href="#adv-or-mapping-s1-7">Lazy Initialization</a></dt><dt><a href="#adv-or-mapping-s1-8">Sorted Collections</a></dt><dt><a href="#adv-or-mapping-s1-9">Garbage Collection</a></dt><dt><a href="#adv-or-mapping-s1-10">Bidirectional Associations</a></dt><dt><a href="#adv-or-mapping-s1-11">Ternary Associations</a></dt><dt><a href="#adv-or-mapping-s1-12">Collection Example</a></dt></dl></dd><dt><a href="#adv-or-mapping-s2">Components</a></dt><dd><dl><dt><a href="#adv-or-mapping-s2-1">As Dependent Objects</a></dt><dt><a href="#adv-or-mapping-s2-2">In Collections</a></dt><dt><a href="#adv-or-mapping-s2-2b">As a Map Index</a></dt><dt><a href="#adv-or-mapping-s2-3">As Composite Identifiers</a></dt></dl></dd><dt><a href="#adv-or-mapping-s3">Cache</a></dt><dd><dl><dt><a href="#adv-or-mapping-s3-1">Mapping</a></dt><dt><a href="#adv-or-mapping-s3-2">Read Only Cache</a></dt><dt><a href="#adv-or-mapping-s3-3">Read / Write Cache</a></dt></dl></dd><dt><a href="#adv-or-mapping-s4">Proxies for Lazy Initialization</a></dt></dl></dd><dt>6. <a href="#manipulating-data">Manipulating Persistent Data</a></dt><dd><dl><dt><a href="#manipulating-data-s1">Creating a persistent object</a></dt><dt><a href="#manipulating-data-s2">Loading an object</a></dt><dt><a href="#manipulating-data-s3">Querying</a></dt><dd><dl><dt><a href="#manipulating-data-s4">Scalar queries</a></dt><dt><a href="#manipulating-data-s5">The Query interface</a></dt><dt><a href="#manipulating-data-s5b">Scrollable iteration</a></dt><dt><a href="#manipulating-data-s6">Filtering collections</a></dt></dl></dd><dt><a href="#manipulating-data-s7">Updating objects saved or loaded in the current session</a></dt><dt><a href="#manipulating-data-s8">Updating objects saved or loaded in a previous session</a></dt><dt><a href="#manipulating-data-s9">Deleting persistent objects</a></dt><dt><a href="#manipulating-data-s10">Graphs of objects</a></dt><dd><dl><dt><a href="#manipulating-data-s11a">Lifecycle objects</a></dt><dt><a href="#manipulating-data-s11b">Persistence by Reachability</a></dt></dl></dd><dt><a href="#manipulating-data-s12">Flushing</a></dt><dt><a href="#manipulating-data-s13">Ending a Session</a></dt><dd><dl><dt><a href="#manipulating-data-s13-1">Flushing the session</a></dt><dt><a href="#manipulating-data-s13-2">Committing the transaction</a></dt><dt><a href="#manipulating-data-s13-3">Closing the session</a></dt><dt><a href="#manipulating-data-s13-4">Exception handling</a></dt></dl></dd><dt><a href="#manipulating-data-s14">Interceptors</a></dt></dl></dd><dt>7. <a href="#query-language">Hibernate Query Language</a></dt><dd><dl><dt><a href="#query-language-s1">Case Sensitivity</a></dt><dt><a href="#query-language-s2">The from clause</a></dt><dt><a href="#query-language-s3">The select clause</a></dt><dt><a href="#query-language-s3b">polymorphism</a></dt><dt><a href="#query-language-s4">from collections</a></dt><dt><a href="#query-language-s5">The where clause</a></dt><dt><a href="#query-language-s6">Expressions</a></dt><dt><a href="#query-language-s7">The order by clause</a></dt><dt><a href="#query-language-s8">The group by clause</a></dt><dt><a href="#query-language-s9">Subqueries</a></dt></dl></dd><dt>8. <a href="#transactions">Transactions And Concurrency</a></dt><dd><dl><dt><a href="#transactions-s1">Datastores, Sessions and Factories</a></dt><dt><a href="#transactions-s2">Threads and connections</a></dt><dt><a href="#transactions-s3">Optimistic Locking / Versioning</a></dt><dd><dl><dt><a href="#transactions-s3-1">Long session with automatic versioning</a></dt><dt><a href="#transactions-s3-2">Many sessions with automatic versioning</a></dt><dt><a href="#transactions-s3-3">Application version checking</a></dt></dl></dd><dt><a href="#transactions-s4">Session disconnection</a></dt><dt><a href="#transactions-s5">Pessimistic Locking</a></dt></dl></dd><dt>9. <a href="#examples">Examples</a></dt><dd><dl><dt><a href="#examples-s0">Employer / Employee</a></dt><dt><a href="#examples-s1">Author / Work</a></dt><dt><a href="#examples-s2">Customer / Order / Product</a></dt></dl></dd><dt>10. <a href="#best-practices">Best Practices</a></dt></dl></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="architecture"></a>Chapter 1. Architecture</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#architecture-s1">Overview</a></dt><dt><a href="#architecture-s2">Persistent Object Identity</a></dt><dt><a href="#architecture-s3">JMX Integration</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="architecture-s1"></a>Overview</h2></div></div><p> A (very) high-level view of the Hibernate architecture: </p><div class="mediaobject"><img src="../images/overview.gif" align="center"></div><p> --- 1,5 ---- <html><head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> ! <title>Hibernate Reference Documentation</title><link rel="stylesheet" href="../style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.49"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book"><div class="titlepage"><div><h1 class="title"><a name="d0e1"></a>Hibernate Reference Documentation</h1></div><div><h2 class="subtitle">Relational Persistence for Idiomatic Java</h2></div><div><h2 class="subtitle">http://hibernate.sourceforge.net/</h2></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>1. <a href="#architecture">Architecture</a></dt><dd><dl><dt><a href="#architecture-s1">Overview</a></dt><dt><a href="#architecture-s2">Persistent Object Identity</a></dt><dt><a href="#architecture-s3">JMX Integration</a></dt></dl></dd><dt>2. <a href="#session-configuration">SessionFactory Configuration</a></dt><dd><dl><dt><a href="#session-configuration-s1">Programmatic Datastore Configuration</a></dt><dt><a href="#session-configuration-s2">Obtaining a SessionFactory</a></dt><dt><a href="#session-configuration-s3">User provided JDBC connection</a></dt><dt><a href="#session-configuration-s4">Hibernate provided JDBC connection</a></dt><dt><a href="#session-configuration-s5">Other properties</a></dt><dt><a href="#session-configuration-s6">XML Configuration File</a></dt><dt><a href="#session-configuration-s7">Logging</a></dt></dl></dd><dt>3. <a href="#persistent-classes">Persistent Classes</a></dt><dd><dl><dt><a href="#persistent-classes-s1">Simple Example</a></dt><dd><dl><dt><a href="#persistent-classes-s1-1">Declare accessors and mutators for persistent fields</a></dt><dt><a href="#persistent-classes-s1-2">Implement a default constructor</a></dt><dt><a href="#persistent-classes-s1-3">Provide an identifier property (optional)</a></dt></dl></dd><dt><a href="#persistent-classes-s2">Inheritance</a></dt><dt><a href="#persistent-classes-s3">Persistent Lifecycle Callbacks</a></dt><dt><a href="#persistent-classes-s4">Validatable</a></dt></dl></dd><dt>4. <a href="#or-mapping">Basic O/R Mapping</a></dt><dd><dl><dt><a href="#or-mapping-s1">Mapping declaration</a></dt><dd><dl><dt><a href="#or-mapping-s1-1">Doctype</a></dt><dt><a href="#or-mapping-s1-2">hibernate-mapping</a></dt><dt><a href="#or-mapping-s1-3">class</a></dt><dt><a href="#or-mapping-s1-4">id</a></dt><dt><a href="#or-mapping-s1-4b">composite-id</a></dt><dt><a href="#or-mapping-s1-5">discriminator</a></dt><dt><a href="#or-mapping-s1-6">version (optional)</a></dt><dt><a href="#or-mapping-s1-6b">timestamp (optional)</a></dt><dt><a href="#or-mapping-s1-7">property</a></dt><dt><a href="#or-mapping-s1-8">many-to-one</a></dt><dt><a href="#or-mapping-s1-9">one-to-one</a></dt><dt><a href="#or-mapping-s1-10">component</a></dt><dt><a href="#or-mapping-s1-11">subclass</a></dt><dt><a href="#or-mapping-s1-11b">joined-subclass</a></dt><dt><a href="#or-mapping-s1-12">map, set, list, bag</a></dt></dl></dd><dt><a href="#or-mapping-s2">Hibernate Types</a></dt><dd><dl><dt><a href="#or-mapping-s2-1">Entities and values</a></dt><dt><a href="#or-mapping-s2-2">Basic value types</a></dt><dt><a href="#or-mapping-s2-3">Persistent enum types</a></dt><dt><a href="#or-mapping-s2-4">Custom value types</a></dt><dt><a href="#or-mapping-s2-5">The object type</a></dt></dl></dd></dl></dd><dt>5. <a href="#adv-or-mapping">Advanced O/R Mapping</a></dt><dd><dl><dt><a href="#adv-or-mapping-s1">Collections</a></dt><dd><dl><dt><a href="#adv-or-mapping-s1-1">Persistent Collection Styles</a></dt><dt><a href="#adv-or-mapping-s1-2">Toplevel and Nested Collections</a></dt><dt><a href="#adv-or-mapping-s1-3">Mapping a Collection</a></dt><dt><a href="#adv-or-mapping-s1-4">Mapping a Property to a Toplevel Collection</a></dt><dt><a href="#adv-or-mapping-s1-5">Collections of Values and Many To Many Associations</a></dt><dt><a href="#adv-or-mapping-s1-6">One To Many Associations</a></dt><dt><a href="#adv-or-mapping-s1-7">Lazy Initialization</a></dt><dt><a href="#adv-or-mapping-s1-8">Sorted Collections</a></dt><dt><a href="#adv-or-mapping-s1-9">Garbage Collection</a></dt><dt><a href="#adv-or-mapping-s1-10">Bidirectional Associations</a></dt><dt><a href="#adv-or-mapping-s1-11">Ternary Associations</a></dt><dt><a href="#adv-or-mapping-s1-12">Collection Example</a></dt></dl></dd><dt><a href="#adv-or-mapping-s2">Components</a></dt><dd><dl><dt><a href="#adv-or-mapping-s2-1">As Dependent Objects</a></dt><dt><a href="#adv-or-mapping-s2-2">In Collections</a></dt><dt><a href="#adv-or-mapping-s2-2b">As a Map Index</a></dt><dt><a href="#adv-or-mapping-s2-3">As Composite Identifiers</a></dt></dl></dd><dt><a href="#adv-or-mapping-s3">Cache</a></dt><dd><dl><dt><a href="#adv-or-mapping-s3-1">Mapping</a></dt><dt><a href="#adv-or-mapping-s3-2">Read Only Cache</a></dt><dt><a href="#adv-or-mapping-s3-3">Read / Write Cache</a></dt></dl></dd><dt><a href="#adv-or-mapping-s4">Proxies for Lazy Initialization</a></dt></dl></dd><dt>6. <a href="#manipulating-data">Manipulating Persistent Data</a></dt><dd><dl><dt><a href="#manipulating-data-s1">Creating a persistent object</a></dt><dt><a href="#manipulating-data-s2">Loading an object</a></dt><dt><a href="#manipulating-data-s3">Querying</a></dt><dd><dl><dt><a href="#manipulating-data-s4">Scalar queries</a></dt><dt><a href="#manipulating-data-s5">The Query interface</a></dt><dt><a href="#manipulating-data-s5b">Scrollable iteration</a></dt><dt><a href="#manipulating-data-s6">Filtering collections</a></dt></dl></dd><dt><a href="#manipulating-data-s7">Updating objects saved or loaded in the current session</a></dt><dt><a href="#manipulating-data-s8">Updating objects saved or loaded in a previous session</a></dt><dt><a href="#manipulating-data-s9">Deleting persistent objects</a></dt><dt><a href="#manipulating-data-s10">Graphs of objects</a></dt><dd><dl><dt><a href="#manipulating-data-s11a">Lifecycle objects</a></dt><dt><a href="#manipulating-data-s11b">Persistence by Reachability</a></dt></dl></dd><dt><a href="#manipulating-data-s12">Flushing</a></dt><dt><a href="#manipulating-data-s13">Ending a Session</a></dt><dd><dl><dt><a href="#manipulating-data-s13-1">Flushing the session</a></dt><dt><a href="#manipulating-data-s13-2">Committing the transaction</a></dt><dt><a href="#manipulating-data-s13-3">Closing the session</a></dt><dt><a href="#manipulating-data-s13-4">Exception handling</a></dt></dl></dd><dt><a href="#manipulating-data-s14">Interceptors</a></dt></dl></dd><dt>7. <a href="#query-language">Hibernate Query Language</a></dt><dd><dl><dt><a href="#query-language-s1">Case Sensitivity</a></dt><dt><a href="#query-language-s2">The from clause</a></dt><dt><a href="#query-language-s3">The select clause</a></dt><dt><a href="#query-language-s3b">polymorphism</a></dt><dt><a href="#query-language-s4">from collections</a></dt><dt><a href="#query-language-s5">The where clause</a></dt><dt><a href="#query-language-s6">Expressions</a></dt><dt><a href="#query-language-s7">The order by clause</a></dt><dt><a href="#query-language-s8">The group by clause</a></dt><dt><a href="#query-language-s9">Subqueries</a></dt></dl></dd><dt>8. <a href="#transactions">Transactions And Concurrency</a></dt><dd><dl><dt><a href="#transactions-s1">Datastores, Sessions and Factories</a></dt><dt><a href="#transactions-s2">Threads and connections</a></dt><dt><a href="#transactions-s3">Optimistic Locking / Versioning</a></dt><dd><dl><dt><a href="#transactions-s3-1">Long session with automatic versioning</a></dt><dt><a href="#transactions-s3-2">Many sessions with automatic versioning</a></dt><dt><a href="#transactions-s3-3">Application version checking</a></dt></dl></dd><dt><a href="#transactions-s4">Session disconnection</a></dt><dt><a href="#transactions-s5">Pessimistic Locking</a></dt></dl></dd><dt>9. <a href="#examples">Examples</a></dt><dd><dl><dt><a href="#examples-s0">Employer / Employee</a></dt><dt><a href="#examples-s1">Author / Work</a></dt><dt><a href="#examples-s2">Customer / Order / Product</a></dt></dl></dd><dt>10. <a href="#best-practices">Best Practices</a></dt></dl></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="architecture"></a>Chapter 1. Architecture</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#architecture-s1">Overview</a></dt><dt><a href="#architecture-s2">Persistent Object Identity</a></dt><dt><a href="#architecture-s3">JMX Integration</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="architecture-s1"></a>Overview</h2></div></div><p> A (very) high-level view of the Hibernate architecture: </p><div class="mediaobject"><img src="../images/overview.gif" align="center"></div><p> *************** *** 242,246 **** certain platform dependent features</td></tr><tr><td><tt>hibernate.default_schema</tt></td><td><tt>SCHEMA_NAME</tt></td><td>qualify unqualified tablenames with the given schema / tablespace in generated SQL</td></tr><tr><td><tt>hibernate.session_factory_name</tt></td><td><tt>jndi/composite/name</tt></td><td>bind this name to the <tt>SessionFactory</tt></td></tr><tr><td><tt>hibernate.use_outer_join</tt></td><td><tt>true</tt> | <tt>false</tt></td><td>enables <span class="emphasis"><i>outer join fetching</i></span></td></tr><tr><td><tt>hibernate.jdbc.fetch_size</tt></td><td> </td><td>a non-zero value determines the JDBC fetch size ( calls ! <tt>Statement.setFetchSize()</tt> )</td></tr><tr><td><tt>hibernate.jdbc.batch_size</tt></td><td>recommended values between 5 and 30</td><td>a nonzero value enables use of JDBC2 batch updates by Hibernate</td></tr><tr><td><tt>hibernate.jdbc.use_scrollable_resultsets</tt></td><td><tt>true</tt> | <tt>false</tt></td><td>enables use of JDBC2 scrollable resultsets by Hibernate. This property is only necessary when using user supplied connections. Hibernate uses connection metadata otherwise.</td></tr><tr><td><tt>hibernate.jdbc.use_streams_for_binary</tt></td><td><tt>true</tt> | <tt>false</tt></td><td>use streams when writing / reading <tt>binary</tt> --- 242,246 ---- certain platform dependent features</td></tr><tr><td><tt>hibernate.default_schema</tt></td><td><tt>SCHEMA_NAME</tt></td><td>qualify unqualified tablenames with the given schema / tablespace in generated SQL</td></tr><tr><td><tt>hibernate.session_factory_name</tt></td><td><tt>jndi/composite/name</tt></td><td>bind this name to the <tt>SessionFactory</tt></td></tr><tr><td><tt>hibernate.use_outer_join</tt></td><td><tt>true</tt> | <tt>false</tt></td><td>enables <span class="emphasis"><i>outer join fetching</i></span></td></tr><tr><td><tt>hibernate.jdbc.fetch_size</tt></td><td> </td><td>a non-zero value determines the JDBC fetch size ( calls ! <tt>Statement.setFetchSize()</tt> )</td></tr><tr><td><tt>hibernate.jdbc.batch_size</tt></td><td>recommended values between 5 and 30</td><td>a nonzero value enables use of JDBC2 batch updates by Hibernate</td></tr><tr><td><tt>hibernate.jdbc.use_scrollable_resultset</tt></td><td><tt>true</tt> | <tt>false</tt></td><td>enables use of JDBC2 scrollable resultsets by Hibernate. This property is only necessary when using user supplied connections. Hibernate uses connection metadata otherwise.</td></tr><tr><td><tt>hibernate.jdbc.use_streams_for_binary</tt></td><td><tt>true</tt> | <tt>false</tt></td><td>use streams when writing / reading <tt>binary</tt> |
From: <one...@us...> - 2002-11-26 03:38:03
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/transaction In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/transaction Modified Files: JBossTransactionManagerLookup.java JNDITransactionManagerLookup.java OrionTransactionManagerLookup.java TransactionManagerLookup.java WebSphereTransactionManagerLookup.java WeblogicTransactionManagerLookup.java Log Message: fixed broken line-endings and added a test Index: JBossTransactionManagerLookup.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/transaction/JBossTransactionManagerLookup.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JBossTransactionManagerLookup.java 8 Oct 2002 15:46:42 -0000 1.1 --- JBossTransactionManagerLookup.java 26 Nov 2002 03:35:45 -0000 1.2 *************** *** 1,13 **** ! //$Id$ ! package cirrus.hibernate.transaction; ! ! public final class JBossTransactionManagerLookup extends JNDITransactionManagerLookup { ! ! /** ! * @see cirrus.hibernate.transaction.JNDITransactionManagerLookup#getName() ! */ ! protected String getName() { ! return "java:/TransactionManager"; ! } ! ! } --- 1,13 ---- ! //$Id$ ! package cirrus.hibernate.transaction; ! ! public final class JBossTransactionManagerLookup extends JNDITransactionManagerLookup { ! ! /** ! * @see cirrus.hibernate.transaction.JNDITransactionManagerLookup#getName() ! */ ! protected String getName() { ! return "java:/TransactionManager"; ! } ! ! } Index: JNDITransactionManagerLookup.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/transaction/JNDITransactionManagerLookup.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** JNDITransactionManagerLookup.java 27 Oct 2002 03:11:33 -0000 1.3 --- JNDITransactionManagerLookup.java 26 Nov 2002 03:35:45 -0000 1.4 *************** *** 1,31 **** ! //$Id$ ! package cirrus.hibernate.transaction; ! ! import java.util.Properties; ! ! import javax.naming.NamingException; ! import javax.transaction.TransactionManager; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.helpers.NamingHelper; ! ! /** ! * Locates a <tt>TransactionManager</tt> in JNDI. ! */ ! public abstract class JNDITransactionManagerLookup implements TransactionManagerLookup { ! ! /** ! * @see cirrus.hibernate.transaction.TransactionManagerLookup#getTransactionManager(java.util.Properties) ! */ ! public TransactionManager getTransactionManager(Properties props) throws HibernateException { ! try { ! return (TransactionManager) NamingHelper.getInitialContext(props).lookup( getName() ); ! } ! catch (NamingException ne) { ! throw new HibernateException( "Could not locate TransactionManager", ne ); ! } ! } ! ! protected abstract String getName(); ! ! } --- 1,31 ---- ! //$Id$ ! package cirrus.hibernate.transaction; ! ! import java.util.Properties; ! ! import javax.naming.NamingException; ! import javax.transaction.TransactionManager; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.helpers.NamingHelper; ! ! /** ! * Locates a <tt>TransactionManager</tt> in JNDI. ! */ ! public abstract class JNDITransactionManagerLookup implements TransactionManagerLookup { ! ! /** ! * @see cirrus.hibernate.transaction.TransactionManagerLookup#getTransactionManager(java.util.Properties) ! */ ! public TransactionManager getTransactionManager(Properties props) throws HibernateException { ! try { ! return (TransactionManager) NamingHelper.getInitialContext(props).lookup( getName() ); ! } ! catch (NamingException ne) { ! throw new HibernateException( "Could not locate TransactionManager", ne ); ! } ! } ! ! protected abstract String getName(); ! ! } Index: OrionTransactionManagerLookup.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/transaction/OrionTransactionManagerLookup.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OrionTransactionManagerLookup.java 14 Nov 2002 12:42:19 -0000 1.1 --- OrionTransactionManagerLookup.java 26 Nov 2002 03:35:45 -0000 1.2 *************** *** 1,14 **** ! //$Id$ ! package cirrus.hibernate.transaction; ! ! public class OrionTransactionManagerLookup ! extends JNDITransactionManagerLookup { ! ! /** ! * @see cirrus.hibernate.transaction.JNDITransactionManagerLookup#getName() ! */ ! protected String getName() { ! return "java:comp/UserTransaction"; ! } ! ! } --- 1,14 ---- ! //$Id$ ! package cirrus.hibernate.transaction; ! ! public class OrionTransactionManagerLookup ! extends JNDITransactionManagerLookup { ! ! /** ! * @see cirrus.hibernate.transaction.JNDITransactionManagerLookup#getName() ! */ ! protected String getName() { ! return "java:comp/UserTransaction"; ! } ! ! } Index: TransactionManagerLookup.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/transaction/TransactionManagerLookup.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TransactionManagerLookup.java 8 Oct 2002 15:46:43 -0000 1.1 --- TransactionManagerLookup.java 26 Nov 2002 03:35:45 -0000 1.2 *************** *** 1,15 **** ! //$Id$ ! package cirrus.hibernate.transaction; ! ! import java.util.Properties; ! import javax.transaction.TransactionManager; ! ! import cirrus.hibernate.HibernateException; ! ! /** ! * Concrete implementations locate and return the JTA ! * <tt>TransactionManager</tt>. ! */ ! public interface TransactionManagerLookup { ! public TransactionManager getTransactionManager(Properties props) throws HibernateException; ! } --- 1,15 ---- ! //$Id$ ! package cirrus.hibernate.transaction; ! ! import java.util.Properties; ! import javax.transaction.TransactionManager; ! ! import cirrus.hibernate.HibernateException; ! ! /** ! * Concrete implementations locate and return the JTA ! * <tt>TransactionManager</tt>. ! */ ! public interface TransactionManagerLookup { ! public TransactionManager getTransactionManager(Properties props) throws HibernateException; ! } Index: WebSphereTransactionManagerLookup.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/transaction/WebSphereTransactionManagerLookup.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WebSphereTransactionManagerLookup.java 27 Oct 2002 03:11:33 -0000 1.2 --- WebSphereTransactionManagerLookup.java 26 Nov 2002 03:35:45 -0000 1.3 *************** *** 1,26 **** ! //$Id$ ! package cirrus.hibernate.transaction; ! ! import java.util.Properties; ! ! import javax.transaction.TransactionManager; ! ! import cirrus.hibernate.HibernateException; ! ! public class WebSphereTransactionManagerLookup implements TransactionManagerLookup { ! ! /** ! * @see cirrus.hibernate.transaction.TransactionManagerLookup#getTransactionManager(Properties) ! */ ! public TransactionManager getTransactionManager(Properties props) throws HibernateException { ! try { ! return (TransactionManager) Class.forName("com.ibm.ejcs.jts.jta.JTSXA") ! .getMethod("getTransactionManager", null) ! .invoke(null, null); ! } ! catch (Exception e) { ! throw new HibernateException( "Could not obtain WebSphere JTSXA instance", e ); ! } ! } ! ! } --- 1,26 ---- ! //$Id$ ! package cirrus.hibernate.transaction; ! ! import java.util.Properties; ! ! import javax.transaction.TransactionManager; ! ! import cirrus.hibernate.HibernateException; ! ! public class WebSphereTransactionManagerLookup implements TransactionManagerLookup { ! ! /** ! * @see cirrus.hibernate.transaction.TransactionManagerLookup#getTransactionManager(Properties) ! */ ! public TransactionManager getTransactionManager(Properties props) throws HibernateException { ! try { ! return (TransactionManager) Class.forName("com.ibm.ejcs.jts.jta.JTSXA") ! .getMethod("getTransactionManager", null) ! .invoke(null, null); ! } ! catch (Exception e) { ! throw new HibernateException( "Could not obtain WebSphere JTSXA instance", e ); ! } ! } ! ! } Index: WeblogicTransactionManagerLookup.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/transaction/WeblogicTransactionManagerLookup.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WeblogicTransactionManagerLookup.java 8 Oct 2002 15:46:43 -0000 1.1 --- WeblogicTransactionManagerLookup.java 26 Nov 2002 03:35:45 -0000 1.2 *************** *** 1,13 **** ! //$Id$ ! package cirrus.hibernate.transaction; ! ! public final class WeblogicTransactionManagerLookup extends JNDITransactionManagerLookup { ! ! /** ! * @see cirrus.hibernate.transaction.JNDITransactionManagerLookup#getName() ! */ ! protected String getName() { ! return "javax.transaction.TransactionCoordinator"; ! } ! ! } --- 1,13 ---- ! //$Id$ ! package cirrus.hibernate.transaction; ! ! public final class WeblogicTransactionManagerLookup extends JNDITransactionManagerLookup { ! ! /** ! * @see cirrus.hibernate.transaction.JNDITransactionManagerLookup#getName() ! */ ! protected String getName() { ! return "javax.transaction.TransactionCoordinator"; ! } ! ! } |
From: <one...@us...> - 2002-11-26 03:38:02
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/type In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/type Modified Files: AssociationType.java CalendarDateType.java CalendarType.java ComponentType.java CurrencyType.java DoubleType.java IdentifierType.java LiteralType.java TimeZoneType.java Log Message: fixed broken line-endings and added a test Index: AssociationType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/AssociationType.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AssociationType.java 3 Oct 2002 17:03:28 -0000 1.5 --- AssociationType.java 26 Nov 2002 03:35:45 -0000 1.6 *************** *** 1,43 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! import cirrus.hibernate.engine.Cascades; ! ! /** ! * A type that represents some kind of association between entities. ! * @see cirrus.hibernate.engine.Cascades ! */ ! public interface AssociationType { ! /** ! * Represents directionality of the foreign key constraint ! */ ! public static abstract class ForeignKeyType { ! protected ForeignKeyType() {} ! /** ! * Should we cascade at this cascade point? ! * @see cirrus.hibernate.engine.Cascades ! */ ! public abstract boolean cascadeNow(int cascadePoint); ! } ! /** ! * A foreign key from child to parent ! */ ! public static final ForeignKeyType FOREIGN_KEY_TO_PARENT = new ForeignKeyType() { ! public boolean cascadeNow(int cascadePoint) { ! return cascadePoint!=Cascades.CASCADE_BEFORE_INSERT_AFTER_DELETE; ! } ! }; ! /** ! * A foreign key from parent to child ! */ ! public static final ForeignKeyType FOREIGN_KEY_FROM_PARENT = new ForeignKeyType() { ! public boolean cascadeNow(int cascadePoint) { ! return cascadePoint!=Cascades.CASCADE_AFTER_INSERT_BEFORE_DELETE; ! } ! }; ! ! /** ! * Get the foreign key directionality of this association ! */ ! public ForeignKeyType getForeignKeyType(); ! } --- 1,43 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! import cirrus.hibernate.engine.Cascades; ! ! /** ! * A type that represents some kind of association between entities. ! * @see cirrus.hibernate.engine.Cascades ! */ ! public interface AssociationType { ! /** ! * Represents directionality of the foreign key constraint ! */ ! public static abstract class ForeignKeyType { ! protected ForeignKeyType() {} ! /** ! * Should we cascade at this cascade point? ! * @see cirrus.hibernate.engine.Cascades ! */ ! public abstract boolean cascadeNow(int cascadePoint); ! } ! /** ! * A foreign key from child to parent ! */ ! public static final ForeignKeyType FOREIGN_KEY_TO_PARENT = new ForeignKeyType() { ! public boolean cascadeNow(int cascadePoint) { ! return cascadePoint!=Cascades.CASCADE_BEFORE_INSERT_AFTER_DELETE; ! } ! }; ! /** ! * A foreign key from parent to child ! */ ! public static final ForeignKeyType FOREIGN_KEY_FROM_PARENT = new ForeignKeyType() { ! public boolean cascadeNow(int cascadePoint) { ! return cascadePoint!=Cascades.CASCADE_AFTER_INSERT_BEFORE_DELETE; ! } ! }; ! ! /** ! * Get the foreign key directionality of this association ! */ ! public ForeignKeyType getForeignKeyType(); ! } Index: CalendarDateType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/CalendarDateType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CalendarDateType.java 22 Nov 2002 00:27:09 -0000 1.1 --- CalendarDateType.java 26 Nov 2002 03:35:45 -0000 1.2 *************** *** 1,89 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.sql.Date; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.sql.Types; ! import java.util.Calendar; ! import java.util.GregorianCalendar; ! ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type mapping for a <tt>Calendar</tt> object that represents a date. ! */ ! public class CalendarDateType extends MutableType { ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! Calendar cal = new GregorianCalendar(); ! cal.setTimeInMillis( rs.getDate(name).getTime() ); ! return cal; ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! ! st.setDate( index, new Date( ( (Calendar) value ).getTimeInMillis() ) ); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Types.DATE; ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! //TODO: ! return value.toString(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#deepCopyNotNull(Object) ! */ ! public Object deepCopyNotNull(Object value) throws HibernateException { ! return ( (Calendar) value ).clone(); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return Calendar.class; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! if (x==y) return true; ! if (x==null || y==null) return false; ! ! Calendar calendar1 = (Calendar) x; ! Calendar calendar2 = (Calendar) y; ! ! return calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH) ! && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH) ! && calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "calendar_date"; ! } ! ! } --- 1,89 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.sql.Date; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.sql.Types; ! import java.util.Calendar; ! import java.util.GregorianCalendar; ! ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type mapping for a <tt>Calendar</tt> object that represents a date. ! */ ! public class CalendarDateType extends MutableType { ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! Calendar cal = new GregorianCalendar(); ! cal.setTimeInMillis( rs.getDate(name).getTime() ); ! return cal; ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! ! st.setDate( index, new Date( ( (Calendar) value ).getTimeInMillis() ) ); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Types.DATE; ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! //TODO: ! return value.toString(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#deepCopyNotNull(Object) ! */ ! public Object deepCopyNotNull(Object value) throws HibernateException { ! return ( (Calendar) value ).clone(); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return Calendar.class; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! if (x==y) return true; ! if (x==null || y==null) return false; ! ! Calendar calendar1 = (Calendar) x; ! Calendar calendar2 = (Calendar) y; ! ! return calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH) ! && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH) ! && calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "calendar_date"; ! } ! ! } Index: CalendarType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/CalendarType.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CalendarType.java 22 Nov 2002 00:27:09 -0000 1.2 --- CalendarType.java 26 Nov 2002 03:35:45 -0000 1.3 *************** *** 1,101 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.sql.Timestamp; ! import java.sql.Types; ! import java.util.Calendar; ! import java.util.GregorianCalendar; ! ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type mapping for a <tt>Calendar</tt> object that represents a datetime. ! */ ! public class CalendarType extends MutableType { ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! ! Timestamp ts = rs.getTimestamp(name); ! if (ts!=null) { ! Calendar cal = new GregorianCalendar(); ! cal.setTimeInMillis( ts.getTime() ); ! return cal; ! } ! else { ! return null; ! } ! ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! ! st.setTimestamp( index, new Timestamp( ( (Calendar) value ).getTimeInMillis() ) ); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Types.TIMESTAMP; ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! //TODO: ! return value.toString(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#deepCopyNotNull(Object) ! */ ! public Object deepCopyNotNull(Object value) throws HibernateException { ! return ( (Calendar) value ).clone(); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return Calendar.class; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! if (x==y) return true; ! if (x==null || y==null) return false; ! ! Calendar calendar1 = (Calendar) x; ! Calendar calendar2 = (Calendar) y; ! ! return calendar1.get(Calendar.MILLISECOND) == calendar2.get(Calendar.MILLISECOND) ! && calendar1.get(Calendar.SECOND) == calendar2.get(Calendar.SECOND) ! && calendar1.get(Calendar.MINUTE) == calendar2.get(Calendar.MINUTE) ! && calendar1.get(Calendar.HOUR_OF_DAY) == calendar2.get(Calendar.HOUR_OF_DAY) ! && calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH) ! && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH) ! && calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "calendar"; ! } ! ! } --- 1,101 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.sql.Timestamp; ! import java.sql.Types; ! import java.util.Calendar; ! import java.util.GregorianCalendar; ! ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type mapping for a <tt>Calendar</tt> object that represents a datetime. ! */ ! public class CalendarType extends MutableType { ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! ! Timestamp ts = rs.getTimestamp(name); ! if (ts!=null) { ! Calendar cal = new GregorianCalendar(); ! cal.setTimeInMillis( ts.getTime() ); ! return cal; ! } ! else { ! return null; ! } ! ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! ! st.setTimestamp( index, new Timestamp( ( (Calendar) value ).getTimeInMillis() ) ); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Types.TIMESTAMP; ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! //TODO: ! return value.toString(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#deepCopyNotNull(Object) ! */ ! public Object deepCopyNotNull(Object value) throws HibernateException { ! return ( (Calendar) value ).clone(); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return Calendar.class; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! if (x==y) return true; ! if (x==null || y==null) return false; ! ! Calendar calendar1 = (Calendar) x; ! Calendar calendar2 = (Calendar) y; ! ! return calendar1.get(Calendar.MILLISECOND) == calendar2.get(Calendar.MILLISECOND) ! && calendar1.get(Calendar.SECOND) == calendar2.get(Calendar.SECOND) ! && calendar1.get(Calendar.MINUTE) == calendar2.get(Calendar.MINUTE) ! && calendar1.get(Calendar.HOUR_OF_DAY) == calendar2.get(Calendar.HOUR_OF_DAY) ! && calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH) ! && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH) ! && calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "calendar"; ! } ! ! } Index: ComponentType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/ComponentType.java,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** ComponentType.java 9 Nov 2002 01:49:23 -0000 1.46 --- ComponentType.java 26 Nov 2002 03:35:45 -0000 1.47 *************** *** 1,278 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.io.Serializable; ! import java.lang.reflect.Constructor; ! import java.lang.reflect.Method; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.InstantiationException; ! import cirrus.hibernate.MappingException; ! import cirrus.hibernate.engine.Cascades; ! import cirrus.hibernate.engine.Mapping; ! import cirrus.hibernate.engine.SessionFactoryImplementor; ! import cirrus.hibernate.engine.SessionImplementor; ! import cirrus.hibernate.helpers.ArrayHelper; ! import cirrus.hibernate.helpers.ReflectHelper; ! ! public class ComponentType extends AbstractType implements AbstractComponentType { ! ! private final Class componentClass; ! private final Constructor constructor; ! private final Type[] types; ! private final Method[] getters; ! private final Method[] setters; ! private final String[] propertyNames; ! private final Cascades.CascadeStyle[] cascade; ! private final int propertySpan; ! private final int[] joinedFetch; ! private final String parentProperty; ! private final Method parentSetter; ! ! public int[] sqlTypes(Mapping pi) throws MappingException { ! //Not called at runtime so doesn't matter if its slow :) ! int[] sqlTypes = new int[ getColumnSpan(pi) ]; ! int n=0; ! for ( int i=0; i<propertySpan; i++ ) { ! int[] subtypes = types[i].sqlTypes(pi); ! for ( int j=0; j<subtypes.length; j++ ) { ! sqlTypes[n++] = subtypes[j]; ! } ! } ! return sqlTypes; ! } ! ! public int getColumnSpan(Mapping pi) throws MappingException { ! int span = 0; ! for ( int i=0; i<types.length; i++ ) { ! span += types[i].getColumnSpan(pi); ! } ! return span; ! } ! ! public ComponentType( ! Class componentClass, ! Type[] types, ! String[] properties, ! int[] joinedFetch, ! Cascades.CascadeStyle[] ! cascade, ! String parentProperty, ! boolean embedded ! ) throws MappingException { ! ! this.componentClass = componentClass; ! this.types = types; ! propertySpan = properties.length; ! getters = new Method[propertySpan]; ! setters = new Method[propertySpan]; ! for ( int i=0; i<properties.length; i++ ) { ! getters[i] = ReflectHelper.getGetterMethod( componentClass, properties[i] ); ! setters[i] = ReflectHelper.getSetterMethod( componentClass, properties[i] ); ! } ! this.parentSetter = (parentProperty==null) ? null : ReflectHelper.getSetterMethod(componentClass, parentProperty); ! this.parentProperty = parentProperty; ! this.propertyNames = properties; ! this.cascade = cascade; ! this.joinedFetch = joinedFetch; ! constructor = ReflectHelper.getDefaultConstructor(componentClass); ! } ! ! public boolean isPersistentCollectionType() { ! return false; ! } ! public final boolean isComponentType() { ! return true; ! } ! public final boolean isEntityType() { ! return false; ! } ! ! public Class returnedClass() { ! return componentClass; ! } ! ! public boolean equals(Object x, Object y) throws HibernateException { ! if (x==y) return true; ! if (x==null || y==null) return false; ! for ( int i=0; i<getters.length; i++ ) { ! try { ! if ( !types[i].equals( getters[i].invoke(x, null), getters[i].invoke(y, null) ) ) return false; ! } ! catch (Exception e) { ! throw new HibernateException( "Could not compare component property values: " + componentClass.getName() ); ! } ! } ! return true; ! } ! ! public boolean isDirty(Object x, Object y, Object owner, SessionFactoryImplementor factory) throws HibernateException { ! if (x==y) return false; ! if (x==null || y==null) return true; ! for ( int i=0; i<getters.length; i++ ) { ! try { ! if ( types[i].isDirty( getters[i].invoke(x, null), getters[i].invoke(y, null), owner, factory ) ) return true; ! } ! catch (Exception e) { ! throw new HibernateException( "Could not compare component property values: " + componentClass.getName() ); ! } ! } ! return false; ! } ! ! public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! ! int begin=0; ! boolean notNull=false; ! Object[] values = new Object[propertySpan]; ! for ( int i=0; i<propertySpan; i++ ) { ! int length = types[i].getColumnSpan( session.getFactory() ); ! String[] range = ArrayHelper.slice(names, begin, length); //cache this ! Object val = types[i].nullSafeGet(rs, range, session, owner); ! if (val!=null) notNull=true; ! values[i] = val; ! begin+=length; ! } ! ! if (notNull) { ! Object result = instantiate(owner); ! for ( int i=0; i<propertySpan; i++ ) { ! ReflectHelper.set( setters[i], result, values[i], componentClass, propertyNames[i] ); ! } ! return result; ! } ! else { ! return null; ! } ! } ! ! public void nullSafeSet(PreparedStatement st, Object value, int begin, SessionImplementor session) ! throws HibernateException, SQLException { ! ! Object[] subvalues = nullSafeGetValues(value); ! ! for ( int i=0; i<propertySpan; i++ ) { ! types[i].nullSafeSet(st, subvalues[i], begin, session); ! begin += types[i].getColumnSpan( session.getFactory() ); ! } ! } ! ! private Object[] nullSafeGetValues(Object value) throws HibernateException { ! if ( value==null ) { ! return new Object[propertySpan]; ! } ! else { ! return getPropertyValues(value); ! } ! } ! ! public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! ! return nullSafeGet(rs, new String[] {name}, session, owner); ! } ! ! public Object getPropertyValue(Object component, int i) throws HibernateException { ! return ReflectHelper.get( getters[i], component, componentClass, propertyNames[i] ); ! } ! ! public Object[] getPropertyValues(Object component) throws HibernateException { ! Object[] values = new Object[propertySpan]; ! for ( int i=0; i<propertySpan; i++ ) { ! values[i] = getPropertyValue(component, i); ! } ! return values; ! } ! ! public void setPropertyValues(Object component, Object[] values) throws HibernateException { ! for ( int i=0; i<propertySpan; i++ ) { ! ReflectHelper.set( setters[i], component, values[i], componentClass, propertyNames[i] ); ! } ! } ! public Type[] getSubtypes() { ! return types; ! } ! public String getName() { return componentClass.getName(); } ! public String toXML(Object value, SessionFactoryImplementor factory) { ! return (value==null) ? null : value.toString(); ! } ! public String[] getPropertyNames() { ! return propertyNames; ! } ! ! public Object deepCopy(Object component) throws HibernateException { ! if (component==null) return null; ! ! Object[] values = getPropertyValues(component); ! for ( int i=0; i<propertySpan; i++ ) { ! values[i] = types[i].deepCopy( values[i] ); ! } ! Object result = instantiate(null); //TODO: note that this doesn't copy reference to parent. Is that okay?? ! setPropertyValues(result, values); ! return result; ! } ! ! public Object instantiate(Object parent) throws HibernateException { ! try { ! Object inst = constructor.newInstance(null); ! if (parentSetter!=null) ReflectHelper.set(parentSetter, inst, parent, componentClass, parentProperty); ! return inst; ! } ! catch (Exception e) { ! throw new InstantiationException("Could not instantiate component ", componentClass, e); ! } ! } ! ! public Cascades.CascadeStyle cascade(int i) { ! return cascade[i]; ! } ! ! public boolean isMutable() { ! return true; ! } ! ! public Serializable disassemble(Object value, SessionImplementor session) ! throws HibernateException { ! ! if (value==null) { ! return null; ! } ! else { ! Object[] values = getPropertyValues(value); ! for ( int i=0; i<types.length; i++ ) { ! values[i] = types[i].disassemble(values[i], session); ! } ! return values; ! } ! } ! ! public Object assemble(Serializable object, SessionImplementor session, Object owner) throws HibernateException, SQLException { ! if ( object==null ) { ! return null; ! } ! else { ! Object[] values = (Object[]) object; ! Object[] assembled = new Object[values.length]; ! for ( int i=0; i<types.length; i++ ) { ! assembled[i] = types[i].assemble( (Serializable) values[i], session, owner ); ! } ! Object result = instantiate(owner); ! setPropertyValues(result, assembled); ! return result; ! } ! } ! ! public boolean hasNiceEquals() { ! return false; ! } ! ! public int enableJoinedFetch(int i) { ! return joinedFetch[i]; ! } ! ! } ! --- 1,278 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.io.Serializable; ! import java.lang.reflect.Constructor; ! import java.lang.reflect.Method; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.InstantiationException; ! import cirrus.hibernate.MappingException; ! import cirrus.hibernate.engine.Cascades; ! import cirrus.hibernate.engine.Mapping; ! import cirrus.hibernate.engine.SessionFactoryImplementor; ! import cirrus.hibernate.engine.SessionImplementor; ! import cirrus.hibernate.helpers.ArrayHelper; ! import cirrus.hibernate.helpers.ReflectHelper; ! ! public class ComponentType extends AbstractType implements AbstractComponentType { ! ! private final Class componentClass; ! private final Constructor constructor; ! private final Type[] types; ! private final Method[] getters; ! private final Method[] setters; ! private final String[] propertyNames; ! private final Cascades.CascadeStyle[] cascade; ! private final int propertySpan; ! private final int[] joinedFetch; ! private final String parentProperty; ! private final Method parentSetter; ! ! public int[] sqlTypes(Mapping pi) throws MappingException { ! //Not called at runtime so doesn't matter if its slow :) ! int[] sqlTypes = new int[ getColumnSpan(pi) ]; ! int n=0; ! for ( int i=0; i<propertySpan; i++ ) { ! int[] subtypes = types[i].sqlTypes(pi); ! for ( int j=0; j<subtypes.length; j++ ) { ! sqlTypes[n++] = subtypes[j]; ! } ! } ! return sqlTypes; ! } ! ! public int getColumnSpan(Mapping pi) throws MappingException { ! int span = 0; ! for ( int i=0; i<types.length; i++ ) { ! span += types[i].getColumnSpan(pi); ! } ! return span; ! } ! ! public ComponentType( ! Class componentClass, ! Type[] types, ! String[] properties, ! int[] joinedFetch, ! Cascades.CascadeStyle[] ! cascade, ! String parentProperty, ! boolean embedded ! ) throws MappingException { ! ! this.componentClass = componentClass; ! this.types = types; ! propertySpan = properties.length; ! getters = new Method[propertySpan]; ! setters = new Method[propertySpan]; ! for ( int i=0; i<properties.length; i++ ) { ! getters[i] = ReflectHelper.getGetterMethod( componentClass, properties[i] ); ! setters[i] = ReflectHelper.getSetterMethod( componentClass, properties[i] ); ! } ! this.parentSetter = (parentProperty==null) ? null : ReflectHelper.getSetterMethod(componentClass, parentProperty); ! this.parentProperty = parentProperty; ! this.propertyNames = properties; ! this.cascade = cascade; ! this.joinedFetch = joinedFetch; ! constructor = ReflectHelper.getDefaultConstructor(componentClass); ! } ! ! public boolean isPersistentCollectionType() { ! return false; ! } ! public final boolean isComponentType() { ! return true; ! } ! public final boolean isEntityType() { ! return false; ! } ! ! public Class returnedClass() { ! return componentClass; ! } ! ! public boolean equals(Object x, Object y) throws HibernateException { ! if (x==y) return true; ! if (x==null || y==null) return false; ! for ( int i=0; i<getters.length; i++ ) { ! try { ! if ( !types[i].equals( getters[i].invoke(x, null), getters[i].invoke(y, null) ) ) return false; ! } ! catch (Exception e) { ! throw new HibernateException( "Could not compare component property values: " + componentClass.getName() ); ! } ! } ! return true; ! } ! ! public boolean isDirty(Object x, Object y, Object owner, SessionFactoryImplementor factory) throws HibernateException { ! if (x==y) return false; ! if (x==null || y==null) return true; ! for ( int i=0; i<getters.length; i++ ) { ! try { ! if ( types[i].isDirty( getters[i].invoke(x, null), getters[i].invoke(y, null), owner, factory ) ) return true; ! } ! catch (Exception e) { ! throw new HibernateException( "Could not compare component property values: " + componentClass.getName() ); ! } ! } ! return false; ! } ! ! public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! ! int begin=0; ! boolean notNull=false; ! Object[] values = new Object[propertySpan]; ! for ( int i=0; i<propertySpan; i++ ) { ! int length = types[i].getColumnSpan( session.getFactory() ); ! String[] range = ArrayHelper.slice(names, begin, length); //cache this ! Object val = types[i].nullSafeGet(rs, range, session, owner); ! if (val!=null) notNull=true; ! values[i] = val; ! begin+=length; ! } ! ! if (notNull) { ! Object result = instantiate(owner); ! for ( int i=0; i<propertySpan; i++ ) { ! ReflectHelper.set( setters[i], result, values[i], componentClass, propertyNames[i] ); ! } ! return result; ! } ! else { ! return null; ! } ! } ! ! public void nullSafeSet(PreparedStatement st, Object value, int begin, SessionImplementor session) ! throws HibernateException, SQLException { ! ! Object[] subvalues = nullSafeGetValues(value); ! ! for ( int i=0; i<propertySpan; i++ ) { ! types[i].nullSafeSet(st, subvalues[i], begin, session); ! begin += types[i].getColumnSpan( session.getFactory() ); ! } ! } ! ! private Object[] nullSafeGetValues(Object value) throws HibernateException { ! if ( value==null ) { ! return new Object[propertySpan]; ! } ! else { ! return getPropertyValues(value); ! } ! } ! ! public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! ! return nullSafeGet(rs, new String[] {name}, session, owner); ! } ! ! public Object getPropertyValue(Object component, int i) throws HibernateException { ! return ReflectHelper.get( getters[i], component, componentClass, propertyNames[i] ); ! } ! ! public Object[] getPropertyValues(Object component) throws HibernateException { ! Object[] values = new Object[propertySpan]; ! for ( int i=0; i<propertySpan; i++ ) { ! values[i] = getPropertyValue(component, i); ! } ! return values; ! } ! ! public void setPropertyValues(Object component, Object[] values) throws HibernateException { ! for ( int i=0; i<propertySpan; i++ ) { ! ReflectHelper.set( setters[i], component, values[i], componentClass, propertyNames[i] ); ! } ! } ! public Type[] getSubtypes() { ! return types; ! } ! public String getName() { return componentClass.getName(); } ! public String toXML(Object value, SessionFactoryImplementor factory) { ! return (value==null) ? null : value.toString(); ! } ! public String[] getPropertyNames() { ! return propertyNames; ! } ! ! public Object deepCopy(Object component) throws HibernateException { ! if (component==null) return null; ! ! Object[] values = getPropertyValues(component); ! for ( int i=0; i<propertySpan; i++ ) { ! values[i] = types[i].deepCopy( values[i] ); ! } ! Object result = instantiate(null); //TODO: note that this doesn't copy reference to parent. Is that okay?? ! setPropertyValues(result, values); ! return result; ! } ! ! public Object instantiate(Object parent) throws HibernateException { ! try { ! Object inst = constructor.newInstance(null); ! if (parentSetter!=null) ReflectHelper.set(parentSetter, inst, parent, componentClass, parentProperty); ! return inst; ! } ! catch (Exception e) { ! throw new InstantiationException("Could not instantiate component ", componentClass, e); ! } ! } ! ! public Cascades.CascadeStyle cascade(int i) { ! return cascade[i]; ! } ! ! public boolean isMutable() { ! return true; ! } ! ! public Serializable disassemble(Object value, SessionImplementor session) ! throws HibernateException { ! ! if (value==null) { ! return null; ! } ! else { ! Object[] values = getPropertyValues(value); ! for ( int i=0; i<types.length; i++ ) { ! values[i] = types[i].disassemble(values[i], session); ! } ! return values; ! } ! } ! ! public Object assemble(Serializable object, SessionImplementor session, Object owner) throws HibernateException, SQLException { ! if ( object==null ) { ! return null; ! } ! else { ! Object[] values = (Object[]) object; ! Object[] assembled = new Object[values.length]; ! for ( int i=0; i<types.length; i++ ) { ! assembled[i] = types[i].assemble( (Serializable) values[i], session, owner ); ! } ! Object result = instantiate(owner); ! setPropertyValues(result, assembled); ! return result; ! } ! } ! ! public boolean hasNiceEquals() { ! return false; ! } ! ! public int enableJoinedFetch(int i) { ! return joinedFetch[i]; ! } ! ! } ! Index: CurrencyType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/CurrencyType.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CurrencyType.java 28 Oct 2002 15:41:53 -0000 1.5 --- CurrencyType.java 26 Nov 2002 03:35:45 -0000 1.6 *************** *** 1,131 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.lang.reflect.Method; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! ! import cirrus.hibernate.AssertionFailure; ! import cirrus.hibernate.Hibernate; ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type for <tt>java.util.Currency</tt> ! * @see java.util.Currency ! */ ! public class CurrencyType extends ImmutableType implements LiteralType { ! ! public static final Class CURRENCY_CLASS; ! private static final Method CURRENCY_GET_INSTANCE; ! private static final Method CURRENCY_GET_CODE; ! ! static { ! Class clazz; ! try { ! clazz = Class.forName("java.util.Currency"); ! } ! catch (ClassNotFoundException cnfe) { ! clazz = null; ! } ! if (clazz==null) { ! CURRENCY_CLASS = null; ! CURRENCY_GET_INSTANCE = null; ! CURRENCY_GET_CODE = null; ! } ! else { ! CURRENCY_CLASS = clazz; ! try { ! CURRENCY_GET_INSTANCE = clazz.getMethod("getInstance", new Class[] { String.class } ); ! CURRENCY_GET_CODE = clazz.getMethod("getCurrencyCode", new Class[0] ); ! } ! catch (Exception e) { ! throw new AssertionFailure("Exception in static initializer of CurrencyType", e); ! } ! } ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! String code = (String) Hibernate.STRING.nullSafeGet(rs, name); ! try { ! return (code==null) ? null : CURRENCY_GET_INSTANCE.invoke(null, new Object[] { code } ); ! } ! catch (Exception e) { ! throw new HibernateException("Could not resolve currency code: " + code); ! } ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! Object code; ! try { ! code = CURRENCY_GET_CODE.invoke(value, null); ! } ! catch (Exception e) { ! throw new HibernateException("Could not get Currency code", e); ! } ! Hibernate.STRING.set(st, code, index); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Hibernate.STRING.sqlType(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! try { ! return (String) CURRENCY_GET_CODE.invoke(value, null); ! } ! catch (Exception e) { ! throw new HibernateException("Could not get Currency code", e); ! } ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return CURRENCY_CLASS; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! return x==y || ( x!=null && y!=null && x.equals(y) ); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "currency"; ! } ! ! /** ! * @see cirrus.hibernate.type.LiteralType#objectToSQLString(Object) ! */ ! public String objectToSQLString(Object value) throws Exception { ! String code; ! try { ! code = (String) CURRENCY_GET_CODE.invoke(value, null); ! } ! catch (Exception e) { ! throw new HibernateException("Could not get Currency code", e); ! } ! return ( (LiteralType) Hibernate.STRING ).objectToSQLString(code); ! } ! ! } --- 1,131 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.lang.reflect.Method; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! ! import cirrus.hibernate.AssertionFailure; ! import cirrus.hibernate.Hibernate; ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type for <tt>java.util.Currency</tt> ! * @see java.util.Currency ! */ ! public class CurrencyType extends ImmutableType implements LiteralType { ! ! public static final Class CURRENCY_CLASS; ! private static final Method CURRENCY_GET_INSTANCE; ! private static final Method CURRENCY_GET_CODE; ! ! static { ! Class clazz; ! try { ! clazz = Class.forName("java.util.Currency"); ! } ! catch (ClassNotFoundException cnfe) { ! clazz = null; ! } ! if (clazz==null) { ! CURRENCY_CLASS = null; ! CURRENCY_GET_INSTANCE = null; ! CURRENCY_GET_CODE = null; ! } ! else { ! CURRENCY_CLASS = clazz; ! try { ! CURRENCY_GET_INSTANCE = clazz.getMethod("getInstance", new Class[] { String.class } ); ! CURRENCY_GET_CODE = clazz.getMethod("getCurrencyCode", new Class[0] ); ! } ! catch (Exception e) { ! throw new AssertionFailure("Exception in static initializer of CurrencyType", e); ! } ! } ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! String code = (String) Hibernate.STRING.nullSafeGet(rs, name); ! try { ! return (code==null) ? null : CURRENCY_GET_INSTANCE.invoke(null, new Object[] { code } ); ! } ! catch (Exception e) { ! throw new HibernateException("Could not resolve currency code: " + code); ! } ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! Object code; ! try { ! code = CURRENCY_GET_CODE.invoke(value, null); ! } ! catch (Exception e) { ! throw new HibernateException("Could not get Currency code", e); ! } ! Hibernate.STRING.set(st, code, index); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Hibernate.STRING.sqlType(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! try { ! return (String) CURRENCY_GET_CODE.invoke(value, null); ! } ! catch (Exception e) { ! throw new HibernateException("Could not get Currency code", e); ! } ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return CURRENCY_CLASS; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! return x==y || ( x!=null && y!=null && x.equals(y) ); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "currency"; ! } ! ! /** ! * @see cirrus.hibernate.type.LiteralType#objectToSQLString(Object) ! */ ! public String objectToSQLString(Object value) throws Exception { ! String code; ! try { ! code = (String) CURRENCY_GET_CODE.invoke(value, null); ! } ! catch (Exception e) { ! throw new HibernateException("Could not get Currency code", e); ! } ! return ( (LiteralType) Hibernate.STRING ).objectToSQLString(code); ! } ! ! } Index: DoubleType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/DoubleType.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** DoubleType.java 28 Oct 2002 15:41:53 -0000 1.10 --- DoubleType.java 26 Nov 2002 03:35:45 -0000 1.11 *************** *** 1,5 **** ! //$Id$ package cirrus.hibernate.type; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; ! public class DoubleType extends PrimitiveType { public Object get(ResultSet rs, String name) throws SQLException { --- 1,5 ---- ! //$Id$ package cirrus.hibernate.type; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; ! public class DoubleType extends PrimitiveType { public Object get(ResultSet rs, String name) throws SQLException { Index: IdentifierType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/IdentifierType.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IdentifierType.java 6 Sep 2002 17:03:00 -0000 1.3 --- IdentifierType.java 26 Nov 2002 03:35:46 -0000 1.4 *************** *** 1,16 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! /** ! * A <tt>Type</tt> that may be used as an identifier. ! */ ! public interface IdentifierType extends Type { ! /** ! * Convert the value from the mapping file to a Java object. ! * @param xml the value of <tt>discriminator-value</tt> or <tt>unsaved-value</tt> attribute ! * @return Object ! * @throws Exception ! */ ! public Object stringToObject(String xml) throws Exception; ! ! } --- 1,16 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! /** ! * A <tt>Type</tt> that may be used as an identifier. ! */ ! public interface IdentifierType extends Type { ! /** ! * Convert the value from the mapping file to a Java object. ! * @param xml the value of <tt>discriminator-value</tt> or <tt>unsaved-value</tt> attribute ! * @return Object ! * @throws Exception ! */ ! public Object stringToObject(String xml) throws Exception; ! ! } Index: LiteralType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/LiteralType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LiteralType.java 28 Oct 2002 15:44:38 -0000 1.1 --- LiteralType.java 26 Nov 2002 03:35:46 -0000 1.2 *************** *** 1,17 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! /** ! * A type that may appear as an SQL literal ! */ ! public interface LiteralType { ! /** ! * String representation of the value, suitable for embedding in ! * an SQL statement. ! * @param value ! * @return String ! * @throws Exception ! */ ! public String objectToSQLString(Object value) throws Exception; ! ! } --- 1,17 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! /** ! * A type that may appear as an SQL literal ! */ ! public interface LiteralType { ! /** ! * String representation of the value, suitable for embedding in ! * an SQL statement. ! * @param value ! * @return String ! * @throws Exception ! */ ! public String objectToSQLString(Object value) throws Exception; ! ! } Index: TimeZoneType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/TimeZoneType.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TimeZoneType.java 28 Oct 2002 15:41:53 -0000 1.2 --- TimeZoneType.java 26 Nov 2002 03:35:46 -0000 1.3 *************** *** 1,79 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.util.TimeZone; ! ! import cirrus.hibernate.Hibernate; ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type for <tt>java.util.TimeZone</tt> ! * @see java.util.TimeZone ! */ ! public class TimeZoneType extends ImmutableType implements LiteralType { ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! String id = (String) Hibernate.STRING.nullSafeGet(rs, name); ! return (id==null) ? null : TimeZone.getTimeZone(id); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! Hibernate.STRING.set(st, ( (TimeZone) value ).getID(), index); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Hibernate.STRING.sqlType(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! return ( (TimeZone) value ).getID(); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return TimeZone.class; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! return x==y || ( x!=null && y!=null && x.equals(y) ); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "timezone"; ! } ! ! /** ! * @see cirrus.hibernate.type.LiteralType#objectToSQLString(Object) ! */ ! public String objectToSQLString(Object value) throws Exception { ! return ( (LiteralType) Hibernate.STRING ).objectToSQLString( ! ( (TimeZone) value ).getID() ! ); ! } ! ! } --- 1,79 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.util.TimeZone; ! ! import cirrus.hibernate.Hibernate; ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type for <tt>java.util.TimeZone</tt> ! * @see java.util.TimeZone ! */ ! public class TimeZoneType extends ImmutableType implements LiteralType { ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! String id = (String) Hibernate.STRING.nullSafeGet(rs, name); ! return (id==null) ? null : TimeZone.getTimeZone(id); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! Hibernate.STRING.set(st, ( (TimeZone) value ).getID(), index); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Hibernate.STRING.sqlType(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! return ( (TimeZone) value ).getID(); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return TimeZone.class; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! return x==y || ( x!=null && y!=null && x.equals(y) ); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "timezone"; ! } ! ! /** ! * @see cirrus.hibernate.type.LiteralType#objectToSQLString(Object) ! */ ! public String objectToSQLString(Object value) throws Exception { ! return ( (LiteralType) Hibernate.STRING ).objectToSQLString( ! ( (TimeZone) value ).getID() ! ); ! } ! ! } |
From: <one...@us...> - 2002-11-26 03:38:02
|
Update of /cvsroot/hibernate/Hibernate/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv20166/doc/reference/src Modified Files: session_configuration.xml Log Message: fixed broken line-endings and added a test Index: session_configuration.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/reference/src/session_configuration.xml,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** session_configuration.xml 20 Nov 2002 10:28:08 -0000 1.24 --- session_configuration.xml 26 Nov 2002 03:35:46 -0000 1.25 *************** *** 338,342 **** </row> <row> ! <entry><literal>hibernate.jdbc.use_scrollable_resultsets</literal></entry> <entry><literal>true</literal> | <literal>false</literal></entry> <entry>enables use of JDBC2 scrollable resultsets by Hibernate. --- 338,342 ---- </row> <row> ! <entry><literal>hibernate.jdbc.use_scrollable_resultset</literal></entry> <entry><literal>true</literal> | <literal>false</literal></entry> <entry>enables use of JDBC2 scrollable resultsets by Hibernate. |
From: <one...@us...> - 2002-11-26 03:36:16
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/odmg In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/odmg Modified Files: Database.java Implementation.java Name.java OQLQuery.java Transaction.java Log Message: fixed broken line-endings and added a test Index: Database.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/odmg/Database.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Database.java 26 Oct 2002 09:39:47 -0000 1.6 --- Database.java 26 Nov 2002 03:35:43 -0000 1.7 *************** *** 1,9 **** //$Id$ ! package cirrus.hibernate.odmg; ! import java.sql.SQLException; import org.odmg.ODMGException; import org.odmg.ODMGRuntimeException; import org.odmg.ObjectNameNotFoundException; ! import org.odmg.ObjectNameNotUniqueException; import cirrus.hibernate.Hibernate; import cirrus.hibernate.HibernateException; --- 1,9 ---- //$Id$ ! package cirrus.hibernate.odmg; ! import java.sql.SQLException; import org.odmg.ODMGException; import org.odmg.ODMGRuntimeException; import org.odmg.ObjectNameNotFoundException; ! import org.odmg.ObjectNameNotUniqueException; import cirrus.hibernate.Hibernate; import cirrus.hibernate.HibernateException; *************** *** 11,15 **** import cirrus.hibernate.Session; import cirrus.hibernate.SessionFactory; ! import cirrus.hibernate.impl.SessionFactoryObjectFactory; /** --- 11,15 ---- import cirrus.hibernate.Session; import cirrus.hibernate.SessionFactory; ! import cirrus.hibernate.impl.SessionFactoryObjectFactory; /** *************** *** 28,32 **** * @see Transaction */ ! public class Database implements org.odmg.Database { private SessionFactory sessionFactory; private final ThreadLocal threadTransaction = new ThreadLocal(); --- 28,32 ---- * @see Transaction */ ! public class Database implements org.odmg.Database { private SessionFactory sessionFactory; private final ThreadLocal threadTransaction = new ThreadLocal(); *************** *** 47,51 **** * Get the <tt>Session</tt> underlying the <tt>Transaction</tt> associated * with the current thread. ! */ public Session getSession() { return currentTransaction().getSession(); --- 47,51 ---- * Get the <tt>Session</tt> underlying the <tt>Transaction</tt> associated * with the current thread. ! */ public Session getSession() { return currentTransaction().getSession(); *************** *** 58,62 **** return sessionFactory; } ! /** * Get the <tt>Transaction</tt> associatedm with the current thread. --- 58,62 ---- return sessionFactory; } ! /** * Get the <tt>Transaction</tt> associatedm with the current thread. *************** *** 64,71 **** public Transaction currentTransaction() { return (Transaction) threadTransaction.get(); ! } void associateThread(Transaction trans) { threadTransaction.set(trans); ! } void disassociateThread() { threadTransaction.set(null); --- 64,71 ---- public Transaction currentTransaction() { return (Transaction) threadTransaction.get(); ! } void associateThread(Transaction trans) { threadTransaction.set(trans); ! } void disassociateThread() { threadTransaction.set(null); *************** *** 75,79 **** * @see org.odmg.Database#open(String, int) */ ! public void open(String name, int accessMode) throws ODMGException { try { Hibernate.configure(); --- 75,79 ---- * @see org.odmg.Database#open(String, int) */ ! public void open(String name, int accessMode) throws ODMGException { try { Hibernate.configure(); *************** *** 89,95 **** catch (NamingException ne) { throw new ODMGException( ne.getMessage() ); ! }*/ } ! /** * Close the <tt>Database</tt> (but not the underlying <tt>SessionFactory</tt>). --- 89,95 ---- catch (NamingException ne) { throw new ODMGException( ne.getMessage() ); ! }*/ } ! /** * Close the <tt>Database</tt> (but not the underlying <tt>SessionFactory</tt>). *************** *** 101,105 **** sessionFactory = null; //TODO: remove it from ThreadLocal storage on Implementation ! } /** --- 101,105 ---- sessionFactory = null; //TODO: remove it from ThreadLocal storage on Implementation ! } /** *************** *** 107,115 **** * @see org.odmg.Database#bind(Object, String) */ ! public void bind(Object object, String name) throws ObjectNameNotUniqueException { ! try { Session s = getSession(); Name nameObj = new Name( name, object.getClass(), s.save(object) ); ! s.save(nameObj); //TODO: handle ObjectNameNotUniqueException properly } --- 107,115 ---- * @see org.odmg.Database#bind(Object, String) */ ! public void bind(Object object, String name) throws ObjectNameNotUniqueException { ! try { Session s = getSession(); Name nameObj = new Name( name, object.getClass(), s.save(object) ); ! s.save(nameObj); //TODO: handle ObjectNameNotUniqueException properly } *************** *** 119,132 **** catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); ! } ! } ! /** * Retrieve the persistent object bound to the given name. * @see org.odmg.Database#lookup(String) */ ! public Object lookup(String name) throws ObjectNameNotFoundException { ! try { ! Session s = getSession(); Name nameObj; try { --- 119,132 ---- catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); ! } ! } ! /** * Retrieve the persistent object bound to the given name. * @see org.odmg.Database#lookup(String) */ ! public Object lookup(String name) throws ObjectNameNotFoundException { ! try { ! Session s = getSession(); Name nameObj; try { *************** *** 136,140 **** throw new ObjectNameNotFoundException(); } ! return s.load( nameObj.getPersistentClass(), nameObj.getId() ); } catch (HibernateException he) { --- 136,140 ---- throw new ObjectNameNotFoundException(); } ! return s.load( nameObj.getPersistentClass(), nameObj.getId() ); } catch (HibernateException he) { *************** *** 143,148 **** catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); ! } ! } /** --- 143,148 ---- catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); ! } ! } /** *************** *** 150,160 **** * @see org.odmg.Database#unbind(String) */ ! public void unbind(String name) throws ObjectNameNotFoundException { ! try { ! Session s = getSession(); ! Name nameObj; try { nameObj = (Name) s.load(Name.class, name); } catch (ObjectNotFoundException onfe) { throw new ObjectNameNotFoundException(); } s.delete(nameObj); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); ! } ! } /** --- 150,160 ---- * @see org.odmg.Database#unbind(String) */ ! public void unbind(String name) throws ObjectNameNotFoundException { ! try { ! Session s = getSession(); ! Name nameObj; try { nameObj = (Name) s.load(Name.class, name); } catch (ObjectNotFoundException onfe) { throw new ObjectNameNotFoundException(); } s.delete(nameObj); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); ! } ! } /** *************** *** 162,166 **** * @see org.odmg.Database#makePersistent(Object) */ ! public void makePersistent(Object object) { try { getSession().save(object); --- 162,166 ---- * @see org.odmg.Database#makePersistent(Object) */ ! public void makePersistent(Object object) { try { getSession().save(object); *************** *** 171,181 **** catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); ! } ! } /** * Delete the given object from the database. * @see org.odmg.Database#deletePersistent(Object) */ ! public void deletePersistent(Object object) { try { getSession().delete(object); --- 171,181 ---- catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); ! } ! } /** * Delete the given object from the database. * @see org.odmg.Database#deletePersistent(Object) */ ! public void deletePersistent(Object object) { try { getSession().delete(object); *************** *** 186,191 **** catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); ! } ! } ! ! } --- 186,191 ---- catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); ! } ! } ! ! } Index: Implementation.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/odmg/Implementation.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Implementation.java 5 Nov 2002 16:58:14 -0000 1.8 --- Implementation.java 26 Nov 2002 03:35:43 -0000 1.9 *************** *** 1,4 **** //$Id$ ! package cirrus.hibernate.odmg; import java.util.ArrayList; import java.util.HashMap; --- 1,4 ---- //$Id$ ! package cirrus.hibernate.odmg; import java.util.ArrayList; import java.util.HashMap; *************** *** 11,15 **** import org.odmg.DSet; import org.odmg.ODMGException; ! import org.odmg.ODMGRuntimeException; import cirrus.hibernate.HibernateException; import cirrus.hibernate.collections.Bag; --- 11,15 ---- import org.odmg.DSet; import org.odmg.ODMGException; ! import org.odmg.ODMGRuntimeException; import cirrus.hibernate.HibernateException; import cirrus.hibernate.collections.Bag; *************** *** 17,21 **** import cirrus.hibernate.collections.Map; import cirrus.hibernate.collections.Set; ! import cirrus.hibernate.engine.SessionImplementor; /** * Singleton class implementing the ODMG <tt>Implementation</tt> interface. --- 17,21 ---- import cirrus.hibernate.collections.Map; import cirrus.hibernate.collections.Set; ! import cirrus.hibernate.engine.SessionImplementor; /** * Singleton class implementing the ODMG <tt>Implementation</tt> interface. *************** *** 24,28 **** */ public class Implementation implements org.odmg.Implementation { ! private Database database; private final ThreadLocal threadDatabase = new ThreadLocal(); --- 24,28 ---- */ public class Implementation implements org.odmg.Implementation { ! private Database database; private final ThreadLocal threadDatabase = new ThreadLocal(); *************** *** 34,38 **** public static Implementation getInstance() { return INSTANCE; ! } /** * Instantiate a new <tt>Transaction</tt> associated with the current --- 34,38 ---- public static Implementation getInstance() { return INSTANCE; ! } /** * Instantiate a new <tt>Transaction</tt> associated with the current *************** *** 61,65 **** return database; } ! } /** * Get the <tt>Transaction</tt> associated with the current thread. --- 61,65 ---- return database; } ! } /** * Get the <tt>Transaction</tt> associated with the current thread. *************** *** 68,72 **** public org.odmg.Transaction currentTransaction() { return currentDatabase().currentTransaction(); ! } /** * Create a new <tt>Database</tt> and associate it with the current thread. --- 68,72 ---- public org.odmg.Transaction currentTransaction() { return currentDatabase().currentTransaction(); ! } /** * Create a new <tt>Database</tt> and associate it with the current thread. *************** *** 81,85 **** threadDatabase.set(db); return db; ! } /** * Instantiate an <tt>OQLQuery</tt> for the <tt>Database</tt> associated with --- 81,85 ---- threadDatabase.set(db); return db; ! } /** * Instantiate an <tt>OQLQuery</tt> for the <tt>Database</tt> associated with *************** *** 89,93 **** public org.odmg.OQLQuery newOQLQuery() { return new OQLQuery( currentDatabase() ); ! } /** * @see org.odmg.Implementation#newDList() --- 89,93 ---- public org.odmg.OQLQuery newOQLQuery() { return new OQLQuery( currentDatabase() ); ! } /** * @see org.odmg.Implementation#newDList() *************** *** 95,99 **** public DList newDList() { return new List( (SessionImplementor) currentDatabase().getSession(), new ArrayList() ); ! } /** * @see org.odmg.Implementation#newDBag() --- 95,99 ---- public DList newDList() { return new List( (SessionImplementor) currentDatabase().getSession(), new ArrayList() ); ! } /** * @see org.odmg.Implementation#newDBag() *************** *** 101,105 **** public DBag newDBag() { return new Bag( (SessionImplementor) currentDatabase().getSession(), new ArrayList() ); ! } /** * @see org.odmg.Implementation#newDSet() --- 101,105 ---- public DBag newDBag() { return new Bag( (SessionImplementor) currentDatabase().getSession(), new ArrayList() ); ! } /** * @see org.odmg.Implementation#newDSet() *************** *** 107,111 **** public DSet newDSet() { return new Set( (SessionImplementor) currentDatabase().getSession(), new HashSet() ); ! } /** * @see org.odmg.Implementation#newDArray() --- 107,111 ---- public DSet newDSet() { return new Set( (SessionImplementor) currentDatabase().getSession(), new HashSet() ); ! } /** * @see org.odmg.Implementation#newDArray() *************** *** 113,117 **** public DArray newDArray() { return new List( (SessionImplementor) currentDatabase().getSession(), new ArrayList() ); ! } /** * @see org.odmg.Implementation#newDMap() --- 113,117 ---- public DArray newDArray() { return new List( (SessionImplementor) currentDatabase().getSession(), new ArrayList() ); ! } /** * @see org.odmg.Implementation#newDMap() *************** *** 119,128 **** public DMap newDMap() { return new Map( (SessionImplementor) currentDatabase().getSession(), new HashMap() ); ! } /** * Get the stringified identifier of the given object. * @see org.odmg.Implementation#getObjectId(Object) */ ! public String getObjectId(Object obj) { try { return database.getSession().getIdentifier(obj).toString(); --- 119,128 ---- public DMap newDMap() { return new Map( (SessionImplementor) currentDatabase().getSession(), new HashMap() ); ! } /** * Get the stringified identifier of the given object. * @see org.odmg.Implementation#getObjectId(Object) */ ! public String getObjectId(Object obj) { try { return database.getSession().getIdentifier(obj).toString(); *************** *** 130,135 **** catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); ! } ! } /** * Get the <tt>Database</tt> associated with the current thread (the most recent --- 130,135 ---- catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); ! } ! } /** * Get the <tt>Database</tt> associated with the current thread (the most recent *************** *** 141,144 **** return currentDatabase(); } ! ! } --- 141,144 ---- return currentDatabase(); } ! ! } Index: Name.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/odmg/Name.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Name.java 11 Sep 2002 09:39:53 -0000 1.2 --- Name.java 26 Nov 2002 03:35:43 -0000 1.3 *************** *** 1,15 **** ! //$Id$ package cirrus.hibernate.odmg; ! import java.io.Serializable; ! /** * An ODMG name that may be bound to a persistent object. */ public class Name { ! private String name; private Class persistentClass; private Serializable id; ! public Name(String name, Class persistentClass, Serializable id) { this.name = name; this.persistentClass = persistentClass; this.id = id; } ! public Name() {} ! /** * Returns the name. * @return String */ ! public String getName() { return name; } ! /** * Returns the persistentClass. * @return Class */ public Class getPersistentClass() { return persistentClass; } ! /** * Sets the name. * @param name The name to set */ public void setName(String name) { this.name = name; } ! /** * Sets the persistentClass. * @param persistentClass The persistentClass to set */ public void setPersistentClass(Class persistentClass) { this.persistentClass = persistentClass; } ! /** * Returns the id. * @return Serializable */ public Serializable getId() { return id; } ! /** * Sets the id. * @param id The id to set */ public void setId(Serializable id) { this.id = id; } ! } --- 1,15 ---- ! //$Id$ package cirrus.hibernate.odmg; ! import java.io.Serializable; ! /** * An ODMG name that may be bound to a persistent object. */ public class Name { ! private String name; private Class persistentClass; private Serializable id; ! public Name(String name, Class persistentClass, Serializable id) { this.name = name; this.persistentClass = persistentClass; this.id = id; } ! public Name() {} ! /** * Returns the name. * @return String */ ! public String getName() { return name; } ! /** * Returns the persistentClass. * @return Class */ public Class getPersistentClass() { return persistentClass; } ! /** * Sets the name. * @param name The name to set */ public void setName(String name) { this.name = name; } ! /** * Sets the persistentClass. * @param persistentClass The persistentClass to set */ public void setPersistentClass(Class persistentClass) { this.persistentClass = persistentClass; } ! /** * Returns the id. * @return Serializable */ public Serializable getId() { return id; } ! /** * Sets the id. * @param id The id to set */ public void setId(Serializable id) { this.id = id; } ! } Index: OQLQuery.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/odmg/OQLQuery.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OQLQuery.java 12 Sep 2002 18:19:15 -0000 1.4 --- OQLQuery.java 26 Nov 2002 03:35:43 -0000 1.5 *************** *** 1,11 **** ! //$Id$ package cirrus.hibernate.odmg; ! import java.sql.SQLException; ! import org.odmg.ODMGRuntimeException; import org.odmg.QueryException; import org.odmg.QueryInvalidException; import org.odmg.QueryParameterCountInvalidException; import org.odmg.QueryParameterTypeInvalidException; ! import cirrus.hibernate.HibernateException; import cirrus.hibernate.Query; ! /** Experimental implementation of the ODMG <tt>OQLQuery</tt> interface. The supported query language is actually the Hibernate query language and the <tt>execute()</tt> method returns results in the same format as <tt>Session.find()</tt>.<br> <br> Warning: this implementation will change significantly as ODMG support matures! */ public class OQLQuery implements org.odmg.OQLQuery { ! private Transaction tx; private Query query; private int param=0; /** * Instantiate an <tt>OQLQuery</tt> for the current transaction. */ ! public OQLQuery(Database db) { this.tx = db.currentTransaction(); } ! /** * Instantiate an <tt>OQLQuery</tt> for the given transaction. */ public OQLQuery(Transaction tx) { this.tx = tx; } /** * Instantiate an <tt>OQLQuery</tt> for the current transaction. */ public OQLQuery() { this.tx = (Transaction) Implementation.getInstance().currentTransaction(); } /** * Get the underlying Hibernate <tt>Query</tt>. */ public Query getQuery() { return query; } /** * Set the HIbernate query string. Scalar return values are not supported. * @see org.odmg.OQLQuery#create(String) */ public void create(String queryString) throws QueryInvalidException { //TODO: the right exception try { this.query = tx.getSession().createQuery(queryString); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } } ! /** * Bind a value to the next <tt>?</tt> style parameter. * @see org.odmg.OQLQuery#bind(Object) */ public void bind(Object parameter) throws QueryParameterCountInvalidException, QueryParameterTypeInvalidException { //TODO: the right exception try { query.setParameter(param++, parameter); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } } ! /** * Get the query results as a collection. * @see org.odmg.OQLQuery#execute() */ public Object execute() throws QueryException { //TODO: how are results meant to be returned in ODMG? try { return query.list(); } catch (SQLException sqle) { throw new QueryException( sqle.getMessage() ); } catch (HibernateException he) { throw new QueryException( he.getMessage() ); } } ! } --- 1,11 ---- ! //$Id$ package cirrus.hibernate.odmg; ! import java.sql.SQLException; ! import org.odmg.ODMGRuntimeException; import org.odmg.QueryException; import org.odmg.QueryInvalidException; import org.odmg.QueryParameterCountInvalidException; import org.odmg.QueryParameterTypeInvalidException; ! import cirrus.hibernate.HibernateException; import cirrus.hibernate.Query; ! /** Experimental implementation of the ODMG <tt>OQLQuery</tt> interface. The supported query language is actually the Hibernate query language and the <tt>execute()</tt> method returns results in the same format as <tt>Session.find()</tt>.<br> <br> Warning: this implementation will change significantly as ODMG support matures! */ public class OQLQuery implements org.odmg.OQLQuery { ! private Transaction tx; private Query query; private int param=0; /** * Instantiate an <tt>OQLQuery</tt> for the current transaction. */ ! public OQLQuery(Database db) { this.tx = db.currentTransaction(); } ! /** * Instantiate an <tt>OQLQuery</tt> for the given transaction. */ public OQLQuery(Transaction tx) { this.tx = tx; } /** * Instantiate an <tt>OQLQuery</tt> for the current transaction. */ public OQLQuery() { this.tx = (Transaction) Implementation.getInstance().currentTransaction(); } /** * Get the underlying Hibernate <tt>Query</tt>. */ public Query getQuery() { return query; } /** * Set the HIbernate query string. Scalar return values are not supported. * @see org.odmg.OQLQuery#create(String) */ public void create(String queryString) throws QueryInvalidException { //TODO: the right exception try { this.query = tx.getSession().createQuery(queryString); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } } ! /** * Bind a value to the next <tt>?</tt> style parameter. * @see org.odmg.OQLQuery#bind(Object) */ public void bind(Object parameter) throws QueryParameterCountInvalidException, QueryParameterTypeInvalidException { //TODO: the right exception try { query.setParameter(param++, parameter); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } } ! /** * Get the query results as a collection. * @see org.odmg.OQLQuery#execute() */ public Object execute() throws QueryException { //TODO: how are results meant to be returned in ODMG? try { return query.list(); } catch (SQLException sqle) { throw new QueryException( sqle.getMessage() ); } catch (HibernateException he) { throw new QueryException( he.getMessage() ); } } ! } Index: Transaction.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/odmg/Transaction.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Transaction.java 5 Nov 2002 16:58:14 -0000 1.6 --- Transaction.java 26 Nov 2002 03:35:43 -0000 1.7 *************** *** 1,17 **** ! //$Id$ package cirrus.hibernate.odmg; ! import java.sql.SQLException; ! import org.odmg.LockNotGrantedException; import org.odmg.ODMGException; import org.odmg.ODMGRuntimeException; ! import cirrus.hibernate.HibernateException; import cirrus.hibernate.LockMode; import cirrus.hibernate.Session; ! /** * Implements the ODMG <tt>Transaction</tt> API. */ public class Transaction implements org.odmg.Transaction { ! private final Database database; private final Session session; private cirrus.hibernate.Transaction tx; ! /** * Instantiate a <tt>Transaction</tt> for the given <tt>Database</tt>. */ public Transaction(org.odmg.Database database) throws ODMGException { this.database = (Database) database; try { this.session = this.database.getSessionFactory().openSession(); } catch (SQLException sqle) { throw new ODMGException( sqle.getMessage() ); } this.database.associateThread(this); } /** * Instantiate a <tt>Transaction</tt> for a <tt>Database</tt> created * by the current thread. */ public Transaction() throws ODMGException { this( Implementation.getInstance().currentDatabase() ); } /** * Get the underlying Hibernate <tt>Session</tt>. (Very useful!) */ ! public Session getSession() { return session; } ! /** * Associate the current thread with this <tt>Transaction</tt> and * disassociate the thread from any other <tt>Transaction</tt>. * @see org.odmg.Transaction#join() */ public void join() { //database.disassociateThread(); database.associateThread(this); } ! /** * Disassociate the thread the <tt>Transaction</tt>. * @see org.odmg.Transaction#leave() */ public void leave() { database.disassociateThread(); } ! /** * Begin the transaction. * @see org.odmg.Transaction#begin() */ public void begin() { try { tx = session.beginTransaction(); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } } ! /** * Is the transaction open? Returns true if <tt>begin()</tt> was called but * neither <tt>commit()</tt> nor <tt>abort()</tt> was called. * @see org.odmg.Transaction#isOpen() */ public boolean isOpen() { return tx==null; } ! /** * Commit the transaction. * @see org.odmg.Transaction#commit() */ public void commit() { database.disassociateThread(); try { tx.commit(); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); } finally { tx=null; try { session.close(); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); } } } ! /** * Abort the transaction. * @see org.odmg.Transaction#abort() */ public void abort() { database.disassociateThread(); try { tx.rollback(); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } finally { tx=null; try { session.close(); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); } } } ! /** * Commit the changes, but leave the transaction open. This implementation * does not have quite the same semantics os ODMG (locks are not retained). * So you should only use this with versioned data. * @see org.odmg.Transaction#checkpoint() */ public void checkpoint() { try { tx.commit(); tx = session.beginTransaction(); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); } } /** * Obtain a lock upon the given object. In the present implementation, * <tt>READ</tt> lock mode is ignored while <tt>UPGRADE</tt> and * <tt>WRITE</tt> lock modes obtain an <tt>UPGRADE</tt> lock for databases * which support <tt>for update</tt>. We should improve this eventually.... * @see org.odmg.Transaction#lock(Object, int) */ public void lock(Object obj, int lockMode) throws LockNotGrantedException { //TODO: check the semantics of this... try { if ( lockMode==org.odmg.Transaction.READ ) { session.lock(obj, LockMode.READ); } else { session.lock(obj, LockMode.UPGRADE); } } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); } } ! /** * Not implemented. * @see org.odmg.Transaction#tryLock(Object, int) */ public boolean tryLock(Object obj, int lockMode) { throw new UnsupportedOperationException("try using lock()"); } ! } --- 1,17 ---- ! //$Id$ package cirrus.hibernate.odmg; ! import java.sql.SQLException; ! import org.odmg.LockNotGrantedException; import org.odmg.ODMGException; import org.odmg.ODMGRuntimeException; ! import cirrus.hibernate.HibernateException; import cirrus.hibernate.LockMode; import cirrus.hibernate.Session; ! /** * Implements the ODMG <tt>Transaction</tt> API. */ public class Transaction implements org.odmg.Transaction { ! private final Database database; private final Session session; private cirrus.hibernate.Transaction tx; ! /** * Instantiate a <tt>Transaction</tt> for the given <tt>Database</tt>. */ public Transaction(org.odmg.Database database) throws ODMGException { this.database = (Database) database; try { this.session = this.database.getSessionFactory().openSession(); } catch (SQLException sqle) { throw new ODMGException( sqle.getMessage() ); } this.database.associateThread(this); } /** * Instantiate a <tt>Transaction</tt> for a <tt>Database</tt> created * by the current thread. */ public Transaction() throws ODMGException { this( Implementation.getInstance().currentDatabase() ); } /** * Get the underlying Hibernate <tt>Session</tt>. (Very useful!) */ ! public Session getSession() { return session; } ! /** * Associate the current thread with this <tt>Transaction</tt> and * disassociate the thread from any other <tt>Transaction</tt>. * @see org.odmg.Transaction#join() */ public void join() { //database.disassociateThread(); database.associateThread(this); } ! /** * Disassociate the thread the <tt>Transaction</tt>. * @see org.odmg.Transaction#leave() */ public void leave() { database.disassociateThread(); } ! /** * Begin the transaction. * @see org.odmg.Transaction#begin() */ public void begin() { try { tx = session.beginTransaction(); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } } ! /** * Is the transaction open? Returns true if <tt>begin()</tt> was called but * neither <tt>commit()</tt> nor <tt>abort()</tt> was called. * @see org.odmg.Transaction#isOpen() */ public boolean isOpen() { return tx==null; } ! /** * Commit the transaction. * @see org.odmg.Transaction#commit() */ public void commit() { database.disassociateThread(); try { tx.commit(); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); } finally { tx=null; try { session.close(); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); } } } ! /** * Abort the transaction. * @see org.odmg.Transaction#abort() */ public void abort() { database.disassociateThread(); try { tx.rollback(); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } finally { tx=null; try { session.close(); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); } } } ! /** * Commit the changes, but leave the transaction open. This implementation * does not have quite the same semantics os ODMG (locks are not retained). * So you should only use this with versioned data. * @see org.odmg.Transaction#checkpoint() */ public void checkpoint() { try { tx.commit(); tx = session.beginTransaction(); } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); } } /** * Obtain a lock upon the given object. In the present implementation, * <tt>READ</tt> lock mode is ignored while <tt>UPGRADE</tt> and * <tt>WRITE</tt> lock modes obtain an <tt>UPGRADE</tt> lock for databases * which support <tt>for update</tt>. We should improve this eventually.... * @see org.odmg.Transaction#lock(Object, int) */ public void lock(Object obj, int lockMode) throws LockNotGrantedException { //TODO: check the semantics of this... try { if ( lockMode==org.odmg.Transaction.READ ) { session.lock(obj, LockMode.READ); } else { session.lock(obj, LockMode.UPGRADE); } } catch (HibernateException he) { throw new ODMGRuntimeException( he.getMessage() ); } catch (SQLException sqle) { throw new ODMGRuntimeException( sqle.getMessage() ); } } ! /** * Not implemented. * @see org.odmg.Transaction#tryLock(Object, int) */ public boolean tryLock(Object obj, int lockMode) { throw new UnsupportedOperationException("try using lock()"); } ! } |
From: <one...@us...> - 2002-11-26 03:36:16
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/metadata In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/metadata Modified Files: ClassMetadata.java CollectionMetadata.java Visitor.java Log Message: fixed broken line-endings and added a test Index: ClassMetadata.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/metadata/ClassMetadata.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ClassMetadata.java 13 Oct 2002 13:54:56 -0000 1.2 --- ClassMetadata.java 26 Nov 2002 03:35:43 -0000 1.3 *************** *** 1,85 **** ! //$Id$ ! package cirrus.hibernate.metadata; ! ! import java.io.Serializable; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.type.Type; ! ! /** ! * Exposes entity class metadata to the application ! * ! * @see cirrus.hibernate.SessionFactory#getClassMetadata(Class) ! */ ! public interface ClassMetadata { ! ! /** ! * The persistent class ! */ ! public Class getMappedClass(); ! ! /** ! * Get the name of the identifier property (or return null) ! */ ! public String getIdentifierPropertyName(); ! ! /** ! * Get the names of the class' persistent properties ! */ ! public String[] getPropertyNames(); ! ! /** ! * Get the identifier Hibernate type ! */ ! public Type getIdentifierType(); ! ! /** ! * Get the Hibernate types of the class properties ! */ ! public Type[] getPropertyTypes(); ! ! /** ! * Return the values of the mapped properties of the object ! */ ! public Object[] getPropertyValues(Object entity) throws HibernateException; ! ! /** ! * Set the given values to the mapped properties of the given object ! */ ! public void setPropertyValues(Object object, Object[] values) throws HibernateException; ! ! /** ! * Get the identifier of an instance (throw an exception if no identifier property) ! */ ! public Serializable getIdentifier(Object entity) throws HibernateException; ! ! /** ! * Set the identifier of an instance (or do nothing if no identifier property) ! */ ! public void setIdentifier(Object object, Serializable id) throws HibernateException; ! ! /** ! * Does the class implement the <tt>Lifecycle</tt> interface? ! */ ! public boolean implementsLifecycle(); ! ! /** ! * Does the class implement the <tt>Validatable</tt> interface? ! */ ! public boolean implementsValidatable(); ! ! /** ! * Does this class support dynamic proxies? ! */ ! public boolean hasProxy(); ! ! /** ! * Are instances of this class mutable? ! */ ! public boolean isMutable(); ! ! /** ! * Are instances of this class versioned by a timestamp or version number column? ! */ ! public boolean isVersioned(); ! } --- 1,85 ---- ! //$Id$ ! package cirrus.hibernate.metadata; ! ! import java.io.Serializable; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.type.Type; ! ! /** ! * Exposes entity class metadata to the application ! * ! * @see cirrus.hibernate.SessionFactory#getClassMetadata(Class) ! */ ! public interface ClassMetadata { ! ! /** ! * The persistent class ! */ ! public Class getMappedClass(); ! ! /** ! * Get the name of the identifier property (or return null) ! */ ! public String getIdentifierPropertyName(); ! ! /** ! * Get the names of the class' persistent properties ! */ ! public String[] getPropertyNames(); ! ! /** ! * Get the identifier Hibernate type ! */ ! public Type getIdentifierType(); ! ! /** ! * Get the Hibernate types of the class properties ! */ ! public Type[] getPropertyTypes(); ! ! /** ! * Return the values of the mapped properties of the object ! */ ! public Object[] getPropertyValues(Object entity) throws HibernateException; ! ! /** ! * Set the given values to the mapped properties of the given object ! */ ! public void setPropertyValues(Object object, Object[] values) throws HibernateException; ! ! /** ! * Get the identifier of an instance (throw an exception if no identifier property) ! */ ! public Serializable getIdentifier(Object entity) throws HibernateException; ! ! /** ! * Set the identifier of an instance (or do nothing if no identifier property) ! */ ! public void setIdentifier(Object object, Serializable id) throws HibernateException; ! ! /** ! * Does the class implement the <tt>Lifecycle</tt> interface? ! */ ! public boolean implementsLifecycle(); ! ! /** ! * Does the class implement the <tt>Validatable</tt> interface? ! */ ! public boolean implementsValidatable(); ! ! /** ! * Does this class support dynamic proxies? ! */ ! public boolean hasProxy(); ! ! /** ! * Are instances of this class mutable? ! */ ! public boolean isMutable(); ! ! /** ! * Are instances of this class versioned by a timestamp or version number column? ! */ ! public boolean isVersioned(); ! } Index: CollectionMetadata.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/metadata/CollectionMetadata.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CollectionMetadata.java 13 Oct 2002 13:54:56 -0000 1.2 --- CollectionMetadata.java 26 Nov 2002 03:35:43 -0000 1.3 *************** *** 1,42 **** ! //$Id$ ! package cirrus.hibernate.metadata; ! ! import cirrus.hibernate.type.Type; ! ! /** ! * Exposes collection metadata to the application ! */ ! public interface CollectionMetadata { ! /** ! * The collection key type ! */ ! public Type getKeyType(); ! /** ! * The collection element type ! */ ! public Type getElementType(); ! /** ! * The collection index type (or null if the collection has no index) ! */ ! public Type getIndexType(); ! /** ! * Is this collection indexed? ! */ ! public boolean hasIndex(); ! /** ! * The name of this collection role ! */ ! public String getRole(); ! /** ! * Is the collection an array? ! */ ! public boolean isArray(); ! /** ! * Is the collection a primitive array? ! */ ! public boolean isPrimitiveArray(); ! /** ! * Is the collection lazily initialized? ! */ ! public boolean isLazy(); ! } --- 1,42 ---- ! //$Id$ ! package cirrus.hibernate.metadata; ! ! import cirrus.hibernate.type.Type; ! ! /** ! * Exposes collection metadata to the application ! */ ! public interface CollectionMetadata { ! /** ! * The collection key type ! */ ! public Type getKeyType(); ! /** ! * The collection element type ! */ ! public Type getElementType(); ! /** ! * The collection index type (or null if the collection has no index) ! */ ! public Type getIndexType(); ! /** ! * Is this collection indexed? ! */ ! public boolean hasIndex(); ! /** ! * The name of this collection role ! */ ! public String getRole(); ! /** ! * Is the collection an array? ! */ ! public boolean isArray(); ! /** ! * Is the collection a primitive array? ! */ ! public boolean isPrimitiveArray(); ! /** ! * Is the collection lazily initialized? ! */ ! public boolean isLazy(); ! } Index: Visitor.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/metadata/Visitor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Visitor.java 13 Oct 2002 13:19:56 -0000 1.1 --- Visitor.java 26 Nov 2002 03:35:43 -0000 1.2 *************** *** 1,148 **** ! //$Id$ ! package cirrus.hibernate.metadata; ! ! import java.util.Collection; ! import java.util.Iterator; ! import java.util.List; ! import java.util.Map; ! import java.util.Set; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.SessionFactory; ! import cirrus.hibernate.type.AbstractComponentType; ! import cirrus.hibernate.type.BagType; ! import cirrus.hibernate.type.ListType; ! import cirrus.hibernate.type.MapType; ! import cirrus.hibernate.type.PersistentCollectionType; ! import cirrus.hibernate.type.SetType; ! import cirrus.hibernate.type.Type; ! ! /** ! * Abstract visitor superclass implementing tree-walking functionality for a graph ! * of Hibernate-persistable objects, based upon known metadata. Applications that ! * need to process object graphs could implement subclasses that override appropriate ! * <tt>process...</tt> methods of this class. ! */ ! public class Visitor { ! ! public static final boolean RECURSE = true; ! public static final boolean STOP = false; ! ! private SessionFactory factory; ! ! /** ! * Create a new instance, using the specified <tt>SessionFactory</tt> as ! * a source of persistence metadata. ! */ ! public Visitor(SessionFactory factory) { ! this.factory = factory; ! } ! ! public void visit(Object object) throws HibernateException { ! if ( process(object) ) { ! ClassMetadata cmd = factory.getClassMetadata( object.getClass() ); ! visitProperties( cmd.getPropertyValues(object), cmd.getPropertyTypes(), cmd.getPropertyNames(), object ); ! } ! } ! ! public void visitProperties( Object[] values, Type[] types, String[] names, Object owner ) throws HibernateException { ! for ( int i=0; i<values.length; i++ ) visitProperty( values[i], types[i], names[i], owner ); ! } ! ! public void visitProperty(Object value, Type type, String name, Object owner) throws HibernateException { ! if ( type.isPersistentCollectionType() ) { ! visitCollection( value, (PersistentCollectionType) type, owner ); ! } ! else if ( type.isComponentType() ) { ! visitComponent( value, (AbstractComponentType) type, owner ); ! } ! else if ( type.isEntityType() ) { ! visitAssociation(value, type, owner); ! } ! else { ! processPropertyValue(value, type, name, owner); ! } ! } ! ! public void visitElement(Object value, Type type, Object owner) throws HibernateException { ! if ( type.isPersistentCollectionType() ) { ! visitCollection( value, (PersistentCollectionType) type, owner ); ! } ! else if ( type.isComponentType() ) { ! visitComponent( value, (AbstractComponentType) type, owner ); ! } ! else if ( type.isEntityType() ) { ! visitAssociation(value, type, owner); ! } ! else { ! processElement(value, type, owner); ! } ! } ! ! public void visitAssociation(Object value, Type type, Object owner) throws HibernateException { ! if ( processAssociation(value, owner) ) visit(value); ! } ! ! public void visitComponent(Object value, AbstractComponentType type, Object owner) throws HibernateException { ! visitProperties( type.getPropertyValues(value), type.getSubtypes(), type.getPropertyNames(), owner ); ! } ! ! public void visitCollection(Object collection, PersistentCollectionType type, Object owner) throws HibernateException { ! boolean shouldRecurse = true; ! if ( type instanceof MapType ) { ! shouldRecurse = processMap( (Map) collection, owner ); ! } ! else if ( type instanceof SetType) { ! shouldRecurse = processSet( (Set) collection, owner ); ! } ! else if ( type instanceof ListType) { ! shouldRecurse = processList( (List) collection, owner ); ! } ! else if ( type instanceof BagType) { ! shouldRecurse = processBag( (Collection) collection, owner ); ! } ! else if ( type.isArrayType() ) { ! shouldRecurse = processArray(collection, owner); ! } ! if (shouldRecurse) { ! CollectionMetadata cmd = factory.getCollectionMetadata( type.getRole() ); ! Iterator iter = type.getElementsIterator(collection); ! while ( iter.hasNext() ) { ! visitElement( iter.next(), cmd.getElementType(), owner ); ! } ! } ! } ! ! public boolean process(Object object) throws HibernateException { ! return RECURSE; ! } ! ! public boolean processMap(Map map, Object owner) throws HibernateException { ! return RECURSE; ! } ! public boolean processSet(Set set, Object owner) throws HibernateException { ! return RECURSE; ! } ! public boolean processList(List list, Object owner) throws HibernateException { ! return RECURSE; ! } ! public boolean processBag(Collection bag, Object owner) throws HibernateException { ! return RECURSE; ! } ! public boolean processArray(Object array, Object owner) throws HibernateException { ! return RECURSE; ! } ! ! public boolean processAssociation(Object value, Object owner) throws HibernateException { ! return STOP; ! } ! ! public void processPropertyValue(Object value, Type type, String propertyName, Object owner) throws HibernateException { ! // do nothing ! } ! ! public void processElement(Object value, Type type, Object owner) throws HibernateException { ! // do nothing ! } ! ! } --- 1,148 ---- ! //$Id$ ! package cirrus.hibernate.metadata; ! ! import java.util.Collection; ! import java.util.Iterator; ! import java.util.List; ! import java.util.Map; ! import java.util.Set; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.SessionFactory; ! import cirrus.hibernate.type.AbstractComponentType; ! import cirrus.hibernate.type.BagType; ! import cirrus.hibernate.type.ListType; ! import cirrus.hibernate.type.MapType; ! import cirrus.hibernate.type.PersistentCollectionType; ! import cirrus.hibernate.type.SetType; ! import cirrus.hibernate.type.Type; ! ! /** ! * Abstract visitor superclass implementing tree-walking functionality for a graph ! * of Hibernate-persistable objects, based upon known metadata. Applications that ! * need to process object graphs could implement subclasses that override appropriate ! * <tt>process...</tt> methods of this class. ! */ ! public class Visitor { ! ! public static final boolean RECURSE = true; ! public static final boolean STOP = false; ! ! private SessionFactory factory; ! ! /** ! * Create a new instance, using the specified <tt>SessionFactory</tt> as ! * a source of persistence metadata. ! */ ! public Visitor(SessionFactory factory) { ! this.factory = factory; ! } ! ! public void visit(Object object) throws HibernateException { ! if ( process(object) ) { ! ClassMetadata cmd = factory.getClassMetadata( object.getClass() ); ! visitProperties( cmd.getPropertyValues(object), cmd.getPropertyTypes(), cmd.getPropertyNames(), object ); ! } ! } ! ! public void visitProperties( Object[] values, Type[] types, String[] names, Object owner ) throws HibernateException { ! for ( int i=0; i<values.length; i++ ) visitProperty( values[i], types[i], names[i], owner ); ! } ! ! public void visitProperty(Object value, Type type, String name, Object owner) throws HibernateException { ! if ( type.isPersistentCollectionType() ) { ! visitCollection( value, (PersistentCollectionType) type, owner ); ! } ! else if ( type.isComponentType() ) { ! visitComponent( value, (AbstractComponentType) type, owner ); ! } ! else if ( type.isEntityType() ) { ! visitAssociation(value, type, owner); ! } ! else { ! processPropertyValue(value, type, name, owner); ! } ! } ! ! public void visitElement(Object value, Type type, Object owner) throws HibernateException { ! if ( type.isPersistentCollectionType() ) { ! visitCollection( value, (PersistentCollectionType) type, owner ); ! } ! else if ( type.isComponentType() ) { ! visitComponent( value, (AbstractComponentType) type, owner ); ! } ! else if ( type.isEntityType() ) { ! visitAssociation(value, type, owner); ! } ! else { ! processElement(value, type, owner); ! } ! } ! ! public void visitAssociation(Object value, Type type, Object owner) throws HibernateException { ! if ( processAssociation(value, owner) ) visit(value); ! } ! ! public void visitComponent(Object value, AbstractComponentType type, Object owner) throws HibernateException { ! visitProperties( type.getPropertyValues(value), type.getSubtypes(), type.getPropertyNames(), owner ); ! } ! ! public void visitCollection(Object collection, PersistentCollectionType type, Object owner) throws HibernateException { ! boolean shouldRecurse = true; ! if ( type instanceof MapType ) { ! shouldRecurse = processMap( (Map) collection, owner ); ! } ! else if ( type instanceof SetType) { ! shouldRecurse = processSet( (Set) collection, owner ); ! } ! else if ( type instanceof ListType) { ! shouldRecurse = processList( (List) collection, owner ); ! } ! else if ( type instanceof BagType) { ! shouldRecurse = processBag( (Collection) collection, owner ); ! } ! else if ( type.isArrayType() ) { ! shouldRecurse = processArray(collection, owner); ! } ! if (shouldRecurse) { ! CollectionMetadata cmd = factory.getCollectionMetadata( type.getRole() ); ! Iterator iter = type.getElementsIterator(collection); ! while ( iter.hasNext() ) { ! visitElement( iter.next(), cmd.getElementType(), owner ); ! } ! } ! } ! ! public boolean process(Object object) throws HibernateException { ! return RECURSE; ! } ! ! public boolean processMap(Map map, Object owner) throws HibernateException { ! return RECURSE; ! } ! public boolean processSet(Set set, Object owner) throws HibernateException { ! return RECURSE; ! } ! public boolean processList(List list, Object owner) throws HibernateException { ! return RECURSE; ! } ! public boolean processBag(Collection bag, Object owner) throws HibernateException { ! return RECURSE; ! } ! public boolean processArray(Object array, Object owner) throws HibernateException { ! return RECURSE; ! } ! ! public boolean processAssociation(Object value, Object owner) throws HibernateException { ! return STOP; ! } ! ! public void processPropertyValue(Object value, Type type, String propertyName, Object owner) throws HibernateException { ! // do nothing ! } ! ! public void processElement(Object value, Type type, Object owner) throws HibernateException { ! // do nothing ! } ! ! } |
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/map In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/map Modified Files: Array.java Collection.java Column.java Component.java Constraint.java ForeignKey.java Index.java IndexedCollection.java IntegerValue.java List.java Map.java OneToMany.java PrimaryKey.java PrimitiveArray.java Property.java RelationalModel.java Set.java Log Message: fixed broken line-endings and added a test Index: Array.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/Array.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Array.java 5 Oct 2002 07:52:10 -0000 1.12 --- Array.java 26 Nov 2002 03:35:42 -0000 1.13 *************** *** 9,13 **** import cirrus.hibernate.*; import org.w3c.dom.Node; ! import org.w3c.dom.NodeList; public class Array extends List { --- 9,13 ---- import cirrus.hibernate.*; import org.w3c.dom.Node; ! import org.w3c.dom.NodeList; public class Array extends List { *************** *** 67,69 **** } ! --- 67,69 ---- } ! Index: Collection.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/Collection.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** Collection.java 24 Nov 2002 11:48:11 -0000 1.48 --- Collection.java 26 Nov 2002 03:35:42 -0000 1.49 *************** *** 71,75 **** String barerole = atts.getNamedItem("role").getNodeValue(); role = prefix + Root.ROLE_SEPERATOR + barerole; ! toplevel = owner==null; --- 71,75 ---- String barerole = atts.getNamedItem("role").getNodeValue(); role = prefix + Root.ROLE_SEPERATOR + barerole; ! toplevel = owner==null; *************** *** 176,180 **** doneSecondPass=true; } ! public boolean isLazy() { return lazy; --- 176,180 ---- doneSecondPass=true; } ! public boolean isLazy() { return lazy; *************** *** 183,187 **** this.lazy = lazy; } ! public String getRole() { return role; --- 183,187 ---- this.lazy = lazy; } ! public String getRole() { return role; *************** *** 198,202 **** return false; } ! public boolean isOneToMany() { return isOneToMany; --- 198,202 ---- return false; } ! public boolean isOneToMany() { return isOneToMany; *************** *** 206,210 **** return toplevel; } ! public OneToMany getOneToMany() { return oneToMany; --- 206,210 ---- return toplevel; } ! public OneToMany getOneToMany() { return oneToMany; *************** *** 227,235 **** return cache; } ! public boolean isReadOnly() { return readonly; } ! } ! --- 227,235 ---- return cache; } ! public boolean isReadOnly() { return readonly; } ! } ! Index: Column.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/Column.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Column.java 27 Oct 2002 03:11:33 -0000 1.19 --- Column.java 26 Nov 2002 03:35:43 -0000 1.20 *************** *** 40,44 **** this.name = name; } ! public boolean isNullable() { return nullable; --- 40,44 ---- this.name = name; } ! public boolean isNullable() { return nullable; *************** *** 65,69 **** sqlType = (typeNode==null) ? null : typeNode.getNodeValue(); } ! public int getTypeIndex() { return typeIndex; --- 65,69 ---- sqlType = (typeNode==null) ? null : typeNode.getNodeValue(); } ! public int getTypeIndex() { return typeIndex; *************** *** 92,94 **** } ! --- 92,94 ---- } ! Index: Component.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/Component.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** Component.java 22 Nov 2002 00:27:08 -0000 1.34 --- Component.java 26 Nov 2002 03:35:43 -0000 1.35 *************** *** 81,85 **** //component path path += Root.ROLE_SEPERATOR + StringHelper.unqualify(className); ! NodeList list = node.getChildNodes(); for ( int i=0; i<list.getLength(); i++ ) { --- 81,85 ---- //component path path += Root.ROLE_SEPERATOR + StringHelper.unqualify(className); ! NodeList list = node.getChildNodes(); for ( int i=0; i<list.getLength(); i++ ) { *************** *** 156,158 **** } ! --- 156,158 ---- } ! Index: Constraint.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/Constraint.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Constraint.java 1 Oct 2002 01:25:30 -0000 1.8 --- Constraint.java 26 Nov 2002 03:35:43 -0000 1.9 *************** *** 16,20 **** public void setName(String name) { this.name = name; ! } public Iterator getColumnIterator() { return columns.iterator(); --- 16,20 ---- public void setName(String name) { this.name = name; ! } public Iterator getColumnIterator() { return columns.iterator(); *************** *** 48,50 **** public abstract String sqlConstraintString(Dialect d, String constraintName); } ! --- 48,50 ---- public abstract String sqlConstraintString(Dialect d, String constraintName); } ! Index: ForeignKey.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/ForeignKey.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ForeignKey.java 11 Oct 2002 04:37:43 -0000 1.11 --- ForeignKey.java 26 Nov 2002 03:35:43 -0000 1.12 *************** *** 12,16 **** private Table referencedTable; private Class referencedClass; ! public String sqlConstraintString(Dialect d, String constraintName) { String[] cols = new String[ getColumnSpan() ]; --- 12,16 ---- private Table referencedTable; private Class referencedClass; ! public String sqlConstraintString(Dialect d, String constraintName) { String[] cols = new String[ getColumnSpan() ]; *************** *** 51,55 **** public ForeignKey() { } ! } ! --- 51,55 ---- public ForeignKey() { } ! } ! Index: Index.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/Index.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Index.java 1 Oct 2002 01:25:30 -0000 1.4 --- Index.java 26 Nov 2002 03:35:43 -0000 1.5 *************** *** 1,24 **** ! //$Id$ ! package cirrus.hibernate.map; ! ! import java.util.ArrayList; ! import java.util.Iterator; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.engine.Mapping; ! import cirrus.hibernate.helpers.StringHelper; ! import cirrus.hibernate.sql.Dialect; ! ! public class Index implements RelationalModel { private Table table; private ArrayList columns = new ArrayList(); ! private String name; public String sqlCreateString(Dialect dialect, Mapping p) ! throws HibernateException { StringBuffer buf = new StringBuffer("create index ") .append( dialect.qualifyIndexName() ? name : StringHelper.unqualify(name) ) .append(" on ") .append( table.getQualifiedName() ) ! .append(" ("); Iterator iter = getColumnIterator(); while ( iter.hasNext() ) { --- 1,24 ---- ! //$Id$ ! package cirrus.hibernate.map; ! ! import java.util.ArrayList; ! import java.util.Iterator; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.engine.Mapping; ! import cirrus.hibernate.helpers.StringHelper; ! import cirrus.hibernate.sql.Dialect; ! ! public class Index implements RelationalModel { private Table table; private ArrayList columns = new ArrayList(); ! private String name; public String sqlCreateString(Dialect dialect, Mapping p) ! throws HibernateException { StringBuffer buf = new StringBuffer("create index ") .append( dialect.qualifyIndexName() ? name : StringHelper.unqualify(name) ) .append(" on ") .append( table.getQualifiedName() ) ! .append(" ("); Iterator iter = getColumnIterator(); while ( iter.hasNext() ) { *************** *** 27,52 **** } buf.append(")"); ! return buf.toString(); ! } public String sqlDropString(Dialect dialect) { return "drop index " + table.getQualifiedName() + '.' + name; ! } public Table getTable() { return table; ! } public void setTable(Table table) { this.table = table; ! } public Iterator getColumnIterator() { return columns.iterator(); ! } public void addColumn(Column column) { this.columns.add(column); ! } public String getName() { return name; ! } public void setName(String name) { this.name = name; ! } ! } --- 27,52 ---- } buf.append(")"); ! return buf.toString(); ! } public String sqlDropString(Dialect dialect) { return "drop index " + table.getQualifiedName() + '.' + name; ! } public Table getTable() { return table; ! } public void setTable(Table table) { this.table = table; ! } public Iterator getColumnIterator() { return columns.iterator(); ! } public void addColumn(Column column) { this.columns.add(column); ! } public String getName() { return name; ! } public void setName(String name) { this.name = name; ! } ! } Index: IndexedCollection.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/IndexedCollection.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** IndexedCollection.java 24 Nov 2002 11:48:11 -0000 1.9 --- IndexedCollection.java 26 Nov 2002 03:35:43 -0000 1.10 *************** *** 39,43 **** } ! } ! --- 39,43 ---- } ! } ! Index: IntegerValue.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/IntegerValue.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** IntegerValue.java 10 Feb 2002 10:03:21 -0000 1.7 --- IntegerValue.java 26 Nov 2002 03:35:43 -0000 1.8 *************** *** 19,23 **** col.setTypeIndex(0); } ! } ! --- 19,23 ---- col.setTypeIndex(0); } ! } ! Index: List.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/List.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** List.java 5 Oct 2002 07:52:10 -0000 1.13 --- List.java 26 Nov 2002 03:35:43 -0000 1.14 *************** *** 10,14 **** private boolean doneSecondPass; ! public List(Node node, String prefix, PersistentClass owner, Root root) throws MappingException { super(node, prefix, owner, root); --- 10,14 ---- private boolean doneSecondPass; ! public List(Node node, String prefix, PersistentClass owner, Root root) throws MappingException { super(node, prefix, owner, root); *************** *** 39,43 **** return cirrus.hibernate.collections.List.class; } ! } ! --- 39,43 ---- return cirrus.hibernate.collections.List.class; } ! } ! Index: Map.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/Map.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Map.java 9 Oct 2002 03:52:10 -0000 1.21 --- Map.java 26 Nov 2002 03:35:43 -0000 1.22 *************** *** 15,19 **** private Comparator comparator; private boolean doneSecondPass; ! public Map(Node node, String prefix, PersistentClass owner, Root root) throws MappingException { super(node, prefix, owner, root); --- 15,19 ---- private Comparator comparator; private boolean doneSecondPass; ! public Map(Node node, String prefix, PersistentClass owner, Root root) throws MappingException { super(node, prefix, owner, root); *************** *** 70,78 **** return sorted ? TypeFactory.sortedMap( getRole(), !isToplevel(), comparator ): TypeFactory.map( getRole(), !isToplevel() ); } ! public Class wrapperClass() { return sorted ? cirrus.hibernate.collections.SortedMap.class : cirrus.hibernate.collections.Map.class; } ! } ! --- 70,78 ---- return sorted ? TypeFactory.sortedMap( getRole(), !isToplevel(), comparator ): TypeFactory.map( getRole(), !isToplevel() ); } ! public Class wrapperClass() { return sorted ? cirrus.hibernate.collections.SortedMap.class : cirrus.hibernate.collections.Map.class; } ! } ! Index: OneToMany.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/OneToMany.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** OneToMany.java 27 Oct 2002 03:11:33 -0000 1.12 --- OneToMany.java 26 Nov 2002 03:35:43 -0000 1.13 *************** *** 6,10 **** import cirrus.hibernate.Hibernate; import cirrus.hibernate.MappingException; ! public class OneToMany { --- 6,10 ---- import cirrus.hibernate.Hibernate; import cirrus.hibernate.MappingException; ! public class OneToMany { *************** *** 32,36 **** public Table getReferencingTable() { return referencingTable; ! } } ! --- 32,36 ---- public Table getReferencingTable() { return referencingTable; ! } } ! Index: PrimaryKey.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/PrimaryKey.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PrimaryKey.java 1 Jul 2002 13:45:32 -0000 1.8 --- PrimaryKey.java 26 Nov 2002 03:35:43 -0000 1.9 *************** *** 28,32 **** } return buf.append(")").toString(); ! } } ! --- 28,32 ---- } return buf.append(")").toString(); ! } } ! Index: PrimitiveArray.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/PrimitiveArray.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PrimitiveArray.java 5 Oct 2002 07:52:10 -0000 1.5 --- PrimitiveArray.java 26 Nov 2002 03:35:43 -0000 1.6 *************** *** 6,10 **** import org.w3c.dom.Node; ! public class PrimitiveArray extends Array { public PrimitiveArray(Node node, String prefix, PersistentClass owner, Root root) throws MappingException { super(node, prefix, owner, root); --- 6,10 ---- import org.w3c.dom.Node; ! public class PrimitiveArray extends Array { public PrimitiveArray(Node node, String prefix, PersistentClass owner, Root root) throws MappingException { super(node, prefix, owner, root); *************** *** 16,18 **** } ! --- 16,18 ---- } ! Index: Property.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/Property.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Property.java 10 Oct 2002 05:17:27 -0000 1.21 --- Property.java 26 Nov 2002 03:35:43 -0000 1.22 *************** *** 26,30 **** public Iterator getColumnIterator() { return value.getColumnIterator(); ! } public String getName() { return name; --- 26,30 ---- public Iterator getColumnIterator() { return value.getColumnIterator(); ! } public String getName() { return name; *************** *** 53,57 **** return (propertyName==null) ? null : propertyName.getNodeValue(); } ! public Cascades.CascadeStyle cascade() throws MappingException { if ( value.getType().isComponentType() ) { --- 53,57 ---- return (propertyName==null) ? null : propertyName.getNodeValue(); } ! public Cascades.CascadeStyle cascade() throws MappingException { if ( value.getType().isComponentType() ) { *************** *** 84,86 **** } ! --- 84,86 ---- } ! Index: RelationalModel.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/RelationalModel.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RelationalModel.java 1 Oct 2002 01:25:30 -0000 1.4 --- RelationalModel.java 26 Nov 2002 03:35:43 -0000 1.5 *************** *** 10,12 **** public String sqlDropString(Dialect dialect); } ! --- 10,12 ---- public String sqlDropString(Dialect dialect); } ! Index: Set.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/Set.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Set.java 24 Nov 2002 11:48:11 -0000 1.14 --- Set.java 26 Nov 2002 03:35:43 -0000 1.15 *************** *** 85,87 **** } ! --- 85,87 ---- } ! |
From: <one...@us...> - 2002-11-26 03:36:15
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/loader Modified Files: CollectionInitializer.java OneToManyLoader.java UniqueEntityLoader.java Log Message: fixed broken line-endings and added a test Index: CollectionInitializer.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/CollectionInitializer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CollectionInitializer.java 5 Nov 2002 06:46:06 -0000 1.4 --- CollectionInitializer.java 26 Nov 2002 03:35:42 -0000 1.5 *************** *** 1,21 **** ! //$Id$ ! package cirrus.hibernate.loader; ! ! import java.io.Serializable; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.collections.PersistentCollection; ! import cirrus.hibernate.engine.SessionImplementor; ! ! /** ! * An interface for collection loaders ! * @see CollectionLoader ! * @see OneToManyLoader ! */ ! public interface CollectionInitializer { ! /** ! * Initialize the given collection ! */ ! public void initialize(Serializable id, PersistentCollection collection, SessionImplementor session) throws SQLException, HibernateException; ! } --- 1,21 ---- ! //$Id$ ! package cirrus.hibernate.loader; ! ! import java.io.Serializable; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.collections.PersistentCollection; ! import cirrus.hibernate.engine.SessionImplementor; ! ! /** ! * An interface for collection loaders ! * @see CollectionLoader ! * @see OneToManyLoader ! */ ! public interface CollectionInitializer { ! /** ! * Initialize the given collection ! */ ! public void initialize(Serializable id, PersistentCollection collection, SessionImplementor session) throws SQLException, HibernateException; ! } Index: OneToManyLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/OneToManyLoader.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** OneToManyLoader.java 25 Nov 2002 07:25:20 -0000 1.12 --- OneToManyLoader.java 26 Nov 2002 03:35:42 -0000 1.13 *************** *** 59,63 **** outerJoinGenerator.outerJoinStringAfterFrom(associations), // WHERE CLAUSE ! whereString( collPersister.getKeyColumnNames(), alias ), // OUTER JOINS (Insertion Point 2) outerJoinGenerator.outerJoinStringAfterWhere(associations) + --- 59,63 ---- outerJoinGenerator.outerJoinStringAfterFrom(associations), // WHERE CLAUSE ! whereString( collPersister.getKeyColumnNames(), alias ), //BUG!!!!!!!!!!! // OUTER JOINS (Insertion Point 2) outerJoinGenerator.outerJoinStringAfterWhere(associations) + Index: UniqueEntityLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/UniqueEntityLoader.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** UniqueEntityLoader.java 5 Nov 2002 06:46:06 -0000 1.3 --- UniqueEntityLoader.java 26 Nov 2002 03:35:42 -0000 1.4 *************** *** 1,16 **** ! //$Id$ ! package cirrus.hibernate.loader; ! ! import java.io.Serializable; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.engine.SessionImplementor; ! ! public interface UniqueEntityLoader { ! /** ! * Load an entity instance. If <tt>optionalObject</tt> is supplied, ! * load the entity state into the given (uninitialized) object. ! */ ! public Object load(SessionImplementor session, Serializable id, Object optionalObject) throws HibernateException, SQLException; ! } --- 1,16 ---- ! //$Id$ ! package cirrus.hibernate.loader; ! ! import java.io.Serializable; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.engine.SessionImplementor; ! ! public interface UniqueEntityLoader { ! /** ! * Load an entity instance. If <tt>optionalObject</tt> is supplied, ! * load the entity state into the given (uninitialized) object. ! */ ! public Object load(SessionImplementor session, Serializable id, Object optionalObject) throws HibernateException, SQLException; ! } |
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/impl Modified Files: BatcherImpl.java BatchingBatcher.java CacheEntry.java CollectionPersister.java FilterImpl.java NonBatchingBatcher.java ScrollableResultsImpl.java Log Message: fixed broken line-endings and added a test Index: BatcherImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/BatcherImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BatcherImpl.java 25 Nov 2002 10:42:54 -0000 1.2 --- BatcherImpl.java 26 Nov 2002 03:35:42 -0000 1.3 *************** *** 1,117 **** ! //$Id$ ! package cirrus.hibernate.impl; ! ! import java.sql.PreparedStatement; ! import java.sql.SQLException; ! import java.util.HashSet; ! import java.util.Iterator; ! ! import org.apache.commons.logging.Log; ! import org.apache.commons.logging.LogFactory; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.engine.Batcher; ! import cirrus.hibernate.engine.SessionFactoryImplementor; ! import cirrus.hibernate.engine.SessionImplementor; ! ! /** ! * Manages prepared statements and batching. Class exists to enforce seperation of concerns. ! */ ! public abstract class BatcherImpl implements Batcher { ! ! public static int open; ! ! protected static final Log log = LogFactory.getLog(BatcherImpl.class); ! ! protected final SessionImplementor session; ! protected final SessionFactoryImplementor factory; ! ! private PreparedStatement batchUpdate; ! private String batchUpdateSQL; ! ! private HashSet statementsToClose = new HashSet(); ! ! public BatcherImpl(SessionImplementor session) { ! this.session = session; ! this.factory = session.getFactory(); ! } ! ! protected PreparedStatement getStatement() { ! return batchUpdate; ! } ! ! public PreparedStatement prepareStatement(String sql) throws SQLException, HibernateException { ! executeBatch(); ! logOpen(); ! return factory.getPreparedStatement( session.connection(), sql, false ); ! } ! public PreparedStatement prepareQueryStatement(String sql, boolean scrollable) throws SQLException, HibernateException { ! logOpen(); ! PreparedStatement ps = factory.getPreparedStatement( session.connection(), sql, scrollable ); ! factory.setFetchSize(ps); ! statementsToClose.add(ps); ! return ps; ! } ! ! public void closeQueryStatement(PreparedStatement ps) throws SQLException { ! statementsToClose.remove(ps); ! logClose(); ! factory.closePreparedStatement(ps); ! } ! ! public void closeStatement(PreparedStatement ps) throws SQLException { ! logClose(); ! factory.closePreparedStatement(ps); ! } ! ! public PreparedStatement prepareBatchStatement(String sql) throws SQLException, HibernateException { ! if ( !sql.equals(batchUpdateSQL) ) { ! batchUpdate=prepareStatement(sql); // calls executeBatch() ! batchUpdateSQL=sql; ! } ! return batchUpdate; ! } ! ! public void executeBatch() throws SQLException, HibernateException { ! if (batchUpdate!=null) { ! final PreparedStatement ps = batchUpdate; ! batchUpdate=null; ! batchUpdateSQL=null; ! try { ! doExecuteBatch(ps); ! } ! finally { ! closeStatement(ps); ! } ! } ! } ! ! public void closeStatements() { ! Iterator iter = statementsToClose.iterator(); ! while ( iter.hasNext() ) { ! try { ! closeStatement( (PreparedStatement) iter.next() ); ! } ! catch (SQLException e) { ! // no big deal ! log.warn("Could not close a JDBC statement", e); ! } ! iter.remove(); ! } ! statementsToClose.clear(); ! } ! ! protected abstract void doExecuteBatch(PreparedStatement ps) throws SQLException, HibernateException; ! ! private static void logOpen() { ! if ( log.isTraceEnabled() ) { ! open++; ! log.trace( open + " open PreparedStatements" ); ! } ! } ! ! private static void logClose() { ! if ( log.isTraceEnabled() ) ! open--; ! } ! } --- 1,117 ---- ! //$Id$ ! package cirrus.hibernate.impl; ! ! import java.sql.PreparedStatement; ! import java.sql.SQLException; ! import java.util.HashSet; ! import java.util.Iterator; ! ! import org.apache.commons.logging.Log; ! import org.apache.commons.logging.LogFactory; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.engine.Batcher; ! import cirrus.hibernate.engine.SessionFactoryImplementor; ! import cirrus.hibernate.engine.SessionImplementor; ! ! /** ! * Manages prepared statements and batching. Class exists to enforce seperation of concerns. ! */ ! public abstract class BatcherImpl implements Batcher { ! ! public static int open; ! ! protected static final Log log = LogFactory.getLog(BatcherImpl.class); ! ! protected final SessionImplementor session; ! protected final SessionFactoryImplementor factory; ! ! private PreparedStatement batchUpdate; ! private String batchUpdateSQL; ! ! private HashSet statementsToClose = new HashSet(); ! ! public BatcherImpl(SessionImplementor session) { ! this.session = session; ! this.factory = session.getFactory(); ! } ! ! protected PreparedStatement getStatement() { ! return batchUpdate; ! } ! ! public PreparedStatement prepareStatement(String sql) throws SQLException, HibernateException { ! executeBatch(); ! logOpen(); ! return factory.getPreparedStatement( session.connection(), sql, false ); ! } ! public PreparedStatement prepareQueryStatement(String sql, boolean scrollable) throws SQLException, HibernateException { ! logOpen(); ! PreparedStatement ps = factory.getPreparedStatement( session.connection(), sql, scrollable ); ! factory.setFetchSize(ps); ! statementsToClose.add(ps); ! return ps; ! } ! ! public void closeQueryStatement(PreparedStatement ps) throws SQLException { ! statementsToClose.remove(ps); ! logClose(); ! factory.closePreparedStatement(ps); ! } ! ! public void closeStatement(PreparedStatement ps) throws SQLException { ! logClose(); ! factory.closePreparedStatement(ps); ! } ! ! public PreparedStatement prepareBatchStatement(String sql) throws SQLException, HibernateException { ! if ( !sql.equals(batchUpdateSQL) ) { ! batchUpdate=prepareStatement(sql); // calls executeBatch() ! batchUpdateSQL=sql; ! } ! return batchUpdate; ! } ! ! public void executeBatch() throws SQLException, HibernateException { ! if (batchUpdate!=null) { ! final PreparedStatement ps = batchUpdate; ! batchUpdate=null; ! batchUpdateSQL=null; ! try { ! doExecuteBatch(ps); ! } ! finally { ! closeStatement(ps); ! } ! } ! } ! ! public void closeStatements() { ! Iterator iter = statementsToClose.iterator(); ! while ( iter.hasNext() ) { ! try { ! closeStatement( (PreparedStatement) iter.next() ); ! } ! catch (SQLException e) { ! // no big deal ! log.warn("Could not close a JDBC statement", e); ! } ! iter.remove(); ! } ! statementsToClose.clear(); ! } ! ! protected abstract void doExecuteBatch(PreparedStatement ps) throws SQLException, HibernateException; ! ! private static void logOpen() { ! if ( log.isTraceEnabled() ) { ! open++; ! log.trace( open + " open PreparedStatements" ); ! } ! } ! ! private static void logClose() { ! if ( log.isTraceEnabled() ) ! open--; ! } ! } Index: BatchingBatcher.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/BatchingBatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BatchingBatcher.java 31 Oct 2002 16:58:14 -0000 1.1 --- BatchingBatcher.java 26 Nov 2002 03:35:42 -0000 1.2 *************** *** 1,73 **** ! //$Id$ ! package cirrus.hibernate.impl; ! ! import java.sql.PreparedStatement; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.engine.SessionImplementor; ! import cirrus.hibernate.helpers.JDBCExceptionReporter; ! ! /** ! * An implementation of the <tt>Batcher</tt> interface that actually uses batching ! */ ! public class BatchingBatcher extends BatcherImpl { ! ! private int batchSize; ! ! public BatchingBatcher(SessionImplementor session) { ! super(session); ! } ! ! public void addToBatch(int expectedRowCount) throws SQLException, HibernateException { ! ! log.trace("Adding to batch"); ! PreparedStatement batchUpdate = getStatement(); ! batchUpdate.addBatch(); ! batchSize++; ! if ( batchSize==factory.getJdbcBatchSize() ) { ! try { ! doExecuteBatch(batchUpdate); ! } ! catch (SQLException sqle) { ! closeStatement(batchUpdate); ! throw sqle; ! } ! catch (HibernateException he) { ! closeStatement(batchUpdate); ! throw he; ! } ! } ! ! } ! ! protected void doExecuteBatch(PreparedStatement ps) throws SQLException, HibernateException { ! if ( log.isDebugEnabled() ) ! log.debug("Executing batch size: " + batchSize ); ! ! try { ! if (batchSize!=0) { ! final int[] results = ps.executeBatch(); ! // check return codes ! for ( int i=0; i<batchSize; i++ ) { ! if ( results[i]==-3 ) throw new HibernateException("Batch update failed"); ! } ! } ! } ! catch(SQLException sqle) { ! JDBCExceptionReporter.logExceptions(sqle); ! throw sqle; ! } ! catch(RuntimeException re) { ! log.error("Exception executing batch: ", re); ! throw re; ! } ! finally { ! batchSize=0; ! //ps.clearBatch(); ! } ! } ! ! ! ! } --- 1,73 ---- ! //$Id$ ! package cirrus.hibernate.impl; ! ! import java.sql.PreparedStatement; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.engine.SessionImplementor; ! import cirrus.hibernate.helpers.JDBCExceptionReporter; ! ! /** ! * An implementation of the <tt>Batcher</tt> interface that actually uses batching ! */ ! public class BatchingBatcher extends BatcherImpl { ! ! private int batchSize; ! ! public BatchingBatcher(SessionImplementor session) { ! super(session); ! } ! ! public void addToBatch(int expectedRowCount) throws SQLException, HibernateException { ! ! log.trace("Adding to batch"); ! PreparedStatement batchUpdate = getStatement(); ! batchUpdate.addBatch(); ! batchSize++; ! if ( batchSize==factory.getJdbcBatchSize() ) { ! try { ! doExecuteBatch(batchUpdate); ! } ! catch (SQLException sqle) { ! closeStatement(batchUpdate); ! throw sqle; ! } ! catch (HibernateException he) { ! closeStatement(batchUpdate); ! throw he; ! } ! } ! ! } ! ! protected void doExecuteBatch(PreparedStatement ps) throws SQLException, HibernateException { ! if ( log.isDebugEnabled() ) ! log.debug("Executing batch size: " + batchSize ); ! ! try { ! if (batchSize!=0) { ! final int[] results = ps.executeBatch(); ! // check return codes ! for ( int i=0; i<batchSize; i++ ) { ! if ( results[i]==-3 ) throw new HibernateException("Batch update failed"); ! } ! } ! } ! catch(SQLException sqle) { ! JDBCExceptionReporter.logExceptions(sqle); ! throw sqle; ! } ! catch(RuntimeException re) { ! log.error("Exception executing batch: ", re); ! throw re; ! } ! finally { ! batchSize=0; ! //ps.clearBatch(); ! } ! } ! ! ! ! } Index: CacheEntry.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/CacheEntry.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CacheEntry.java 1 Oct 2002 16:42:40 -0000 1.4 --- CacheEntry.java 26 Nov 2002 03:35:42 -0000 1.5 *************** *** 1,65 **** ! //$Id$ ! package cirrus.hibernate.impl; ! ! import java.io.Serializable; ! import java.sql.SQLException; ! ! import cirrus.hibernate.AssertionFailure; ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.Lifecycle; ! import cirrus.hibernate.engine.*; ! import cirrus.hibernate.persister.ClassPersister; ! import cirrus.hibernate.type.Type; ! ! /** ! * A cached instance of a persistent class ! */ ! public final class CacheEntry implements Serializable { ! ! Object[] state; ! Class subclass; ! public Class getSubclass() { ! return subclass; ! } ! public CacheEntry(Object object, ClassPersister persister, SessionImplementor session) throws HibernateException, SQLException { ! state = disassemble(object, persister, session); ! subclass = object.getClass(); ! } ! ! ! private Object[] disassemble(Object object, ClassPersister persister, SessionImplementor session) throws HibernateException { ! Object[] values = persister.getPropertyValues(object); ! Type[] propertyTypes = persister.getPropertyTypes(); ! for ( int i=0; i<values.length; i++ ) { ! values[i] = propertyTypes[i].disassemble(values[i], session); ! } ! return values; ! } ! ! ! public Object[] assemble(Object instance, Serializable id, ClassPersister persister, SessionImplementor session) throws SQLException, HibernateException { ! ! if ( subclass!=persister.getMappedClass() ) throw new AssertionFailure("Tried to assemble a different subclass instance"); ! ! return assemble(state, instance, id, persister, session); ! ! } ! ! private Object[] assemble(Object[] values, Object result, Serializable id, ClassPersister persister, SessionImplementor session) throws HibernateException, SQLException { ! Type[] propertyTypes = persister.getPropertyTypes(); ! Object[] assembledProps = new Object[propertyTypes.length]; ! for ( int i=0; i<values.length; i++ ) { ! assembledProps[i] = propertyTypes[i].assemble( (Serializable) values[i], session, result ); ! } ! persister.setPropertyValues(result, assembledProps); ! persister.setIdentifier(result, id); ! ! if ( persister.implementsLifecycle() ) { ! ( (Lifecycle) result ).onLoad(session, id); ! } ! ! return assembledProps; ! } ! ! ! } --- 1,65 ---- ! //$Id$ ! package cirrus.hibernate.impl; ! ! import java.io.Serializable; ! import java.sql.SQLException; ! ! import cirrus.hibernate.AssertionFailure; ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.Lifecycle; ! import cirrus.hibernate.engine.*; ! import cirrus.hibernate.persister.ClassPersister; ! import cirrus.hibernate.type.Type; ! ! /** ! * A cached instance of a persistent class ! */ ! public final class CacheEntry implements Serializable { ! ! Object[] state; ! Class subclass; ! public Class getSubclass() { ! return subclass; ! } ! public CacheEntry(Object object, ClassPersister persister, SessionImplementor session) throws HibernateException, SQLException { ! state = disassemble(object, persister, session); ! subclass = object.getClass(); ! } ! ! ! private Object[] disassemble(Object object, ClassPersister persister, SessionImplementor session) throws HibernateException { ! Object[] values = persister.getPropertyValues(object); ! Type[] propertyTypes = persister.getPropertyTypes(); ! for ( int i=0; i<values.length; i++ ) { ! values[i] = propertyTypes[i].disassemble(values[i], session); ! } ! return values; ! } ! ! ! public Object[] assemble(Object instance, Serializable id, ClassPersister persister, SessionImplementor session) throws SQLException, HibernateException { ! ! if ( subclass!=persister.getMappedClass() ) throw new AssertionFailure("Tried to assemble a different subclass instance"); ! ! return assemble(state, instance, id, persister, session); ! ! } ! ! private Object[] assemble(Object[] values, Object result, Serializable id, ClassPersister persister, SessionImplementor session) throws HibernateException, SQLException { ! Type[] propertyTypes = persister.getPropertyTypes(); ! Object[] assembledProps = new Object[propertyTypes.length]; ! for ( int i=0; i<values.length; i++ ) { ! assembledProps[i] = propertyTypes[i].assemble( (Serializable) values[i], session, result ); ! } ! persister.setPropertyValues(result, assembledProps); ! persister.setIdentifier(result, id); ! ! if ( persister.implementsLifecycle() ) { ! ( (Lifecycle) result ).onLoad(session, id); ! } ! ! return assembledProps; ! } ! ! ! } Index: CollectionPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/CollectionPersister.java,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** CollectionPersister.java 24 Nov 2002 11:48:10 -0000 1.84 --- CollectionPersister.java 26 Nov 2002 03:35:42 -0000 1.85 *************** *** 307,311 **** Object element = getElementType().nullSafeGet(rs, unquotedElementColumnNames, session, null); return element; ! } public Object readIndex(ResultSet rs, SessionImplementor session) throws HibernateException, SQLException { return getIndexType().nullSafeGet(rs, unquotedIndexColumnNames, session, null); --- 307,311 ---- Object element = getElementType().nullSafeGet(rs, unquotedElementColumnNames, session, null); return element; ! } public Object readIndex(ResultSet rs, SessionImplementor session) throws HibernateException, SQLException { return getIndexType().nullSafeGet(rs, unquotedIndexColumnNames, session, null); Index: FilterImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/FilterImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FilterImpl.java 24 Oct 2002 20:03:54 -0000 1.1 --- FilterImpl.java 26 Nov 2002 03:35:42 -0000 1.2 *************** *** 1,50 **** ! package cirrus.hibernate.impl; ! ! import java.sql.SQLException; ! import java.util.Iterator; ! import java.util.List; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.ScrollableResults; ! import cirrus.hibernate.engine.SessionImplementor; ! import cirrus.hibernate.type.Type; ! ! /** ! * ! */ ! public class FilterImpl extends QueryImpl { ! ! private Object collection; ! ! public FilterImpl(String queryString, Object collection, SessionImplementor session) { ! super(queryString, session); ! this.collection = collection; ! } ! ! ! /** ! * @see cirrus.hibernate.Query#iterate() ! */ ! public Iterator iterate() throws SQLException, HibernateException { ! values.add(0, null); ! types.add(0, null); ! return session.iterateFilter(collection, queryString, values.toArray(), (Type[]) types.toArray(NO_TYPES), selection, namedParams); ! } ! ! /** ! * @see cirrus.hibernate.Query#list() ! */ ! public List list() throws SQLException, HibernateException { ! values.add(0, null); ! types.add(0, null); ! return session.filter(collection, queryString, values.toArray(), (Type[]) types.toArray(NO_TYPES), selection, namedParams); ! } ! ! /** ! * @see cirrus.hibernate.Query#scroll() ! */ ! public ScrollableResults scroll() throws SQLException, HibernateException { ! throw new UnsupportedOperationException("Can't scroll filters"); ! } ! ! } --- 1,50 ---- ! package cirrus.hibernate.impl; ! ! import java.sql.SQLException; ! import java.util.Iterator; ! import java.util.List; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.ScrollableResults; ! import cirrus.hibernate.engine.SessionImplementor; ! import cirrus.hibernate.type.Type; ! ! /** ! * ! */ ! public class FilterImpl extends QueryImpl { ! ! private Object collection; ! ! public FilterImpl(String queryString, Object collection, SessionImplementor session) { ! super(queryString, session); ! this.collection = collection; ! } ! ! ! /** ! * @see cirrus.hibernate.Query#iterate() ! */ ! public Iterator iterate() throws SQLException, HibernateException { ! values.add(0, null); ! types.add(0, null); ! return session.iterateFilter(collection, queryString, values.toArray(), (Type[]) types.toArray(NO_TYPES), selection, namedParams); ! } ! ! /** ! * @see cirrus.hibernate.Query#list() ! */ ! public List list() throws SQLException, HibernateException { ! values.add(0, null); ! types.add(0, null); ! return session.filter(collection, queryString, values.toArray(), (Type[]) types.toArray(NO_TYPES), selection, namedParams); ! } ! ! /** ! * @see cirrus.hibernate.Query#scroll() ! */ ! public ScrollableResults scroll() throws SQLException, HibernateException { ! throw new UnsupportedOperationException("Can't scroll filters"); ! } ! ! } Index: NonBatchingBatcher.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/NonBatchingBatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NonBatchingBatcher.java 31 Oct 2002 16:58:14 -0000 1.1 --- NonBatchingBatcher.java 26 Nov 2002 03:35:42 -0000 1.2 *************** *** 1,29 **** ! //$Id$ ! package cirrus.hibernate.impl; ! ! import java.sql.PreparedStatement; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.engine.SessionImplementor; ! ! /** ! * An implementation of the <tt>Batcher</tt> interface that does no batching ! */ ! public class NonBatchingBatcher extends BatcherImpl { ! ! public NonBatchingBatcher(SessionImplementor session) { ! super(session); ! } ! ! public void addToBatch(int expectedRowCount) throws SQLException, HibernateException { ! int rowCount = getStatement().executeUpdate(); ! //negative expected row count means we don't know how many rows to expect ! if ( expectedRowCount>0 && expectedRowCount!=rowCount ) ! throw new HibernateException("SQL update or deletion failed (row not found)"); ! } ! ! protected void doExecuteBatch(PreparedStatement ps) throws SQLException, HibernateException { ! } ! ! } --- 1,29 ---- ! //$Id$ ! package cirrus.hibernate.impl; ! ! import java.sql.PreparedStatement; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.engine.SessionImplementor; ! ! /** ! * An implementation of the <tt>Batcher</tt> interface that does no batching ! */ ! public class NonBatchingBatcher extends BatcherImpl { ! ! public NonBatchingBatcher(SessionImplementor session) { ! super(session); ! } ! ! public void addToBatch(int expectedRowCount) throws SQLException, HibernateException { ! int rowCount = getStatement().executeUpdate(); ! //negative expected row count means we don't know how many rows to expect ! if ( expectedRowCount>0 && expectedRowCount!=rowCount ) ! throw new HibernateException("SQL update or deletion failed (row not found)"); ! } ! ! protected void doExecuteBatch(PreparedStatement ps) throws SQLException, HibernateException { ! } ! ! } Index: ScrollableResultsImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/ScrollableResultsImpl.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ScrollableResultsImpl.java 21 Nov 2002 09:03:12 -0000 1.6 --- ScrollableResultsImpl.java 26 Nov 2002 03:35:42 -0000 1.7 *************** *** 1,238 **** ! //$Id$ ! package cirrus.hibernate.impl; ! ! import java.math.BigDecimal; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.util.Calendar; ! import java.util.Date; ! import java.util.Locale; ! import java.util.TimeZone; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.ScrollableResults; ! import cirrus.hibernate.engine.*; ! import cirrus.hibernate.query.QueryTranslator; ! import cirrus.hibernate.type.Type; ! ! public class ScrollableResultsImpl implements ScrollableResults { ! ! private final ResultSet rs; ! private final SessionImplementor sess; ! private final Type[] types; ! private final boolean single; ! private final String[][] names; ! ! /** ! * @see cirrus.hibernate.ScrollableResults#advance(int) ! */ ! public boolean scroll(int i) throws SQLException, HibernateException { ! return rs.relative(i); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#first() ! */ ! public boolean first() throws SQLException, HibernateException { ! return rs.first(); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#last() ! */ ! public boolean last() throws SQLException, HibernateException { ! return rs.last(); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#advance() ! */ ! public boolean next() throws SQLException, HibernateException { ! return rs.next(); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#retreat() ! */ ! public boolean previous() throws SQLException, HibernateException { ! return rs.previous(); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#get() ! */ ! public Object[] get() throws SQLException, HibernateException { ! Object[] row = new Object[types.length]; ! for (int i=0; i<types.length; i++) { ! row[i] = types[i].nullSafeGet( rs, names[i], sess, null ); ! } ! return row; ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#get(int) ! */ ! public Object get(int col) throws SQLException, HibernateException { ! return types[col].nullSafeGet( rs, names[col], sess, null ); ! } ! ! public ScrollableResultsImpl(ResultSet rs, SessionImplementor sess, Type[] types) ! throws HibernateException, SQLException { ! ! this.rs=rs; ! this.sess = sess; ! this.types = types; ! ! single = types.length==1; ! ! names = new String[types.length][]; ! for (int i=0; i<types.length; i++) { ! int span = types[i].getColumnSpan( sess.getFactory() ); ! names[i] = new String[span]; ! for ( int j=0; j<span; j++ ) { ! names[i][j] = QueryTranslator.scalarName(i, j); ! } ! } ! ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getBigDecimal(int) ! */ ! public BigDecimal getBigDecimal(int col) ! throws SQLException, HibernateException { ! return (BigDecimal) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getBinary(int) ! */ ! public byte[] getBinary(int col) throws SQLException, HibernateException { ! return (byte[]) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getBoolean(int) ! */ ! public Boolean getBoolean(int col) throws SQLException, HibernateException { ! return (Boolean) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getByte(int) ! */ ! public Byte getByte(int col) throws SQLException, HibernateException { ! return (Byte) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getCharacter(int) ! */ ! public Character getCharacter(int col) throws SQLException, HibernateException { ! return (Character) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getDate(int) ! */ ! public Date getDate(int col) throws SQLException, HibernateException { ! return (Date) get(col); ! } ! ! public Calendar getCalendar(int col) throws SQLException, HibernateException { ! return (Calendar) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getDouble(int) ! */ ! public Double getDouble(int col) throws SQLException, HibernateException { ! return (Double) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getFloat(int) ! */ ! public Float getFloat(int col) throws SQLException, HibernateException { ! return (Float) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getInteger(int) ! */ ! public Integer getInteger(int col) throws SQLException, HibernateException { ! return (Integer) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getLong(int) ! */ ! public Long getLong(int col) throws SQLException, HibernateException { ! return (Long) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getShort(int) ! */ ! public Short getShort(int col) throws SQLException, HibernateException { ! return (Short) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getString(int) ! */ ! public String getString(int col) throws SQLException, HibernateException { ! return (String) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#afterLast() ! */ ! public void afterLast() throws SQLException, HibernateException { ! rs.afterLast(); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#beforeFirst() ! */ ! public void beforeFirst() throws SQLException, HibernateException { ! rs.beforeFirst(); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#close() ! */ ! public void close() throws SQLException, HibernateException { ! rs.close(); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getLocale(int) ! */ ! public Locale getLocale(int col) throws SQLException, HibernateException { ! return (Locale) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getCurrency(int) ! */ ! /*public Currency getCurrency(int col) throws SQLException, HibernateException { ! return (Currency) get(col); ! }*/ ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getTimeZone(int) ! */ ! public TimeZone getTimeZone(int col) throws SQLException, HibernateException { ! return (TimeZone) get(col); ! } ! ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getType(int) ! */ ! public Type getType(int i) { ! return types[i]; ! } ! ! } --- 1,238 ---- ! //$Id$ ! package cirrus.hibernate.impl; ! ! import java.math.BigDecimal; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.util.Calendar; ! import java.util.Date; ! import java.util.Locale; ! import java.util.TimeZone; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.ScrollableResults; ! import cirrus.hibernate.engine.*; ! import cirrus.hibernate.query.QueryTranslator; ! import cirrus.hibernate.type.Type; ! ! public class ScrollableResultsImpl implements ScrollableResults { ! ! private final ResultSet rs; ! private final SessionImplementor sess; ! private final Type[] types; ! private final boolean single; ! private final String[][] names; ! ! /** ! * @see cirrus.hibernate.ScrollableResults#advance(int) ! */ ! public boolean scroll(int i) throws SQLException, HibernateException { ! return rs.relative(i); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#first() ! */ ! public boolean first() throws SQLException, HibernateException { ! return rs.first(); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#last() ! */ ! public boolean last() throws SQLException, HibernateException { ! return rs.last(); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#advance() ! */ ! public boolean next() throws SQLException, HibernateException { ! return rs.next(); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#retreat() ! */ ! public boolean previous() throws SQLException, HibernateException { ! return rs.previous(); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#get() ! */ ! public Object[] get() throws SQLException, HibernateException { ! Object[] row = new Object[types.length]; ! for (int i=0; i<types.length; i++) { ! row[i] = types[i].nullSafeGet( rs, names[i], sess, null ); ! } ! return row; ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#get(int) ! */ ! public Object get(int col) throws SQLException, HibernateException { ! return types[col].nullSafeGet( rs, names[col], sess, null ); ! } ! ! public ScrollableResultsImpl(ResultSet rs, SessionImplementor sess, Type[] types) ! throws HibernateException, SQLException { ! ! this.rs=rs; ! this.sess = sess; ! this.types = types; ! ! single = types.length==1; ! ! names = new String[types.length][]; ! for (int i=0; i<types.length; i++) { ! int span = types[i].getColumnSpan( sess.getFactory() ); ! names[i] = new String[span]; ! for ( int j=0; j<span; j++ ) { ! names[i][j] = QueryTranslator.scalarName(i, j); ! } ! } ! ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getBigDecimal(int) ! */ ! public BigDecimal getBigDecimal(int col) ! throws SQLException, HibernateException { ! return (BigDecimal) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getBinary(int) ! */ ! public byte[] getBinary(int col) throws SQLException, HibernateException { ! return (byte[]) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getBoolean(int) ! */ ! public Boolean getBoolean(int col) throws SQLException, HibernateException { ! return (Boolean) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getByte(int) ! */ ! public Byte getByte(int col) throws SQLException, HibernateException { ! return (Byte) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getCharacter(int) ! */ ! public Character getCharacter(int col) throws SQLException, HibernateException { ! return (Character) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getDate(int) ! */ ! public Date getDate(int col) throws SQLException, HibernateException { ! return (Date) get(col); ! } ! ! public Calendar getCalendar(int col) throws SQLException, HibernateException { ! return (Calendar) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getDouble(int) ! */ ! public Double getDouble(int col) throws SQLException, HibernateException { ! return (Double) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getFloat(int) ! */ ! public Float getFloat(int col) throws SQLException, HibernateException { ! return (Float) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getInteger(int) ! */ ! public Integer getInteger(int col) throws SQLException, HibernateException { ! return (Integer) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getLong(int) ! */ ! public Long getLong(int col) throws SQLException, HibernateException { ! return (Long) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getShort(int) ! */ ! public Short getShort(int col) throws SQLException, HibernateException { ! return (Short) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getString(int) ! */ ! public String getString(int col) throws SQLException, HibernateException { ! return (String) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#afterLast() ! */ ! public void afterLast() throws SQLException, HibernateException { ! rs.afterLast(); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#beforeFirst() ! */ ! public void beforeFirst() throws SQLException, HibernateException { ! rs.beforeFirst(); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#close() ! */ ! public void close() throws SQLException, HibernateException { ! rs.close(); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getLocale(int) ! */ ! public Locale getLocale(int col) throws SQLException, HibernateException { ! return (Locale) get(col); ! } ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getCurrency(int) ! */ ! /*public Currency getCurrency(int col) throws SQLException, HibernateException { ! return (Currency) get(col); ! }*/ ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getTimeZone(int) ! */ ! public TimeZone getTimeZone(int col) throws SQLException, HibernateException { ! return (TimeZone) get(col); ! } ! ! ! /** ! * @see cirrus.hibernate.ScrollableResults#getType(int) ! */ ! public Type getType(int i) { ! return types[i]; ! } ! ! } |
From: <one...@us...> - 2002-11-26 03:36:14
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/helpers In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/helpers Modified Files: IdentityMap.java JoinedIterator.java PropertiesHelper.java ReflectHelper.java Log Message: fixed broken line-endings and added a test Index: IdentityMap.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/helpers/IdentityMap.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** IdentityMap.java 10 Aug 2002 02:18:53 -0000 1.18 --- IdentityMap.java 26 Nov 2002 03:35:41 -0000 1.19 *************** *** 140,144 **** } return set; ! } } --- 140,144 ---- } return set; ! } } Index: JoinedIterator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/helpers/JoinedIterator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JoinedIterator.java 28 May 2002 15:09:25 -0000 1.2 --- JoinedIterator.java 26 Nov 2002 03:35:42 -0000 1.3 *************** *** 32,36 **** iterators[current].remove(); } ! } --- 32,36 ---- iterators[current].remove(); } ! } Index: PropertiesHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/helpers/PropertiesHelper.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PropertiesHelper.java 2 Nov 2002 14:32:12 -0000 1.2 --- PropertiesHelper.java 26 Nov 2002 03:35:42 -0000 1.3 *************** *** 1,17 **** ! //$Id$ ! package cirrus.hibernate.helpers; ! ! import java.util.HashMap; ! import java.util.Map; ! import java.util.Properties; ! import java.util.StringTokenizer; ! ! ! public final class PropertiesHelper { ! public static boolean getBoolean(String property, Properties properties) { return Boolean.valueOf( properties.getProperty(property) ).booleanValue(); ! } ! public static int getInt(String property, Properties properties, int defaultValue) { String propValue = properties.getProperty(property); --- 1,17 ---- ! //$Id$ ! package cirrus.hibernate.helpers; ! ! import java.util.HashMap; ! import java.util.Map; ! import java.util.Properties; ! import java.util.StringTokenizer; ! ! ! public final class PropertiesHelper { ! public static boolean getBoolean(String property, Properties properties) { return Boolean.valueOf( properties.getProperty(property) ).booleanValue(); ! } ! public static int getInt(String property, Properties properties, int defaultValue) { String propValue = properties.getProperty(property); *************** *** 19,24 **** } ! ! public static Integer getInteger(String property, Properties properties) { String propValue = properties.getProperty(property); --- 19,24 ---- } ! ! public static Integer getInteger(String property, Properties properties) { String propValue = properties.getProperty(property); *************** *** 26,56 **** } ! public static Map toMap(String property, String delim, Properties properties) { ! Map map = new HashMap(); ! String propValue = properties.getProperty(property); ! if (propValue!=null) { ! StringTokenizer tokens = new StringTokenizer(propValue, delim); ! while ( tokens.hasMoreTokens() ) { ! map.put( ! tokens.nextToken(), ! tokens.hasMoreElements() ? tokens.nextToken() : "" ! ); ! } ! } ! return map; ! } ! ! public static String[] toStringArray(String property, String delim, Properties properties) { ! return toStringArray( properties.getProperty(property), delim ); } ! ! public static String[] toStringArray(String propValue, String delim) { ! if (propValue!=null) { ! return StringHelper.split(delim, propValue); ! } ! else { ! return new String[0]; ! } } ! ! } --- 26,56 ---- } ! public static Map toMap(String property, String delim, Properties properties) { ! Map map = new HashMap(); ! String propValue = properties.getProperty(property); ! if (propValue!=null) { ! StringTokenizer tokens = new StringTokenizer(propValue, delim); ! while ( tokens.hasMoreTokens() ) { ! map.put( ! tokens.nextToken(), ! tokens.hasMoreElements() ? tokens.nextToken() : "" ! ); ! } ! } ! return map; } ! ! public static String[] toStringArray(String property, String delim, Properties properties) { ! return toStringArray( properties.getProperty(property), delim ); } ! ! public static String[] toStringArray(String propValue, String delim) { ! if (propValue!=null) { ! return StringHelper.split(delim, propValue); ! } ! else { ! return new String[0]; ! } ! } ! ! } Index: ReflectHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/helpers/ReflectHelper.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** ReflectHelper.java 9 Nov 2002 01:38:05 -0000 1.33 --- ReflectHelper.java 26 Nov 2002 03:35:42 -0000 1.34 *************** *** 1,254 **** ! //$Id$ ! package cirrus.hibernate.helpers; ! ! import java.beans.*; ! import java.lang.reflect.Constructor; ! import java.lang.reflect.InvocationTargetException; ! import java.lang.reflect.Member; ! import java.lang.reflect.Method; ! import java.lang.reflect.Modifier; ! ! import cirrus.hibernate.*; ! import cirrus.hibernate.MappingException; ! import cirrus.hibernate.type.*; ! import cirrus.hibernate.type.Type; ! ! ! public final class ReflectHelper { ! ! private static final Class[] NO_CLASSES = new Class[0]; ! private static final Class[] OBJECT = new Class[] { Object.class }; ! private static final Method OBJECT_EQUALS; ! ! static { ! Method eq; ! try { ! eq = Object.class.getMethod("equals", OBJECT); ! } ! catch (Exception e) { ! throw new AssertionFailure("Could not find Object.equals()", e); ! } ! OBJECT_EQUALS = eq; ! } ! ! public static boolean overridesEquals(Class clazz) { ! Method equals; ! try { ! equals = clazz.getMethod("equals", OBJECT); ! } ! catch (NoSuchMethodException nsme) { ! return false; //its an interface so we can't really tell anything... ! } ! return !OBJECT_EQUALS.equals(equals); ! } ! ! ! public static Method getMethod(Class theClass, String methodName) throws MappingException { ! ! if (theClass==Object.class || theClass==null) throw new MappingException( "Could not find a setter" ); // will be swallowed ! ! Method result; ! try { ! result = theClass.getDeclaredMethod(methodName, null); ! } ! catch (Exception e) { ! try { ! return getMethod( theClass.getSuperclass(), methodName ); ! } ! catch (MappingException me) { ! throw new MappingException( "Could not find method " + methodName + " in class " + theClass.getName() ); ! } ! } ! ! if ( !ReflectHelper.isPublic(theClass, result) ) result.setAccessible(true); ! return result; ! ! } ! ! public static Method getSetterMethod(Class theClass, String propertyName) throws MappingException { ! ! if (theClass==Object.class || theClass==null) throw new MappingException( "Could not find a setter" ); // will be swallowed ! ! Method result = setter(theClass, propertyName); ! ! if(result==null) { ! try { ! return getSetterMethod( theClass.getSuperclass(), propertyName ); ! } ! catch (MappingException me) { ! throw new MappingException( "Could not find a setter for " + propertyName + " in class " + theClass.getName() ); ! } ! } ! else { ! if ( !ReflectHelper.isPublic(theClass, result) ) result.setAccessible(true); ! return result; ! } ! ! } ! ! private static Method setter(Class theClass, String propertyName) { ! ! Method[] methods = theClass.getDeclaredMethods(); ! for (int i=0; i<methods.length; i++) { ! if( ! ( methods[i].getName().length() > 3 ) && ! ( methods[i].getName().startsWith("set") ) ! ) { ! String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(3) ); ! String testOldMethod = methods[i].getName().substring(3); ! if ( ! ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) && ! ( methods[i].getParameterTypes().length==1 ) ! ) return methods[i]; ! } ! } ! return null; ! } ! ! public static Method getGetterMethod(Class theClass, String propertyName) throws MappingException { ! ! if (theClass==Object.class || theClass==null) throw new MappingException( "Could not find a getter" ); // will be swallowed ! ! Method result = getter(theClass, propertyName); ! ! if(result==null) { ! try { ! return getGetterMethod( theClass.getSuperclass(), propertyName ); ! } ! catch (MappingException me) { ! throw new MappingException( "Could not find a getter for " + propertyName + " in class " + theClass.getName() ); ! } ! } ! else { ! if ( !ReflectHelper.isPublic(theClass, result) ) result.setAccessible(true); ! return result; ! } ! } ! ! private static Method getter(Class theClass, String propertyName) { ! ! Method[] methods = theClass.getDeclaredMethods(); ! for (int i=0; i<methods.length; i++) { ! // only carry on if the method has no parameters ! if(methods[i].getParameterTypes().length==0) { ! ! // try "get" ! if( (methods[i].getName().length() > 3) && methods[i].getName().startsWith("get") ) { ! ! String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(3) ); ! String testOldMethod = methods[i].getName().substring(3); ! if( ! ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) && ! methods[i].getParameterTypes().length==0 ! ) return methods[i]; ! ! } ! ! // if not "get" then try "is" ! if( (methods[i].getName().length() > 2) && methods[i].getName().startsWith("is") ) { ! ! String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(2) ); ! String testOldMethod = methods[i].getName().substring(2); ! if( ! ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) && ! methods[i].getParameterTypes().length==0 ! ) return methods[i]; ! } ! } ! } ! return null; ! } ! ! public static Type reflectedPropertyType(Class theClass, String name) throws MappingException { ! return TypeFactory.hueristicType( getGetterMethod(theClass, name).getReturnType().getName() ); ! } ! ! public static Class classForName(String name) throws ClassNotFoundException { ! try { ! return Thread.currentThread().getContextClassLoader().loadClass(name); ! } ! catch (Exception e) { ! return Class.forName(name); ! } ! } ! ! public static void set(Method method, Object target, Object value, Class clazz, String propertyName) throws HibernateException { ! try { ! method.invoke( target, new Object[] { value } ); ! } ! catch (NullPointerException npe) { ! throw new PropertyAccessException(npe, "NullPointerException occurred inside", true, clazz, propertyName); ! } ! catch (InvocationTargetException ite) { ! throw new PropertyAccessException(ite, "Exception occurred inside", true, clazz, propertyName); ! } ! catch (IllegalAccessException iae) { ! throw new PropertyAccessException(iae, "IllegalAccessException occurred while calling", true, clazz, propertyName); ! //cannot occur ! } ! catch (IllegalArgumentException iae) { ! throw new PropertyAccessException(iae, "IllegalArgumentException occurred while calling", true, clazz, propertyName); ! } ! } ! ! public static Object get(Method method, Object target, Class clazz, String propertyName) throws HibernateException { ! try { ! return method.invoke(target, null); ! } ! catch (InvocationTargetException ite) { ! throw new PropertyAccessException(ite, "Exception occurred inside", false, clazz, propertyName); ! } ! catch (IllegalAccessException iae) { ! throw new PropertyAccessException(iae, "IllegalAccessException occurred while calling", false, clazz, propertyName); ! //cannot occur ! } ! catch (IllegalArgumentException iae) { ! throw new PropertyAccessException(iae, "IllegalArgumentException occurred calling", false, clazz, propertyName); ! } ! } ! ! public static boolean isPublic(Class clazz, Member member) { ! return Modifier.isPublic( member.getModifiers() ) && Modifier.isPublic( clazz.getModifiers() ); ! } ! ! public static Object getConstantValue(String name) { ! Class clazz; ! try { ! clazz = classForName( StringHelper.qualifier(name) ); ! } ! catch(ClassNotFoundException cnfe) { ! return null; ! } ! try { ! return clazz.getField( StringHelper.unqualify(name) ).get(null); ! } ! catch (Exception e) { ! return null; ! } ! } ! ! public static Constructor getDefaultConstructor(Class clazz) throws MappingException { ! ! if (isAbstractClass(clazz)) return null; ! ! try { ! Constructor constructor = clazz.getDeclaredConstructor(NO_CLASSES); ! if (!isPublic(clazz, constructor)) { ! constructor.setAccessible(true); ! } ! return constructor; ! } catch (NoSuchMethodException nme) { ! throw new MappingException( ! "Object class " + clazz.getName() + ! " must declare a default (no-argument) constructor" ! ); ! } ! ! } ! ! public static boolean isAbstractClass(Class clazz) { ! int modifier = clazz.getModifiers(); ! return (Modifier.isAbstract(modifier) || Modifier.isInterface(modifier)); ! } ! ! } --- 1,254 ---- ! //$Id$ ! package cirrus.hibernate.helpers; ! ! import java.beans.*; ! import java.lang.reflect.Constructor; ! import java.lang.reflect.InvocationTargetException; ! import java.lang.reflect.Member; ! import java.lang.reflect.Method; ! import java.lang.reflect.Modifier; ! ! import cirrus.hibernate.*; ! import cirrus.hibernate.MappingException; ! import cirrus.hibernate.type.*; ! import cirrus.hibernate.type.Type; ! ! ! public final class ReflectHelper { ! ! private static final Class[] NO_CLASSES = new Class[0]; ! private static final Class[] OBJECT = new Class[] { Object.class }; ! private static final Method OBJECT_EQUALS; ! ! static { ! Method eq; ! try { ! eq = Object.class.getMethod("equals", OBJECT); ! } ! catch (Exception e) { ! throw new AssertionFailure("Could not find Object.equals()", e); ! } ! OBJECT_EQUALS = eq; ! } ! ! public static boolean overridesEquals(Class clazz) { ! Method equals; ! try { ! equals = clazz.getMethod("equals", OBJECT); ! } ! catch (NoSuchMethodException nsme) { ! return false; //its an interface so we can't really tell anything... ! } ! return !OBJECT_EQUALS.equals(equals); ! } ! ! ! public static Method getMethod(Class theClass, String methodName) throws MappingException { ! ! if (theClass==Object.class || theClass==null) throw new MappingException( "Could not find a setter" ); // will be swallowed ! ! Method result; ! try { ! result = theClass.getDeclaredMethod(methodName, null); ! } ! catch (Exception e) { ! try { ! return getMethod( theClass.getSuperclass(), methodName ); ! } ! catch (MappingException me) { ! throw new MappingException( "Could not find method " + methodName + " in class " + theClass.getName() ); ! } ! } ! ! if ( !ReflectHelper.isPublic(theClass, result) ) result.setAccessible(true); ! return result; ! ! } ! ! public static Method getSetterMethod(Class theClass, String propertyName) throws MappingException { ! ! if (theClass==Object.class || theClass==null) throw new MappingException( "Could not find a setter" ); // will be swallowed ! ! Method result = setter(theClass, propertyName); ! ! if(result==null) { ! try { ! return getSetterMethod( theClass.getSuperclass(), propertyName ); ! } ! catch (MappingException me) { ! throw new MappingException( "Could not find a setter for " + propertyName + " in class " + theClass.getName() ); ! } ! } ! else { ! if ( !ReflectHelper.isPublic(theClass, result) ) result.setAccessible(true); ! return result; ! } ! ! } ! ! private static Method setter(Class theClass, String propertyName) { ! ! Method[] methods = theClass.getDeclaredMethods(); ! for (int i=0; i<methods.length; i++) { ! if( ! ( methods[i].getName().length() > 3 ) && ! ( methods[i].getName().startsWith("set") ) ! ) { ! String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(3) ); ! String testOldMethod = methods[i].getName().substring(3); ! if ( ! ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) && ! ( methods[i].getParameterTypes().length==1 ) ! ) return methods[i]; ! } ! } ! return null; ! } ! ! public static Method getGetterMethod(Class theClass, String propertyName) throws MappingException { ! ! if (theClass==Object.class || theClass==null) throw new MappingException( "Could not find a getter" ); // will be swallowed ! ! Method result = getter(theClass, propertyName); ! ! if(result==null) { ! try { ! return getGetterMethod( theClass.getSuperclass(), propertyName ); ! } ! catch (MappingException me) { ! throw new MappingException( "Could not find a getter for " + propertyName + " in class " + theClass.getName() ); ! } ! } ! else { ! if ( !ReflectHelper.isPublic(theClass, result) ) result.setAccessible(true); ! return result; ! } ! } ! ! private static Method getter(Class theClass, String propertyName) { ! ! Method[] methods = theClass.getDeclaredMethods(); ! for (int i=0; i<methods.length; i++) { ! // only carry on if the method has no parameters ! if(methods[i].getParameterTypes().length==0) { ! ! // try "get" ! if( (methods[i].getName().length() > 3) && methods[i].getName().startsWith("get") ) { ! ! String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(3) ); ! String testOldMethod = methods[i].getName().substring(3); ! if( ! ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) && ! methods[i].getParameterTypes().length==0 ! ) return methods[i]; ! ! } ! ! // if not "get" then try "is" ! if( (methods[i].getName().length() > 2) && methods[i].getName().startsWith("is") ) { ! ! String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(2) ); ! String testOldMethod = methods[i].getName().substring(2); ! if( ! ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) && ! methods[i].getParameterTypes().length==0 ! ) return methods[i]; ! } ! } ! } ! return null; ! } ! ! public static Type reflectedPropertyType(Class theClass, String name) throws MappingException { ! return TypeFactory.hueristicType( getGetterMethod(theClass, name).getReturnType().getName() ); ! } ! ! public static Class classForName(String name) throws ClassNotFoundException { ! try { ! return Thread.currentThread().getContextClassLoader().loadClass(name); ! } ! catch (Exception e) { ! return Class.forName(name); ! } ! } ! ! public static void set(Method method, Object target, Object value, Class clazz, String propertyName) throws HibernateException { ! try { ! method.invoke( target, new Object[] { value } ); ! } ! catch (NullPointerException npe) { ! throw new PropertyAccessException(npe, "NullPointerException occurred inside", true, clazz, propertyName); ! } ! catch (InvocationTargetException ite) { ! throw new PropertyAccessException(ite, "Exception occurred inside", true, clazz, propertyName); ! } ! catch (IllegalAccessException iae) { ! throw new PropertyAccessException(iae, "IllegalAccessException occurred while calling", true, clazz, propertyName); ! //cannot occur ! } ! catch (IllegalArgumentException iae) { ! throw new PropertyAccessException(iae, "IllegalArgumentException occurred while calling", true, clazz, propertyName); ! } ! } ! ! public static Object get(Method method, Object target, Class clazz, String propertyName) throws HibernateException { ! try { ! return method.invoke(target, null); ! } ! catch (InvocationTargetException ite) { ! throw new PropertyAccessException(ite, "Exception occurred inside", false, clazz, propertyName); ! } ! catch (IllegalAccessException iae) { ! throw new PropertyAccessException(iae, "IllegalAccessException occurred while calling", false, clazz, propertyName); ! //cannot occur ! } ! catch (IllegalArgumentException iae) { ! throw new PropertyAccessException(iae, "IllegalArgumentException occurred calling", false, clazz, propertyName); ! } ! } ! ! public static boolean isPublic(Class clazz, Member member) { ! return Modifier.isPublic( member.getModifiers() ) && Modifier.isPublic( clazz.getModifiers() ); ! } ! ! public static Object getConstantValue(String name) { ! Class clazz; ! try { ! clazz = classForName( StringHelper.qualifier(name) ); ! } ! catch(ClassNotFoundException cnfe) { ! return null; ! } ! try { ! return clazz.getField( StringHelper.unqualify(name) ).get(null); ! } ! catch (Exception e) { ! return null; ! } ! } ! ! public static Constructor getDefaultConstructor(Class clazz) throws MappingException { ! ! if (isAbstractClass(clazz)) return null; ! ! try { ! Constructor constructor = clazz.getDeclaredConstructor(NO_CLASSES); ! if (!isPublic(clazz, constructor)) { ! constructor.setAccessible(true); ! } ! return constructor; ! } catch (NoSuchMethodException nme) { ! throw new MappingException( ! "Object class " + clazz.getName() + ! " must declare a default (no-argument) constructor" ! ); ! } ! ! } ! ! public static boolean isAbstractClass(Class clazz) { ! int modifier = clazz.getModifiers(); ! return (Modifier.isAbstract(modifier) || Modifier.isInterface(modifier)); ! } ! ! } |
From: <one...@us...> - 2002-11-26 03:36:14
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/engine In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/engine Modified Files: Batcher.java Key.java SessionFactoryImplementor.java Versioning.java Log Message: fixed broken line-endings and added a test Index: Batcher.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/engine/Batcher.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Batcher.java 31 Oct 2002 16:58:16 -0000 1.3 --- Batcher.java 26 Nov 2002 03:35:41 -0000 1.4 *************** *** 1,62 **** ! //$Id$ ! package cirrus.hibernate.engine; ! ! import java.sql.PreparedStatement; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! ! /** ! * Manages <tt>PreparedStatement</tt>s for a session. Abstracts JDBC ! * batching to maintain the illusion that a single logical batch ! * exists for the whole session, even when batching is disabled. ! * Provides transparent <tt>PreparedStatement</tt> caching. ! * @see java.sql.PreparedStatement ! * @see cirrus.hibernate.impl.SessionImpl ! */ ! public interface Batcher { ! /** ! * Get a prepared statement for use in loading / querying. If not explicitly ! * released by <tt>closeQueryStatement()</tt>, it will be released when the ! * session is closed or disconnected. ! */ ! public PreparedStatement prepareQueryStatement(String sql, boolean scrollable) throws SQLException, HibernateException; ! /** ! * Close a prepared statement opened with <tt>prepareQueryStatement()</tt> ! */ ! public void closeQueryStatement(PreparedStatement ps) throws SQLException; ! ! /** ! * Get a non-batchable prepared statement to use for inserting / deleting / updating. ! * Must be explicitly released by <tt>closeStatement()</tt> ! */ ! public PreparedStatement prepareStatement(String sql) throws SQLException, HibernateException; ! /** ! * Close a prepared statement opened using <tt>prepareStatement()</tt> ! */ ! public void closeStatement(PreparedStatement ps) throws SQLException; ! /** ! * Get a batchable prepared statement to use for inserting / deleting / updating ! * (might be called many times before a single call to <tt>executeBatch()</tt>). ! * After setting parameters, call <tt>addToBatch</tt> - do not execute the ! * statement explicitly. ! * @see Batcher#addToBatch(int) ! */ ! public PreparedStatement prepareBatchStatement(String sql) throws SQLException, HibernateException; ! /** ! * Add an insert / delete / update to the current batch (might be called multiple times ! * for single <tt>prepareBatchStatement()</tt>) ! */ ! public void addToBatch(int expectedRowCount) throws SQLException, HibernateException; ! ! /** ! * Execute the batch ! */ ! public void executeBatch() throws SQLException, HibernateException; ! ! /** ! * Close any query statements that were left lying around ! */ ! public void closeStatements(); ! ! } --- 1,62 ---- ! //$Id$ ! package cirrus.hibernate.engine; ! ! import java.sql.PreparedStatement; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! ! /** ! * Manages <tt>PreparedStatement</tt>s for a session. Abstracts JDBC ! * batching to maintain the illusion that a single logical batch ! * exists for the whole session, even when batching is disabled. ! * Provides transparent <tt>PreparedStatement</tt> caching. ! * @see java.sql.PreparedStatement ! * @see cirrus.hibernate.impl.SessionImpl ! */ ! public interface Batcher { ! /** ! * Get a prepared statement for use in loading / querying. If not explicitly ! * released by <tt>closeQueryStatement()</tt>, it will be released when the ! * session is closed or disconnected. ! */ ! public PreparedStatement prepareQueryStatement(String sql, boolean scrollable) throws SQLException, HibernateException; ! /** ! * Close a prepared statement opened with <tt>prepareQueryStatement()</tt> ! */ ! public void closeQueryStatement(PreparedStatement ps) throws SQLException; ! ! /** ! * Get a non-batchable prepared statement to use for inserting / deleting / updating. ! * Must be explicitly released by <tt>closeStatement()</tt> ! */ ! public PreparedStatement prepareStatement(String sql) throws SQLException, HibernateException; ! /** ! * Close a prepared statement opened using <tt>prepareStatement()</tt> ! */ ! public void closeStatement(PreparedStatement ps) throws SQLException; ! /** ! * Get a batchable prepared statement to use for inserting / deleting / updating ! * (might be called many times before a single call to <tt>executeBatch()</tt>). ! * After setting parameters, call <tt>addToBatch</tt> - do not execute the ! * statement explicitly. ! * @see Batcher#addToBatch(int) ! */ ! public PreparedStatement prepareBatchStatement(String sql) throws SQLException, HibernateException; ! /** ! * Add an insert / delete / update to the current batch (might be called multiple times ! * for single <tt>prepareBatchStatement()</tt>) ! */ ! public void addToBatch(int expectedRowCount) throws SQLException, HibernateException; ! ! /** ! * Execute the batch ! */ ! public void executeBatch() throws SQLException, HibernateException; ! ! /** ! * Close any query statements that were left lying around ! */ ! public void closeStatements(); ! ! } Index: Key.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/engine/Key.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Key.java 5 Nov 2002 06:46:06 -0000 1.2 --- Key.java 26 Nov 2002 03:35:41 -0000 1.3 *************** *** 1,49 **** ! //$Id$ ! package cirrus.hibernate.engine; ! ! import java.io.Serializable; ! ! import cirrus.hibernate.impl.CollectionPersister; ! import cirrus.hibernate.persister.ClassPersister; ! ! /** ! * A globally unique identifier of an instance, consisting of the ! * user-visible identifier and the identifier space (eg. tablename). ! */ ! public final class Key implements Serializable { ! private final Serializable id; ! private final Serializable identifierSpace; ! ! private Key(Serializable id, Serializable identifierSpace) { ! this.id=id; ! this.identifierSpace = identifierSpace; ! } ! ! /** ! * Construct a unique identifier for an entity class instance ! */ ! public Key(Serializable id, ClassPersister p) { ! this( id, p.getIdentifierSpace() ); ! } ! ! /** ! * Construct a unique identifier for a collection instance ! */ ! public Key(Serializable id, CollectionPersister p) { ! this( id, p.getQualifiedTableName() ); ! } ! ! /** ! * Get the user-visible identifier ! */ ! public Serializable getIdentifier() { ! return id; ! } ! ! public boolean equals(Object other) { ! Key otherKey = (Key) other; ! return otherKey.identifierSpace.equals(this.identifierSpace) && otherKey.id.equals(this.id); ! } ! ! public int hashCode() { return id.hashCode(); } ! } --- 1,49 ---- ! //$Id$ ! package cirrus.hibernate.engine; ! ! import java.io.Serializable; ! ! import cirrus.hibernate.impl.CollectionPersister; ! import cirrus.hibernate.persister.ClassPersister; ! ! /** ! * A globally unique identifier of an instance, consisting of the ! * user-visible identifier and the identifier space (eg. tablename). ! */ ! public final class Key implements Serializable { ! private final Serializable id; ! private final Serializable identifierSpace; ! ! private Key(Serializable id, Serializable identifierSpace) { ! this.id=id; ! this.identifierSpace = identifierSpace; ! } ! ! /** ! * Construct a unique identifier for an entity class instance ! */ ! public Key(Serializable id, ClassPersister p) { ! this( id, p.getIdentifierSpace() ); ! } ! ! /** ! * Construct a unique identifier for a collection instance ! */ ! public Key(Serializable id, CollectionPersister p) { ! this( id, p.getQualifiedTableName() ); ! } ! ! /** ! * Get the user-visible identifier ! */ ! public Serializable getIdentifier() { ! return id; ! } ! ! public boolean equals(Object other) { ! Key otherKey = (Key) other; ! return otherKey.identifierSpace.equals(this.identifierSpace) && otherKey.id.equals(this.id); ! } ! ! public int hashCode() { return id.hashCode(); } ! } Index: SessionFactoryImplementor.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/engine/SessionFactoryImplementor.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SessionFactoryImplementor.java 31 Oct 2002 16:58:20 -0000 1.4 --- SessionFactoryImplementor.java 26 Nov 2002 03:35:41 -0000 1.5 *************** *** 1,92 **** ! //$Id$ ! package cirrus.hibernate.engine; ! ! import java.sql.Connection; ! import java.sql.PreparedStatement; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.MappingException; ! import cirrus.hibernate.impl.CollectionPersister; ! import cirrus.hibernate.persister.ClassPersister; ! import cirrus.hibernate.sql.Dialect; ! import cirrus.hibernate.type.Type; ! ! /** ! * Defines the internal contract between the <tt>SessionFactory</tt> and other parts of ! * Hibernate such as implementors of <tt>Type</tt>. ! * @see cirrus.hibernate.SessionFactory ! * @see cirrus.hibernate.impl.SessionFactoryImpl ! */ ! public interface SessionFactoryImplementor extends Mapping { ! /** ! * Get the persister for a class ! */ public ClassPersister getPersister(Class clazz) throws MappingException; ! /** ! * Get the persister for the named class ! */ ! public ClassPersister getPersister(String className) throws MappingException; ! /** ! * Get the persister object for a collection role ! */ ! public CollectionPersister getCollectionPersister(String role) throws MappingException; ! ! /** ! * Is outerjoin fetching enabled? ! */ ! public boolean enableJoinedFetch(); ! /** ! * Are scrollable <tt>ResultSet</tt>s supported? ! */ ! public boolean useScrollableResultSets(); ! /** ! * Get the database schema specified in <tt>hibernate.default_schema</tt> ! */ public String getDefaultSchema(); ! /** ! * Get the SQL <tt>Dialect</tt> ! */ ! public Dialect getDialect(); ! ! /** ! * Get the return types of a query ! */ ! public Type[] getReturnTypes(String queryString) throws HibernateException; ! ! /** ! * Obtain a JDBC connection ! */ ! public Connection openConnection() throws SQLException; ! /** ! * Release a JDBC connection ! */ ! public void closeConnection(Connection conn) throws SQLException; ! /** ! * Get the names of all persistent classes that implement/extend the given interface/class ! */ ! public String[] getImplementors(Class clazz); ! /** ! * Get the list of query imports ! */ ! public String[] getImports(); ! ! /** ! * Dispose of a prepared statement ! */ ! public void closePreparedStatement(PreparedStatement ps) throws SQLException; ! ! /** ! * Obtain a prepared statement ! */ ! public PreparedStatement getPreparedStatement(final Connection conn, final String sql, boolean scrollable) throws SQLException; ! ! /** ! * Get the JDBC batch size ! */ ! public int getJdbcBatchSize(); ! ! /** ! * Set the fetch size ! */ ! public void setFetchSize(PreparedStatement statement) throws SQLException; ! } --- 1,92 ---- ! //$Id$ ! package cirrus.hibernate.engine; ! ! import java.sql.Connection; ! import java.sql.PreparedStatement; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.MappingException; ! import cirrus.hibernate.impl.CollectionPersister; ! import cirrus.hibernate.persister.ClassPersister; ! import cirrus.hibernate.sql.Dialect; ! import cirrus.hibernate.type.Type; ! ! /** ! * Defines the internal contract between the <tt>SessionFactory</tt> and other parts of ! * Hibernate such as implementors of <tt>Type</tt>. ! * @see cirrus.hibernate.SessionFactory ! * @see cirrus.hibernate.impl.SessionFactoryImpl ! */ ! public interface SessionFactoryImplementor extends Mapping { ! /** ! * Get the persister for a class ! */ public ClassPersister getPersister(Class clazz) throws MappingException; ! /** ! * Get the persister for the named class ! */ ! public ClassPersister getPersister(String className) throws MappingException; ! /** ! * Get the persister object for a collection role ! */ ! public CollectionPersister getCollectionPersister(String role) throws MappingException; ! ! /** ! * Is outerjoin fetching enabled? ! */ ! public boolean enableJoinedFetch(); ! /** ! * Are scrollable <tt>ResultSet</tt>s supported? ! */ ! public boolean useScrollableResultSets(); ! /** ! * Get the database schema specified in <tt>hibernate.default_schema</tt> ! */ public String getDefaultSchema(); ! /** ! * Get the SQL <tt>Dialect</tt> ! */ ! public Dialect getDialect(); ! ! /** ! * Get the return types of a query ! */ ! public Type[] getReturnTypes(String queryString) throws HibernateException; ! ! /** ! * Obtain a JDBC connection ! */ ! public Connection openConnection() throws SQLException; ! /** ! * Release a JDBC connection ! */ ! public void closeConnection(Connection conn) throws SQLException; ! /** ! * Get the names of all persistent classes that implement/extend the given interface/class ! */ ! public String[] getImplementors(Class clazz); ! /** ! * Get the list of query imports ! */ ! public String[] getImports(); ! ! /** ! * Dispose of a prepared statement ! */ ! public void closePreparedStatement(PreparedStatement ps) throws SQLException; ! ! /** ! * Obtain a prepared statement ! */ ! public PreparedStatement getPreparedStatement(final Connection conn, final String sql, boolean scrollable) throws SQLException; ! ! /** ! * Get the JDBC batch size ! */ ! public int getJdbcBatchSize(); ! ! /** ! * Set the fetch size ! */ ! public void setFetchSize(PreparedStatement statement) throws SQLException; ! } Index: Versioning.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/engine/Versioning.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Versioning.java 1 Oct 2002 01:25:29 -0000 1.1 --- Versioning.java 26 Nov 2002 03:35:41 -0000 1.2 *************** *** 1,71 **** ! //$Id$ ! package cirrus.hibernate.engine; ! ! import org.apache.commons.logging.Log; ! import org.apache.commons.logging.LogFactory; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.persister.ClassPersister; ! import cirrus.hibernate.type.VersionType; ! ! /** ! * Utility methods for managing versions and timestamps ! */ ! public final class Versioning { ! ! private static final Log log = LogFactory.getLog(Versioning.class); ! ! /** ! * Increment the given version number ! */ ! public static Object increment(Object version, VersionType versionType) { ! Object next = versionType.next(version); ! if ( log.isTraceEnabled() ) log.trace("Incrementing: " + version + " to " + next); ! return next; ! } ! ! /** ! * Create an initial version number ! */ ! private static Object seed(VersionType versionType) { ! Object seed = versionType.seed(); ! if ( log.isTraceEnabled() ) log.trace("Seeding: " + seed); ! return seed; ! } ! ! /** ! * Seed the given instance state snapshot with an initial version number ! */ ! public static boolean seedVersion(Object[] fields, int versionProperty, VersionType versionType) { ! if ( fields[versionProperty]==null ) { ! fields[versionProperty] = seed(versionType); ! return true; ! } ! else { ! return false; ! } ! } ! ! private static Object getVersion(Object[] fields, int versionProperty, VersionType versionType) throws HibernateException { ! return fields[versionProperty]; ! } ! ! private static void setVersion(Object[] fields, Object version, int versionProperty, VersionType versionType) throws HibernateException { ! fields[versionProperty] = version; ! } ! ! /** ! * Set the version number of the given instance state snapshot ! */ ! public static void setVersion(Object[] fields, Object version, ClassPersister persister) throws HibernateException { ! setVersion( fields, version, persister.getVersionProperty(), persister.getVersionType() ); ! } ! ! /** ! * Get the version number of the given instance state snapshot ! */ ! public static Object getVersion(Object[] fields, ClassPersister persister) throws HibernateException { ! return persister.isVersioned() ? getVersion( fields, persister.getVersionProperty(), persister.getVersionType() ) : null; ! } ! ! } --- 1,71 ---- ! //$Id$ ! package cirrus.hibernate.engine; ! ! import org.apache.commons.logging.Log; ! import org.apache.commons.logging.LogFactory; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.persister.ClassPersister; ! import cirrus.hibernate.type.VersionType; ! ! /** ! * Utility methods for managing versions and timestamps ! */ ! public final class Versioning { ! ! private static final Log log = LogFactory.getLog(Versioning.class); ! ! /** ! * Increment the given version number ! */ ! public static Object increment(Object version, VersionType versionType) { ! Object next = versionType.next(version); ! if ( log.isTraceEnabled() ) log.trace("Incrementing: " + version + " to " + next); ! return next; ! } ! ! /** ! * Create an initial version number ! */ ! private static Object seed(VersionType versionType) { ! Object seed = versionType.seed(); ! if ( log.isTraceEnabled() ) log.trace("Seeding: " + seed); ! return seed; ! } ! ! /** ! * Seed the given instance state snapshot with an initial version number ! */ ! public static boolean seedVersion(Object[] fields, int versionProperty, VersionType versionType) { ! if ( fields[versionProperty]==null ) { ! fields[versionProperty] = seed(versionType); ! return true; ! } ! else { ! return false; ! } ! } ! ! private static Object getVersion(Object[] fields, int versionProperty, VersionType versionType) throws HibernateException { ! return fields[versionProperty]; ! } ! ! private static void setVersion(Object[] fields, Object version, int versionProperty, VersionType versionType) throws HibernateException { ! fields[versionProperty] = version; ! } ! ! /** ! * Set the version number of the given instance state snapshot ! */ ! public static void setVersion(Object[] fields, Object version, ClassPersister persister) throws HibernateException { ! setVersion( fields, version, persister.getVersionProperty(), persister.getVersionType() ); ! } ! ! /** ! * Get the version number of the given instance state snapshot ! */ ! public static Object getVersion(Object[] fields, ClassPersister persister) throws HibernateException { ! return persister.isVersioned() ? getVersion( fields, persister.getVersionProperty(), persister.getVersionType() ) : null; ! } ! ! } |
From: <one...@us...> - 2002-11-26 03:36:14
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/eg In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/eg Modified Files: Edge.java Source.java Vertex.java Log Message: fixed broken line-endings and added a test Index: Edge.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/eg/Edge.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Edge.java 10 Jun 2002 15:31:20 -0000 1.5 --- Edge.java 26 Nov 2002 03:35:41 -0000 1.6 *************** *** 36,40 **** this.name = name; } ! public Vertex getSource() { return source; --- 36,40 ---- this.name = name; } ! public Vertex getSource() { return source; *************** *** 44,48 **** this.source = source; } ! public Vertex getSink() { return sink; --- 44,48 ---- this.source = source; } ! public Vertex getSink() { return sink; *************** *** 68,72 **** this.creationDate = creationDate; } ! } --- 68,72 ---- this.creationDate = creationDate; } ! } Index: Source.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/eg/Source.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Source.java 15 Dec 2001 12:34:13 -0000 1.1 --- Source.java 26 Nov 2002 03:35:41 -0000 1.2 *************** *** 15,19 **** public float getExcessCapacity() { return super.getExcessCapacity() - strength; ! } } --- 15,19 ---- public float getExcessCapacity() { return super.getExcessCapacity() - strength; ! } } Index: Vertex.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/eg/Vertex.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Vertex.java 10 Jun 2002 15:31:20 -0000 1.5 --- Vertex.java 26 Nov 2002 03:35:41 -0000 1.6 *************** *** 90,94 **** this.creationDate = creationDate; } ! } --- 90,94 ---- this.creationDate = creationDate; } ! } |
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/collections In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/collections Modified Files: ArrayHolder.java List.java Map.java PersistentCollection.java Set.java SortedMap.java Log Message: fixed broken line-endings and added a test Index: ArrayHolder.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/collections/ArrayHolder.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** ArrayHolder.java 27 Oct 2002 03:11:33 -0000 1.49 --- ArrayHolder.java 26 Nov 2002 03:35:41 -0000 1.50 *************** *** 58,65 **** super(session); elementClass = persister.getElementClass(); ! } public Object getArray() { return array; ! } public boolean equalsSnapshot(Type elementType) throws HibernateException { Serializable snapshot = getSnapshot(); --- 58,65 ---- super(session); elementClass = persister.getElementClass(); ! } public Object getArray() { return array; ! } public boolean equalsSnapshot(Type elementType) throws HibernateException { Serializable snapshot = getSnapshot(); *************** *** 84,88 **** } } ! /** * @see PersistentCollection#elements() --- 84,88 ---- } } ! /** * @see PersistentCollection#elements() *************** *** 100,104 **** return false; } ! /** * @see PersistentCollection#writeTo(PreparedStatement, CollectionPersister, Object, int) --- 100,104 ---- return false; } ! /** * @see PersistentCollection#writeTo(PreparedStatement, CollectionPersister, Object, int) *************** *** 110,114 **** persister.writeIndex(st, new Integer(i), writeOrder, session); } ! /** * @see PersistentCollection#readFrom(ResultSet, CollectionPersister) --- 110,114 ---- persister.writeIndex(st, new Integer(i), writeOrder, session); } ! /** * @see PersistentCollection#readFrom(ResultSet, CollectionPersister) *************** *** 127,131 **** return element; } ! /** * @see PersistentCollection#entries() --- 127,131 ---- return element; } ! /** * @see PersistentCollection#entries() *************** *** 227,229 **** } ! --- 227,229 ---- } ! Index: List.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/collections/List.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** List.java 1 Oct 2002 01:25:29 -0000 1.43 --- List.java 26 Nov 2002 03:35:41 -0000 1.44 *************** *** 23,27 **** /** * A persistent wrapper for a java.util.List ! */ public class List extends ODMGCollection implements java.util.List, DList, DArray { --- 23,27 ---- /** * A persistent wrapper for a java.util.List ! */ public class List extends ODMGCollection implements java.util.List, DList, DArray { *************** *** 56,60 **** this.list = list; initialized = true; ! } public void beforeInitialize(CollectionPersister persister) { this.list = new ArrayList(); --- 56,60 ---- this.list = list; initialized = true; ! } public void beforeInitialize(CollectionPersister persister) { this.list = new ArrayList(); *************** *** 68,72 **** return list.size(); } ! /** * @see List#isEmpty() --- 68,72 ---- return list.size(); } ! /** * @see List#isEmpty() *************** *** 76,80 **** return list.isEmpty(); } ! /** * @see List#contains(Object) --- 76,80 ---- return list.isEmpty(); } ! /** * @see List#contains(Object) *************** *** 84,88 **** return list.contains(object); } ! /** * @see List#iterator() --- 84,88 ---- return list.contains(object); } ! /** * @see List#iterator() *************** *** 92,96 **** return new IteratorProxy( list.iterator() ); } ! /** * @see List#toArray() --- 92,96 ---- return new IteratorProxy( list.iterator() ); } ! /** * @see List#toArray() *************** *** 100,104 **** return list.toArray(); } ! /** * @see List#toArray(Object[]) --- 100,104 ---- return list.toArray(); } ! /** * @see List#toArray(Object[]) *************** *** 108,112 **** return list.toArray(array); } ! /** * @see List#add(Object) --- 108,112 ---- return list.toArray(array); } ! /** * @see List#add(Object) *************** *** 116,120 **** return list.add(object); } ! /** * @see List#remove(Object) --- 116,120 ---- return list.add(object); } ! /** * @see List#remove(Object) *************** *** 124,128 **** return list.remove(arg0); } ! /** * @see List#containsAll(Collection) --- 124,128 ---- return list.remove(arg0); } ! /** * @see List#containsAll(Collection) *************** *** 132,136 **** return list.containsAll( arg0); } ! /** * @see List#addAll(Collection) --- 132,136 ---- return list.containsAll( arg0); } ! /** * @see List#addAll(Collection) *************** *** 140,144 **** return list.addAll( arg0); } ! /** * @see List#addAll(int, Collection) --- 140,144 ---- return list.addAll( arg0); } ! /** * @see List#addAll(int, Collection) *************** *** 148,152 **** return list.addAll( arg0, arg1); } ! /** * @see List#removeAll(Collection) --- 148,152 ---- return list.addAll( arg0, arg1); } ! /** * @see List#removeAll(Collection) *************** *** 156,160 **** return list.removeAll( arg0); } ! /** * @see List#retainAll(Collection) --- 156,160 ---- return list.removeAll( arg0); } ! /** * @see List#retainAll(Collection) *************** *** 164,168 **** return list.retainAll( arg0); } ! /** * @see List#clear() --- 164,168 ---- return list.retainAll( arg0); } ! /** * @see List#clear() *************** *** 172,176 **** list.clear(); } ! /** * @see List#get(int) --- 172,176 ---- list.clear(); } ! /** * @see List#get(int) *************** *** 180,184 **** return list.get( arg0); } ! /** * @see List#set(int, Object) --- 180,184 ---- return list.get( arg0); } ! /** * @see List#set(int, Object) *************** *** 188,192 **** return list.set( arg0, arg1); } ! /** * @see List#add(int, Object) --- 188,192 ---- return list.set( arg0, arg1); } ! /** * @see List#add(int, Object) *************** *** 196,200 **** list.add(arg0, arg1); } ! /** * @see List#remove(int) --- 196,200 ---- list.add(arg0, arg1); } ! /** * @see List#remove(int) *************** *** 204,208 **** return list.remove( arg0); } ! /** * @see List#indexOf(Object) --- 204,208 ---- return list.remove( arg0); } ! /** * @see List#indexOf(Object) *************** *** 212,216 **** return list.indexOf( arg0); } ! /** * @see List#lastIndexOf(Object) --- 212,216 ---- return list.indexOf( arg0); } ! /** * @see List#lastIndexOf(Object) *************** *** 220,224 **** return list.lastIndexOf( arg0); } ! /** * @see List#listIterator() --- 220,224 ---- return list.lastIndexOf( arg0); } ! /** * @see List#listIterator() *************** *** 228,232 **** return new ListIteratorProxy( list.listIterator() ); } ! /** * @see List#listIterator(int) --- 228,232 ---- return new ListIteratorProxy( list.listIterator() ); } ! /** * @see List#listIterator(int) *************** *** 236,240 **** return new ListIteratorProxy( list.listIterator(arg0) ); } ! /** * @see List#subList(int, int) --- 236,240 ---- return new ListIteratorProxy( list.listIterator(arg0) ); } ! /** * @see List#subList(int, int) *************** *** 244,248 **** return new ListProxy( list.subList(arg0, arg1) ); } ! /** * @see PersistentCollection#replaceElements(Map) --- 244,248 ---- return new ListProxy( list.subList(arg0, arg1) ); } ! /** * @see PersistentCollection#replaceElements(Map) *************** *** 255,259 **** } } ! /** * @see PersistentCollection#elements() --- 255,259 ---- } } ! /** * @see PersistentCollection#elements() *************** *** 269,273 **** return list.toString(); } ! /** * @see PersistentCollection#writeTo(PreparedStatement, CollectionPersister, Object, int) --- 269,273 ---- return list.toString(); } ! /** * @see PersistentCollection#writeTo(PreparedStatement, CollectionPersister, Object, int) *************** *** 279,283 **** persister.writeIndex(st, new Integer(i), writeOrder, session); } ! /** * @see PersistentCollection#readFrom(ResultSet, CollectionPersister) --- 279,283 ---- persister.writeIndex(st, new Integer(i), writeOrder, session); } ! /** * @see PersistentCollection#readFrom(ResultSet, CollectionPersister) *************** *** 292,296 **** return element; } ! /** * @see PersistentCollection#entries() --- 292,296 ---- return element; } ! /** * @see PersistentCollection#entries() *************** *** 304,308 **** list.add( entries.next() ); } ! } public void assemble(CollectionPersister persister) throws HibernateException, SQLException { --- 304,308 ---- list.add( entries.next() ); } ! } public void assemble(CollectionPersister persister) throws HibernateException, SQLException { *************** *** 383,385 **** } ! --- 383,385 ---- } ! Index: Map.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/collections/Map.java,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** Map.java 5 Oct 2002 04:18:30 -0000 1.45 --- Map.java 26 Nov 2002 03:35:41 -0000 1.46 *************** *** 22,26 **** /** * A persistent wrapper for a java.util.Map ! */ public class Map extends PersistentCollection implements java.util.Map, DMap { --- 22,26 ---- /** * A persistent wrapper for a java.util.Map ! */ public class Map extends PersistentCollection implements java.util.Map, DMap { *************** *** 68,72 **** return map.size(); } ! /** * @see Map#isEmpty() --- 68,72 ---- return map.size(); } ! /** * @see Map#isEmpty() *************** *** 76,80 **** return map.isEmpty(); } ! /** * @see Map#containsKey(Object) --- 76,80 ---- return map.isEmpty(); } ! /** * @see Map#containsKey(Object) *************** *** 84,88 **** return map.containsKey(arg0); } ! /** * @see Map#containsValue(Object) --- 84,88 ---- return map.containsKey(arg0); } ! /** * @see Map#containsValue(Object) *************** *** 92,96 **** return map.containsValue(arg0) ; } ! /** * @see Map#get(Object) --- 92,96 ---- return map.containsValue(arg0) ; } ! /** * @see Map#get(Object) *************** *** 100,104 **** return map.get(arg0); } ! /** * @see Map#put(Object, Object) --- 100,104 ---- return map.get(arg0); } ! /** * @see Map#put(Object, Object) *************** *** 108,112 **** return map.put( arg0, arg1); } ! /** * @see Map#remove(Object) --- 108,112 ---- return map.put( arg0, arg1); } ! /** * @see Map#remove(Object) *************** *** 116,120 **** return map.remove( arg0); } ! /** * @see Map#putAll(Map) --- 116,120 ---- return map.remove( arg0); } ! /** * @see Map#putAll(Map) *************** *** 124,128 **** map.putAll(arg0); } ! /** * @see Map#clear() --- 124,128 ---- map.putAll(arg0); } ! /** * @see Map#clear() *************** *** 132,136 **** map.clear(); } ! /** * @see Map#keySet() --- 132,136 ---- map.clear(); } ! /** * @see Map#keySet() *************** *** 140,144 **** return new SetProxy( map.keySet() ); } ! /** * @see Map#values() --- 140,144 ---- return new SetProxy( map.keySet() ); } ! /** * @see Map#values() *************** *** 148,152 **** return new SetProxy( map.values() ); } ! /** * @see Map#entrySet() --- 148,152 ---- return new SetProxy( map.values() ); } ! /** * @see Map#entrySet() *************** *** 156,160 **** return new EntrySetProxy( map.entrySet() ); } ! /** * @see PersistentCollection#replaceElements(Map) --- 156,160 ---- return new EntrySetProxy( map.entrySet() ); } ! /** * @see PersistentCollection#replaceElements(Map) *************** *** 172,176 **** if ( n!=replacements.size() ) throw new HibernateException("Application error: don't use mutable values for keys of maps"); } ! /** * @see PersistentCollection#elements() --- 172,176 ---- if ( n!=replacements.size() ) throw new HibernateException("Application error: don't use mutable values for keys of maps"); } ! /** * @see PersistentCollection#elements() *************** *** 195,199 **** persister.writeIndex(st, e.getKey(), writeOrder, session); } ! /** * @see PersistentCollection#readFrom(ResultSet, CollectionPersister) --- 195,199 ---- persister.writeIndex(st, e.getKey(), writeOrder, session); } ! /** * @see PersistentCollection#readFrom(ResultSet, CollectionPersister) *************** *** 205,209 **** return element; } ! /** * @see PersistentCollection#entries() --- 205,209 ---- return element; } ! /** * @see PersistentCollection#entries() *************** *** 369,371 **** } ! --- 369,371 ---- } ! Index: PersistentCollection.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/collections/PersistentCollection.java,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** PersistentCollection.java 26 Oct 2002 16:43:27 -0000 1.74 --- PersistentCollection.java 26 Nov 2002 03:35:41 -0000 1.75 *************** *** 40,44 **** */ ! public abstract class PersistentCollection implements Serializable { protected transient SessionImplementor session; protected boolean initialized; --- 40,44 ---- */ ! public abstract class PersistentCollection implements Serializable { protected transient SessionImplementor session; protected boolean initialized; Index: Set.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/collections/Set.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** Set.java 1 Oct 2002 01:25:29 -0000 1.49 --- Set.java 26 Nov 2002 03:35:41 -0000 1.50 *************** *** 23,27 **** /** * A persistent wrapper for a java.util.Set ! */ public class Set extends ODMGCollection implements java.util.Set, DSet { protected java.util.Set set; --- 23,27 ---- /** * A persistent wrapper for a java.util.Set ! */ public class Set extends ODMGCollection implements java.util.Set, DSet { protected java.util.Set set; *************** *** 69,73 **** public void beforeInitialize(CollectionPersister persister) { this.set = persister.hasOrdering() ? LinkedHashCollectionHelper.createLinkedHashSet() : new HashSet(); ! } public Set(SessionImplementor session, java.util.Set set) { super(session); --- 69,73 ---- public void beforeInitialize(CollectionPersister persister) { this.set = persister.hasOrdering() ? LinkedHashCollectionHelper.createLinkedHashSet() : new HashSet(); ! } public Set(SessionImplementor session, java.util.Set set) { super(session); *************** *** 79,83 **** initialized = true; } ! /** * @see PersistentCollection#replaceElements(Map) --- 79,83 ---- initialized = true; } ! /** * @see PersistentCollection#replaceElements(Map) *************** *** 93,97 **** } } ! /** * @see PersistentCollection#elements() --- 93,97 ---- } } ! /** * @see PersistentCollection#elements() *************** *** 103,107 **** return set.isEmpty(); } ! /** * @see Set#size() --- 103,107 ---- return set.isEmpty(); } ! /** * @see Set#size() *************** *** 111,115 **** return set.size(); } ! /** * @see Set#isEmpty() --- 111,115 ---- return set.size(); } ! /** * @see Set#isEmpty() *************** *** 119,123 **** return set.isEmpty(); } ! /** * @see Set#contains(Object) --- 119,123 ---- return set.isEmpty(); } ! /** * @see Set#contains(Object) *************** *** 127,131 **** return set.contains(arg0); } ! /** * @see Set#iterator() --- 127,131 ---- return set.contains(arg0); } ! /** * @see Set#iterator() *************** *** 135,139 **** return new IteratorProxy( set.iterator() ); } ! /** * @see Set#toArray() --- 135,139 ---- return new IteratorProxy( set.iterator() ); } ! /** * @see Set#toArray() *************** *** 143,147 **** return set.toArray(); } ! /** * @see Set#toArray(Object[]) --- 143,147 ---- return set.toArray(); } ! /** * @see Set#toArray(Object[]) *************** *** 151,155 **** return set.toArray(arg0); } ! /** * @see Set#add(Object) --- 151,155 ---- return set.toArray(arg0); } ! /** * @see Set#add(Object) *************** *** 159,163 **** return set.add(arg0); } ! /** * @see Set#remove(Object) --- 159,163 ---- return set.add(arg0); } ! /** * @see Set#remove(Object) *************** *** 167,171 **** return set.remove(arg0); } ! /** * @see Set#containsAll(Collection) --- 167,171 ---- return set.remove(arg0); } ! /** * @see Set#containsAll(Collection) *************** *** 175,179 **** return set.containsAll(arg0); } ! /** * @see Set#addAll(Collection) --- 175,179 ---- return set.containsAll(arg0); } ! /** * @see Set#addAll(Collection) *************** *** 183,187 **** return set.addAll(arg0); } ! /** * @see Set#retainAll(Collection) --- 183,187 ---- return set.addAll(arg0); } ! /** * @see Set#retainAll(Collection) *************** *** 191,195 **** return set.retainAll(arg0); } ! /** * @see Set#removeAll(Collection) --- 191,195 ---- return set.retainAll(arg0); } ! /** * @see Set#removeAll(Collection) *************** *** 199,203 **** return set.remove(arg0); } ! /** * @see Set#clear() --- 199,203 ---- return set.remove(arg0); } ! /** * @see Set#clear() *************** *** 212,216 **** return set.toString(); } ! /** * @see PersistentCollection#writeTo(PreparedStatement, CollectionPersister, Object, int) --- 212,216 ---- return set.toString(); } ! /** * @see PersistentCollection#writeTo(PreparedStatement, CollectionPersister, Object, int) *************** *** 220,224 **** persister.writeElement(st, entry, writeOrder, session); } ! /** * @see PersistentCollection#readFrom(ResultSet, CollectionPersister) --- 220,224 ---- persister.writeElement(st, entry, writeOrder, session); } ! /** * @see PersistentCollection#readFrom(ResultSet, CollectionPersister) *************** *** 229,233 **** return element; } ! /** * @see PersistentCollection#entries() --- 229,233 ---- return element; } ! /** * @see PersistentCollection#entries() *************** *** 389,391 **** } ! --- 389,391 ---- } ! Index: SortedMap.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/collections/SortedMap.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** SortedMap.java 1 Oct 2002 01:25:29 -0000 1.21 --- SortedMap.java 26 Nov 2002 03:35:41 -0000 1.22 *************** *** 19,23 **** * @version 1.x * @author <a href="mailto:dou...@al...">e</a> ! */ public class SortedMap extends Map implements java.util.SortedMap { --- 19,23 ---- * @version 1.x * @author <a href="mailto:dou...@al...">e</a> ! */ public class SortedMap extends Map implements java.util.SortedMap { *************** *** 198,200 **** public SortedMap() {} } ! --- 198,200 ---- public SortedMap() {} } ! |
From: <one...@us...> - 2002-11-26 03:36:14
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/ejb In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/ejb Modified Files: EntityBean.java Log Message: fixed broken line-endings and added a test Index: EntityBean.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/ejb/EntityBean.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** EntityBean.java 6 Sep 2002 16:51:29 -0000 1.5 --- EntityBean.java 26 Nov 2002 03:35:41 -0000 1.6 *************** *** 259,263 **** this.id = id; } ! public void ejbActivate() throws EJBException, RemoteException { } --- 259,263 ---- this.id = id; } ! public void ejbActivate() throws EJBException, RemoteException { } |
From: <one...@us...> - 2002-11-26 03:36:14
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/connection In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/connection Modified Files: UserSuppliedConnectionProvider.java Log Message: fixed broken line-endings and added a test Index: UserSuppliedConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/connection/UserSuppliedConnectionProvider.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** UserSuppliedConnectionProvider.java 12 Sep 2002 17:07:10 -0000 1.3 --- UserSuppliedConnectionProvider.java 26 Nov 2002 03:35:41 -0000 1.4 *************** *** 1,48 **** ! //$Id$ ! package cirrus.hibernate.connection; ! ! import java.sql.Connection; ! import java.sql.SQLException; ! import java.util.Properties; ! ! import org.apache.commons.logging.LogFactory; ! ! import cirrus.hibernate.HibernateException; ! ! /** ! * An implementation of the <literal>ConnectionProvider</literal> interface that ! * simply throws an exception when a connection is requested. This implementation ! * indicates that the user is expected to supply a JDBC connection. ! * @see ConnectionProvider ! */ ! public class UserSuppliedConnectionProvider implements ConnectionProvider { ! ! /** ! * @see cirrus.hibernate.connection.ConnectionProvider#configure(Properties) ! */ ! public void configure(Properties props) throws HibernateException { ! LogFactory.getLog(UserSuppliedConnectionProvider.class).warn("No connection properties specified - the user must supply JDBC connections"); ! } ! ! /** ! * @see cirrus.hibernate.connection.ConnectionProvider#getConnection() ! */ ! public Connection getConnection() throws SQLException { ! throw new UnsupportedOperationException("The user must supply a JDBC connection"); ! } ! ! /** ! * @see cirrus.hibernate.connection.ConnectionProvider#closeConnection(Connection) ! */ ! public void closeConnection(Connection conn) throws SQLException { ! throw new UnsupportedOperationException("The user must supply a JDBC connection"); ! } ! ! /** ! * @see cirrus.hibernate.connection.ConnectionProvider#isStatementCache() ! */ ! public boolean isStatementCache() { ! return false; ! } ! ! } --- 1,48 ---- ! //$Id$ ! package cirrus.hibernate.connection; ! ! import java.sql.Connection; ! import java.sql.SQLException; ! import java.util.Properties; ! ! import org.apache.commons.logging.LogFactory; ! ! import cirrus.hibernate.HibernateException; ! ! /** ! * An implementation of the <literal>ConnectionProvider</literal> interface that ! * simply throws an exception when a connection is requested. This implementation ! * indicates that the user is expected to supply a JDBC connection. ! * @see ConnectionProvider ! */ ! public class UserSuppliedConnectionProvider implements ConnectionProvider { ! ! /** ! * @see cirrus.hibernate.connection.ConnectionProvider#configure(Properties) ! */ ! public void configure(Properties props) throws HibernateException { ! LogFactory.getLog(UserSuppliedConnectionProvider.class).warn("No connection properties specified - the user must supply JDBC connections"); ! } ! ! /** ! * @see cirrus.hibernate.connection.ConnectionProvider#getConnection() ! */ ! public Connection getConnection() throws SQLException { ! throw new UnsupportedOperationException("The user must supply a JDBC connection"); ! } ! ! /** ! * @see cirrus.hibernate.connection.ConnectionProvider#closeConnection(Connection) ! */ ! public void closeConnection(Connection conn) throws SQLException { ! throw new UnsupportedOperationException("The user must supply a JDBC connection"); ! } ! ! /** ! * @see cirrus.hibernate.connection.ConnectionProvider#isStatementCache() ! */ ! public boolean isStatementCache() { ! return false; ! } ! ! } |
From: <one...@us...> - 2002-11-26 03:36:13
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/cache In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/cache Modified Files: Timestamper.java Log Message: fixed broken line-endings and added a test Index: Timestamper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/cache/Timestamper.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Timestamper.java 7 Oct 2002 07:39:38 -0000 1.2 --- Timestamper.java 26 Nov 2002 03:35:40 -0000 1.3 *************** *** 1,26 **** ! //$Id$ ! package cirrus.hibernate.cache; ! ! /** ! * Generates increasing identifiers (in a single VM only). ! * Not valid across multiple VMs. Identifiers are not necessarily ! * strictly increasing, but usually are. ! */ ! public class Timestamper { ! private static short counter = 0; ! private static long time; ! ! public synchronized static long next() { ! ! long newTime = System.currentTimeMillis() << 16; ! if (time<newTime) { ! time = newTime; ! counter = 0; ! } ! else if (counter<Short.MAX_VALUE) { ! counter++; ! } ! ! return time + counter; ! } ! } --- 1,26 ---- ! //$Id$ ! package cirrus.hibernate.cache; ! ! /** ! * Generates increasing identifiers (in a single VM only). ! * Not valid across multiple VMs. Identifiers are not necessarily ! * strictly increasing, but usually are. ! */ ! public class Timestamper { ! private static short counter = 0; ! private static long time; ! ! public synchronized static long next() { ! ! long newTime = System.currentTimeMillis() << 16; ! if (time<newTime) { ! time = newTime; ! counter = 0; ! } ! else if (counter<Short.MAX_VALUE) { ! counter++; ! } ! ! return time + counter; ! } ! } |
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate Modified Files: Interceptor.java LockMode.java QueryException.java ScrollableResults.java Validatable.java ValidationFailure.java Log Message: fixed broken line-endings and added a test Index: Interceptor.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/Interceptor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Interceptor.java 18 Oct 2002 11:02:19 -0000 1.2 --- Interceptor.java 26 Nov 2002 03:35:40 -0000 1.3 *************** *** 1,64 **** ! //$Id$ ! package cirrus.hibernate; ! ! import java.io.Serializable; ! import java.util.Iterator; ! ! import cirrus.hibernate.type.Type; ! ! /** ! * Allows user code to inspect and / or change property values before they are written and after they are read ! * from the database.<br> ! * <br> ! * There might be a single instance of <tt>Interceptor</tt> for a <tt>SessionFactory</tt>, or a new instance ! * might be specified for each <tt>Session</tt>. Whichever approach is used, the interceptor must be ! * serializable if the <tt>Session</tt> is to be serializable. This means that <tt>SessionFactory</tt>-scoped ! * interceptors should implement <tt>readResolve()</tt>.<br> ! * <br> ! * The <tt>Session</tt> may not be invoked from a callback (nor may a callback cause a collection or proxy to ! * be lazily initialized).<br> ! * ! * @see SessionFactory#openSession(Interceptor) ! * @see Datastore#buildSessionFactory(Interceptor) ! */ ! public interface Interceptor { ! /** ! * Called just before an object is initialized. The interceptor may change the <tt>state</tt>, which will ! * be propagated to the persistent object. Note that when this method is called, <tt>entity</tt> will be ! * an empty uninitialized instance of the class. ! * ! * @return <tt>true</tt> if the user modified the <tt>state</tt> in any way. ! */ ! public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types); ! /** ! * Called when an object is detected to be dirty, during a flush. The interceptor may modify the detected ! * <tt>currentState</tt>, which will be propagated to both the database and the persistent object. ! * Note that not all flushes end in actual synchronization with the database, in which case the ! * new <tt>currentState</tt> will be propagated to the object, but not necessarily (immediately) to ! * the database. It is strongly recommended that the interceptor <b>not</b> modify the <tt>previousState</tt>. ! * ! * @return <tt>true</tt> if the user modified the <tt>currentState</tt> in any way. ! */ ! public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types); ! //public void onPostFlush(Object entity, Serializable id, Object[] currentState, String[] propertyNames, Type[] types); ! /** ! * Called before an object is saved. The interceptor may modify the <tt>state</tt>, which will be used for ! * the SQL <tt>INSERT</tt> and propagated to the persistent object. ! * ! * @return <tt>true</tt> if the user modified the <tt>state</tt> in any way. ! */ ! public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types); ! /** ! * Called before an object is deleted. It is not recommended that the interceptor modify the <tt>state</tt>. ! */ ! public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types); ! /** ! * Called before a flush ! */ ! public void preFlush(Iterator entities); ! /** ! * Called after a flush that actually ends in execution of the SQL statements required to synchronize ! * in-memory state with the database. ! */ ! public void postFlush(Iterator entities); ! } --- 1,64 ---- ! //$Id$ ! package cirrus.hibernate; ! ! import java.io.Serializable; ! import java.util.Iterator; ! ! import cirrus.hibernate.type.Type; ! ! /** ! * Allows user code to inspect and / or change property values before they are written and after they are read ! * from the database.<br> ! * <br> ! * There might be a single instance of <tt>Interceptor</tt> for a <tt>SessionFactory</tt>, or a new instance ! * might be specified for each <tt>Session</tt>. Whichever approach is used, the interceptor must be ! * serializable if the <tt>Session</tt> is to be serializable. This means that <tt>SessionFactory</tt>-scoped ! * interceptors should implement <tt>readResolve()</tt>.<br> ! * <br> ! * The <tt>Session</tt> may not be invoked from a callback (nor may a callback cause a collection or proxy to ! * be lazily initialized).<br> ! * ! * @see SessionFactory#openSession(Interceptor) ! * @see Datastore#buildSessionFactory(Interceptor) ! */ ! public interface Interceptor { ! /** ! * Called just before an object is initialized. The interceptor may change the <tt>state</tt>, which will ! * be propagated to the persistent object. Note that when this method is called, <tt>entity</tt> will be ! * an empty uninitialized instance of the class. ! * ! * @return <tt>true</tt> if the user modified the <tt>state</tt> in any way. ! */ ! public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types); ! /** ! * Called when an object is detected to be dirty, during a flush. The interceptor may modify the detected ! * <tt>currentState</tt>, which will be propagated to both the database and the persistent object. ! * Note that not all flushes end in actual synchronization with the database, in which case the ! * new <tt>currentState</tt> will be propagated to the object, but not necessarily (immediately) to ! * the database. It is strongly recommended that the interceptor <b>not</b> modify the <tt>previousState</tt>. ! * ! * @return <tt>true</tt> if the user modified the <tt>currentState</tt> in any way. ! */ ! public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types); ! //public void onPostFlush(Object entity, Serializable id, Object[] currentState, String[] propertyNames, Type[] types); ! /** ! * Called before an object is saved. The interceptor may modify the <tt>state</tt>, which will be used for ! * the SQL <tt>INSERT</tt> and propagated to the persistent object. ! * ! * @return <tt>true</tt> if the user modified the <tt>state</tt> in any way. ! */ ! public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types); ! /** ! * Called before an object is deleted. It is not recommended that the interceptor modify the <tt>state</tt>. ! */ ! public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types); ! /** ! * Called before a flush ! */ ! public void preFlush(Iterator entities); ! /** ! * Called after a flush that actually ends in execution of the SQL statements required to synchronize ! * in-memory state with the database. ! */ ! public void postFlush(Iterator entities); ! } Index: LockMode.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/LockMode.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LockMode.java 3 Oct 2002 05:53:02 -0000 1.4 --- LockMode.java 26 Nov 2002 03:35:40 -0000 1.5 *************** *** 1,67 **** ! //$Id$ ! package cirrus.hibernate; ! ! import java.io.Serializable; ! ! /** ! * Instances represent a lock mode for a row of a relational ! * database table. It is not intended that users spend much ! * time worrying about locking since Hibernate usually ! * obtains exactly the right lock level automatically. ! * Some "advanced" users may wish to explicitly specify lock ! * levels. ! * ! * @see Session#lock(Object,LockMode) ! */ ! public final class LockMode implements Serializable { ! private final int level; ! private final String name; ! private LockMode(int level, String name) { ! this.level=level; ! this.name=name; ! } ! public String toString() { ! return name; ! } ! /** ! * Is this lock mode more restrictive than the given lock mode? ! */ ! public boolean greaterThan(LockMode mode) { ! return level > mode.level; ! } ! /** ! * Is this lock mode less restrictive than the given lock mode? ! */ ! public boolean lessThan(LockMode mode) { ! return level < mode.level; ! } ! /** ! * No lock required. If an object is requested with this lock ! * mode, a <tt>READ</tt> lock might be obtained if necessary. ! */ ! public static final LockMode NONE = new LockMode(0, "NONE"); ! /** ! * A shared lock. Objects are loaded in <tt>READ</tt> mode ! * by default. ! */ ! public static final LockMode READ = new LockMode(5, "READ"); ! /** ! * An upgrade lock. Objects loaded in this lock mode are ! * materialized using an SQL <tt>select ... for update</tt>. ! */ ! public static final LockMode UPGRADE = new LockMode(10, "UPGRADE"); ! /** ! * Attempt to obtain an upgrade lock, using an Oracle-style ! * <tt>select ... for update nowait</tt>. The semantics of ! * this lock mode, once obtained, are the same as ! * <tt>UPGRADE</tt>.<br> ! */ ! public static final LockMode UPGRADE_NOWAIT = new LockMode(10, "UPGRADE_NOWAIT"); ! /** ! * A <tt>WRITE</tt> lock is obtained when an object is updated ! * or inserted. This is not a valid mode for <tt>load()</tt> ! * or <tt>lock()</tt>. ! */ ! public static final LockMode WRITE = new LockMode(10, "WRITE"); ! ! } --- 1,67 ---- ! //$Id$ ! package cirrus.hibernate; ! ! import java.io.Serializable; ! ! /** ! * Instances represent a lock mode for a row of a relational ! * database table. It is not intended that users spend much ! * time worrying about locking since Hibernate usually ! * obtains exactly the right lock level automatically. ! * Some "advanced" users may wish to explicitly specify lock ! * levels. ! * ! * @see Session#lock(Object,LockMode) ! */ ! public final class LockMode implements Serializable { ! private final int level; ! private final String name; ! private LockMode(int level, String name) { ! this.level=level; ! this.name=name; ! } ! public String toString() { ! return name; ! } ! /** ! * Is this lock mode more restrictive than the given lock mode? ! */ ! public boolean greaterThan(LockMode mode) { ! return level > mode.level; ! } ! /** ! * Is this lock mode less restrictive than the given lock mode? ! */ ! public boolean lessThan(LockMode mode) { ! return level < mode.level; ! } ! /** ! * No lock required. If an object is requested with this lock ! * mode, a <tt>READ</tt> lock might be obtained if necessary. ! */ ! public static final LockMode NONE = new LockMode(0, "NONE"); ! /** ! * A shared lock. Objects are loaded in <tt>READ</tt> mode ! * by default. ! */ ! public static final LockMode READ = new LockMode(5, "READ"); ! /** ! * An upgrade lock. Objects loaded in this lock mode are ! * materialized using an SQL <tt>select ... for update</tt>. ! */ ! public static final LockMode UPGRADE = new LockMode(10, "UPGRADE"); ! /** ! * Attempt to obtain an upgrade lock, using an Oracle-style ! * <tt>select ... for update nowait</tt>. The semantics of ! * this lock mode, once obtained, are the same as ! * <tt>UPGRADE</tt>.<br> ! */ ! public static final LockMode UPGRADE_NOWAIT = new LockMode(10, "UPGRADE_NOWAIT"); ! /** ! * A <tt>WRITE</tt> lock is obtained when an object is updated ! * or inserted. This is not a valid mode for <tt>load()</tt> ! * or <tt>lock()</tt>. ! */ ! public static final LockMode WRITE = new LockMode(10, "WRITE"); ! ! } Index: QueryException.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/QueryException.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** QueryException.java 28 Oct 2002 15:41:53 -0000 1.3 --- QueryException.java 26 Nov 2002 03:35:40 -0000 1.4 *************** *** 31,33 **** } ! --- 31,33 ---- } ! Index: ScrollableResults.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/ScrollableResults.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ScrollableResults.java 21 Nov 2002 09:03:09 -0000 1.5 --- ScrollableResults.java 26 Nov 2002 03:35:40 -0000 1.6 *************** *** 1,153 **** ! //$Id$ ! package cirrus.hibernate; ! ! import java.math.BigDecimal; ! import java.sql.SQLException; ! import java.util.Calendar; ! import java.util.Date; ! import java.util.Locale; ! import java.util.TimeZone; ! ! import cirrus.hibernate.type.Type; ! ! /** ! * A result iterator that allows moving around within the results ! * by arbitrary increments. The <tt>Query</tt> / <tt>ScrollableResults</tt> ! * pattern is very similar to the JDBC <tt>PreparedStatement</tt>/ ! * <tt>ResultSet</tt> pattern and the semantics of methods of this interface ! * are similar to the similarly named methods on <tt>ResultSet</tt>.<br> ! * <br> ! * Contrary to JDBC, columns of results are numbered from zero. ! * ! * @see Query#scroll() ! */ ! public interface ScrollableResults { ! /** ! * Advance to the next result ! * @param i ! * @return <tt>true</tt> if there is another result ! */ ! public boolean next() throws SQLException, HibernateException; ! /** ! * Retreat to the previous result ! * @param i ! * @return <tt>true</tt> if there is a previous result ! */ ! public boolean previous() throws SQLException, HibernateException; ! /** ! * Scroll an arbitrary number of locations ! * @param i a positive (forward) or negative (backward) number of rows ! * @return <tt>true</tt> if there is a result at the new location ! */ ! public boolean scroll(int i) throws SQLException, HibernateException; ! /** ! * Go to the last result ! * @return <tt>true</tt> if there are any results ! */ ! public boolean last() throws SQLException, HibernateException; ! /** ! * Go to the first result ! * @return <tt>true</tt> if there are any results ! */ ! public boolean first() throws SQLException, HibernateException; ! /** ! * Go to a location just before first result (this is the initial location) ! * @return <tt>true</tt> if there are any results ! */ ! public void beforeFirst() throws SQLException, HibernateException; ! /** ! * Go to a location just after the last result ! * @return <tt>true</tt> if there are any results ! */ ! public void afterLast() throws SQLException, HibernateException; ! /** ! * Release resources immediately. ! */ ! public void close() throws SQLException, HibernateException; ! /** ! * Get the current row of results ! * @return an object or array ! */ ! public Object[] get() throws SQLException, HibernateException; ! /** ! * Get the <tt>i</tt>th object in the current row of results, without ! * initializing any other results in the row. This method may be used ! * safely, regardless of the type of the column (ie. even for scalar ! * results). ! * @param i the column, numbered from zero ! * @return an object of any Hibernate type or <tt>null</tt> ! */ ! public Object get(int i) throws SQLException, HibernateException; ! ! /** ! * Get the type of the <tt>i</tt>th column of results ! * @param i the column, numbered from zero ! * @return the Hibernate type ! */ ! public Type getType(int i); ! ! /** ! * Convenience method to read an integer ! */ ! public Integer getInteger(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a long ! */ ! public Long getLong(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a float ! */ ! public Float getFloat(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a boolean ! */ ! public Boolean getBoolean(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a double ! */ ! public Double getDouble(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a short ! */ ! public Short getShort(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a byte ! */ ! public Byte getByte(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a character ! */ ! public Character getCharacter(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a binary ! */ ! public byte[] getBinary(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a string ! */ ! public String getString(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a big_decimal ! */ ! public BigDecimal getBigDecimal(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a date, time or timestamp ! */ ! public Date getDate(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a locale ! */ ! public Locale getLocale(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a calendar or calendar date ! */ ! public Calendar getCalendar(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a currency ! */ ! //public Currency getCurrency(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a timezone ! */ ! public TimeZone getTimeZone(int col) throws SQLException, HibernateException; ! } --- 1,153 ---- ! //$Id$ ! package cirrus.hibernate; ! ! import java.math.BigDecimal; ! import java.sql.SQLException; ! import java.util.Calendar; ! import java.util.Date; ! import java.util.Locale; ! import java.util.TimeZone; ! ! import cirrus.hibernate.type.Type; ! ! /** ! * A result iterator that allows moving around within the results ! * by arbitrary increments. The <tt>Query</tt> / <tt>ScrollableResults</tt> ! * pattern is very similar to the JDBC <tt>PreparedStatement</tt>/ ! * <tt>ResultSet</tt> pattern and the semantics of methods of this interface ! * are similar to the similarly named methods on <tt>ResultSet</tt>.<br> ! * <br> ! * Contrary to JDBC, columns of results are numbered from zero. ! * ! * @see Query#scroll() ! */ ! public interface ScrollableResults { ! /** ! * Advance to the next result ! * @param i ! * @return <tt>true</tt> if there is another result ! */ ! public boolean next() throws SQLException, HibernateException; ! /** ! * Retreat to the previous result ! * @param i ! * @return <tt>true</tt> if there is a previous result ! */ ! public boolean previous() throws SQLException, HibernateException; ! /** ! * Scroll an arbitrary number of locations ! * @param i a positive (forward) or negative (backward) number of rows ! * @return <tt>true</tt> if there is a result at the new location ! */ ! public boolean scroll(int i) throws SQLException, HibernateException; ! /** ! * Go to the last result ! * @return <tt>true</tt> if there are any results ! */ ! public boolean last() throws SQLException, HibernateException; ! /** ! * Go to the first result ! * @return <tt>true</tt> if there are any results ! */ ! public boolean first() throws SQLException, HibernateException; ! /** ! * Go to a location just before first result (this is the initial location) ! * @return <tt>true</tt> if there are any results ! */ ! public void beforeFirst() throws SQLException, HibernateException; ! /** ! * Go to a location just after the last result ! * @return <tt>true</tt> if there are any results ! */ ! public void afterLast() throws SQLException, HibernateException; ! /** ! * Release resources immediately. ! */ ! public void close() throws SQLException, HibernateException; ! /** ! * Get the current row of results ! * @return an object or array ! */ ! public Object[] get() throws SQLException, HibernateException; ! /** ! * Get the <tt>i</tt>th object in the current row of results, without ! * initializing any other results in the row. This method may be used ! * safely, regardless of the type of the column (ie. even for scalar ! * results). ! * @param i the column, numbered from zero ! * @return an object of any Hibernate type or <tt>null</tt> ! */ ! public Object get(int i) throws SQLException, HibernateException; ! ! /** ! * Get the type of the <tt>i</tt>th column of results ! * @param i the column, numbered from zero ! * @return the Hibernate type ! */ ! public Type getType(int i); ! ! /** ! * Convenience method to read an integer ! */ ! public Integer getInteger(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a long ! */ ! public Long getLong(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a float ! */ ! public Float getFloat(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a boolean ! */ ! public Boolean getBoolean(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a double ! */ ! public Double getDouble(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a short ! */ ! public Short getShort(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a byte ! */ ! public Byte getByte(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a character ! */ ! public Character getCharacter(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a binary ! */ ! public byte[] getBinary(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a string ! */ ! public String getString(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a big_decimal ! */ ! public BigDecimal getBigDecimal(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a date, time or timestamp ! */ ! public Date getDate(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a locale ! */ ! public Locale getLocale(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a calendar or calendar date ! */ ! public Calendar getCalendar(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a currency ! */ ! //public Currency getCurrency(int col) throws SQLException, HibernateException; ! /** ! * Convenience method to read a timezone ! */ ! public TimeZone getTimeZone(int col) throws SQLException, HibernateException; ! } Index: Validatable.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/Validatable.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Validatable.java 3 Sep 2002 02:10:02 -0000 1.1 --- Validatable.java 26 Nov 2002 03:35:40 -0000 1.2 *************** *** 1,17 **** ! //$Id$ ! package cirrus.hibernate; ! ! /** ! * Implemented by persistent classes with invariants that must ! * be checked before inserting into or updating the database. ! */ ! public interface Validatable { ! /** ! * Validate the state of the object before persisting it. ! * If a violation occurs, throw a <tt>ValidationFailure</tt>. ! * This method must not change the state of the object by ! * side-effect. ! * @throws ValidationFailure if an invariant is violated ! */ ! public void validate() throws ValidationFailure; ! } --- 1,17 ---- ! //$Id$ ! package cirrus.hibernate; ! ! /** ! * Implemented by persistent classes with invariants that must ! * be checked before inserting into or updating the database. ! */ ! public interface Validatable { ! /** ! * Validate the state of the object before persisting it. ! * If a violation occurs, throw a <tt>ValidationFailure</tt>. ! * This method must not change the state of the object by ! * side-effect. ! * @throws ValidationFailure if an invariant is violated ! */ ! public void validate() throws ValidationFailure; ! } Index: ValidationFailure.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/ValidationFailure.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ValidationFailure.java 27 Oct 2002 04:05:20 -0000 1.2 --- ValidationFailure.java 26 Nov 2002 03:35:40 -0000 1.3 *************** *** 1,23 **** ! //$Id$ ! package cirrus.hibernate; ! ! /** ! * Thrown from <tt>Validatable.validate()</tt> when an invariant ! * was violated. Some applications might subclass this exception ! * in order to provide more information about the violation. ! */ ! public class ValidationFailure extends HibernateException { ! ! public ValidationFailure(String message) { ! super(message); ! } ! ! public ValidationFailure(String message, Exception e) { ! super(message, e); ! } ! ! public ValidationFailure(Exception e) { ! super("A validation failure occurred", e); ! } ! ! } --- 1,23 ---- ! //$Id$ ! package cirrus.hibernate; ! ! /** ! * Thrown from <tt>Validatable.validate()</tt> when an invariant ! * was violated. Some applications might subclass this exception ! * in order to provide more information about the violation. ! */ ! public class ValidationFailure extends HibernateException { ! ! public ValidationFailure(String message) { ! super(message); ! } ! ! public ValidationFailure(String message, Exception e) { ! super(message, e); ! } ! ! public ValidationFailure(Exception e) { ! super("A validation failure occurred", e); ! } ! ! } |
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/test Modified Files: A.java ABCProxyTest.java ABCTest.java B.java BasicNameable.java Baz.java C1.java C2.java Category.java Contained.java Custom.java CustomPersister.java D.java DemoTest.java FooComponent.java FooStatus.java Fumm.java Glarch.java Holder.java LessSimple.java Location.java MoreStuff.java Multi.hbm.xml Multi.java MultiTableTest.java Nameable.java Named.java ODMGTest.java ParentChildTest.java Qux.java Several.java Simple.java Single.java Stuff.java SubDetail.java SubMulti.java Trivial.java Log Message: fixed broken line-endings and added a test Index: A.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/A.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** A.java 18 Oct 2002 15:16:11 -0000 1.1 --- A.java 26 Nov 2002 03:35:44 -0000 1.2 *************** *** 1,40 **** ! package cirrus.hibernate.test; ! ! ! public class A { ! private Long id; ! private String name; ! ! /** ! * Returns the id. ! * @return Long ! */ ! public Long getId() { ! return id; ! } ! ! /** ! * Returns the name. ! * @return String ! */ ! public String getName() { ! return name; ! } ! ! /** ! * Sets the id. ! * @param id The id to set ! */ ! public void setId(Long id) { ! this.id = id; ! } ! ! /** ! * Sets the name. ! * @param name The name to set ! */ ! public void setName(String name) { ! this.name = name; ! } ! ! } --- 1,40 ---- ! package cirrus.hibernate.test; ! ! ! public class A { ! private Long id; ! private String name; ! ! /** ! * Returns the id. ! * @return Long ! */ ! public Long getId() { ! return id; ! } ! ! /** ! * Returns the name. ! * @return String ! */ ! public String getName() { ! return name; ! } ! ! /** ! * Sets the id. ! * @param id The id to set ! */ ! public void setId(Long id) { ! this.id = id; ! } ! ! /** ! * Sets the name. ! * @param name The name to set ! */ ! public void setName(String name) { ! this.name = name; ! } ! ! } Index: ABCProxyTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/ABCProxyTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ABCProxyTest.java 20 Nov 2002 10:30:45 -0000 1.3 --- ABCProxyTest.java 26 Nov 2002 03:35:44 -0000 1.4 *************** *** 130,134 **** throw e; } ! } } --- 130,134 ---- throw e; } ! } } Index: ABCTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/ABCTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ABCTest.java 20 Nov 2002 10:30:45 -0000 1.2 --- ABCTest.java 26 Nov 2002 03:35:44 -0000 1.3 *************** *** 80,84 **** throw e; } ! } } --- 80,84 ---- throw e; } ! } } Index: B.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/B.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** B.java 18 Oct 2002 15:16:11 -0000 1.1 --- B.java 26 Nov 2002 03:35:44 -0000 1.2 *************** *** 1,22 **** ! package cirrus.hibernate.test; ! ! ! public class B extends A { ! private int count; ! /** ! * Returns the count. ! * @return int ! */ ! public int getCount() { ! return count; ! } ! ! /** ! * Sets the count. ! * @param count The count to set ! */ ! public void setCount(int count) { ! this.count = count; ! } ! ! } --- 1,22 ---- ! package cirrus.hibernate.test; ! ! ! public class B extends A { ! private int count; ! /** ! * Returns the count. ! * @return int ! */ ! public int getCount() { ! return count; ! } ! ! /** ! * Sets the count. ! * @param count The count to set ! */ ! public void setCount(int count) { ! this.count = count; ! } ! ! } Index: BasicNameable.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/BasicNameable.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BasicNameable.java 30 Oct 2002 13:34:25 -0000 1.1 --- BasicNameable.java 26 Nov 2002 03:35:44 -0000 1.2 *************** *** 1,42 **** ! //$Id$ ! package cirrus.hibernate.test; ! ! /** ! * @author administrator ! * ! * ! */ ! public class BasicNameable implements Nameable { ! ! private String name; ! private Long id; ! ! /** ! * @see cirrus.hibernate.test.Nameable#getName() ! */ ! public String getName() { ! return name; ! } ! ! /** ! * @see cirrus.hibernate.test.Nameable#setName() ! */ ! public void setName(String n) { ! name = n; ! } ! ! /** ! * @see cirrus.hibernate.test.Nameable#getKey() ! */ ! public Long getKey() { ! return id; ! } ! ! /** ! * @see cirrus.hibernate.test.Nameable#setKey() ! */ ! public void setKey(Long k) { ! id = k; ! } ! ! } --- 1,42 ---- ! //$Id$ ! package cirrus.hibernate.test; ! ! /** ! * @author administrator ! * ! * ! */ ! public class BasicNameable implements Nameable { ! ! private String name; ! private Long id; ! ! /** ! * @see cirrus.hibernate.test.Nameable#getName() ! */ ! public String getName() { ! return name; ! } ! ! /** ! * @see cirrus.hibernate.test.Nameable#setName() ! */ ! public void setName(String n) { ! name = n; ! } ! ! /** ! * @see cirrus.hibernate.test.Nameable#getKey() ! */ ! public Long getKey() { ! return id; ! } ! ! /** ! * @see cirrus.hibernate.test.Nameable#setKey() ! */ ! public void setKey(Long k) { ! id = k; ! } ! ! } Index: Baz.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Baz.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Baz.java 28 Oct 2002 19:27:49 -0000 1.28 --- Baz.java 26 Nov 2002 03:35:44 -0000 1.29 *************** *** 172,176 **** this.fooSet = fooSet; } ! public FooComponent[] getComponents() { return components; --- 172,176 ---- this.fooSet = fooSet; } ! public FooComponent[] getComponents() { return components; *************** *** 179,183 **** this.components = components; } ! public Date[] getTimeArray() { return timeArray; --- 179,183 ---- this.components = components; } ! public Date[] getTimeArray() { return timeArray; Index: C1.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/C1.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** C1.java 18 Oct 2002 15:16:11 -0000 1.1 --- C1.java 26 Nov 2002 03:35:44 -0000 1.2 *************** *** 1,39 **** ! package cirrus.hibernate.test; ! ! ! public class C1 extends B{ ! private String address; ! private D d; ! /** ! * Returns the address. ! * @return String ! */ ! public String getAddress() { ! return address; ! } ! ! /** ! * Sets the address. ! * @param address The address to set ! */ ! public void setAddress(String address) { ! this.address = address; ! } ! ! /** ! * Returns the d. ! * @return D ! */ ! public D getD() { ! return d; ! } ! ! /** ! * Sets the d. ! * @param d The d to set ! */ ! public void setD(D d) { ! this.d = d; ! } ! ! } --- 1,39 ---- ! package cirrus.hibernate.test; ! ! ! public class C1 extends B{ ! private String address; ! private D d; ! /** ! * Returns the address. ! * @return String ! */ ! public String getAddress() { ! return address; ! } ! ! /** ! * Sets the address. ! * @param address The address to set ! */ ! public void setAddress(String address) { ! this.address = address; ! } ! ! /** ! * Returns the d. ! * @return D ! */ ! public D getD() { ! return d; ! } ! ! /** ! * Sets the d. ! * @param d The d to set ! */ ! public void setD(D d) { ! this.d = d; ! } ! ! } Index: C2.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/C2.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** C2.java 18 Oct 2002 15:16:11 -0000 1.1 --- C2.java 26 Nov 2002 03:35:44 -0000 1.2 *************** *** 1,22 **** ! package cirrus.hibernate.test; ! ! ! public class C2 extends B{ ! private String address; ! /** ! * Returns the address. ! * @return String ! */ ! public String getAddress() { ! return address; ! } ! ! /** ! * Sets the address. ! * @param address The address to set ! */ ! public void setAddress(String address) { ! this.address = address; ! } ! ! } --- 1,22 ---- ! package cirrus.hibernate.test; ! ! ! public class C2 extends B{ ! private String address; ! /** ! * Returns the address. ! * @return String ! */ ! public String getAddress() { ! return address; ! } ! ! /** ! * Sets the address. ! * @param address The address to set ! */ ! public void setAddress(String address) { ! this.address = address; ! } ! ! } Index: Category.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Category.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Category.java 28 Oct 2002 15:41:53 -0000 1.2 --- Category.java 26 Nov 2002 03:35:44 -0000 1.3 *************** *** 1,65 **** ! //$Id$ ! package cirrus.hibernate.test; ! ! import java.util.ArrayList; ! import java.util.List; ! ! /** ! * ! */ ! public class Category { ! ! public static final String ROOT_CATEGORY = "/"; ! ! private long id; ! private String name; ! private List subcategories = new ArrayList(); ! /** ! * Returns the id. ! * @return long ! */ ! public long getId() { ! return id; ! } ! ! /** ! * Sets the id. ! * @param id The id to set ! */ ! public void setId(long id) { ! this.id = id; ! } ! ! /** ! * Returns the subcategories. ! * @return List ! */ ! public List getSubcategories() { ! return subcategories; ! } ! ! /** ! * Sets the subcategories. ! * @param subcategories The subcategories to set ! */ ! public void setSubcategories(List subcategories) { ! this.subcategories = subcategories; ! } ! ! /** ! * Returns the name. ! * @return String ! */ ! public String getName() { ! return name; ! } ! ! /** ! * Sets the name. ! * @param name The name to set ! */ ! public void setName(String name) { ! this.name = name; ! } ! ! } --- 1,65 ---- ! //$Id$ ! package cirrus.hibernate.test; ! ! import java.util.ArrayList; ! import java.util.List; ! ! /** ! * ! */ ! public class Category { ! ! public static final String ROOT_CATEGORY = "/"; ! ! private long id; ! private String name; ! private List subcategories = new ArrayList(); ! /** ! * Returns the id. ! * @return long ! */ ! public long getId() { ! return id; ! } ! ! /** ! * Sets the id. ! * @param id The id to set ! */ ! public void setId(long id) { ! this.id = id; ! } ! ! /** ! * Returns the subcategories. ! * @return List ! */ ! public List getSubcategories() { ! return subcategories; ! } ! ! /** ! * Sets the subcategories. ! * @param subcategories The subcategories to set ! */ ! public void setSubcategories(List subcategories) { ! this.subcategories = subcategories; ! } ! ! /** ! * Returns the name. ! * @return String ! */ ! public String getName() { ! return name; ! } ! ! /** ! * Sets the name. ! * @param name The name to set ! */ ! public void setName(String name) { ! this.name = name; ! } ! ! } Index: Contained.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Contained.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Contained.java 7 Sep 2002 03:01:52 -0000 1.2 --- Contained.java 26 Nov 2002 03:35:44 -0000 1.3 *************** *** 1,66 **** ! //$Id$ ! package cirrus.hibernate.test; ! ! import java.util.ArrayList; ! import java.util.Collection; ! ! public class Contained { ! private Container container; ! private long id; ! private Collection bag = new ArrayList(); ! public boolean equals(Object other) { ! return id==( (Contained) other ).id; ! } ! public int hashCode() { ! return new Long(id).hashCode(); ! } ! ! /** ! * Returns the container. ! * @return Container ! */ ! public Container getContainer() { ! return container; ! } ! ! /** ! * Returns the id. ! * @return long ! */ ! public long getId() { ! return id; ! } ! ! /** ! * Sets the container. ! * @param container The container to set ! */ ! public void setContainer(Container container) { ! this.container = container; ! } ! ! /** ! * Sets the id. ! * @param id The id to set ! */ ! public void setId(long id) { ! this.id = id; ! } ! ! /** ! * Returns the bag. ! * @return Collection ! */ ! public Collection getBag() { ! return bag; ! } ! ! /** ! * Sets the bag. ! * @param bag The bag to set ! */ ! public void setBag(Collection bag) { ! this.bag = bag; ! } ! ! } --- 1,66 ---- ! //$Id$ ! package cirrus.hibernate.test; ! ! import java.util.ArrayList; ! import java.util.Collection; ! ! public class Contained { ! private Container container; ! private long id; ! private Collection bag = new ArrayList(); ! public boolean equals(Object other) { ! return id==( (Contained) other ).id; ! } ! public int hashCode() { ! return new Long(id).hashCode(); ! } ! ! /** ! * Returns the container. ! * @return Container ! */ ! public Container getContainer() { ! return container; ! } ! ! /** ! * Returns the id. ! * @return long ! */ ! public long getId() { ! return id; ! } ! ! /** ! * Sets the container. ! * @param container The container to set ! */ ! public void setContainer(Container container) { ! this.container = container; ! } ! ! /** ! * Sets the id. ! * @param id The id to set ! */ ! public void setId(long id) { ! this.id = id; ! } ! ! /** ! * Returns the bag. ! * @return Collection ! */ ! public Collection getBag() { ! return bag; ! } ! ! /** ! * Sets the bag. ! * @param bag The bag to set ! */ ! public void setBag(Collection bag) { ! this.bag = bag; ! } ! ! } Index: Custom.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Custom.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Custom.java 28 Sep 2002 07:23:56 -0000 1.1 --- Custom.java 26 Nov 2002 03:35:44 -0000 1.2 *************** *** 1,17 **** ! //$Id$ ! package cirrus.hibernate.test; ! ! ! public class Custom implements Cloneable { ! long id; ! String name; ! ! public Object clone() { ! try { ! return super.clone(); ! } ! catch (CloneNotSupportedException cnse) { ! throw new RuntimeException(); ! } ! } ! } --- 1,17 ---- ! //$Id$ ! package cirrus.hibernate.test; ! ! ! public class Custom implements Cloneable { ! long id; ! String name; ! ! public Object clone() { ! try { ! return super.clone(); ! } ! catch (CloneNotSupportedException cnse) { ! throw new RuntimeException(); ! } ! } ! } Index: CustomPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/CustomPersister.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** CustomPersister.java 5 Nov 2002 11:48:08 -0000 1.14 --- CustomPersister.java 26 Nov 2002 03:35:44 -0000 1.15 *************** *** 1,434 **** ! //$Id$ ! package cirrus.hibernate.test; ! ! import java.io.Serializable; ! import java.lang.reflect.Method; ! import java.sql.SQLException; ! import java.util.Hashtable; ! ! import cirrus.hibernate.Hibernate; ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.LockMode; ! import cirrus.hibernate.MappingException; ! import cirrus.hibernate.cache.CacheConcurrencyStrategy; ! import cirrus.hibernate.engine.Cascades; ! import cirrus.hibernate.engine.Key; ! import cirrus.hibernate.engine.SessionFactoryImplementor; ! import cirrus.hibernate.engine.SessionImplementor; ! import cirrus.hibernate.id.IdentifierGenerator; ! import cirrus.hibernate.id.LongGenerator; ! import cirrus.hibernate.map.PersistentClass; ! import cirrus.hibernate.metadata.ClassMetadata; ! import cirrus.hibernate.persister.ClassPersister; ! import cirrus.hibernate.type.Type; ! import cirrus.hibernate.type.VersionType; ! ! public class CustomPersister implements ClassPersister { ! ! private static final Hashtable instances = new Hashtable(); ! private static final IdentifierGenerator idgen = new LongGenerator(); ! ! public CustomPersister(PersistentClass model, SessionFactoryImplementor factory) {} ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#postInstantiate(SessionFactoryImplementor) ! */ ! public void postInstantiate(SessionFactoryImplementor factory) ! throws MappingException { ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getMappedClass() ! */ ! public Class getMappedClass() { ! return Custom.class; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getClassName() ! */ ! public String getClassName() { ! return Custom.class.getName(); ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#hasCompositeKey() ! */ ! public boolean hasCompositeKey() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#implementsPersistentLifecycle() ! */ ! public boolean implementsPersistentLifecycle() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#implementsLifecycle() ! */ ! public boolean implementsLifecycle() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#implementsValidatable() ! */ ! public boolean implementsValidatable() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#hasProxy() ! */ ! public boolean hasProxy() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getProxyInterfaces() ! */ ! public Class[] getProxyInterfaces() { ! return null; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#hasCollections() ! */ ! public boolean hasCollections() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#hasCascades() ! */ ! public boolean hasCascades() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#isMutable() ! */ ! public boolean isMutable() { ! return true; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#isIdentifierAssignedByInsert() ! */ ! public boolean isIdentifierAssignedByInsert() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#isUnsaved(Serializable) ! */ ! public boolean isUnsaved(Serializable id) { ! return ( (Long) id ).longValue()==0; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#setPropertyValues(Object, Object[]) ! */ ! public void setPropertyValues(Object object, Object[] values) ! throws HibernateException { ! Custom c = (Custom) object; ! c.name = (String) values[0]; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getPropertyValues(Object) ! */ ! public Object[] getPropertyValues(Object object) ! throws HibernateException { ! ! Custom c = (Custom) object; ! return new Object[] { c.name }; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getPropertyValue(Object, int) ! */ ! public Object getPropertyValue(Object obj, int i) ! throws HibernateException { ! return ( (Custom) obj ).name; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#setPropertyValue(Object, int, Object) ! */ ! public void setPropertyValue(Object obj, int i, Object val) ! throws HibernateException { ! ( (Custom) obj ).name = (String) val; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#isDirty(Object[], Object[], Object, SessionImplementor) ! */ ! public int[] findDirty( ! Object[] x, ! Object[] y, ! Object owner, ! SessionImplementor session) ! throws HibernateException { ! if ( x[0]!=y[0] && ( x[0]==null || y[0]==null || !x[0].equals(y[0]) ) ) { ! return new int[] { 0 }; ! } ! else { ! return null; ! } ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#hasIdentifierProperty() ! */ ! public boolean hasIdentifierProperty() { ! return true; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getIdentifier(Object) ! */ ! public Serializable getIdentifier(Object object) ! throws HibernateException { ! return new Long( ( (Custom) object ).id ); ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#setIdentifier(Object, Serializable) ! */ ! public void setIdentifier(Object object, Serializable id) ! throws HibernateException { ! ! ( (Custom) object ).id = ( (Long) id ).longValue(); ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getProxyGetIdentifierMethod() ! */ ! public Method getProxyGetIdentifierMethod() { ! return null; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#isVersioned() ! */ ! public boolean isVersioned() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getVersionType() ! */ ! public VersionType getVersionType() { ! return null; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getVersionProperty() ! */ ! public int getVersionProperty() { ! return 0; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getVersion(Object) ! */ ! public Object getVersion(Object object) throws HibernateException { ! return null; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#instantiate(Serializable) ! */ ! public Object instantiate(Serializable id) throws HibernateException { ! Custom c = new Custom(); ! c.id = ( (Long) id ).longValue(); ! return c; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getIdentifierGenerator() ! */ ! public IdentifierGenerator getIdentifierGenerator() ! throws HibernateException { ! return idgen; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#load(Serializable, Object, boolean, SessionImplementor) ! */ ! public Object load( ! Serializable id, ! Object optionalObject, ! LockMode lockMode, ! SessionImplementor session) ! throws HibernateException, SQLException { ! ! // fails when optional object is supplied ! ! Custom clone = null; ! Custom obj = (Custom) instances.get(id); ! if (obj!=null) { ! clone = (Custom) obj.clone(); ! session.addUninitializedEntity( new Key(id, this), clone, LockMode.NONE ); ! session.postHydrate(this, id, new String[] { obj.name }, clone, LockMode.NONE); ! session.initializeEntity(clone); ! } ! return clone; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#lockForUpdate(Serializable, Object, SessionImplementor) ! */ ! public void lock( ! Serializable id, ! Object version, ! Object object, ! LockMode lockMode, ! SessionImplementor session) ! throws HibernateException, SQLException { ! ! throw new UnsupportedOperationException(); ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#insert(Serializable, Object[], SessionImplementor) ! */ ! public void insert( ! Serializable id, ! Object[] fields, ! Object object, ! SessionImplementor session) ! throws SQLException, HibernateException { ! ! instances.put(id, ( (Custom) object ).clone() ); ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#insert(Object[], SessionImplementor) ! */ ! public Serializable insert(Object[] fields, Object object, SessionImplementor session) ! throws SQLException, HibernateException { ! ! throw new UnsupportedOperationException(); ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#delete(Serializable, Object, SessionImplementor) ! */ ! public void delete( ! Serializable id, ! Object version, ! Object object, ! SessionImplementor session) ! throws SQLException, HibernateException { ! ! instances.remove(id); ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#update(Serializable, Object[], Object, SessionImplementor) ! */ ! public void update( ! Serializable id, ! Object[] fields, ! int[] dirtyFields, ! Object oldVersion, ! Object object, ! SessionImplementor session) ! throws SQLException, HibernateException { ! ! instances.put( id, ( (Custom) object ).clone() ); ! ! } ! ! Type[] TYPES = new Type[] { Hibernate.STRING }; ! String[] NAMES = new String[] { "name" }; ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getPropertyTypes() ! */ ! public Type[] getPropertyTypes() { ! return TYPES; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getPropertyNames() ! */ ! public String[] getPropertyNames() { ! return NAMES; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getPropertyCascadeStyles() ! */ ! public Cascades.CascadeStyle[] getPropertyCascadeStyles() { ! return null; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getIdentifierType() ! */ ! public Type getIdentifierType() { ! return Hibernate.LONG; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getIdentifierPropertyName() ! */ ! public String getIdentifierPropertyName() { ! return "id"; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#hasCache() ! */ ! public boolean hasCache() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getCache() ! */ ! public CacheConcurrencyStrategy getCache() { ! return null; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getIdentifierSpace() ! */ ! public Serializable getIdentifierSpace() { ! return "CUSTOMS"; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getPropertySpaces(Object) ! */ ! public Serializable[] getPropertySpaces(Object instance) { ! return new String[] { "CUSTOMS" }; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getClassMetadata() ! */ ! public ClassMetadata getClassMetadata() { ! return null; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#hasSubclasses() ! */ ! public boolean hasSubclasses() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getConcreteProxyClass() ! */ ! public Class getConcreteProxyClass() { ! return Custom.class; ! } ! ! } --- 1,434 ---- ! //$Id$ ! package cirrus.hibernate.test; ! ! import java.io.Serializable; ! import java.lang.reflect.Method; ! import java.sql.SQLException; ! import java.util.Hashtable; ! ! import cirrus.hibernate.Hibernate; ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.LockMode; ! import cirrus.hibernate.MappingException; ! import cirrus.hibernate.cache.CacheConcurrencyStrategy; ! import cirrus.hibernate.engine.Cascades; ! import cirrus.hibernate.engine.Key; ! import cirrus.hibernate.engine.SessionFactoryImplementor; ! import cirrus.hibernate.engine.SessionImplementor; ! import cirrus.hibernate.id.IdentifierGenerator; ! import cirrus.hibernate.id.LongGenerator; ! import cirrus.hibernate.map.PersistentClass; ! import cirrus.hibernate.metadata.ClassMetadata; ! import cirrus.hibernate.persister.ClassPersister; ! import cirrus.hibernate.type.Type; ! import cirrus.hibernate.type.VersionType; ! ! public class CustomPersister implements ClassPersister { ! ! private static final Hashtable instances = new Hashtable(); ! private static final IdentifierGenerator idgen = new LongGenerator(); ! ! public CustomPersister(PersistentClass model, SessionFactoryImplementor factory) {} ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#postInstantiate(SessionFactoryImplementor) ! */ ! public void postInstantiate(SessionFactoryImplementor factory) ! throws MappingException { ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getMappedClass() ! */ ! public Class getMappedClass() { ! return Custom.class; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getClassName() ! */ ! public String getClassName() { ! return Custom.class.getName(); ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#hasCompositeKey() ! */ ! public boolean hasCompositeKey() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#implementsPersistentLifecycle() ! */ ! public boolean implementsPersistentLifecycle() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#implementsLifecycle() ! */ ! public boolean implementsLifecycle() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#implementsValidatable() ! */ ! public boolean implementsValidatable() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#hasProxy() ! */ ! public boolean hasProxy() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getProxyInterfaces() ! */ ! public Class[] getProxyInterfaces() { ! return null; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#hasCollections() ! */ ! public boolean hasCollections() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#hasCascades() ! */ ! public boolean hasCascades() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#isMutable() ! */ ! public boolean isMutable() { ! return true; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#isIdentifierAssignedByInsert() ! */ ! public boolean isIdentifierAssignedByInsert() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#isUnsaved(Serializable) ! */ ! public boolean isUnsaved(Serializable id) { ! return ( (Long) id ).longValue()==0; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#setPropertyValues(Object, Object[]) ! */ ! public void setPropertyValues(Object object, Object[] values) ! throws HibernateException { ! Custom c = (Custom) object; ! c.name = (String) values[0]; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getPropertyValues(Object) ! */ ! public Object[] getPropertyValues(Object object) ! throws HibernateException { ! ! Custom c = (Custom) object; ! return new Object[] { c.name }; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getPropertyValue(Object, int) ! */ ! public Object getPropertyValue(Object obj, int i) ! throws HibernateException { ! return ( (Custom) obj ).name; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#setPropertyValue(Object, int, Object) ! */ ! public void setPropertyValue(Object obj, int i, Object val) ! throws HibernateException { ! ( (Custom) obj ).name = (String) val; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#isDirty(Object[], Object[], Object, SessionImplementor) ! */ ! public int[] findDirty( ! Object[] x, ! Object[] y, ! Object owner, ! SessionImplementor session) ! throws HibernateException { ! if ( x[0]!=y[0] && ( x[0]==null || y[0]==null || !x[0].equals(y[0]) ) ) { ! return new int[] { 0 }; ! } ! else { ! return null; ! } ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#hasIdentifierProperty() ! */ ! public boolean hasIdentifierProperty() { ! return true; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getIdentifier(Object) ! */ ! public Serializable getIdentifier(Object object) ! throws HibernateException { ! return new Long( ( (Custom) object ).id ); ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#setIdentifier(Object, Serializable) ! */ ! public void setIdentifier(Object object, Serializable id) ! throws HibernateException { ! ! ( (Custom) object ).id = ( (Long) id ).longValue(); ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getProxyGetIdentifierMethod() ! */ ! public Method getProxyGetIdentifierMethod() { ! return null; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#isVersioned() ! */ ! public boolean isVersioned() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getVersionType() ! */ ! public VersionType getVersionType() { ! return null; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getVersionProperty() ! */ ! public int getVersionProperty() { ! return 0; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getVersion(Object) ! */ ! public Object getVersion(Object object) throws HibernateException { ! return null; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#instantiate(Serializable) ! */ ! public Object instantiate(Serializable id) throws HibernateException { ! Custom c = new Custom(); ! c.id = ( (Long) id ).longValue(); ! return c; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getIdentifierGenerator() ! */ ! public IdentifierGenerator getIdentifierGenerator() ! throws HibernateException { ! return idgen; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#load(Serializable, Object, boolean, SessionImplementor) ! */ ! public Object load( ! Serializable id, ! Object optionalObject, ! LockMode lockMode, ! SessionImplementor session) ! throws HibernateException, SQLException { ! ! // fails when optional object is supplied ! ! Custom clone = null; ! Custom obj = (Custom) instances.get(id); ! if (obj!=null) { ! clone = (Custom) obj.clone(); ! session.addUninitializedEntity( new Key(id, this), clone, LockMode.NONE ); ! session.postHydrate(this, id, new String[] { obj.name }, clone, LockMode.NONE); ! session.initializeEntity(clone); ! } ! return clone; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#lockForUpdate(Serializable, Object, SessionImplementor) ! */ ! public void lock( ! Serializable id, ! Object version, ! Object object, ! LockMode lockMode, ! SessionImplementor session) ! throws HibernateException, SQLException { ! ! throw new UnsupportedOperationException(); ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#insert(Serializable, Object[], SessionImplementor) ! */ ! public void insert( ! Serializable id, ! Object[] fields, ! Object object, ! SessionImplementor session) ! throws SQLException, HibernateException { ! ! instances.put(id, ( (Custom) object ).clone() ); ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#insert(Object[], SessionImplementor) ! */ ! public Serializable insert(Object[] fields, Object object, SessionImplementor session) ! throws SQLException, HibernateException { ! ! throw new UnsupportedOperationException(); ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#delete(Serializable, Object, SessionImplementor) ! */ ! public void delete( ! Serializable id, ! Object version, ! Object object, ! SessionImplementor session) ! throws SQLException, HibernateException { ! ! instances.remove(id); ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#update(Serializable, Object[], Object, SessionImplementor) ! */ ! public void update( ! Serializable id, ! Object[] fields, ! int[] dirtyFields, ! Object oldVersion, ! Object object, ! SessionImplementor session) ! throws SQLException, HibernateException { ! ! instances.put( id, ( (Custom) object ).clone() ); ! ! } ! ! Type[] TYPES = new Type[] { Hibernate.STRING }; ! String[] NAMES = new String[] { "name" }; ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getPropertyTypes() ! */ ! public Type[] getPropertyTypes() { ! return TYPES; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getPropertyNames() ! */ ! public String[] getPropertyNames() { ! return NAMES; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getPropertyCascadeStyles() ! */ ! public Cascades.CascadeStyle[] getPropertyCascadeStyles() { ! return null; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getIdentifierType() ! */ ! public Type getIdentifierType() { ! return Hibernate.LONG; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getIdentifierPropertyName() ! */ ! public String getIdentifierPropertyName() { ! return "id"; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#hasCache() ! */ ! public boolean hasCache() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getCache() ! */ ! public CacheConcurrencyStrategy getCache() { ! return null; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getIdentifierSpace() ! */ ! public Serializable getIdentifierSpace() { ! return "CUSTOMS"; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getPropertySpaces(Object) ! */ ! public Serializable[] getPropertySpaces(Object instance) { ! return new String[] { "CUSTOMS" }; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getClassMetadata() ! */ ! public ClassMetadata getClassMetadata() { ! return null; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#hasSubclasses() ! */ ! public boolean hasSubclasses() { ! return false; ! } ! ! /** ! * @see cirrus.hibernate.persister.ClassPersister#getConcreteProxyClass() ! */ ! public Class getConcreteProxyClass() { ! return Custom.class; ! } ! ! } Index: D.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/D.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** D.java 18 Oct 2002 15:20:01 -0000 1.1 --- D.java 26 Nov 2002 03:35:44 -0000 1.2 *************** *** 1,38 **** ! package cirrus.hibernate.test; ! ! public class D { ! private Long id; ! private float amount; ! /** ! * Returns the amount. ! * @return float ! */ ! public float getAmount() { ! return amount; ! } ! ! /** ! * Returns the id. ! * @return long ! */ ! public Long getId() { ! return id; ! } ! ! /** ! * Sets the amount. ! * @param amount The amount to set ! */ ! public void setAmount(float amount) { ! this.amount = amount; ! } ! ! /** ! * Sets the id. ! * @param id The id to set ! */ ! public void setId(Long id) { ! this.id = id; ! } ! ! } --- 1,38 ---- ! package cirrus.hibernate.test; ! ! public class D { ! private Long id; ! private float amount; ! /** ! * Returns the amount. ! * @return float ! */ ! public float getAmount() { ! return amount; ! } ! ! /** ! * Returns the id. ! * @return long ! */ ! public Long getId() { ! return id; ! } ! ! /** ! * Sets the amount. ! * @param amount The amount to set ! */ ! public void setAmount(float amount) { ! this.amount = amount; ! } ! ! /** ! * Sets the id. ! * @param id The id to set ! */ ! public void setId(Long id) { ! this.id = id; ! } ! ! } Index: DemoTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/DemoTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DemoTest.java 18 Aug 2002 09:47:45 -0000 1.1 --- DemoTest.java 26 Nov 2002 03:35:44 -0000 1.2 *************** *** 1,46 **** ! package cirrus.hibernate.test; ! ! import cirrus.hibernate.eg.NetworkDemo; ! ! import junit.framework.TestCase; ! ! public class DemoTest extends TestCase { ! ! public DemoTest(String arg0) { ! super(arg0); ! } ! ! public void testDemo() throws Exception { ! ! Thread t = new Thread() { ! public void run() { ! try { ! NetworkDemo.main(new String[0]); ! } ! catch (Exception e) { ! assertTrue(false); ! } ! } ! }; ! t.start(); ! ! Thread.sleep(2000); ! ! NetworkDemo.command("setup"); ! NetworkDemo.command("create vertex v"); ! NetworkDemo.command("create vertex w"); ! NetworkDemo.command("create edge x 1 1 v w"); ! NetworkDemo.command("create edge y 1 1 v w"); ! NetworkDemo.command("show"); ! NetworkDemo.command("find from e in class cirrus.hibernate.eg.Edge where e.length>0.5"); ! NetworkDemo.command("delete edge y"); ! NetworkDemo.command("delete vertex v"); ! NetworkDemo.command("drop"); ! t.stop(); ! ! } ! ! ! public static void main(String[] args) { ! } ! } --- 1,46 ---- ! package cirrus.hibernate.test; ! ! import cirrus.hibernate.eg.NetworkDemo; ! ! import junit.framework.TestCase; ! ! public class DemoTest extends TestCase { ! ! public DemoTest(String arg0) { ! super(arg0); ! } ! ! public void testDemo() throws Exception { ! ! Thread t = new Thread() { ! public void run() { ! try { ! NetworkDemo.main(new String[0]); ! } ! catch (Exception e) { ! assertTrue(false); ! } ! } ! }; ! t.start(); ! ! Thread.sleep(2000); ! ! NetworkDemo.command("setup"); ! NetworkDemo.command("create vertex v"); ! NetworkDemo.command("create vertex w"); ! NetworkDemo.command("create edge x 1 1 v w"); ! NetworkDemo.command("create edge y 1 1 v w"); ! NetworkDemo.command("show"); ! NetworkDemo.command("find from e in class cirrus.hibernate.eg.Edge where e.length>0.5"); ! NetworkDemo.command("delete edge y"); ! NetworkDemo.command("delete vertex v"); ! NetworkDemo.command("drop"); ! t.stop(); ! ! } ! ! ! public static void main(String[] args) { ! } ! } Index: FooComponent.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/FooComponent.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** FooComponent.java 28 Oct 2002 19:27:49 -0000 1.10 --- FooComponent.java 26 Nov 2002 03:35:44 -0000 1.11 *************** *** 52,56 **** this.count = count; } ! public String getName() { return name; --- 52,56 ---- this.count = count; } ! public String getName() { return name; *************** *** 59,63 **** this.name = name; } ! public Date[] getImportantDates() { return importantDates; --- 59,63 ---- this.name = name; } ! public Date[] getImportantDates() { return importantDates; *************** *** 79,83 **** private void setNull(String str) throws Exception { if (str!=null) throw new Exception("null component property"); ! } public Fee getFee() { return fee; --- 79,83 ---- private void setNull(String str) throws Exception { if (str!=null) throw new Exception("null component property"); ! } public Fee getFee() { return fee; Index: FooStatus.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/FooStatus.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FooStatus.java 28 Oct 2002 19:27:49 -0000 1.2 --- FooStatus.java 26 Nov 2002 03:35:44 -0000 1.3 *************** *** 31,35 **** return fromInt(code); } ! } --- 31,35 ---- return fromInt(code); } ! } Index: Fumm.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Fumm.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Fumm.java 29 Aug 2002 10:46:35 -0000 1.1 --- Fumm.java 26 Nov 2002 03:35:44 -0000 1.2 *************** *** 1,53 **** ! //$Id$ ! package cirrus.hibernate.test; ! ! import java.util.Locale; ! ! public class Fumm { ! ! private Locale locale; ! private Fum fum; ! ! public FumCompositeID getId() { ! return fum.getId(); ! } ! public void setId(FumCompositeID id) { ! } ! ! public Fumm() { ! super(); ! } ! ! /** ! * Returns the fum. ! * @return Fum ! */ ! public Fum getFum() { ! return fum; ! } ! ! /** ! * Returns the locale. ! * @return Locale ! */ ! public Locale getLocale() { ! return locale; ! } ! ! /** ! * Sets the fum. ! * @param fum The fum to set ! */ ! public void setFum(Fum fum) { ! this.fum = fum; ! } ! ! /** ! * Sets the locale. ! * @param locale The locale to set ! */ ! public void setLocale(Locale locale) { ! this.locale = locale; ! } ! ! } --- 1,53 ---- ! //$Id$ ! package cirrus.hibernate.test; ! ! import java.util.Locale; ! ! public class Fumm { ! ! private Locale locale; ! private Fum fum; ! ! public FumCompositeID getId() { ! return fum.getId(); ! } ! public void setId(FumCompositeID id) { ! } ! ! public Fumm() { ! super(); ! } ! ! /** ! * Returns the fum. ! * @return Fum ! */ ! public Fum getFum() { ! return fum; ! } ! ! /** ! * Returns the locale. ! * @return Locale ! */ ! public Locale getLocale() { ! return locale; ! } ! ! /** ! * Sets the fum. ! * @param fum The fum to set ! */ ! public void setFum(Fum fum) { ! this.fum = fum; ! } ! ! /** ! * Sets the locale. ! * @param locale The locale to set ! */ ! public void setLocale(Locale locale) { ! this.locale = locale; ! } ! ! } Index: Glarch.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Glarch.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Glarch.java 28 Oct 2002 19:27:49 -0000 1.17 --- Glarch.java 26 Nov 2002 03:35:44 -0000 1.18 *************** *** 51,55 **** this.order = order; } ! public List getStrings() { return strings; --- 51,55 ---- this.order = order; } ! public List getStrings() { return strings; *************** *** 81,85 **** public void setProxyArray(GlarchProxy[] proxyArray) { this.proxyArray = proxyArray; ! } public Set getProxySet() { return proxySet; --- 81,85 ---- public void setProxyArray(GlarchProxy[] proxyArray) { this.proxyArray = proxyArray; ! } public Set getProxySet() { return proxySet; Index: Holder.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Holder.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Holder.java 20 Nov 2002 10:30:45 -0000 1.3 --- Holder.java 26 Nov 2002 03:35:44 -0000 1.4 *************** *** 1,99 **** ! //$Id$ ! package cirrus.hibernate.test; ! ! import java.util.*; ! ! public class Holder implements Named { ! private String id; ! private List ones; ! private Foo[] fooArray; ! private Set foos; ! private String name; ! ! public Holder() { ! } ! public Holder(String name) { ! this.name=name; ! } ! ! /** ! * Returns the fooArray. ! * @return Foo[] ! */ ! public Foo[] getFooArray() { ! return fooArray; ! } ! ! /** ! * Returns the foos. ! * @return Set ! */ ! public Set getFoos() { ! return foos; ! } ! ! /** ! * Sets the fooArray. ! * @param fooArray The fooArray to set ! */ ! public void setFooArray(Foo[] fooArray) { ! this.fooArray = fooArray; ! } ! ! /** ! * Sets the foos. ! * @param foos The foos to set ! */ ! public void setFoos(Set foos) { ! this.foos = foos; ! } ! ! /** ! * Returns the id. ! * @return String ! */ ! public String getId() { ! return id; ! } ! ! /** ! * Sets the id. ! * @param id The id to set ! */ ! public void setId(String id) { ! this.id = id; ! } ! ! /** ! * Returns the name. ! * @return String ! */ ! public String getName() { ! return name; ! } ! ! /** ! * Sets the name. ! * @param name The name to set ! */ ! public void setName(String name) { ! this.name = name; ! } ! ! /** ! * Returns the ones. ! * @return List ! */ ! public List getOnes() { ! return ones; ! } ! ! /** ! * Sets the ones. ! * @param ones The ones to set ! */ ! public void setOnes(List ones) { ! this.ones = ones; ! } ! ! } --- 1,99 ---- ! //$Id$ ! package cirrus.hibernate.test; ! ! import java.util.*; ! ! public class Holder implements Named { ! private String id; ! private List ones; ! private Foo[] fooArray; ! private Set foos; ! private String name; ! ! public Holder() { ! } ! public Holder(String name) { ! this.name=name; ! } ! ! /** ! * Returns the fooArray. ! * @return Foo[] ! */ ! public Foo[] getFooArray() { ! return fooArray; ! } ! ! /** ! * Returns the foos. ! * @return Set ! */ ! public Set getFoos() { ! return foos; ! } ! ! /** ! * Sets the fooArray. ! * @param fooArray The fooArray to set ! */ ! public void setFooArray(Foo[] fooArray) { ! this.fooArray = fooArray; ! } ! ! /** ! * Sets the foos. ! * @param foos The foos to set ! */ ! public void setFoos(Set foos) { ! this.foos = foos; ! } ! ! /** ! * Returns the id. ! * @return String ! */ ! public String getId() { ! return id; ! } ! ! /** ! * Sets the id. ! * @param id The id to set ! */ ! public void setId(String id) { ! this.id = id; ! } ! ! /** ! * Returns the name. ! * @return String ! */ ! public String getName() { ! return name; ! } ! ! /** ! * Sets the name. ! * @param name The name to set ! */ ! public void setName(String name) { ! this.name = name; ! } ! ! /** ! * Returns the ones. ! * @return List ! */ ! public List getOnes() { ! return ones; ! } ! ! /** ! * Sets the ones. ! * @param ones The ones to set ! */ ! public void setOnes(List ones) { ! this.ones = ones; ! } ! ! } Index: LessSimple.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/LessSimple.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LessSimple.java 5 Nov 2002 03:44:02 -0000 1.3 --- LessSimple.java 26 Nov 2002 03:35:44 -0000 1.4 *************** *** 1,92 **** ! //$Id$ ! package cirrus.hibernate.test; ! ! import java.util.Set; ! ! public class LessSimple extends Simple { ! private int intprop; ! private String foo; ! private Set set; ! private Simple another; ! private LessSimple yetanother; ! /** ! * Returns the intprop. ! * @return int ! */ ! public int getIntprop() { ! return intprop; ! } ! ! /** ! * Sets the intprop. ! * @param intprop The intprop to set ! */ ! public void setIntprop(int intprop) { ! this.intprop = intprop; ! } ! ! /** ! * Returns the foo. ! * @return String ! */ ! public String getFoo() { ! return foo; ! } ! ! /** ! * Sets the foo. ! * @param foo The foo to set ! */ ! public void setFoo(String foo) { ! this.foo = foo; ! } ! ! /** ! * Returns the set. ! * @return Set ! */ ! public Set getSet() { ! return set; ! } ! ! /** ! * Sets the set. ! * @param set The set to set ! */ ! public void setSet(Set set) { ! this.set = set; ! } ! ! /** ! * Returns the another. ! * @return Simple ! */ ! public Simple getAnother() { ! return another; ! } ! ! /** ! * Returns the yetanother. ! * @return LessSimple ! */ ! public LessSimple getYetanother() { ! return yetanother; ! } ! ! /** ! * Sets the another. ! * @param another The another to set ! */ ! public void setAnother(Simple another) { ! this.another = another; ! } ! ! /** ! * Sets the yetanother. ! * @param yetanother The yetanother to set ! */ ! public void setYetanother(LessSimple yetanother) { ! this.yetanother = yetanother; ! } ! ! } --- 1,92 ---- ! //$Id$ ! package cirrus.hibernate.test; ! ! import java.util.Set; ! ! public class LessSimple extends Simple { ! private int intprop; ! private String foo; ! private Set set; ! private Simple another; ! private LessSimple yetanother; ! /** ! * Returns the intprop. ! * @return int ! */ ! public int getIntprop() { ! return intprop; ! } ! ! /** ! * Sets the intprop. ! * @param intprop The intprop to set ! */ ! public void setIntprop(int intprop) { ! this.intprop = intprop; ! } ! ! /** ! * Returns the foo. ! * @return String ! */ ! public String getFoo() { ! return foo; ! } ! ! /** ! * Sets the foo. ! * @param foo The foo to set ! */ ! public void setFoo(String foo) { ! this.foo = foo; ! } ! ! /** ! * Returns the set. ! * @return Set ! */ ! public Set getSet() { ! return set; ! } ! ! /** ! * Sets the set. ! * @param set The set to set ! */ ! public void setSet(Set set) { ! this.set = set; ! } ! ! /** ! * Returns the another. ! * @return Simple ! */ ! public Simple getAnother() { ! return another; ! } ! ! /** ! * Returns the yetanother. ! * @return LessSimple ! */ ! public LessSimple getYetanother() { ! return yetanother; ! } ! ! /** ! * Sets the another. ! * @param another The another to set ! */ ! public void setAnother(Simple another) { ! this.another = another; ! } ! ! /** ! * Sets the yetanother. ! * @param yetanother The yetanother to set ! */ ! public void setYetanother(LessSimple yetanother) { ! this.yetanother = yetanother; ! } ! ! } Index: Location.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Location.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Location.java 4 Sep 2002 04:27:44 -0000 1.1 --- Location.java 26 Nov 2002 03:35:44 -0000 1.2 *************** *** 1,119 **** ! //$Id$ ! package cirrus.hibernate.test; ! ! import java.io.Serializable; ! import java.util.Locale; ! ! public class Location implements Serializable { ! private int streetNumber; ! private String city; ! private String streetName; ! private String countryCode; ! private Locale locale; ! private String description; ! ! /** ! * Returns the countryCode. ! * @return String ! */ ! public String getCountryCode() { ! return countryCode; ! } ! ! /** ! * Returns the description. ! * @return String ! */ ! public String getDescription() { ! return description; ! } ! ! /** ! * Returns the locale. ! * @return Locale ! */ ! public Locale getLocale() { ! return locale; ! } ! ! /** ! * Returns the streetName. ! * @return String ! */ ! public String getStreetName() { ! return streetName; ! } ! ! /** ! * Returns the streetNumber. ! * @return int ! */ ! public int getStreetNumber() { ! return streetNumber; ! } ! ! /** ! * Sets the countryCode. ! * @param countryCode The countryCode to set ! */ ! public void setCountryCode(String countryCode) { ! this.countryCode = countryCode; ! } ! ! /** ! * Sets the description. ! * @param description The description to set ! */ ! public void setDescription(String description) { ! this.description = description; ! } ! ! /** ! * Sets the locale. ! * @param locale The locale to set ! */ ! public void setLocale(Locale locale) { ! this.locale = locale; ! } ! ! /** ! * Sets the streetName. ! * @param streetName The streetName to set ! */ ! public void setStreetName(String streetName) { ! this.streetName = streetName; ! } ! ! /** ! * Sets the streetNumber. ! * @param streetNumber The streetNumber to set ! */ ! public void setStreetNumber(int streetNumber) { ! this.streetNumber = streetNumber; ! } ! ! /** ! * Returns the city. ! * @return String ! */ ! public String getCity() { ! return city; ! } ! ! /** ! * Sets the city. ! * @param city The city to set ! */ ! public void setCity(String city) { ! this.city = city; ! } ! ! public boolean equals(Object other) { ! Location l = (Location) other; ! return l.getCity().equals(city) && l.getStreetName().equals(streetName) && l.getCountryCode().equals(countryCode) && l.getStreetNumber()==streetNumber; ! } ! public int hashCode() { ! return streetName.hashCode(); ! } ! ! } --- 1,119 ---- ! //$Id$ ! package cirrus.hibernate.test; ! ! import java.io.Serializable; ! import java.util.Locale; ! ! public class Location implements Serializable { ! private int streetNumber; ! private String city; ! private String streetName; ! private String countryCode; ! private Locale locale; ! private String description; ! ! /** ! * Returns the countryCode. ! * @return String ! */ ! public String getCountryCode() { ! return countryCode; ! } ! ! /** ! * Returns the description. ! * @return String ! */ ! public String getDescription() { ! return description; ! } ! ! /** ! * Returns the locale. ! * @return Locale ! */ ! public Locale getLocale() { ! return locale; ! } ! ! /** ! * Returns the streetName. ! * @return String ! */ ! public String getStreetName() { ! return streetName; ! } ! ! /** ! * Returns the streetNumber. ! * @return int ! */ ! public int getStreetNumber() { ! return streetNumber; ! } ! ! /** ! * Sets the countryCode. ! * @param countryCode The countryCode to set ! */ ! public void setCountryCode(String countryCode) { ! this.countryCode = countryCode; ! } ! ! /** ! * Sets the description. ! * @param description The description to set ! */ ! public void setDescription(String description) { ! this.description = description; ! } ! ! /** ! * Sets the locale. ! * @param locale The locale to set ! */ ! public void setLocale(Locale locale) { ! this.locale = locale; ! } ! ! /** ! * Sets the streetName. ! * @param streetName The streetName to set ! */ ! public void setStreetName(String streetName) { ! this.streetName = streetName; ! } ! ! /** ! * Sets the streetNumber. ! * @param streetNumber The streetNumber to set ! */ ! public void setStreetNumber(int streetNumber) { ! this.streetNumber = streetNumber; ! } ! ! /** ! * Returns the city. ! * @return String ! */ ! public String getCity() { ! return city; ! } ! ! /** ! * Sets the city. ! * @param city The city to set ! */ ! public void setCity(String city) { ! this.city = city; ! } ! ! public boolean equals(Object other) { ! Location l = (Location) other; ! return l.getCity().equals(city) && l.getStreetName().equals(streetName) && l.getCountryCode().equals(countryCode) && l.getStreetNumber()==streetNumber; ! } ! public int hashCode() { ! return streetName.hashCode(); ! } ! ! } Index: MoreStuff.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/MoreStuff.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MoreStuff.java 7 Nov 2002 11:33:49 -0000 1.2 --- MoreStuff.java 26 Nov 2002 03:35:44 -0000 1.3 *************** *** 1,86 **** ! //$Id$ ! package cirrus.hibernate.test; ! ! import java.io.Serializable; ! import java.util.Collection; ! ! ! public class MoreStuff implements Serializable { ! private String stringId; ! private int intId; ! private Collection stuffs; ! private String name; ! ! public boolean equals(Object other) { ! return ( (MoreStuff) other ).getIntId()==intId && ( (MoreStuff) other ).getStringId().equals(stringId); ! } ! ! public int hashCode() { ! return stringId.hashCode(); ! } ! ! /** ! * Returns the stuffs. ! * @return Collection ! */ ! public Collection getStuffs() { ! return stuffs; ! } ! ! /** ! * Sets the stuffs. ! * @param stuffs The stuffs to set ! */ ! public void setStuffs(Collection stuffs) { ! th... [truncated message content] |
From: <one...@us...> - 2002-11-26 03:35:49
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/reflect In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/tools/reflect Modified Files: MappingByReflection.java ReflectedArrayProperty.java ReflectedClass.java ReflectedCollectionProperty.java ReflectedComponent.java ReflectedListProperty.java ReflectedMapProperty.java ReflectedProperty.java ReflectedSetProperty.java Log Message: fixed broken line-endings and added a test Index: MappingByReflection.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/reflect/MappingByReflection.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** MappingByReflection.java 11 Nov 2002 01:25:07 -0000 1.15 --- MappingByReflection.java 26 Nov 2002 03:35:45 -0000 1.16 *************** *** 1,672 **** ! //$Id$ ! package cirrus.hibernate.tools.reflect; ! ! import java.lang.reflect.*; ! import java.util.Hashtable; ! import java.util.Vector; ! import java.io.InputStreamReader; ! import java.io.BufferedReader; ! import java.io.Reader; ! import java.io.StreamTokenizer; [...1315 lines suppressed...] ! } ! ! ! } ! ! /* TO DO ! * new dtd accommodated? ! * length property for string/blob/binary? ! * top level collections (see PEntity and entities) ! * (nice)... ! * maybe also give access to ReflectedClass so callers can set... ! * UID property name and generator ! * (or heuristically?)... ! * get real UID, index, and data colummns for collections ! * nesting into collections ! * optimistic locking ! * ... ! * ! */ ! Index: ReflectedArrayProperty.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/reflect/ReflectedArrayProperty.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReflectedArrayProperty.java 9 Feb 2002 23:08:18 -0000 1.3 --- ReflectedArrayProperty.java 26 Nov 2002 03:35:45 -0000 1.4 *************** *** 1,65 **** ! package cirrus.hibernate.tools.reflect; ! ! /** ! * @version 1.x ! * @author <a href="mailto:dou...@al...">e</a> ! */ ! class ReflectedArrayProperty extends ReflectedProperty { ! ! protected ReflectedProperty element; ! ! /** ! * Constructor for ReflectedArrayProperty. ! * @param name ! * @param type ! * @param comment ! */ ! ReflectedArrayProperty( String name, Class type, MappingByReflection map ) { ! super(name, type, map, "array"); ! this.element = null; ! Class elmcls = type.getComponentType(); ! if( elmcls == null ) { ! // huh! not an array after all!? ! // use type.getName() in case tynm modified ! emitPCommentStr( 1,"NOT an array!?", name, type.getName() ); ! return; ! } ! String roleName = map.tableNameFor(elmcls.getName()); ! this.element = map.makeProperty( roleName, elmcls ); ! // TO DO ! // if elmcls is a collection, it would be nice to make ! // the top level collection template here with role name roleName ! } ! ! protected void getXMLinArray( int level, StringBuffer buf ) { ! this.buf = buf; ! emitPCommentStr(level, "BUG!?: array of array ", name, element.name); ! } ! ! protected void getXMLinComposite( int level, StringBuffer buf ) { ! this.buf = buf; ! emitCollectionInCompositeStr(level); ! } ! ! //<!ELEMENT array (key, index, (element|one-to-many|many-to-many|subcollection|composite-element))> ! // <!ATTLIST array role CDATA #REQUIRED> ! // <!ATTLIST array table CDATA #IMPLIED> ! ! protected void getXML( int level, StringBuffer buf ) { ! this.buf = buf; ! if( comment != null ) { ! emitPCommentStr(level, comment, name, type.getName()); ! } ! if( element == null ) { ! emitPCommentStr(level, "BUG array of unknown kind!", name, element.name); ! } ! else { ! boolean p = element.type.isPrimitive(); ! emitCollectionStrL(level, p ? "primitive-array" : "array", name, false); ! emitCollectionStrK(level+1, "uid"); ! emitCollectionStrI(level+1, "idx"); ! element.getXMLinArray( level+1, buf ); ! emitCollectionStrR(level, p ? "primitive-array" : "array"); ! } ! } ! } --- 1,65 ---- ! package cirrus.hibernate.tools.reflect; ! ! /** ! * @version 1.x ! * @author <a href="mailto:dou...@al...">e</a> ! */ ! class ReflectedArrayProperty extends ReflectedProperty { ! ! protected ReflectedProperty element; ! ! /** ! * Constructor for ReflectedArrayProperty. ! * @param name ! * @param type ! * @param comment ! */ ! ReflectedArrayProperty( String name, Class type, MappingByReflection map ) { ! super(name, type, map, "array"); ! this.element = null; ! Class elmcls = type.getComponentType(); ! if( elmcls == null ) { ! // huh! not an array after all!? ! // use type.getName() in case tynm modified ! emitPCommentStr( 1,"NOT an array!?", name, type.getName() ); ! return; ! } ! String roleName = map.tableNameFor(elmcls.getName()); ! this.element = map.makeProperty( roleName, elmcls ); ! // TO DO ! // if elmcls is a collection, it would be nice to make ! // the top level collection template here with role name roleName ! } ! ! protected void getXMLinArray( int level, StringBuffer buf ) { ! this.buf = buf; ! emitPCommentStr(level, "BUG!?: array of array ", name, element.name); ! } ! ! protected void getXMLinComposite( int level, StringBuffer buf ) { ! this.buf = buf; ! emitCollectionInCompositeStr(level); ! } ! ! //<!ELEMENT array (key, index, (element|one-to-many|many-to-many|subcollection|composite-element))> ! // <!ATTLIST array role CDATA #REQUIRED> ! // <!ATTLIST array table CDATA #IMPLIED> ! ! protected void getXML( int level, StringBuffer buf ) { ! this.buf = buf; ! if( comment != null ) { ! emitPCommentStr(level, comment, name, type.getName()); ! } ! if( element == null ) { ! emitPCommentStr(level, "BUG array of unknown kind!", name, element.name); ! } ! else { ! boolean p = element.type.isPrimitive(); ! emitCollectionStrL(level, p ? "primitive-array" : "array", name, false); ! emitCollectionStrK(level+1, "uid"); ! emitCollectionStrI(level+1, "idx"); ! element.getXMLinArray( level+1, buf ); ! emitCollectionStrR(level, p ? "primitive-array" : "array"); ! } ! } ! } Index: ReflectedClass.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/reflect/ReflectedClass.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ReflectedClass.java 11 Nov 2002 01:25:07 -0000 1.8 --- ReflectedClass.java 26 Nov 2002 03:35:45 -0000 1.9 *************** *** 1,401 **** ! package cirrus.hibernate.tools.reflect; ! ! import java.lang.reflect.*; ! import java.beans.Introspector; ! import java.util.Enumeration; ! import java.util.Hashtable; ! import java.util.Vector; ! ! import cirrus.hibernate.helpers.StringHelper; ! ! /** a ReflectedClass is created by MappingByReflection instances for ! * every class encountered, from map.addClass(), while chasing the ! * superclass chain, or grokking properties ! * ! * @version 1.x ! * @author <a href="mailto:dou...@al...">e</a> ! */ ! public class ReflectedClass { ! ! private MappingByReflection map; // my containing map ! private StringBuffer buf;// shared buffer provided by MappingByReflection ! private Class clazz; // my class ! private Vector subs; // my ReflectedClass subclasses ! private Hashtable props;// my ReflectedProperty(s) keyed by property name ! private ReflectedProperty uid; ! private boolean persistent; // true => persistent class or subclass ! // false => component or serializable ! ! private Hashtable setprops; ! private Hashtable getprops; ! ! protected ReflectedClass( MappingByReflection map, Class cls ) { ! this.clazz = cls; ! this.map = map; ! this.subs = new Vector(); ! this.uid = null; ! this.persistent = false; // default to component until told otherwise ! map.rClasses.put( cls, this ); // this must happen to avoid infinite regress... ! this.reflect(); // here ! } ! ! /** used by gui */ ! public String getName() { ! return clazz.getName(); ! } ! ! /** used by gui */ ! public ReflectedProperty[] getProperties() { ! ReflectedProperty[] rp = new ReflectedProperty[props.size()]; ! Enumeration e = props.elements(); ! int i = 0; ! while( e.hasMoreElements() ) { ! rp[i++] = (ReflectedProperty )e.nextElement(); ! } ! return rp; ! } ! ! /** used by gui */ ! public ReflectedClass[] getSubclasses() { ! ReflectedClass[] v = new ReflectedClass[subs.size()]; ! subs.copyInto(v); ! return v; ! } ! ! protected void addReflectedClass( ReflectedClass rc ) { ! subs.add( rc ); ! } ! ! /* no longer used; see getUidProp ! protected boolean isRoot() { ! return ( uid != null ); ! }*/ ! ! /** has the class been deemed hibernate-persistable? <br> ! * if not, it may still be useful as a component or may be serializable ! */ ! protected boolean isPersistent() { ! return this.persistent; ! } ! ! /** called by MappinByReflection when this class has been ! * deemed hibernate-persistable ! */ ! protected void setPersistent( boolean p ) { ! this.persistent = p; ! } ! ! /** does this class have any properties? <br> this is not reliable ! * until addSuperclassProps() is called once first ! */ ! protected boolean hasProperties() { ! return ( props.size() != 0 ); ! } ! ! /** add to this class the properties of all its superclasses ! */ ! protected void addSuperclassProps() { ! // add properties from superclasses ! addSuperclassProps( clazz.getSuperclass() ); ! } // with helper... ! private void addSuperclassProps( Class supz ) { ! if( supz != null ) { ! reflectClass( supz ); ! addSuperclassProps( supz.getSuperclass() ); // recurse ! } ! } ! ! /** dump the OR-Mapping XML for a root class and all of its subclasses ! * that share a table and UID ! */ ! protected void getXML(int level) { ! // dumps in map.buf ! this.buf = map.buf; ! String name = clazz.getName(); ! String shortName = StringHelper.unqualify(name); ! // debug... ! map.emitPrefix(level);; ! buf.append("<!-- ") ! .append(name) ! .append(" root -->\n"); ! // a root class -- polymorphic style ! map.emitPrefix(level);; ! buf.append("<class name=\"") ! .append(name) ! .append("\" table=\"") ! .append(map.tableNameFor(name)) ! .append((subs.size() > 0) ? "\" discriminator-value=\"" + shortName : "") ! .append("\">\n"); ! // first find the uid ! if( uid == null ) { ! // report error ! map.emitPrefix(level); ! buf.append("<!-- NO UID!? class=\"") ! .append(name) ! .append("\" -->\n"); ! } else { ! uid.getUidXML(level+1, buf); ! } ! //the discriminator element ! if ( subs.size() > 0 ) { ! map.emitPrefix(level+1); ! buf.append("<discriminator column=\"subclass\" type=\"string\"/>\n"); ! } ! // now the properties already classified by heuristic ! Enumeration ps = props.elements(); ! while( ps.hasMoreElements() ) { ! ReflectedProperty prop = (ReflectedProperty )ps.nextElement(); ! if( prop.isUid ) continue; // done above ! // we're root and top component level ! map.cycleBuster = new Hashtable(); ! prop.getXML( level+1, buf ); ! } ! // now the subclasses ! int len = subs.size(); ! for( int i=0; i<len; i++ ) { ! ReflectedClass rsc = (ReflectedClass )subs.get(i); ! rsc.getXMLasSubclass(level+1); ! } ! map.emitPrefix(level);; ! buf.append("</class>\n"); ! } ! ! /** dump the OR-Mapping XML for a non-root class and all of its ! * subclasses that share its table and UID ! */ ! protected void getXMLasSubclass(int level) { ! // dumps in map.buf ! this.buf = map.buf; ! String name = clazz.getName(); ! // debug... ! map.emitPrefix(level);; ! buf.append("<!-- ") ! .append(name) ! .append(" -->\n"); ! // a sub class -- polymorphic style ! map.emitPrefix(level);; ! buf.append("<subclass name=\"") ! .append(name) ! .append("\">\n"); ! // now the properties already classified by heuristic ! Enumeration ps = props.elements(); ! while( ps.hasMoreElements() ) { ! ReflectedProperty prop = (ReflectedProperty )ps.nextElement(); ! if( prop.isUid ) continue; // done above ! prop.getXML( level+1, buf ); ! } ! // now the subclasses ! int len = subs.size(); ! for( int i=0; i<len; i++ ) { ! ReflectedClass rsc = (ReflectedClass )subs.get(i); ! rsc.getXMLasSubclass(level+1); ! } ! map.emitPrefix(level);; ! buf.append("</subclass>\n"); ! } ! ! /** dump the OR-Mapping XML for a class used as a component ! * ! * @param propName the property name of the property containing this component ! */ ! protected void getXMLasComponent( int level, String propName ) { ! // dumps in buf ! this.buf = map.buf; ! String name = clazz.getName(); ! /* debug... ! map.emitPrefix(level);; ! buf.append("<!-- ") ! .append(name) ! .append(" -->\n");*/ ! // a component ! map.emitPrefix(level);; ! buf.append("<component name=\"") ! .append(propName) ! .append("\" class=\"") ! .append(name) ! .append("\">\n"); ! // now the properties already classified by heuristic ! Enumeration ps = props.elements(); ! while( ps.hasMoreElements() ) { ! ReflectedProperty prop = (ReflectedProperty )ps.nextElement(); ! prop.getXML( level+1, buf ); ! } ! // NOT the subclasses ! map.emitPrefix(level);; ! buf.append("</component>\n"); ! } ! ! protected void getXMLasComposite(int level) { ! // dumps in buf ! this.buf = map.buf; ! String name = clazz.getName(); ! // a composite-element ! map.emitPrefix(level);; ! buf.append("<composite-element class=\"") ! .append(name) ! .append("\">\n"); ! // now the properties already classified by heuristic ! Enumeration ps = props.elements(); ! while( ps.hasMoreElements() ) { ! ReflectedProperty prop = (ReflectedProperty )ps.nextElement(); ! // call a restricted form of getXML that disallows inline ! // collections and uses composite-element instead of component ! prop.getXMLinComposite( level, buf ); ! } ! // NOT the subclasses ! map.emitPrefix(level);; ! buf.append("</composite-element>\n"); ! } ! ! protected void getXMLasMany2Many(int level) { ! // dumps in buf ! this.buf = map.buf; ! String name = clazz.getName(); ! // a many-to-many ! map.emitPrefix(level);; ! buf.append("<many-to-many class=\"" ) ! .append(name) ! .append("\" column=\"") ! .append(map.columnNameFor(name)) ! .append("\"/>\n"); ! } ! ! private String capitalize( String s ) { ! char c = s.charAt(0); ! if( Character.isUpperCase(c) ) return s; ! char[] ca = {Character.toUpperCase(c)}; ! return new String(ca).concat(s.substring(1)); ! } ! ! /** called to determine if the class has a UID property ! * ! * @param niceKeys an array of candidate UID names ! * @return the UID ReflectedProperty ! */ ! protected ReflectedProperty getUidProp( String[] niceKeys ) { ! if( uid != null ) return uid; // cache ! // ugh; we'll try some things... ! ReflectedProperty p; ! // try a prop named identically to a niceKey[] ! for( int i=0; i<niceKeys.length; i++ ) { ! p = (ReflectedProperty )props.get(niceKeys[i]); ! // TO DO is isUidOK OK? ! if( p != null && p.isUidOK() ) { ! uid = p; ! break; ! } ! } ! /* now that we're using this for finding roots this tries too hard?... ! if( uid != null ) return uid; ! // try a prop whose name starts with a niceKey[] ! for( int i=0; i<niceKeys.length; i++ ) { ! Enumeration ps = props.elements(); ! while( ps.hasMoreElements() ) { ! p = (ReflectedProperty )ps.nextElement(); ! if( p.isUidOK() && p.name.startsWith(niceKeys[i])) { ! uid = p; ! break; ! } ! } ! } ! if( uid != null ) return uid; ! // try a prop whose name ends with (capitalized) niceKey[] ! for( int i=0; i<niceKeys.length; i++ ) { ! String candidate = capitalize( niceKeys[i] ); ! Enumeration ps = props.elements(); ! while( ps.hasMoreElements() ) { ! p = (ReflectedProperty )ps.nextElement(); ! if( p.isUidOK() && p.name.endsWith(candidate)) { ! uid = p; ! break; ! } ! } ! } ! if( uid != null ) return uid; ! // more to try ? ! // use anything with an appropriate type ! Enumeration ps = props.elements(); ! while( ps.hasMoreElements() ) { ! p = (ReflectedProperty )ps.nextElement(); ! if( p.isUidOK() ) { ! uid = p; ! break; ! } ! }*/ ! return uid; ! } ! ! private void maybeAddProp( String name, Class type ! , Hashtable thisprops, Hashtable thatprops ) { ! Object ty = thatprops.get( name ); ! if( ty == type ) { ! // a winner! ! thatprops.remove( name ); ! ReflectedProperty prop = map.makeProperty( name, type ); ! if (prop!=null) props.put( name, prop ); ! } ! else { ! // maybe later ! thisprops.put( name, type ); ! } ! } ! ! private void addSetter( String name, Class type ) { ! maybeAddProp( name, type, setprops, getprops ); ! } ! ! private void addGetter( String name, Class type ) { ! maybeAddProp( name, type, getprops, setprops ); ! } ! ! /** called by the constructor ! */ ! private void reflect() { ! props = new Hashtable(); ! setprops = new Hashtable(); ! getprops = new Hashtable(); ! reflectClass( clazz ); ! } ! /** called to get the properties of a class, ! * or add properties from a superclass ! */ ! private void reflectClass( Class cls ) { ! // empty getprops and setprops if a getter and setter pair ! // should come from one class and not a class and its superclass ! try { ! Method[] ms = cls.getDeclaredMethods(); ! for( int i=0; i<ms.length; i++ ) { ! Method m = ms[i]; ! if( m == null ) continue; ! int mmod = m.getModifiers(); ! if( Modifier.isStatic( mmod ) ) continue; ! Class argtyp[] = m.getParameterTypes(); ! if( argtyp.length > 1 ) continue; ! String name = m.getName(); ! Class restyp = m.getReturnType(); ! if( argtyp.length == 1 ) { ! if( restyp == void.class && name.startsWith("set") ) { ! addSetter( Introspector.decapitalize(name.substring(3)) ! , argtyp[0] ); ! } ! } ! else { // argtyp.length == 0 ! if( name.startsWith("get") ) { ! addGetter( Introspector.decapitalize(name.substring(3)) ! , restyp ); ! } ! else if( restyp == boolean.class && name.startsWith("is") ) { ! addGetter( Introspector.decapitalize(name.substring(2)) ! , restyp ); ! } ! } ! } ! } ! catch( SecurityException e ) { ! // ignore!? ! } ! } ! ! ! } ! --- 1,401 ---- ! package cirrus.hibernate.tools.reflect; ! ! import java.lang.reflect.*; ! import java.beans.Introspector; ! import java.util.Enumeration; ! import java.util.Hashtable; ! import java.util.Vector; ! ! import cirrus.hibernate.helpers.StringHelper; ! ! /** a ReflectedClass is created by MappingByReflection instances for ! * every class encountered, from map.addClass(), while chasing the ! * superclass chain, or grokking properties ! * ! * @version 1.x ! * @author <a href="mailto:dou...@al...">e</a> ! */ ! public class ReflectedClass { ! ! private MappingByReflection map; // my containing map ! private StringBuffer buf;// shared buffer provided by MappingByReflection ! private Class clazz; // my class ! private Vector subs; // my ReflectedClass subclasses ! private Hashtable props;// my ReflectedProperty(s) keyed by property name ! private ReflectedProperty uid; ! private boolean persistent; // true => persistent class or subclass ! // false => component or serializable ! ! private Hashtable setprops; ! private Hashtable getprops; ! ! protected ReflectedClass( MappingByReflection map, Class cls ) { ! this.clazz = cls; ! this.map = map; ! this.subs = new Vector(); ! this.uid = null; ! this.persistent = false; // default to component until told otherwise ! map.rClasses.put( cls, this ); // this must happen to avoid infinite regress... ! this.reflect(); // here ! } ! ! /** used by gui */ ! public String getName() { ! return clazz.getName(); ! } ! ! /** used by gui */ ! public ReflectedProperty[] getProperties() { ! ReflectedProperty[] rp = new ReflectedProperty[props.size()]; ! Enumeration e = props.elements(); ! int i = 0; ! while( e.hasMoreElements() ) { ! rp[i++] = (ReflectedProperty )e.nextElement(); ! } ! return rp; ! } ! ! /** used by gui */ ! public ReflectedClass[] getSubclasses() { ! ReflectedClass[] v = new ReflectedClass[subs.size()]; ! subs.copyInto(v); ! return v; ! } ! ! protected void addReflectedClass( ReflectedClass rc ) { ! subs.add( rc ); ! } ! ! /* no longer used; see getUidProp ! protected boolean isRoot() { ! return ( uid != null ); ! }*/ ! ! /** has the class been deemed hibernate-persistable? <br> ! * if not, it may still be useful as a component or may be serializable ! */ ! protected boolean isPersistent() { ! return this.persistent; ! } ! ! /** called by MappinByReflection when this class has been ! * deemed hibernate-persistable ! */ ! protected void setPersistent( boolean p ) { ! this.persistent = p; ! } ! ! /** does this class have any properties? <br> this is not reliable ! * until addSuperclassProps() is called once first ! */ ! protected boolean hasProperties() { ! return ( props.size() != 0 ); ! } ! ! /** add to this class the properties of all its superclasses ! */ ! protected void addSuperclassProps() { ! // add properties from superclasses ! addSuperclassProps( clazz.getSuperclass() ); ! } // with helper... ! private void addSuperclassProps( Class supz ) { ! if( supz != null ) { ! reflectClass( supz ); ! addSuperclassProps( supz.getSuperclass() ); // recurse ! } ! } ! ! /** dump the OR-Mapping XML for a root class and all of its subclasses ! * that share a table and UID ! */ ! protected void getXML(int level) { ! // dumps in map.buf ! this.buf = map.buf; ! String name = clazz.getName(); ! String shortName = StringHelper.unqualify(name); ! // debug... ! map.emitPrefix(level);; ! buf.append("<!-- ") ! .append(name) ! .append(" root -->\n"); ! // a root class -- polymorphic style ! map.emitPrefix(level);; ! buf.append("<class name=\"") ! .append(name) ! .append("\" table=\"") ! .append(map.tableNameFor(name)) ! .append((subs.size() > 0) ? "\" discriminator-value=\"" + shortName : "") ! .append("\">\n"); ! // first find the uid ! if( uid == null ) { ! // report error ! map.emitPrefix(level); ! buf.append("<!-- NO UID!? class=\"") ! .append(name) ! .append("\" -->\n"); ! } else { ! uid.getUidXML(level+1, buf); ! } ! //the discriminator element ! if ( subs.size() > 0 ) { ! map.emitPrefix(level+1); ! buf.append("<discriminator column=\"subclass\" type=\"string\"/>\n"); ! } ! // now the properties already classified by heuristic ! Enumeration ps = props.elements(); ! while( ps.hasMoreElements() ) { ! ReflectedProperty prop = (ReflectedProperty )ps.nextElement(); ! if( prop.isUid ) continue; // done above ! // we're root and top component level ! map.cycleBuster = new Hashtable(); ! prop.getXML( level+1, buf ); ! } ! // now the subclasses ! int len = subs.size(); ! for( int i=0; i<len; i++ ) { ! ReflectedClass rsc = (ReflectedClass )subs.get(i); ! rsc.getXMLasSubclass(level+1); ! } ! map.emitPrefix(level);; ! buf.append("</class>\n"); ! } ! ! /** dump the OR-Mapping XML for a non-root class and all of its ! * subclasses that share its table and UID ! */ ! protected void getXMLasSubclass(int level) { ! // dumps in map.buf ! this.buf = map.buf; ! String name = clazz.getName(); ! // debug... ! map.emitPrefix(level);; ! buf.append("<!-- ") ! .append(name) ! .append(" -->\n"); ! // a sub class -- polymorphic style ! map.emitPrefix(level);; ! buf.append("<subclass name=\"") ! .append(name) ! .append("\">\n"); ! // now the properties already classified by heuristic ! Enumeration ps = props.elements(); ! while( ps.hasMoreElements() ) { ! ReflectedProperty prop = (ReflectedProperty )ps.nextElement(); ! if( prop.isUid ) continue; // done above ! prop.getXML( level+1, buf ); ! } ! // now the subclasses ! int len = subs.size(); ! for( int i=0; i<len; i++ ) { ! ReflectedClass rsc = (ReflectedClass )subs.get(i); ! rsc.getXMLasSubclass(level+1); ! } ! map.emitPrefix(level);; ! buf.append("</subclass>\n"); ! } ! ! /** dump the OR-Mapping XML for a class used as a component ! * ! * @param propName the property name of the property containing this component ! */ ! protected void getXMLasComponent( int level, String propName ) { ! // dumps in buf ! this.buf = map.buf; ! String name = clazz.getName(); ! /* debug... ! map.emitPrefix(level);; ! buf.append("<!-- ") ! .append(name) ! .append(" -->\n");*/ ! // a component ! map.emitPrefix(level);; ! buf.append("<component name=\"") ! .append(propName) ! .append("\" class=\"") ! .append(name) ! .append("\">\n"); ! // now the properties already classified by heuristic ! Enumeration ps = props.elements(); ! while( ps.hasMoreElements() ) { ! ReflectedProperty prop = (ReflectedProperty )ps.nextElement(); ! prop.getXML( level+1, buf ); ! } ! // NOT the subclasses ! map.emitPrefix(level);; ! buf.append("</component>\n"); ! } ! ! protected void getXMLasComposite(int level) { ! // dumps in buf ! this.buf = map.buf; ! String name = clazz.getName(); ! // a composite-element ! map.emitPrefix(level);; ! buf.append("<composite-element class=\"") ! .append(name) ! .append("\">\n"); ! // now the properties already classified by heuristic ! Enumeration ps = props.elements(); ! while( ps.hasMoreElements() ) { ! ReflectedProperty prop = (ReflectedProperty )ps.nextElement(); ! // call a restricted form of getXML that disallows inline ! // collections and uses composite-element instead of component ! prop.getXMLinComposite( level, buf ); ! } ! // NOT the subclasses ! map.emitPrefix(level);; ! buf.append("</composite-element>\n"); ! } ! ! protected void getXMLasMany2Many(int level) { ! // dumps in buf ! this.buf = map.buf; ! String name = clazz.getName(); ! // a many-to-many ! map.emitPrefix(level);; ! buf.append("<many-to-many class=\"" ) ! .append(name) ! .append("\" column=\"") ! .append(map.columnNameFor(name)) ! .append("\"/>\n"); ! } ! ! private String capitalize( String s ) { ! char c = s.charAt(0); ! if( Character.isUpperCase(c) ) return s; ! char[] ca = {Character.toUpperCase(c)}; ! return new String(ca).concat(s.substring(1)); ! } ! ! /** called to determine if the class has a UID property ! * ! * @param niceKeys an array of candidate UID names ! * @return the UID ReflectedProperty ! */ ! protected ReflectedProperty getUidProp( String[] niceKeys ) { ! if( uid != null ) return uid; // cache ! // ugh; we'll try some things... ! ReflectedProperty p; ! // try a prop named identically to a niceKey[] ! for( int i=0; i<niceKeys.length; i++ ) { ! p = (ReflectedProperty )props.get(niceKeys[i]); ! // TO DO is isUidOK OK? ! if( p != null && p.isUidOK() ) { ! uid = p; ! break; ! } ! } ! /* now that we're using this for finding roots this tries too hard?... ! if( uid != null ) return uid; ! // try a prop whose name starts with a niceKey[] ! for( int i=0; i<niceKeys.length; i++ ) { ! Enumeration ps = props.elements(); ! while( ps.hasMoreElements() ) { ! p = (ReflectedProperty )ps.nextElement(); ! if( p.isUidOK() && p.name.startsWith(niceKeys[i])) { ! uid = p; ! break; ! } ! } ! } ! if( uid != null ) return uid; ! // try a prop whose name ends with (capitalized) niceKey[] ! for( int i=0; i<niceKeys.length; i++ ) { ! String candidate = capitalize( niceKeys[i] ); ! Enumeration ps = props.elements(); ! while( ps.hasMoreElements() ) { ! p = (ReflectedProperty )ps.nextElement(); ! if( p.isUidOK() && p.name.endsWith(candidate)) { ! uid = p; ! break; ! } ! } ! } ! if( uid != null ) return uid; ! // more to try ? ! // use anything with an appropriate type ! Enumeration ps = props.elements(); ! while( ps.hasMoreElements() ) { ! p = (ReflectedProperty )ps.nextElement(); ! if( p.isUidOK() ) { ! uid = p; ! break; ! } ! }*/ ! return uid; ! } ! ! private void maybeAddProp( String name, Class type ! , Hashtable thisprops, Hashtable thatprops ) { ! Object ty = thatprops.get( name ); ! if( ty == type ) { ! // a winner! ! thatprops.remove( name ); ! ReflectedProperty prop = map.makeProperty( name, type ); ! if (prop!=null) props.put( name, prop ); ! } ! else { ! // maybe later ! thisprops.put( name, type ); ! } ! } ! ! private void addSetter( String name, Class type ) { ! maybeAddProp( name, type, setprops, getprops ); ! } ! ! private void addGetter( String name, Class type ) { ! maybeAddProp( name, type, getprops, setprops ); ! } ! ! /** called by the constructor ! */ ! private void reflect() { ! props = new Hashtable(); ! setprops = new Hashtable(); ! getprops = new Hashtable(); ! reflectClass( clazz ); ! } ! /** called to get the properties of a class, ! * or add properties from a superclass ! */ ! private void reflectClass( Class cls ) { ! // empty getprops and setprops if a getter and setter pair ! // should come from one class and not a class and its superclass ! try { ! Method[] ms = cls.getDeclaredMethods(); ! for( int i=0; i<ms.length; i++ ) { ! Method m = ms[i]; ! if( m == null ) continue; ! int mmod = m.getModifiers(); ! if( Modifier.isStatic( mmod ) ) continue; ! Class argtyp[] = m.getParameterTypes(); ! if( argtyp.length > 1 ) continue; ! String name = m.getName(); ! Class restyp = m.getReturnType(); ! if( argtyp.length == 1 ) { ! if( restyp == void.class && name.startsWith("set") ) { ! addSetter( Introspector.decapitalize(name.substring(3)) ! , argtyp[0] ); ! } ! } ! else { // argtyp.length == 0 ! if( name.startsWith("get") ) { ! addGetter( Introspector.decapitalize(name.substring(3)) ! , restyp ); ! } ! else if( restyp == boolean.class && name.startsWith("is") ) { ! addGetter( Introspector.decapitalize(name.substring(2)) ! , restyp ); ! } ! } ! } ! } ! catch( SecurityException e ) { ! // ignore!? ! } ! } ! ! ! } ! Index: ReflectedCollectionProperty.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/reflect/ReflectedCollectionProperty.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ReflectedCollectionProperty.java 19 Sep 2002 08:27:41 -0000 1.1 --- ReflectedCollectionProperty.java 26 Nov 2002 03:35:45 -0000 1.2 *************** *** 1,38 **** ! package cirrus.hibernate.tools.reflect; ! ! /** ! * @version 1.x ! * @author <a href="mailto:dou...@al...">e</a> ! */ ! class ReflectedCollectionProperty extends ReflectedProperty { ! ! /** ! * Constructor for ReflectedListProperty. ! * @param name ! * @param type ! */ ! ReflectedCollectionProperty(String name, Class type, MappingByReflection map) { ! super(name, type, map, "bag"); ! } ! ! protected void getXMLinArray( int level, StringBuffer buf ) { ! this.buf = buf; ! emitSubCollectionStr(level, name); ! } ! ! protected void getXMLinComposite( int level, StringBuffer buf ) { ! this.buf = buf; ! emitCollectionInCompositeStr(level); ! } ! ! protected void getXML( int level, StringBuffer buf ) { ! this.buf = buf; ! if( comment != null ) { ! emitPCommentStr(level, comment, name, type.getName()); ! } ! emitCollectionStrL(level, "bag", name, true); ! emitCollectionStrK(level+1, "uid"); ! emitCollectionStrET(level+1, "elm", "string"); ! emitCollectionStrR(level, "bag"); ! } ! } --- 1,38 ---- ! package cirrus.hibernate.tools.reflect; ! ! /** ! * @version 1.x ! * @author <a href="mailto:dou...@al...">e</a> ! */ ! class ReflectedCollectionProperty extends ReflectedProperty { ! ! /** ! * Constructor for ReflectedListProperty. ! * @param name ! * @param type ! */ ! ReflectedCollectionProperty(String name, Class type, MappingByReflection map) { ! super(name, type, map, "bag"); ! } ! ! protected void getXMLinArray( int level, StringBuffer buf ) { ! this.buf = buf; ! emitSubCollectionStr(level, name); ! } ! ! protected void getXMLinComposite( int level, StringBuffer buf ) { ! this.buf = buf; ! emitCollectionInCompositeStr(level); ! } ! ! protected void getXML( int level, StringBuffer buf ) { ! this.buf = buf; ! if( comment != null ) { ! emitPCommentStr(level, comment, name, type.getName()); ! } ! emitCollectionStrL(level, "bag", name, true); ! emitCollectionStrK(level+1, "uid"); ! emitCollectionStrET(level+1, "elm", "string"); ! emitCollectionStrR(level, "bag"); ! } ! } Index: ReflectedComponent.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/reflect/ReflectedComponent.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ReflectedComponent.java 10 Jun 2002 15:31:26 -0000 1.5 --- ReflectedComponent.java 26 Nov 2002 03:35:45 -0000 1.6 *************** *** 1,147 **** ! package cirrus.hibernate.tools.reflect; ! ! import java.io.Serializable; ! ! /** ! * @version 1.x ! * @author <a href="mailto:dou...@al...">e</a> ! */ ! class ReflectedComponent extends ReflectedProperty { ! ! private static final int KIND_UNKNOWN = 0; ! private static final int KIND_BASIC = 1; // nothing or serializable ! private static final int KIND_ASSOCIATION = 2; ! private static final int KIND_COMPONENT = 3; ! ! private ReflectedClass component; // my component ! private int kind = KIND_UNKNOWN; ! ! protected ReflectedComponent( String name, Class type ! , MappingByReflection map, ReflectedClass comp ) ! { ! super( name, type, map, "prospective-component" ); ! this.component = comp; ! } ! ! private int determineKind() { ! // this decision has to be delayed to avoid circularities ! // e.g., a component which includes itself will not have ! // access to this info until it is fully processed ! // but we cache it here... ! if( kind != KIND_UNKNOWN ) return kind; ! // is the prospective component a persistent class ! if( component.isPersistent() ) { ! // make it an association ! comment = "association"; ! kind = KIND_ASSOCIATION; ! return KIND_ASSOCIATION; ! } ! // does the prospective component have any properties? ! // first let it look in superclasses ! component.addSuperclassProps(); ! if( component.hasProperties() ) { ! // make it a component ! comment = "component"; ! kind = KIND_COMPONENT; ! return KIND_COMPONENT; ! } ! if ( Serializable.class.isAssignableFrom(type) ) { ! // make it a serializable ! tynm = "serializable"; ! comment = "serializable"; ! kind = KIND_BASIC; ! return KIND_BASIC; ! } ! else { ! buf.append("<!-- BUG unknown kind! name=\"") ! .append(name) ! .append("\" type=\"") ! .append(type.getName()) ! .append("\" -->\n"); ! kind = KIND_BASIC; ! return KIND_BASIC; ! } ! } ! ! protected void getXMLinArray( int level, StringBuffer buf ) { ! this.buf = buf; ! switch( determineKind() ) { ! case KIND_BASIC: ! super.getXML( level, buf ); ! break; ! case KIND_COMPONENT: ! getXMLas(level, true); ! break; ! case KIND_ASSOCIATION: ! component.getXMLasMany2Many(level); ! break; ! default: ! emitPCommentStr(level, "BUG! unknown component kind", name, type.getName()); ! break; ! } ! } ! ! protected void getXMLinComposite( int level, StringBuffer buf ) { ! //this.buf = buf; ! getXMLinArray( level, buf ); ! } ! ! protected void emitMany2OneStr(int level) { ! map.emitPrefix(level); ! buf.append("<many-to-one name=\"" ) ! .append(name) ! .append("\" column=\"") ! .append(map.columnNameFor(name)) ! .append("\" class=\"") ! .append(tynm) ! .append("\"/>\n"); ! } ! ! protected void getXML( int level, StringBuffer buf ) { ! this.buf = buf; ! switch( determineKind() ) { ! case KIND_BASIC: ! super.getXML( level, buf ); ! return; ! case KIND_COMPONENT: ! getXMLas(level, false); //go on... ! return; ! case KIND_ASSOCIATION: ! emitMany2OneStr(level); ! return; ! default: ! emitPCommentStr(level, "BUG! unknown component kind", name, type.getName()); ! return; ! } ! } ! ! private void getXMLas( int level, boolean isComposite ) { ! if( component != null ) { ! Integer x = (Integer )map.cycleBuster.get( component ); ! if( x != null ) { ! // we're nested ! int i = x.intValue(); ! if( i >= map.maxDepth ) { ! emitPCommentStr(level, "component too deeply nested", name, type.getName()); ! return; // bail! ! } ! else { ! map.cycleBuster.put( component, new Integer( i + 1 ) ); ! } ! } ! else { ! map.cycleBuster.put( component, new Integer( 1 ) ); ! } ! if( isComposite ) { ! component.getXMLasComposite(level); ! } ! else { ! component.getXMLasComponent( level, name ); ! } ! } ! else { ! emitPCommentStr(level, "not component?", name, type.getName()); ! } ! } ! ! } --- 1,147 ---- ! package cirrus.hibernate.tools.reflect; ! ! import java.io.Serializable; ! ! /** ! * @version 1.x ! * @author <a href="mailto:dou...@al...">e</a> ! */ ! class ReflectedComponent extends ReflectedProperty { ! ! private static final int KIND_UNKNOWN = 0; ! private static final int KIND_BASIC = 1; // nothing or serializable ! private static final int KIND_ASSOCIATION = 2; ! private static final int KIND_COMPONENT = 3; ! ! private ReflectedClass component; // my component ! private int kind = KIND_UNKNOWN; ! ! protected ReflectedComponent( String name, Class type ! , MappingByReflection map, ReflectedClass comp ) ! { ! super( name, type, map, "prospective-component" ); ! this.component = comp; ! } ! ! private int determineKind() { ! // this decision has to be delayed to avoid circularities ! // e.g., a component which includes itself will not have ! // access to this info until it is fully processed ! // but we cache it here... ! if( kind != KIND_UNKNOWN ) return kind; ! // is the prospective component a persistent class ! if( component.isPersistent() ) { ! // make it an association ! comment = "association"; ! kind = KIND_ASSOCIATION; ! return KIND_ASSOCIATION; ! } ! // does the prospective component have any properties? ! // first let it look in superclasses ! component.addSuperclassProps(); ! if( component.hasProperties() ) { ! // make it a component ! comment = "component"; ! kind = KIND_COMPONENT; ! return KIND_COMPONENT; ! } ! if ( Serializable.class.isAssignableFrom(type) ) { ! // make it a serializable ! tynm = "serializable"; ! comment = "serializable"; ! kind = KIND_BASIC; ! return KIND_BASIC; ! } ! else { ! buf.append("<!-- BUG unknown kind! name=\"") ! .append(name) ! .append("\" type=\"") ! .append(type.getName()) ! .append("\" -->\n"); ! kind = KIND_BASIC; ! return KIND_BASIC; ! } ! } ! ! protected void getXMLinArray( int level, StringBuffer buf ) { ! this.buf = buf; ! switch( determineKind() ) { ! case KIND_BASIC: ! super.getXML( level, buf ); ! break; ! case KIND_COMPONENT: ! getXMLas(level, true); ! break; ! case KIND_ASSOCIATION: ! component.getXMLasMany2Many(level); ! break; ! default: ! emitPCommentStr(level, "BUG! unknown component kind", name, type.getName()); ! break; ! } ! } ! ! protected void getXMLinComposite( int level, StringBuffer buf ) { ! //this.buf = buf; ! getXMLinArray( level, buf ); ! } ! ! protected void emitMany2OneStr(int level) { ! map.emitPrefix(level); ! buf.append("<many-to-one name=\"" ) ! .append(name) ! .append("\" column=\"") ! .append(map.columnNameFor(name)) ! .append("\" class=\"") ! .append(tynm) ! .append("\"/>\n"); ! } ! ! protected void getXML( int level, StringBuffer buf ) { ! this.buf = buf; ! switch( determineKind() ) { ! case KIND_BASIC: ! super.getXML( level, buf ); ! return; ! case KIND_COMPONENT: ! getXMLas(level, false); //go on... ! return; ! case KIND_ASSOCIATION: ! emitMany2OneStr(level); ! return; ! default: ! emitPCommentStr(level, "BUG! unknown component kind", name, type.getName()); ! return; ! } ! } ! ! private void getXMLas( int level, boolean isComposite ) { ! if( component != null ) { ! Integer x = (Integer )map.cycleBuster.get( component ); ! if( x != null ) { ! // we're nested ! int i = x.intValue(); ! if( i >= map.maxDepth ) { ! emitPCommentStr(level, "component too deeply nested", name, type.getName()); ! return; // bail! ! } ! else { ! map.cycleBuster.put( component, new Integer( i + 1 ) ); ! } ! } ! else { ! map.cycleBuster.put( component, new Integer( 1 ) ); ! } ! if( isComposite ) { ! component.getXMLasComposite(level); ! } ! else { ! component.getXMLasComponent( level, name ); ! } ! } ! else { ! emitPCommentStr(level, "not component?", name, type.getName()); ! } ! } ! ! } Index: ReflectedListProperty.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/reflect/ReflectedListProperty.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReflectedListProperty.java 9 Feb 2002 23:08:18 -0000 1.3 --- ReflectedListProperty.java 26 Nov 2002 03:35:45 -0000 1.4 *************** *** 1,39 **** ! package cirrus.hibernate.tools.reflect; ! ! /** ! * @version 1.x ! * @author <a href="mailto:dou...@al...">e</a> ! */ ! class ReflectedListProperty extends ReflectedProperty { ! ! /** ! * Constructor for ReflectedListProperty. ! * @param name ! * @param type ! */ ! ReflectedListProperty(String name, Class type, MappingByReflection map ) { ! super(name, type, map, "list"); ! } ! ! protected void getXMLinArray( int level, StringBuffer buf ) { ! this.buf = buf; ! emitSubCollectionStr(level, name); ! } ! ! protected void getXMLinComposite( int level, StringBuffer buf ) { ! this.buf = buf; ! emitCollectionInCompositeStr(level); ! } ! ! protected void getXML( int level, StringBuffer buf ) { ! this.buf = buf; ! if( comment != null ) { ! emitPCommentStr(level, comment, name, type.getName()); ! } ! emitCollectionStrL(level, "list", name, true); ! emitCollectionStrK(level+1, "uid"); ! emitCollectionStrI(level+1, "i"); ! emitCollectionStrE(level+1, "elm"); ! emitCollectionStrR(level, "list"); ! } ! } --- 1,39 ---- ! package cirrus.hibernate.tools.reflect; ! ! /** ! * @version 1.x ! * @author <a href="mailto:dou...@al...">e</a> ! */ ! class ReflectedListProperty extends ReflectedProperty { ! ! /** ! * Constructor for ReflectedListProperty. ! * @param name ! * @param type ! */ ! ReflectedListProperty(String name, Class type, MappingByReflection map ) { ! super(name, type, map, "list"); ! } ! ! protected void getXMLinArray( int level, StringBuffer buf ) { ! this.buf = buf; ! emitSubCollectionStr(level, name); ! } ! ! protected void getXMLinComposite( int level, StringBuffer buf ) { ! this.buf = buf; ! emitCollectionInCompositeStr(level); ! } ! ! protected void getXML( int level, StringBuffer buf ) { ! this.buf = buf; ! if( comment != null ) { ! emitPCommentStr(level, comment, name, type.getName()); ! } ! emitCollectionStrL(level, "list", name, true); ! emitCollectionStrK(level+1, "uid"); ! emitCollectionStrI(level+1, "i"); ! emitCollectionStrE(level+1, "elm"); ! emitCollectionStrR(level, "list"); ! } ! } Index: ReflectedMapProperty.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/reflect/ReflectedMapProperty.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ReflectedMapProperty.java 19 Sep 2002 08:26:45 -0000 1.4 --- ReflectedMapProperty.java 26 Nov 2002 03:35:45 -0000 1.5 *************** *** 1,39 **** ! package cirrus.hibernate.tools.reflect; ! ! /** ! * @version 1.x ! * @author <a href="mailto:dou...@al...">e</a> ! */ ! class ReflectedMapProperty extends ReflectedProperty { ! ! /** ! * Constructor for ReflectedMapProperty. ! * @param name ! * @param type ! */ ! ReflectedMapProperty(String name, Class type, MappingByReflection map) { ! super(name, type, map, "map"); ! } ! ! protected void getXMLinArray( int level, StringBuffer buf ) { ! this.buf = buf; ! emitSubCollectionStr(level, name); ! } ! ! protected void getXMLinComposite( int level, StringBuffer buf ) { ! this.buf = buf; ! emitCollectionInCompositeStr(level); ! } ! ! protected void getXML( int level, StringBuffer buf ) { ! this.buf = buf; ! if( comment != null ) { ! emitPCommentStr(level, comment, name, type.getName()); ! } ! emitCollectionStrL(level, "map", name, true); ! emitCollectionStrK(level+1, "uid"); ! emitCollectionStrIT(level+1, "key", "string"); ! emitCollectionStrE(level+1, "elm"); ! emitCollectionStrR(level, "map"); ! } ! } --- 1,39 ---- ! package cirrus.hibernate.tools.reflect; ! ! /** ! * @version 1.x ! * @author <a href="mailto:dou...@al...">e</a> ! */ ! class ReflectedMapProperty extends ReflectedProperty { ! ! /** ! * Constructor for ReflectedMapProperty. ! * @param name ! * @param type ! */ ! ReflectedMapProperty(String name, Class type, MappingByReflection map) { ! super(name, type, map, "map"); ! } ! ! protected void getXMLinArray( int level, StringBuffer buf ) { ! this.buf = buf; ! emitSubCollectionStr(level, name); ! } ! ! protected void getXMLinComposite( int level, StringBuffer buf ) { ! this.buf = buf; ! emitCollectionInCompositeStr(level); ! } ! ! protected void getXML( int level, StringBuffer buf ) { ! this.buf = buf; ! if( comment != null ) { ! emitPCommentStr(level, comment, name, type.getName()); ! } ! emitCollectionStrL(level, "map", name, true); ! emitCollectionStrK(level+1, "uid"); ! emitCollectionStrIT(level+1, "key", "string"); ! emitCollectionStrE(level+1, "elm"); ! emitCollectionStrR(level, "map"); ! } ! } Index: ReflectedProperty.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/reflect/ReflectedProperty.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ReflectedProperty.java 21 Nov 2002 09:03:14 -0000 1.16 --- ReflectedProperty.java 26 Nov 2002 03:35:45 -0000 1.17 *************** *** 1,264 **** ! package cirrus.hibernate.tools.reflect; ! ! import java.math.BigDecimal; ! import java.sql.Time; ! import java.sql.Timestamp; ! import java.util.Calendar; ! import java.util.HashMap; ! import java.util.Locale; ! import java.util.TimeZone; ! ! import cirrus.hibernate.Hibernate; ! import cirrus.hibernate.type.CurrencyType; ! ! /** a ReflectedProperty is made by an instance of MappingByReflection ! * to model properties of Reflected classes;<br> ! * basic properties are handled here: primitive, enum, custom;<br> ! * subclasses handle more involved cases ! * ! * @version 1.x ! * @author <a href="mailto:dou...@al...">e</a> ! */ ! public class ReflectedProperty { ! ! protected boolean isUid; ! protected Class type; ! protected String tynm; ! protected String name; ! protected String comment; ! protected StringBuffer buf; ! protected MappingByReflection map; ! ! private static HashMap shortTypeNames = new HashMap(); ! static { ! shortTypeNames.put( Long.class.getName(), Hibernate.LONG.getName() ); ! shortTypeNames.put( Integer.class.getName(), Hibernate.INTEGER.getName() ); ! shortTypeNames.put( Boolean.class.getName(), Hibernate.BOOLEAN.getName() ); ! shortTypeNames.put( Short.class.getName(), Hibernate.SHORT.getName() ); ! shortTypeNames.put( Byte.class.getName(), Hibernate.BYTE.getName()); ! shortTypeNames.put( Float.class.getName(), Hibernate.FLOAT.getName() ); ! shortTypeNames.put( Double.class.getName(), Hibernate.DOUBLE.getName() ); ! shortTypeNames.put( Character.class.getName(), Hibernate.CHARACTER.getName() ); ! shortTypeNames.put( String.class.getName(), Hibernate.STRING.getName() ); ! shortTypeNames.put( Locale.class.getName(), Hibernate.LOCALE.getName() ); ! shortTypeNames.put( Calendar.class.getName(), Hibernate.CALENDAR.getName() ); ! if ( CurrencyType.CURRENCY_CLASS!=null) shortTypeNames.put( CurrencyType.CURRENCY_CLASS.getName(), Hibernate.CURRENCY.getName() ); ! shortTypeNames.put( TimeZone.class.getName(), Hibernate.TIMEZONE.getName() ); ! shortTypeNames.put( BigDecimal.class.getName(), Hibernate.BIG_DECIMAL.getName() ); ! shortTypeNames.put( Class.class.getName(), Hibernate.CLASS.getName() ); ! shortTypeNames.put( Object.class.getName(), Hibernate.OBJECT.getName() ); ! shortTypeNames.put( Time.class.getName(), Hibernate.TIME.getName() ); ! shortTypeNames.put( Timestamp.class.getName(), Hibernate.TIMESTAMP.getName() ); ! shortTypeNames.put( java.util.Date.class.getName(), Hibernate.TIMESTAMP.getName() ); ! shortTypeNames.put( java.sql.Date.class.getName(), Hibernate.DATE.getName() ); ! shortTypeNames.put( byte[].class.getName(), Hibernate.BINARY.getName() ); // not shorter, but nicer ! } ! ! protected static String abbreviateType(String typeName) { ! String abbreviated = (String) shortTypeNames.get(typeName); ! return (abbreviated==null) ? typeName : abbreviated; ! } ! ! ReflectedProperty( String name, Class type ! , MappingByReflection map, String comment ) { ! this.name = name; ! this.type = type; ! this.tynm = abbreviateType( type.getName() ); // default; may be changed later ! this.comment = comment; ! this.map = map; ! this.isUid = false; ! } ! ! /** used by gui */ ! public String getName() { ! return name; ! } ! ! /** used by gui */ ! public String getTypeName() { ! return tynm; ! } ! ! protected boolean isUidOK() { ! /*if( long.class == type ) return true; ! if( Long.class == type ) return true; ! if( String.class == type ) return true; ! // more? ! return false;*/ ! return ( !type.isArray() ); // since arrays never implement equals properly ! } ! ! protected void emitIntUidStr(int level) { ! map.emitPrefix(level); ! buf.append("<id name=\"") ! .append(name) ! .append("\" type=\"") ! .append(tynm) // or just use "long" ? ! .append("\" column=\"") ! .append(map.columnNameFor(name)) ! .append("\">\n"); ! map.emitPrefix(level+1); ! buf.append("<generator class=\"hilo.long\"/>\n"); ! map.emitPrefix(level); ! buf.append("</id>\n"); ! } ! ! protected void emitStrUidStr(int level) { ! map.emitPrefix(level); ! buf.append("<id name=\"" ) ! .append(name) ! .append("\" type=\"") ! .append(tynm) // or just use "string" ? ! .append("\">\n"); ! map.emitPrefix(level+1); ! buf.append("<column name=\"") ! .append(map.columnNameFor(name)) ! .append("\" length=\"16\"/>\n"); ! map.emitPrefix(level+1); ! buf.append("<generator class=\"hilo.hex\"/>\n"); ! map.emitPrefix(level); ! buf.append("</id>\n"); ! } ! ! protected void emitPropertyStr(int level) { ! map.emitPrefix(level); ! buf.append("<property name=\"" ) ! .append(name) ! .append("\" column=\"") ! .append(map.columnNameFor(name)) ! .append("\" type=\"") ! .append(tynm) ! .append("\"/>\n"); ! } ! ! protected void emitPCommentStr( int level, String comment, String name, String tynm ) { ! /*map.emitPrefix(level); ! buf.append("<!-- ") ! .append(comment) ! .append(" name=\"") ! .append(name) ! .append("\" type=\"") ! .append(tynm) ! .append("\" -->\n");*/ ! } ! ! protected void emitCollectionStrL( int level, String collection ! , String name, boolean lazy ) { ! map.emitPrefix(level); ! buf.append("<") ! .append(collection) ! .append(" role=\"" ) ! .append(name) ! .append("\" table=\"") ! .append(map.tableNameFor(name)); ! if( lazy ) { ! buf.append("\" lazy=\"true"); ! } ! buf.append("\">\n"); ! } ! protected void emitCollectionStrK( int level, String key ) { ! map.emitPrefix(level); ! buf.append("<key column=\"") ! .append(map.columnNameFor(key)) ! .append("\"/>\n"); ! } ! protected void emitCollectionStrI( int level, String idx ) { ! map.emitPrefix(level); ! buf.append("<index column=\"") ! .append(map.columnNameFor(idx)) ! .append("\"/>\n"); ! } ! protected void emitCollectionStrIT( int level, String idx, String type ) { ! map.emitPrefix(level); ! buf.append("<index column=\"") ! .append(map.columnNameFor(idx)) ! .append("\" type =\"") ! .append(type) ! .append("\"/>\n"); ! } ! protected void emitCollectionStrE( int level, String elm ) { ! map.emitPrefix(level); ! buf.append("<element column=\"") ! .append(map.columnNameFor(elm)) ! .append("\"/>\n"); ! } ! protected void emitCollectionStrET( int level, String elm, String type ) { ! map.emitPrefix(level); ! buf.append("<element column=\"") ! .append(map.columnNameFor(elm)) ! .append("\" type =\"") ! .append(type) ! .append("\"/>\n"); ! } ! protected void emitCollectionStrR( int level, String collection ) { ! map.emitPrefix(level); ! buf.append("</") ! .append(collection) ! .append(">\n"); ! } ! //protected void emitCollectionStrLazy(int level) { ! // map.emitPrefix(level); ! // buf.append("<lazy=\"true\">\n"); ! //} ! ! //<!ELEMENT subcollection (column*)> ! // <!ATTLIST subcollection column CDATA #IMPLIED> ! // <!ATTLIST subcollection role CDATA #REQUIRED> ! // <!ATTLIST subcollection length CDATA #IMPLIED> ! // <!ATTLIST subcollection not-null CDATA #IMPLIED> ! ! protected void emitSubCollectionStr( int level, String name ) { ! map.emitPrefix(level); ! buf.append("<subcollection role=\"" ) ! .append(name) ! .append("\" column=\"") ! .append(map.columnNameFor(name)) ! .append("\">\n"); ! } ! ! //<!ELEMENT collection (column*)> ! // <!ATTLIST collection name CDATA #REQUIRED> ! // <!ATTLIST collection role CDATA #IMPLIED> ! // <!ATTLIST collection column CDATA #IMPLIED> ! // <!ATTLIST collection length CDATA #IMPLIED> ! // <!ATTLIST collection not-null CDATA #IMPLIED> ! ! protected void emitCollectionInCompositeStr(int level) { ! map.emitPrefix(level); ! buf.append("<collection name=\"" ) ! .append(name) ! .append("\" column=\"") ! .append(map.columnNameFor(name)) ! .append("\">\n"); ! } ! ! protected void getUidXML(int level, StringBuffer buf) { ! this.buf = buf; ! isUid = true; // to prevent being emitted twice ! if( type == String.class ) { ! emitStrUidStr(level); ! } ! else { ! emitIntUidStr(level); ! } ! } ! ! protected void getXMLinComposite( int level, StringBuffer buf ) { ! this.buf = buf; ! // basic types are OK in composite-elements ! emitPropertyStr(level); ! } ! ! protected void getXMLinArray( int level, StringBuffer buf ) { ! this.buf = buf; ! emitCollectionStrET(level, "elm", tynm); ! } ! ! protected void getXML( int level, StringBuffer buf ) { ! this.buf = buf; ! if( comment != null ) { ! emitPCommentStr(level, comment, name, type.getName()); ! } ! emitPropertyStr(level); ! } ! } --- 1,264 ---- ! package cirrus.hibernate.tools.reflect; ! ! import java.math.BigDecimal; ! import java.sql.Time; ! import java.sql.Timestamp; ! import java.util.Calendar; ! import java.util.HashMap; ! import java.util.Locale; ! import java.util.TimeZone; ! ! import cirrus.hibernate.Hibernate; ! import cirrus.hibernate.type.CurrencyType; ! ! /** a ReflectedProperty is made by an instance of MappingByReflection ! * to model properties of Reflected classes;<br> ! * basic properties are handled here: primitive, enum, custom;<br> ! * subclasses handle more involved cases ! * ! * @version 1.x ! * @author <a href="mailto:dou...@al...">e</a> ! */ ! public class ReflectedProperty { ! ! protected boolean isUid; ! protected Class type; ! protected String tynm; ! protected String name; ! protected String comment; ! protected StringBuffer buf; ! protected MappingByReflection map; ! ! private static HashMap shortTypeNames = new HashMap(); ! static { ! shortTypeNames.put( Long.class.getName(), Hibernate.LONG.getName() ); ! shortTypeNames.put( Integer.class.getName(), Hibernate.INTEGER.getName() ); ! shortTypeNames.put( Boolean.class.getName(), Hibernate.BOOLEAN.getName() ); ! shortTypeNames.put( Short.class.getName(), Hibernate.SHORT.getName() ); ! shortTypeNames.put( Byte.class.getName(), Hibernate.BYTE.getName()); ! shortTypeNames.put( Float.class.getName(), Hibernate.FLOAT.getName() ); ! shortTypeNames.put( Double.class.getName(), Hibernate.DOUBLE.getName() ); ! shortTypeNames.put( Character.class.getName(), Hibernate.CHARACTER.getName() ); ! shortTypeNames.put( String.class.getName(), Hibernate.STRING.getName() ); ! shortTypeNames.put( Locale.class.getName(), Hibernate.LOCALE.getName() ); ! shortTypeNames.put( Calendar.class.getName(), Hibernate.CALENDAR.getName() ); ! if ( CurrencyType.CURRENCY_CLASS!=null) shortTypeNames.put( CurrencyType.CURRENCY_CLASS.getName(), Hibernate.CURRENCY.getName() ); ! shortTypeNames.put( TimeZone.class.getName(), Hibernate.TIMEZONE.getName() ); ! shortTypeNames.put( BigDecimal.class.getName(), Hibernate.BIG_DECIMAL.getName() ); ! shortTypeNames.put( Class.class.getName(), Hibernate.CLASS.getName() ); ! shortTypeNames.put( Object.class.getName(), Hibernate.OBJECT.getName() ); ! shortTypeNames.put( Time.class.getName(), Hibernate.TIME.getName() ); ! shortTypeNames.put( Timestamp.class.getName(), Hibernate.TIMESTAMP.getName() ); ! shortTypeNames.put( java.util.Date.class.getName(), Hibernate.TIMESTAMP.getName() ); ! shortTypeNames.put( java.sql.Date.class.getName(), Hibernate.DATE.getName() ); ! shortTypeNames.put( byte[].class.getName(), Hibernate.BINARY.getName() ); // not shorter, but nicer ! } ! ! protected static String abbreviateType(String typeName) { ! String abbreviated = (String) shortTypeNames.get(typeName); ! return (abbreviated==null) ? typeName : abbreviated; ! } ! ! ReflectedProperty( String name, Class type ! , MappingByReflection map, String comment ) { ! this.name = name; ! this.type = type; ! this.tynm = abbreviateType( type.getName() ); // default; may be changed later ! this.comment = comment; ! this.map = map; ! this.isUid = false; ! } ! ! /** used by gui */ ! public String getName() { ! return name; ! } ! ! /** used by gui */ ! public String getTypeName() { ! return tynm; ! } ! ! protected boolean isUidOK() { ! /*if( long.class == type ) return true; ! if( Long.class == type ) return true; ! if( String.class == type ) return true; ! // more? ! return false;*/ ! return ( !type.isArray() ); // since arrays never implement equals properly ! } ! ! protected void emitIntUidStr(int level... [truncated message content] |
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/query In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/query Modified Files: ClauseParser.java FromParser.java OrderByParser.java Parser.java PreprocessingParser.java SelectParser.java WhereParser.java Log Message: fixed broken line-endings and added a test Index: ClauseParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/query/ClauseParser.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ClauseParser.java 19 Nov 2002 15:28:06 -0000 1.16 --- ClauseParser.java 26 Nov 2002 03:35:44 -0000 1.17 *************** *** 10,14 **** /** * Parses the hibernate query into its constituent clauses. ! */ public class ClauseParser implements Parser { --- 10,14 ---- /** * Parses the hibernate query into its constituent clauses. ! */ public class ClauseParser implements Parser { *************** *** 105,109 **** cacheSelectTokens = false; } ! } ! --- 105,109 ---- cacheSelectTokens = false; } ! } ! Index: FromParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/query/FromParser.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** FromParser.java 19 Nov 2002 15:28:06 -0000 1.10 --- FromParser.java 26 Nov 2002 03:35:44 -0000 1.11 *************** *** 16,20 **** private String name; private PathExpressionParser peParser = new PathExpressionParser(); ! public void token(String token, QueryTranslator q) throws QueryException { --- 16,20 ---- private String name; private PathExpressionParser peParser = new PathExpressionParser(); ! public void token(String token, QueryTranslator q) throws QueryException { *************** *** 68,72 **** public void end(QueryTranslator q) { } ! } ! --- 68,72 ---- public void end(QueryTranslator q) { } ! } ! Index: OrderByParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/query/OrderByParser.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** OrderByParser.java 19 Nov 2002 15:28:07 -0000 1.12 --- OrderByParser.java 26 Nov 2002 03:35:44 -0000 1.13 *************** *** 38,42 **** public void end(QueryTranslator q) throws QueryException { } ! } --- 38,42 ---- public void end(QueryTranslator q) throws QueryException { } ! } Index: Parser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/query/Parser.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Parser.java 29 Jul 2002 07:27:42 -0000 1.4 --- Parser.java 26 Nov 2002 03:35:44 -0000 1.5 *************** *** 16,18 **** public void end(QueryTranslator q) throws QueryException; } ! --- 16,18 ---- public void end(QueryTranslator q) throws QueryException; } ! Index: PreprocessingParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/query/PreprocessingParser.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PreprocessingParser.java 20 Nov 2002 07:06:44 -0000 1.2 --- PreprocessingParser.java 26 Nov 2002 03:35:44 -0000 1.3 *************** *** 1,108 **** ! //$Id$ ! package cirrus.hibernate.query; ! ! import java.util.HashSet; ! import java.util.Map; ! import java.util.Set; ! ! import cirrus.hibernate.QueryException; ! ! /** ! * ! */ ! public class PreprocessingParser implements Parser { ! ! private static final Set operators; ! static { ! operators = new HashSet(); ! operators.add("<="); ! operators.add(">="); ! operators.add("=>"); ! operators.add("=<"); ! operators.add("!="); ! operators.add("<>"); ! operators.add("!#"); ! operators.add("!~"); ! operators.add("!<"); ! operators.add("!>"); ! operators.add("is not"); ! operators.add("not like"); ! operators.add("not in"); ! operators.add("not between"); ! operators.add("not exists"); ! } ! ! private Map replacements; ! private boolean quoted; ! private StringBuffer quotedString; ! private ClauseParser parser = new ClauseParser(); ! private String lastToken; ! ! public PreprocessingParser(Map replacements) { ! this.replacements=replacements; ! } ! ! /** ! * @see cirrus.hibernate.query.Parser#token(String, QueryTranslator) ! */ ! public void token(String token, QueryTranslator q) throws QueryException { ! ! //handle quoted strings ! if (quoted) { ! quotedString.append(token); ! } ! if ( "'".equals(token) ) { ! if (quoted) { ! token = quotedString.toString(); ! } ! else { ! quotedString = new StringBuffer(20).append(token); ! } ! quoted = !quoted; ! } ! if (quoted) return; ! ! //ignore whitespace ! if ( ParserHelper.isWhitespace(token) ) return; ! ! //do replacements ! String substoken = (String) replacements.get(token); ! token = (substoken==null) ? token : substoken; ! ! //handle <=, >=, !=, is not, not between, not in ! if (lastToken==null) { ! lastToken=token; ! } ! else { ! String doubleToken = (token.length()>1) ? ! lastToken + ' ' + token : ! lastToken + token; ! if ( operators.contains(doubleToken) ) { ! parser.token(doubleToken, q); ! lastToken=null; ! } ! else { ! parser.token(lastToken, q); ! lastToken=token; ! } ! } ! ! } ! ! /** ! * @see cirrus.hibernate.query.Parser#start(QueryTranslator) ! */ ! public void start(QueryTranslator q) throws QueryException { ! quoted = false; ! parser.start(q); ! } ! ! /** ! * @see cirrus.hibernate.query.Parser#end(QueryTranslator) ! */ ! public void end(QueryTranslator q) throws QueryException { ! if (lastToken!=null) parser.token(lastToken, q); ! parser.end(q); ! } ! ! } --- 1,108 ---- ! //$Id$ ! package cirrus.hibernate.query; ! ! import java.util.HashSet; ! import java.util.Map; ! import java.util.Set; ! ! import cirrus.hibernate.QueryException; ! ! /** ! * ! */ ! public class PreprocessingParser implements Parser { ! ! private static final Set operators; ! static { ! operators = new HashSet(); ! operators.add("<="); ! operators.add(">="); ! operators.add("=>"); ! operators.add("=<"); ! operators.add("!="); ! operators.add("<>"); ! operators.add("!#"); ! operators.add("!~"); ! operators.add("!<"); ! operators.add("!>"); ! operators.add("is not"); ! operators.add("not like"); ! operators.add("not in"); ! operators.add("not between"); ! operators.add("not exists"); ! } ! ! private Map replacements; ! private boolean quoted; ! private StringBuffer quotedString; ! private ClauseParser parser = new ClauseParser(); ! private String lastToken; ! ! public PreprocessingParser(Map replacements) { ! this.replacements=replacements; ! } ! ! /** ! * @see cirrus.hibernate.query.Parser#token(String, QueryTranslator) ! */ ! public void token(String token, QueryTranslator q) throws QueryException { ! ! //handle quoted strings ! if (quoted) { ! quotedString.append(token); ! } ! if ( "'".equals(token) ) { ! if (quoted) { ! token = quotedString.toString(); ! } ! else { ! quotedString = new StringBuffer(20).append(token); ! } ! quoted = !quoted; ! } ! if (quoted) return; ! ! //ignore whitespace ! if ( ParserHelper.isWhitespace(token) ) return; ! ! //do replacements ! String substoken = (String) replacements.get(token); ! token = (substoken==null) ? token : substoken; ! ! //handle <=, >=, !=, is not, not between, not in ! if (lastToken==null) { ! lastToken=token; ! } ! else { ! String doubleToken = (token.length()>1) ? ! lastToken + ' ' + token : ! lastToken + token; ! if ( operators.contains(doubleToken) ) { ! parser.token(doubleToken, q); ! lastToken=null; ! } ! else { ! parser.token(lastToken, q); ! lastToken=token; ! } ! } ! ! } ! ! /** ! * @see cirrus.hibernate.query.Parser#start(QueryTranslator) ! */ ! public void start(QueryTranslator q) throws QueryException { ! quoted = false; ! parser.start(q); ! } ! ! /** ! * @see cirrus.hibernate.query.Parser#end(QueryTranslator) ! */ ! public void end(QueryTranslator q) throws QueryException { ! if (lastToken!=null) parser.token(lastToken, q); ! parser.end(q); ! } ! ! } Index: SelectParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/query/SelectParser.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** SelectParser.java 22 Nov 2002 07:03:07 -0000 1.35 --- SelectParser.java 26 Nov 2002 03:35:44 -0000 1.36 *************** *** 136,140 **** public void end(QueryTranslator q) { } ! } ! --- 136,140 ---- public void end(QueryTranslator q) { } ! } ! Index: WhereParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/query/WhereParser.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** WhereParser.java 21 Nov 2002 07:44:57 -0000 1.40 --- WhereParser.java 26 Nov 2002 03:35:44 -0000 1.41 *************** *** 173,177 **** } return name; ! } public void token(String token, QueryTranslator q) throws QueryException { --- 173,177 ---- } return name; ! } public void token(String token, QueryTranslator q) throws QueryException { *************** *** 454,456 **** } } ! --- 454,456 ---- } } ! |
From: <one...@us...> - 2002-11-26 03:35:47
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/proxy In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/proxy Modified Files: CGLIBLazyInitializer.java LazyInitializer.java SerializableProxy.java Log Message: fixed broken line-endings and added a test Index: CGLIBLazyInitializer.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/proxy/CGLIBLazyInitializer.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CGLIBLazyInitializer.java 7 Nov 2002 10:10:59 -0000 1.5 --- CGLIBLazyInitializer.java 26 Nov 2002 03:35:44 -0000 1.6 *************** *** 1,56 **** ! //$Id$ ! package cirrus.hibernate.proxy; ! ! import java.io.Serializable; ! import java.lang.reflect.Method; ! import org.apache.commons.logging.LogFactory; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.engine.SessionImplementor; ! import net.sf.cglib.proxy.Enhancer; ! import net.sf.cglib.proxy.MethodInterceptor; ! - /** - * - */ - public final class CGLIBLazyInitializer extends LazyInitializer implements MethodInterceptor { - - private Class[] interfaces; - - public static HibernateProxy getProxy(Class persistentClass, Class[] interfaces, Method getIdentifierMethod, Serializable id, SessionImplementor session) throws HibernateException { - try { - return (HibernateProxy) Enhancer.enhance( - persistentClass, - interfaces, - new CGLIBLazyInitializer(persistentClass, interfaces, id, getIdentifierMethod, session), - persistentClass.getClassLoader() - ); - } - catch (Throwable t) { - LogFactory.getLog(LazyInitializer.class).error("CGLIB Enhancement failed", t); - throw new HibernateException( "CGLIB Enhancement failed", t ); - } - } - - private CGLIBLazyInitializer(Class persistentClass, Class[] interfaces, Serializable id, Method getIdentifierMethod, SessionImplementor session) { - super(persistentClass, id, getIdentifierMethod, session); - this.interfaces = interfaces; - } - - public boolean invokeSuper(Object obj, Method method, Object args[]) throws Throwable { - return false; - } - - - public Object afterReturn(Object obj, Method method, Object args[], boolean invokedSuper, Object retValFromSuper, Throwable e) throws Throwable{ - return invoke(method, args); - } - - protected Object serializableProxy() { - return new SerializableProxy(persistentClass, interfaces, id, getIdentifierMethod); - } - } --- 1,56 ---- ! //$Id$ ! package cirrus.hibernate.proxy; ! import java.io.Serializable; ! import java.lang.reflect.Method; ! import org.apache.commons.logging.LogFactory; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.engine.SessionImplementor; ! ! import net.sf.cglib.proxy.Enhancer; ! import net.sf.cglib.proxy.MethodInterceptor; ! ! ! /** ! * ! */ ! public final class CGLIBLazyInitializer extends LazyInitializer implements MethodInterceptor { ! ! private Class[] interfaces; ! ! public static HibernateProxy getProxy(Class persistentClass, Class[] interfaces, Method getIdentifierMethod, Serializable id, SessionImplementor session) throws HibernateException { ! try { ! return (HibernateProxy) Enhancer.enhance( ! persistentClass, ! interfaces, ! new CGLIBLazyInitializer(persistentClass, interfaces, id, getIdentifierMethod, session), ! persistentClass.getClassLoader() ! ); ! } ! catch (Throwable t) { ! LogFactory.getLog(LazyInitializer.class).error("CGLIB Enhancement failed", t); ! throw new HibernateException( "CGLIB Enhancement failed", t ); ! } ! } ! ! private CGLIBLazyInitializer(Class persistentClass, Class[] interfaces, Serializable id, Method getIdentifierMethod, SessionImplementor session) { ! super(persistentClass, id, getIdentifierMethod, session); ! this.interfaces = interfaces; ! } ! ! public boolean invokeSuper(Object obj, Method method, Object args[]) throws Throwable { ! return false; ! } ! ! ! public Object afterReturn(Object obj, Method method, Object args[], boolean invokedSuper, Object retValFromSuper, Throwable e) throws Throwable{ ! return invoke(method, args); ! } ! ! protected Object serializableProxy() { ! return new SerializableProxy(persistentClass, interfaces, id, getIdentifierMethod); ! } } Index: LazyInitializer.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/proxy/LazyInitializer.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** LazyInitializer.java 5 Nov 2002 06:46:06 -0000 1.10 --- LazyInitializer.java 26 Nov 2002 03:35:44 -0000 1.11 *************** *** 1,156 **** ! //$Id$ ! package cirrus.hibernate.proxy; ! ! import java.io.Serializable; ! import java.lang.reflect.Method; ! import java.sql.SQLException; ! ! import org.apache.commons.logging.LogFactory; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.LazyInitializationException; ! import cirrus.hibernate.engine.Key; ! import cirrus.hibernate.engine.SessionImplementor; ! import cirrus.hibernate.helpers.ReflectHelper; ! ! /** ! * ! */ ! public abstract class LazyInitializer { ! ! protected Object target = null; ! protected Serializable id; ! protected SessionImplementor session; ! protected Class persistentClass; ! protected Method getIdentifierMethod; ! protected boolean overridesEquals; ! ! protected LazyInitializer(Class persistentClass, Serializable id, Method getIdentifierMethod, SessionImplementor session) { ! this.id = id; ! this.session = session; ! this.persistentClass = persistentClass; ! this.getIdentifierMethod = getIdentifierMethod; ! overridesEquals = ReflectHelper.overridesEquals(persistentClass); ! } ! ! public void initialize() throws HibernateException, SQLException { ! if (target==null) { ! if ( session==null ) { ! throw new HibernateException("Could not initialize proxy - no Session"); ! } ! else if ( !session.isOpen() ) { ! throw new HibernateException("Could not initialize proxy - the owning Session was closed"); ! } ! else { ! target = session.immediateLoad(persistentClass, id); ! } ! } ! } ! ! private void initializeWrapExceptions() { ! try { ! initialize(); ! } ! catch (Exception e) { ! LogFactory.getLog(LazyInitializer.class).error("Exception initializing proxy", e); ! throw new LazyInitializationException(e); ! } ! } ! ! protected abstract Object serializableProxy(); ! ! protected final Object invoke(Method method, Object[] args) throws Throwable { ! ! String methodName = method.getName(); ! int params = method.getParameterTypes().length; ! ! if ( params==0 ) { ! ! if ( "writeReplace".equals(methodName) ) { ! ! if (target==null && session!=null ) target = session.getEntity( ! new Key( id, session.getFactory().getPersister(persistentClass) ) ! ); ! if (target==null) { ! /*if ( session==null || !session.isOpen() ) { ! return session.getFactory().getPersister(persistentClass).instantiate(id); //A little "empty" object ! } ! else {*/ ! return serializableProxy(); ! //} ! } ! else { ! return target; ! } ! ! } ! else if ( !overridesEquals && "hashCode".equals(methodName) ) { ! // kinda dodgy, since it redefines the hashcode of the proxied object. ! // but necessary if we are to keep proxies in HashSets without ! // forcing them to be initialized ! return new Integer( id.hashCode() ); ! } ! else if ( method.equals(getIdentifierMethod) ) { ! return id; ! } ! else if ( "finalize".equals( method.getName() ) ) { ! return null; ! } ! ! } ! else if ( params==1 && !overridesEquals && "equals".equals(methodName) ) { ! // less dodgy because Hibernate forces == to be same as identifier equals ! return new Boolean( id.equals( getIdentifierMethod.invoke( args[0], null ) ) ); ! } ! ! // otherwise: ! return method.invoke( getImplementation(), args ); ! ! } ! ! public final Serializable getIdentifier() { ! return id; ! } ! ! public final Class getPersistentClass() { ! return persistentClass; ! } ! ! public final boolean isUninitialized() { ! return target == null; ! } ! ! public final SessionImplementor getSession() { ! return session; ! } ! ! public final void setSession(SessionImplementor s) { ! if (s!=session) { ! if ( session!=null && session.isOpen() ) { ! //TODO: perhaps this should be some other RuntimeException... ! throw new LazyInitializationException("Illegally attempted to associate a proxy with two open Sessions"); ! } ! else { ! session = s; ! } ! } ! } ! ! /** ! * Return the underlying persistent object, initializing if necessary ! */ ! public final Object getImplementation() throws HibernateException, SQLException { ! initializeWrapExceptions(); ! return target; ! } ! ! /** ! * Return the underlying persistent object in the given <tt>Session</tt>, or null ! */ ! public final Object getImplementation(SessionImplementor s) throws HibernateException { ! return s.getEntity( new Key( ! getIdentifier(), ! s.getFactory().getPersister( getPersistentClass() ) ! ) ); ! } ! } --- 1,156 ---- ! //$Id$ ! package cirrus.hibernate.proxy; ! ! import java.io.Serializable; ! import java.lang.reflect.Method; ! import java.sql.SQLException; ! ! import org.apache.commons.logging.LogFactory; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.LazyInitializationException; ! import cirrus.hibernate.engine.Key; ! import cirrus.hibernate.engine.SessionImplementor; ! import cirrus.hibernate.helpers.ReflectHelper; ! ! /** ! * ! */ ! public abstract class LazyInitializer { ! ! protected Object target = null; ! protected Serializable id; ! protected SessionImplementor session; ! protected Class persistentClass; ! protected Method getIdentifierMethod; ! protected boolean overridesEquals; ! ! protected LazyInitializer(Class persistentClass, Serializable id, Method getIdentifierMethod, SessionImplementor session) { ! this.id = id; ! this.session = session; ! this.persistentClass = persistentClass; ! this.getIdentifierMethod = getIdentifierMethod; ! overridesEquals = ReflectHelper.overridesEquals(persistentClass); ! } ! ! public void initialize() throws HibernateException, SQLException { ! if (target==null) { ! if ( session==null ) { ! throw new HibernateException("Could not initialize proxy - no Session"); ! } ! else if ( !session.isOpen() ) { ! throw new HibernateException("Could not initialize proxy - the owning Session was closed"); ! } ! else { ! target = session.immediateLoad(persistentClass, id); ! } ! } ! } ! ! private void initializeWrapExceptions() { ! try { ! initialize(); ! } ! catch (Exception e) { ! LogFactory.getLog(LazyInitializer.class).error("Exception initializing proxy", e); ! throw new LazyInitializationException(e); ! } ! } ! ! protected abstract Object serializableProxy(); ! ! protected final Object invoke(Method method, Object[] args) throws Throwable { ! ! String methodName = method.getName(); ! int params = method.getParameterTypes().length; ! ! if ( params==0 ) { ! ! if ( "writeReplace".equals(methodName) ) { ! ! if (target==null && session!=null ) target = session.getEntity( ! new Key( id, session.getFactory().getPersister(persistentClass) ) ! ); ! if (target==null) { ! /*if ( session==null || !session.isOpen() ) { ! return session.getFactory().getPersister(persistentClass).instantiate(id); //A little "empty" object ! } ! else {*/ ! return serializableProxy(); ! //} ! } ! else { ! return target; ! } ! ! } ! else if ( !overridesEquals && "hashCode".equals(methodName) ) { ! // kinda dodgy, since it redefines the hashcode of the proxied object. ! // but necessary if we are to keep proxies in HashSets without ! // forcing them to be initialized ! return new Integer( id.hashCode() ); ! } ! else if ( method.equals(getIdentifierMethod) ) { ! return id; ! } ! else if ( "finalize".equals( method.getName() ) ) { ! return null; ! } ! ! } ! else if ( params==1 && !overridesEquals && "equals".equals(methodName) ) { ! // less dodgy because Hibernate forces == to be same as identifier equals ! return new Boolean( id.equals( getIdentifierMethod.invoke( args[0], null ) ) ); ! } ! ! // otherwise: ! return method.invoke( getImplementation(), args ); ! ! } ! ! public final Serializable getIdentifier() { ! return id; ! } ! ! public final Class getPersistentClass() { ! return persistentClass; ! } ! ! public final boolean isUninitialized() { ! return target == null; ! } ! ! public final SessionImplementor getSession() { ! return session; ! } ! ! public final void setSession(SessionImplementor s) { ! if (s!=session) { ! if ( session!=null && session.isOpen() ) { ! //TODO: perhaps this should be some other RuntimeException... ! throw new LazyInitializationException("Illegally attempted to associate a proxy with two open Sessions"); ! } ! else { ! session = s; ! } ! } ! } ! ! /** ! * Return the underlying persistent object, initializing if necessary ! */ ! public final Object getImplementation() throws HibernateException, SQLException { ! initializeWrapExceptions(); ! return target; ! } ! ! /** ! * Return the underlying persistent object in the given <tt>Session</tt>, or null ! */ ! public final Object getImplementation(SessionImplementor s) throws HibernateException { ! return s.getEntity( new Key( ! getIdentifier(), ! s.getFactory().getPersister( getPersistentClass() ) ! ) ); ! } ! } Index: SerializableProxy.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/proxy/SerializableProxy.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SerializableProxy.java 29 Oct 2002 02:45:42 -0000 1.2 --- SerializableProxy.java 26 Nov 2002 03:35:44 -0000 1.3 *************** *** 1,46 **** ! //$Id$ ! package cirrus.hibernate.proxy; ! ! import java.io.Serializable; ! import java.lang.reflect.Method; ! ! import org.apache.commons.logging.LogFactory; ! ! import cirrus.hibernate.helpers.ReflectHelper; ! ! /** ! * Serializable placeholder for <tt>CGLIB</tt> proxies ! */ ! public final class SerializableProxy implements Serializable { ! ! public SerializableProxy() {} ! ! public SerializableProxy(Class persistentClass, Class[] interfaces, Serializable id, Method getIdentifierMethod) { ! this.persistentClass = persistentClass; ! this.interfaces = interfaces; ! this.id = id; ! this.getIdentifierMethod = (getIdentifierMethod==null) ? null : getIdentifierMethod.getName(); ! } ! ! private Class persistentClass; ! private Class[] interfaces; ! private Serializable id; ! private String getIdentifierMethod; ! ! Object readResolve() { ! try { ! return CGLIBLazyInitializer.getProxy( ! persistentClass, ! interfaces, ! (getIdentifierMethod==null) ? null : ReflectHelper.getMethod(persistentClass, getIdentifierMethod), ! id, ! null ! ); ! } ! catch (Exception e) { ! LogFactory.getLog(CGLIBLazyInitializer.class).error("Exception deserializing proxy", e); ! //TODO ! return null; ! } ! } ! } --- 1,46 ---- ! //$Id$ ! package cirrus.hibernate.proxy; ! ! import java.io.Serializable; ! import java.lang.reflect.Method; ! ! import org.apache.commons.logging.LogFactory; ! ! import cirrus.hibernate.helpers.ReflectHelper; ! ! /** ! * Serializable placeholder for <tt>CGLIB</tt> proxies ! */ ! public final class SerializableProxy implements Serializable { ! ! public SerializableProxy() {} ! ! public SerializableProxy(Class persistentClass, Class[] interfaces, Serializable id, Method getIdentifierMethod) { ! this.persistentClass = persistentClass; ! this.interfaces = interfaces; ! this.id = id; ! this.getIdentifierMethod = (getIdentifierMethod==null) ? null : getIdentifierMethod.getName(); ! } ! ! private Class persistentClass; ! private Class[] interfaces; ! private Serializable id; ! private String getIdentifierMethod; ! ! Object readResolve() { ! try { ! return CGLIBLazyInitializer.getProxy( ! persistentClass, ! interfaces, ! (getIdentifierMethod==null) ? null : ReflectHelper.getMethod(persistentClass, getIdentifierMethod), ! id, ! null ! ); ! } ! catch (Exception e) { ! LogFactory.getLog(CGLIBLazyInitializer.class).error("Exception deserializing proxy", e); ! //TODO ! return null; ! } ! } ! } |
From: <one...@us...> - 2002-11-26 03:35:47
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/persister Modified Files: AbstractEntityPersister.java Loadable.java Queryable.java Log Message: fixed broken line-endings and added a test Index: AbstractEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/AbstractEntityPersister.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** AbstractEntityPersister.java 25 Nov 2002 05:18:00 -0000 1.15 --- AbstractEntityPersister.java 26 Nov 2002 03:35:44 -0000 1.16 *************** *** 1,706 **** ! //$Id$ ! package cirrus.hibernate.persister; ! ! import java.io.Serializable; ! import java.lang.reflect.Constructor; ! import java.lang.reflect.Method; ! import java.util.HashMap; ! import java.util.HashSet; ! import java.util.Iterator; ! [...1383 lines suppressed...] ! ! StringBuffer aliasBuilder = new StringBuffer(name.length()); ! ! if (nameEscaped) aliasBuilder.append(quote); ! aliasBuilder.append(name); ! aliasBuilder.append(suffix); ! if (nameEscaped) aliasBuilder.append(quote); ! ! return aliasBuilder.toString(); ! } ! ! public Class getMappedSuperclass() { ! return superclass; ! } ! ! public boolean isExplicitPolymorphism() { ! return explicitPolymorphism; ! } ! ! } Index: Loadable.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/Loadable.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Loadable.java 25 Nov 2002 07:25:20 -0000 1.13 --- Loadable.java 26 Nov 2002 03:35:44 -0000 1.14 *************** *** 1,107 **** ! //$Id$ ! package cirrus.hibernate.persister; ! ! import cirrus.hibernate.type.DiscriminatorType; ! import cirrus.hibernate.type.Type; ! ! /** ! * Implemented by a <tt>ClassPersister</tt> that uses <tt>Loader</tt>. There are several optional ! * operations used only by loaders that inherit <tt>OuterJoinLoader</tt>. ! * ! * @see cirrus.hibernate.loader.Loader ! * @see cirrus.hibernate.loader.OuterJoinLoader ! */ ! public interface Loadable extends ClassPersister { ! ! /** ! * Get the names of columns used to persist the identifier ! */ ! public String[] getIdentifierColumnNames(); ! ! /** ! * Does this persistent class have subclasses? ! */ ! public boolean hasSubclasses(); ! ! /** ! * Get the name of the column used as a discriminator ! */ ! public String getDiscriminatorColumnName(); ! ! /** ! * Get the discriminator type ! */ ! public DiscriminatorType getDiscriminatorType(); ! ! /** ! * Get the concrete subclass corresponding to the given discriminator ! * value ! */ ! public Class getSubclassForDiscriminatorValue(Object value); ! ! /** ! * Get the column names for the numbered property of <em>this</em> class ! */ ! public String[] getPropertyColumnNames(int i); ! ! //USED BY OuterJoinLoader + subclasses ! ! /** ! * Get the fully-qualified tablename used to persist this class ! */ ! public String getTableName(); ! ! /** ! * How many properties are there, for this class and all subclasses? ! * (optional operation) ! */ ! public int countSubclassProperties(); ! ! /** ! * May this property be fetched using an SQL outerjoin? ! * (optional operation) ! */ ! public int enableJoinedFetch(int i); ! ! /** ! * Is this property defined on a subclass of the mapped class? ! */ ! public boolean isDefinedOnSubclass(int i); ! ! /** ! * Get an array of the types of all properties of all subclasses ! * (optional operation) ! */ ! public Type getSubclassPropertyType(int i); ! ! /** ! * Return the column names used to persist all properties of ! * all subclasses of the persistent class ! * (optional operation) ! */ ! public String[] getSubclassPropertyColumnNames(int i); ! /** ! * Given the number of a property of a subclass, and a table alias, ! * return the aliased column names ! */ ! public String[] toColumns(String name, int i); ! ! /** ! * Given a query alias and an identifying suffix, render the ! * property select fragment ! */ ! public String propertySelectClauseFragment(String name, String suffix); ! /** ! * Get the from clause fragment, given a query alias ! */ ! public String fromClauseFragment(String name, boolean innerJoin); ! /** ! * Get any the outer join SQL fragments that appear in the <tt>FROM</tt> clause ! */ ! public String outerJoinsAfterFrom(String name, boolean innerJoin); ! /** ! * Get any the outer join SQL fragments that appear in the <tt>WHERE</tt> clause ! */ ! public String outerJoinsAfterWhere(String name, boolean innerJoin); ! ! } --- 1,107 ---- ! //$Id$ ! package cirrus.hibernate.persister; ! ! import cirrus.hibernate.type.DiscriminatorType; ! import cirrus.hibernate.type.Type; ! ! /** ! * Implemented by a <tt>ClassPersister</tt> that uses <tt>Loader</tt>. There are several optional ! * operations used only by loaders that inherit <tt>OuterJoinLoader</tt>. ! * ! * @see cirrus.hibernate.loader.Loader ! * @see cirrus.hibernate.loader.OuterJoinLoader ! */ ! public interface Loadable extends ClassPersister { ! ! /** ! * Get the names of columns used to persist the identifier ! */ ! public String[] getIdentifierColumnNames(); ! ! /** ! * Does this persistent class have subclasses? ! */ ! public boolean hasSubclasses(); ! ! /** ! * Get the name of the column used as a discriminator ! */ ! public String getDiscriminatorColumnName(); ! ! /** ! * Get the discriminator type ! */ ! public DiscriminatorType getDiscriminatorType(); ! ! /** ! * Get the concrete subclass corresponding to the given discriminator ! * value ! */ ! public Class getSubclassForDiscriminatorValue(Object value); ! ! /** ! * Get the column names for the numbered property of <em>this</em> class ! */ ! public String[] getPropertyColumnNames(int i); ! ! //USED BY OuterJoinLoader + subclasses ! ! /** ! * Get the fully-qualified tablename used to persist this class ! */ ! public String getTableName(); ! ! /** ! * How many properties are there, for this class and all subclasses? ! * (optional operation) ! */ ! public int countSubclassProperties(); ! ! /** ! * May this property be fetched using an SQL outerjoin? ! * (optional operation) ! */ ! public int enableJoinedFetch(int i); ! ! /** ! * Is this property defined on a subclass of the mapped class? ! */ ! public boolean isDefinedOnSubclass(int i); ! ! /** ! * Get an array of the types of all properties of all subclasses ! * (optional operation) ! */ ! public Type getSubclassPropertyType(int i); ! ! /** ! * Return the column names used to persist all properties of ! * all subclasses of the persistent class ! * (optional operation) ! */ ! public String[] getSubclassPropertyColumnNames(int i); ! /** ! * Given the number of a property of a subclass, and a table alias, ! * return the aliased column names ! */ ! public String[] toColumns(String name, int i); ! ! /** ! * Given a query alias and an identifying suffix, render the ! * property select fragment ! */ ! public String propertySelectClauseFragment(String name, String suffix); ! /** ! * Get the from clause fragment, given a query alias ! */ ! public String fromClauseFragment(String name, boolean innerJoin); ! /** ! * Get any the outer join SQL fragments that appear in the <tt>FROM</tt> clause ! */ ! public String outerJoinsAfterFrom(String name, boolean innerJoin); ! /** ! * Get any the outer join SQL fragments that appear in the <tt>WHERE</tt> clause ! */ ! public String outerJoinsAfterWhere(String name, boolean innerJoin); ! ! } Index: Queryable.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/Queryable.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Queryable.java 19 Nov 2002 10:42:17 -0000 1.9 --- Queryable.java 26 Nov 2002 03:35:44 -0000 1.10 *************** *** 1,58 **** ! //$Id$ ! package cirrus.hibernate.persister; ! ! import cirrus.hibernate.MappingException; ! import cirrus.hibernate.QueryException; ! import cirrus.hibernate.type.Type; ! ! /** ! * Extends the generic <tt>ClassPersister</tt> contract to add ! * operations required by the query language ! */ ! public interface Queryable extends Loadable { ! ! /** ! * Is this class mapped as a subclass of another class? ! */ ! public boolean isInherited(); ! /** ! * Is this class explicit polymorphism only? ! */ ! public boolean isExplicitPolymorphism(); ! /** ! * Get the class that this class is mapped as a subclass of - ! * not necessarily the direct superclass ! */ ! public Class getMappedSuperclass(); ! /** ! * Get the discriminator value for this particular concrete subclass, ! * as a string that may be embedded in a select statement ! */ ! public String getDiscriminatorSQLString(); ! ! /** ! * Given a component path expression, get the type of the property ! */ ! public Type getPropertyType(String path); ! /** ! * Given a component path expression, get the type of the composite ! * identifier property ! */ ! public Type getIdentifierPropertyType(String path); ! ! /** ! * Get the where clause fragment, given a query alias ! */ ! public String getQueryWhereClause(String name) throws MappingException; ! ! /** ! * Given a query alias and an identifying suffix, render the ! * intentifier select fragment ! */ ! public String selectIdentifierString(String name, String suffix); ! /** ! * Given a query alias and a property path, return the qualified ! * column name ! */ ! public String[] toColumns(String name, String property) throws QueryException; ! } --- 1,58 ---- ! //$Id$ ! package cirrus.hibernate.persister; ! ! import cirrus.hibernate.MappingException; ! import cirrus.hibernate.QueryException; ! import cirrus.hibernate.type.Type; ! ! /** ! * Extends the generic <tt>ClassPersister</tt> contract to add ! * operations required by the query language ! */ ! public interface Queryable extends Loadable { ! ! /** ! * Is this class mapped as a subclass of another class? ! */ ! public boolean isInherited(); ! /** ! * Is this class explicit polymorphism only? ! */ ! public boolean isExplicitPolymorphism(); ! /** ! * Get the class that this class is mapped as a subclass of - ! * not necessarily the direct superclass ! */ ! public Class getMappedSuperclass(); ! /** ! * Get the discriminator value for this particular concrete subclass, ! * as a string that may be embedded in a select statement ! */ ! public String getDiscriminatorSQLString(); ! ! /** ! * Given a component path expression, get the type of the property ! */ ! public Type getPropertyType(String path); ! /** ! * Given a component path expression, get the type of the composite ! * identifier property ! */ ! public Type getIdentifierPropertyType(String path); ! ! /** ! * Get the where clause fragment, given a query alias ! */ ! public String getQueryWhereClause(String name) throws MappingException; ! ! /** ! * Given a query alias and an identifying suffix, render the ! * intentifier select fragment ! */ ! public String selectIdentifierString(String name, String suffix); ! /** ! * Given a query alias and a property path, return the qualified ! * column name ! */ ! public String[] toColumns(String name, String property) throws QueryException; ! } |
From: <tu...@us...> - 2002-11-25 21:02:20
|
Update of /cvsroot/hibernate/Hibernate/doc/reference/html_single In directory sc8-pr-cvs1:/tmp/cvs-serv31818/doc/reference/html_single Modified Files: index.html Log Message: Updated using the new style and scripts Index: index.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/reference/html_single/index.html,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** index.html 25 Nov 2002 16:14:37 -0000 1.85 --- index.html 25 Nov 2002 21:01:40 -0000 1.86 *************** *** 1,5 **** <html><head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> ! <title>Hibernate Reference Documentation</title><link rel="stylesheet" href="../style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.52.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book"><div class="titlepage"><div><h1 class="title"><a name="d0e1"></a>Hibernate Reference Documentation</h1></div><div><h2 class="subtitle">Relational Persistence for Idiomatic Java</h2></div><div><h2 class="subtitle">http://hibernate.sourceforge.net/</h2></div><hr noshade="true"></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>1. <a href="#architecture">Architecture</a></dt><dd><dl><dt>1.1. <a href="#architecture-s1">Overview</a></dt><dt>1.2. <a href="#architecture-s2">Persistent Object Identity</a></dt><dt>1.3. <a href="#architecture-s3">JMX Integration</a></dt></dl></dd><dt>2. <a href="#session-configuration">SessionFactory Configuration</a></dt><dd><dl><dt>2.1. <a href="#session-configuration-s1">Programmatic Datastore Configuration</a></dt><dt>2.2. <a href="#session-configuration-s2">Obtaining a SessionFactory</a></dt><dt>2.3. <a href="#session-configuration-s3">User provided JDBC connection</a></dt><dt>2.4. <a href="#session-configuration-s4">Hibernate provided JDBC connection</a></dt><dt>2.5. <a href="#session-configuration-s5">Other properties</a></dt><dt>2.6. <a href="#session-configuration-s6">XML Configuration File</a></dt><dt>2.7. <a href="#session-configuration-s7">Logging</a></dt></dl></dd><dt>3. <a href="#persistent-classes">Persistent Classes</a></dt><dd><dl><dt>3.1. <a href="#persistent-classes-s1">Simple Example</a></dt><dd><dl><dt>3.1.1. <a href="#persistent-classes-s1-1">Declare accessors and mutators for persistent fields</a></dt><dt>3.1.2. <a href="#persistent-classes-s1-2">Implement a default constructor</a></dt><dt>3.1.3. <a href="#persistent-classes-s1-3">Provide an identifier property (optional)</a></dt></dl></dd><dt>3.2. <a href="#persistent-classes-s2">Inheritance</a></dt><dt>3.3. <a href="#persistent-classes-s3">Persistent Lifecycle Callbacks</a></dt><dt>3.4. <a href="#persistent-classes-s4">Validatable</a></dt></dl></dd><dt>4. <a href="#or-mapping">Basic O/R Mapping</a></dt><dd><dl><dt>4.1. <a href="#or-mapping-s1">Mapping declaration</a></dt><dd><dl><dt>4.1.1. <a href="#or-mapping-s1-1">Doctype</a></dt><dt>4.1.2. <a href="#or-mapping-s1-2">hibernate-mapping</a></dt><dt>4.1.3. <a href="#or-mapping-s1-3">class</a></dt><dt>4.1.4. <a href="#or-mapping-s1-4">id</a></dt><dt>4.1.5. <a href="#or-mapping-s1-4b">composite-id</a></dt><dt>4.1.6. <a href="#or-mapping-s1-5">discriminator</a></dt><dt>4.1.7. <a href="#or-mapping-s1-6">version (optional)</a></dt><dt>4.1.8. <a href="#or-mapping-s1-6b">timestamp (optional)</a></dt><dt>4.1.9. <a href="#or-mapping-s1-7">property</a></dt><dt>4.1.10. <a href="#or-mapping-s1-8">many-to-one</a></dt><dt>4.1.11. <a href="#or-mapping-s1-9">one-to-one</a></dt><dt>4.1.12. <a href="#or-mapping-s1-10">component</a></dt><dt>4.1.13. <a href="#or-mapping-s1-11">subclass</a></dt><dt>4.1.14. <a href="#or-mapping-s1-11b">joined-subclass</a></dt><dt>4.1.15. <a href="#or-mapping-s1-12">map, set, list, bag</a></dt></dl></dd><dt>4.2. <a href="#or-mapping-s2">Hibernate Types</a></dt><dd><dl><dt>4.2.1. <a href="#or-mapping-s2-1">Entities and values</a></dt><dt>4.2.2. <a href="#or-mapping-s2-2">Basic value types</a></dt><dt>4.2.3. <a href="#or-mapping-s2-3">Persistent enum types</a></dt><dt>4.2.4. <a href="#or-mapping-s2-4">Custom value types</a></dt><dt>4.2.5. <a href="#or-mapping-s2-5">The object type</a></dt></dl></dd></dl></dd><dt>5. <a href="#adv-or-mapping">Advanced O/R Mapping</a></dt><dd><dl><dt>5.1. <a href="#adv-or-mapping-s1">Collections</a></dt><dd><dl><dt>5.1.1. <a href="#adv-or-mapping-s1-1">Persistent Collection Styles</a></dt><dt>5.1.2. <a href="#adv-or-mapping-s1-2">Toplevel and Nested Collections</a></dt><dt>5.1.3. <a href="#adv-or-mapping-s1-3">Mapping a Collection</a></dt><dt>5.1.4. <a href="#adv-or-mapping-s1-4">Mapping a Property to a Toplevel Collection</a></dt><dt>5.1.5. <a href="#adv-or-mapping-s1-5">Collections of Values and Many To Many Associations</a></dt><dt>5.1.6. <a href="#adv-or-mapping-s1-6">One To Many Associations</a></dt><dt>5.1.7. <a href="#adv-or-mapping-s1-7">Lazy Initialization</a></dt><dt>5.1.8. <a href="#adv-or-mapping-s1-8">Sorted Collections</a></dt><dt>5.1.9. <a href="#adv-or-mapping-s1-9">Garbage Collection</a></dt><dt>5.1.10. <a href="#adv-or-mapping-s1-10">Bidirectional Associations</a></dt><dt>5.1.11. <a href="#adv-or-mapping-s1-11">Ternary Associations</a></dt><dt>5.1.12. <a href="#adv-or-mapping-s1-12">Collection Example</a></dt></dl></dd><dt>5.2. <a href="#adv-or-mapping-s2">Components</a></dt><dd><dl><dt>5.2.1. <a href="#adv-or-mapping-s2-1">As Dependent Objects</a></dt><dt>5.2.2. <a href="#adv-or-mapping-s2-2">In Collections</a></dt><dt>5.2.3. <a href="#adv-or-mapping-s2-2b">As a Map Index</a></dt><dt>5.2.4. <a href="#adv-or-mapping-s2-3">As Composite Identifiers</a></dt></dl></dd><dt>5.3. <a href="#adv-or-mapping-s3">Cache</a></dt><dd><dl><dt>5.3.1. <a href="#adv-or-mapping-s3-1">Mapping</a></dt><dt>5.3.2. <a href="#adv-or-mapping-s3-2">Read Only Cache</a></dt><dt>5.3.3. <a href="#adv-or-mapping-s3-3">Read / Write Cache</a></dt></dl></dd><dt>5.4. <a href="#adv-or-mapping-s4">Proxies for Lazy Initialization</a></dt></dl></dd><dt>6. <a href="#manipulating-data">Manipulating Persistent Data</a></dt><dd><dl><dt>6.1. <a href="#manipulating-data-s1">Creating a persistent object</a></dt><dt>6.2. <a href="#manipulating-data-s2">Loading an object</a></dt><dt>6.3. <a href="#manipulating-data-s3">Querying</a></dt><dd><dl><dt>6.3.1. <a href="#manipulating-data-s4">Scalar queries</a></dt><dt>6.3.2. <a href="#manipulating-data-s5">The Query interface</a></dt><dt>6.3.3. <a href="#manipulating-data-s5b">Scrollable iteration</a></dt><dt>6.3.4. <a href="#manipulating-data-s6">Filtering collections</a></dt></dl></dd><dt>6.4. <a href="#manipulating-data-s7">Updating objects saved or loaded in the current session</a></dt><dt>6.5. <a href="#manipulating-data-s8">Updating objects saved or loaded in a previous session</a></dt><dt>6.6. <a href="#manipulating-data-s9">Deleting persistent objects</a></dt><dt>6.7. <a href="#manipulating-data-s10">Graphs of objects</a></dt><dd><dl><dt>6.7.1. <a href="#manipulating-data-s11a">Lifecycle objects</a></dt><dt>6.7.2. <a href="#manipulating-data-s11b">Persistence by Reachability</a></dt></dl></dd><dt>6.8. <a href="#manipulating-data-s12">Flushing</a></dt><dt>6.9. <a href="#manipulating-data-s13">Ending a Session</a></dt><dd><dl><dt>6.9.1. <a href="#manipulating-data-s13-1">Flushing the session</a></dt><dt>6.9.2. <a href="#manipulating-data-s13-2">Committing the transaction</a></dt><dt>6.9.3. <a href="#manipulating-data-s13-3">Closing the session</a></dt><dt>6.9.4. <a href="#manipulating-data-s13-4">Exception handling</a></dt></dl></dd><dt>6.10. <a href="#manipulating-data-s14">Interceptors</a></dt></dl></dd><dt>7. <a href="#query-language">Hibernate Query Language</a></dt><dd><dl><dt>7.1. <a href="#query-language-s1">Case Sensitivity</a></dt><dt>7.2. <a href="#query-language-s2">The from clause</a></dt><dt>7.3. <a href="#query-language-s3">The select clause</a></dt><dt>7.4. <a href="#query-language-s3b">polymorphism</a></dt><dt>7.5. <a href="#query-language-s4">from collections</a></dt><dt>7.6. <a href="#query-language-s5">The where clause</a></dt><dt>7.7. <a href="#query-language-s6">Expressions</a></dt><dt>7.8. <a href="#query-language-s7">The order by clause</a></dt><dt>7.9. <a href="#query-language-s8">The group by clause</a></dt><dt>7.10. <a href="#query-language-s9">Subqueries</a></dt></dl></dd><dt>8. <a href="#transactions">Transactions And Concurrency</a></dt><dd><dl><dt>8.1. <a href="#transactions-s1">Datastores, Sessions and Factories</a></dt><dt>8.2. <a href="#transactions-s3">Threads and connections</a></dt><dt>8.3. <a href="#transactions-s5">Optimistic Locking / Versioning</a></dt><dd><dl><dt>8.3.1. <a href="#transactions-s5-1">Long session with automatic versioning</a></dt><dt>8.3.2. <a href="#transactions-s5-2">Many sessions with automatic versioning</a></dt><dt>8.3.3. <a href="#transactions-s5-3">Application version checking</a></dt></dl></dd><dt>8.4. <a href="#transactions-s2">Session disconnection</a></dt><dt>8.5. <a href="#transactions-s4">Pessimistic Locking</a></dt></dl></dd><dt>9. <a href="#examples">Examples</a></dt><dd><dl><dt>9.1. <a href="#examples-s0">Employer / Employee</a></dt><dt>9.2. <a href="#examples-s1">Author / Work</a></dt><dt>9.3. <a href="#examples-s2">Customer / Order / Product</a></dt></dl></dd><dt>10. <a href="#best-practices">Best Practices</a></dt></dl></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="architecture"></a>Chapter 1. Architecture</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>1.1. <a href="#architecture-s1">Overview</a></dt><dt>1.2. <a href="#architecture-s2">Persistent Object Identity</a></dt><dt>1.3. <a href="#architecture-s3">JMX Integration</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="architecture-s1"></a>1.1. Overview</h2></div></div><p> A (very) high-level view of the Hibernate architecture: </p><div class="mediaobject"><img src="../images/overview.gif" align="center"></div><p> --- 1,5 ---- <html><head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> ! <title>Hibernate Reference Documentation</title><link rel="stylesheet" href="'../style.css'" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.49"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book"><div class="titlepage"><div><h1 class="title"><a name="d0e1"></a>Hibernate Reference Documentation</h1></div><div><h2 class="subtitle">Relational Persistence for Idiomatic Java</h2></div><div><h2 class="subtitle">http://hibernate.sourceforge.net/</h2></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>1. <a href="#architecture">Architecture</a></dt><dd><dl><dt><a href="#architecture-s1">Overview</a></dt><dt><a href="#architecture-s2">Persistent Object Identity</a></dt><dt><a href="#architecture-s3">JMX Integration</a></dt></dl></dd><dt>2. <a href="#session-configuration">SessionFactory Configuration</a></dt><dd><dl><dt><a href="#session-configuration-s1">Programmatic Datastore Configuration</a></dt><dt><a href="#session-configuration-s2">Obtaining a SessionFactory</a></dt><dt><a href="#session-configuration-s3">User provided JDBC connection</a></dt><dt><a href="#session-configuration-s4">Hibernate provided JDBC connection</a></dt><dt><a href="#session-configuration-s5">Other properties</a></dt><dt><a href="#session-configuration-s6">XML Configuration File</a></dt><dt><a href="#session-configuration-s7">Logging</a></dt></dl></dd><dt>3. <a href="#persistent-classes">Persistent Classes</a></dt><dd><dl><dt><a href="#persistent-classes-s1">Simple Example</a></dt><dd><dl><dt><a href="#persistent-classes-s1-1">Declare accessors and mutators for persistent fields</a></dt><dt><a href="#persistent-classes-s1-2">Implement a default constructor</a></dt><dt><a href="#persistent-classes-s1-3">Provide an identifier property (optional)</a></dt></dl></dd><dt><a href="#persistent-classes-s2">Inheritance</a></dt><dt><a href="#persistent-classes-s3">Persistent Lifecycle Callbacks</a></dt><dt><a href="#persistent-classes-s4">Validatable</a></dt></dl></dd><dt>4. <a href="#or-mapping">Basic O/R Mapping</a></dt><dd><dl><dt><a href="#or-mapping-s1">Mapping declaration</a></dt><dd><dl><dt><a href="#or-mapping-s1-1">Doctype</a></dt><dt><a href="#or-mapping-s1-2">hibernate-mapping</a></dt><dt><a href="#or-mapping-s1-3">class</a></dt><dt><a href="#or-mapping-s1-4">id</a></dt><dt><a href="#or-mapping-s1-4b">composite-id</a></dt><dt><a href="#or-mapping-s1-5">discriminator</a></dt><dt><a href="#or-mapping-s1-6">version (optional)</a></dt><dt><a href="#or-mapping-s1-6b">timestamp (optional)</a></dt><dt><a href="#or-mapping-s1-7">property</a></dt><dt><a href="#or-mapping-s1-8">many-to-one</a></dt><dt><a href="#or-mapping-s1-9">one-to-one</a></dt><dt><a href="#or-mapping-s1-10">component</a></dt><dt><a href="#or-mapping-s1-11">subclass</a></dt><dt><a href="#or-mapping-s1-11b">joined-subclass</a></dt><dt><a href="#or-mapping-s1-12">map, set, list, bag</a></dt></dl></dd><dt><a href="#or-mapping-s2">Hibernate Types</a></dt><dd><dl><dt><a href="#or-mapping-s2-1">Entities and values</a></dt><dt><a href="#or-mapping-s2-2">Basic value types</a></dt><dt><a href="#or-mapping-s2-3">Persistent enum types</a></dt><dt><a href="#or-mapping-s2-4">Custom value types</a></dt><dt><a href="#or-mapping-s2-5">The object type</a></dt></dl></dd></dl></dd><dt>5. <a href="#adv-or-mapping">Advanced O/R Mapping</a></dt><dd><dl><dt><a href="#adv-or-mapping-s1">Collections</a></dt><dd><dl><dt><a href="#adv-or-mapping-s1-1">Persistent Collection Styles</a></dt><dt><a href="#adv-or-mapping-s1-2">Toplevel and Nested Collections</a></dt><dt><a href="#adv-or-mapping-s1-3">Mapping a Collection</a></dt><dt><a href="#adv-or-mapping-s1-4">Mapping a Property to a Toplevel Collection</a></dt><dt><a href="#adv-or-mapping-s1-5">Collections of Values and Many To Many Associations</a></dt><dt><a href="#adv-or-mapping-s1-6">One To Many Associations</a></dt><dt><a href="#adv-or-mapping-s1-7">Lazy Initialization</a></dt><dt><a href="#adv-or-mapping-s1-8">Sorted Collections</a></dt><dt><a href="#adv-or-mapping-s1-9">Garbage Collection</a></dt><dt><a href="#adv-or-mapping-s1-10">Bidirectional Associations</a></dt><dt><a href="#adv-or-mapping-s1-11">Ternary Associations</a></dt><dt><a href="#adv-or-mapping-s1-12">Collection Example</a></dt></dl></dd><dt><a href="#adv-or-mapping-s2">Components</a></dt><dd><dl><dt><a href="#adv-or-mapping-s2-1">As Dependent Objects</a></dt><dt><a href="#adv-or-mapping-s2-2">In Collections</a></dt><dt><a href="#adv-or-mapping-s2-2b">As a Map Index</a></dt><dt><a href="#adv-or-mapping-s2-3">As Composite Identifiers</a></dt></dl></dd><dt><a href="#adv-or-mapping-s3">Cache</a></dt><dd><dl><dt><a href="#adv-or-mapping-s3-1">Mapping</a></dt><dt><a href="#adv-or-mapping-s3-2">Read Only Cache</a></dt><dt><a href="#adv-or-mapping-s3-3">Read / Write Cache</a></dt></dl></dd><dt><a href="#adv-or-mapping-s4">Proxies for Lazy Initialization</a></dt></dl></dd><dt>6. <a href="#manipulating-data">Manipulating Persistent Data</a></dt><dd><dl><dt><a href="#manipulating-data-s1">Creating a persistent object</a></dt><dt><a href="#manipulating-data-s2">Loading an object</a></dt><dt><a href="#manipulating-data-s3">Querying</a></dt><dd><dl><dt><a href="#manipulating-data-s4">Scalar queries</a></dt><dt><a href="#manipulating-data-s5">The Query interface</a></dt><dt><a href="#manipulating-data-s5b">Scrollable iteration</a></dt><dt><a href="#manipulating-data-s6">Filtering collections</a></dt></dl></dd><dt><a href="#manipulating-data-s7">Updating objects saved or loaded in the current session</a></dt><dt><a href="#manipulating-data-s8">Updating objects saved or loaded in a previous session</a></dt><dt><a href="#manipulating-data-s9">Deleting persistent objects</a></dt><dt><a href="#manipulating-data-s10">Graphs of objects</a></dt><dd><dl><dt><a href="#manipulating-data-s11a">Lifecycle objects</a></dt><dt><a href="#manipulating-data-s11b">Persistence by Reachability</a></dt></dl></dd><dt><a href="#manipulating-data-s12">Flushing</a></dt><dt><a href="#manipulating-data-s13">Ending a Session</a></dt><dd><dl><dt><a href="#manipulating-data-s13-1">Flushing the session</a></dt><dt><a href="#manipulating-data-s13-2">Committing the transaction</a></dt><dt><a href="#manipulating-data-s13-3">Closing the session</a></dt><dt><a href="#manipulating-data-s13-4">Exception handling</a></dt></dl></dd><dt><a href="#manipulating-data-s14">Interceptors</a></dt></dl></dd><dt>7. <a href="#query-language">Hibernate Query Language</a></dt><dd><dl><dt><a href="#query-language-s1">Case Sensitivity</a></dt><dt><a href="#query-language-s2">The from clause</a></dt><dt><a href="#query-language-s3">The select clause</a></dt><dt><a href="#query-language-s3b">polymorphism</a></dt><dt><a href="#query-language-s4">from collections</a></dt><dt><a href="#query-language-s5">The where clause</a></dt><dt><a href="#query-language-s6">Expressions</a></dt><dt><a href="#query-language-s7">The order by clause</a></dt><dt><a href="#query-language-s8">The group by clause</a></dt><dt><a href="#query-language-s9">Subqueries</a></dt></dl></dd><dt>8. <a href="#transactions">Transactions And Concurrency</a></dt><dd><dl><dt><a href="#transactions-s1">Datastores, Sessions and Factories</a></dt><dt><a href="#transactions-s2">Threads and connections</a></dt><dt><a href="#transactions-s3">Optimistic Locking / Versioning</a></dt><dd><dl><dt><a href="#transactions-s3-1">Long session with automatic versioning</a></dt><dt><a href="#transactions-s3-2">Many sessions with automatic versioning</a></dt><dt><a href="#transactions-s3-3">Application version checking</a></dt></dl></dd><dt><a href="#transactions-s4">Session disconnection</a></dt><dt><a href="#transactions-s5">Pessimistic Locking</a></dt></dl></dd><dt>9. <a href="#examples">Examples</a></dt><dd><dl><dt><a href="#examples-s0">Employer / Employee</a></dt><dt><a href="#examples-s1">Author / Work</a></dt><dt><a href="#examples-s2">Customer / Order / Product</a></dt></dl></dd><dt>10. <a href="#best-practices">Best Practices</a></dt></dl></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="architecture"></a>Chapter 1. Architecture</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#architecture-s1">Overview</a></dt><dt><a href="#architecture-s2">Persistent Object Identity</a></dt><dt><a href="#architecture-s3">JMX Integration</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="architecture-s1"></a>Overview</h2></div></div><p> A (very) high-level view of the Hibernate architecture: [...2251 lines suppressed...] provider. ! </p></dd><dt><span class="term">Understand <tt>Session</tt> flushing.</span></dt><dd><p> From time to time the Session synchronizes its persistent state with the database. Performance will be affected if this process occurs too often. You may sometimes minimize unnecessary flushing by disabling automatic flushing or even by changing the order of queries and other operations within a particular transaction. ! </p></dd><dt><span class="term">In a three tiered architecture, consider using <tt>saveOrUpdate()</tt>.</span></dt><dd><p> When using a servlet / session bean architecture, you could pass persistent objects loaded in the session bean to and from the servlet / JSP layer. Use a new session to service each request. Use <tt>Session.update()</tt> or <tt>Session.saveOrUpdate()</tt> to update the persistent state of an object. ! </p></dd><dt><span class="term">In a two tiered architecture, consider using session disconnection.</span></dt><dd><p> When using a servlet only, you may reuse the same session for multiple client requests. Just remember to disconnect the session before returning control to the client. ! </p></dd><dt><span class="term">Don't treat exceptions as recoverable.</span></dt><dd><p> This is more of a necessary paractice than a "best" practice. When an exception occurs, roll back the <tt>Transaction</tt> and close the <tt>Session</tt>. If you don't, Hibernate can't guarantee that in-memory state accurately represents persistent state ! </p></dd></dl></div></div></div></body></html> \ No newline at end of file |
From: <tu...@us...> - 2002-11-25 21:02:04
|
Update of /cvsroot/hibernate/Hibernate/doc/reference/html In directory sc8-pr-cvs1:/tmp/cvs-serv31818/doc/reference/html Modified Files: adv-or-mapping.html architecture.html best-practices.html examples.html index.html manipulating-data.html or-mapping.html persistent-classes.html query-language.html session-configuration.html transactions.html Log Message: Updated using the new style and scripts Index: adv-or-mapping.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/reference/html/adv-or-mapping.html,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** adv-or-mapping.html 21 Nov 2002 09:03:15 -0000 1.26 --- adv-or-mapping.html 25 Nov 2002 21:01:45 -0000 1.27 *************** *** 1,5 **** <html><head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> ! <title>Chapter 5. Advanced O/R Mapping</title><link rel="stylesheet" href="../style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.52.1"><link rel="home" href="index.html" title="Hibernate Reference Documentation"><link rel="up" href="index.html" title="Hibernate Reference Documentation"><link rel="previous" href="or-mapping.html" title="Chapter 4. Basic O/R Mapping"><link rel="next" href="manipulating-data.html" title="Chapter 6. Manipulating Persistent Data"><link rel="chapter" href="architecture.html" title="Chapter 1. Architecture"><link rel="chapter" href="session-configuration.html" title="Chapter 2. SessionFactory Configuration"><link rel="chapter" href="persistent-classes.html" title="Chapter 3. Persistent Classes"><link rel="chapter" href="or-mapping.html" title="Chapter 4. Basic O/R Mapping"><link rel="chapter" href="adv-or-mapping.html" title="Chapter 5. Advanced O/R Mapping"><link rel="chapter" href="manipulating-data.html" title="Chapter 6. Manipulating Persistent Data"><link rel="chapter" href="query-language.html" title="Chapter 7. Hibernate Query Language"><link rel="chapter" href="transactions.html" title="Chapter 8. Transactions And Concurrency"><link rel="chapter" href="examples.html" title="Chapter 9. Examples"><link rel="chapter" href="best-practices.html" title="Chapter 10. Best Practices"><link rel="section" href="adv-or-mapping.html#adv-or-mapping-s1" title="5.1. Collections"><link rel="section" href="adv-or-mapping.html#adv-or-mapping-s2" title="5.2. Components"><link rel="section" href="adv-or-mapping.html#adv-or-mapping-s3" title="5.3. Cache"><link rel="section" href="adv-or-mapping.html#adv-or-mapping-s4" title="5.4. Proxies for Lazy Initialization"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 5. Advanced O/R Mapping</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="or-mapping.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="manipulating-data.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="adv-or-mapping"></a>Chapter 5. Advanced O/R Mapping</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>5.1. <a href="adv-or-mapping.html#adv-or-mapping-s1">Collections</a></dt><dd><dl><dt>5.1.1. <a href="adv-or-mapping.html#adv-or-mapping-s1-1">Persistent Collection Styles</a></dt><dt>5.1.2. <a href="adv-or-mapping.html#adv-or-mapping-s1-2">Toplevel and Nested Collections</a></dt><dt>5.1.3. <a href="adv-or-mapping.html#adv-or-mapping-s1-3">Mapping a Collection</a></dt><dt>5.1.4. <a href="adv-or-mapping.html#adv-or-mapping-s1-4">Mapping a Property to a Toplevel Collection</a></dt><dt>5.1.5. <a href="adv-or-mapping.html#adv-or-mapping-s1-5">Collections of Values and Many To Many Associations</a></dt><dt>5.1.6. <a href="adv-or-mapping.html#adv-or-mapping-s1-6">One To Many Associations</a></dt><dt>5.1.7. <a href="adv-or-mapping.html#adv-or-mapping-s1-7">Lazy Initialization</a></dt><dt>5.1.8. <a href="adv-or-mapping.html#adv-or-mapping-s1-8">Sorted Collections</a></dt><dt>5.1.9. <a href="adv-or-mapping.html#adv-or-mapping-s1-9">Garbage Collection</a></dt><dt>5.1.10. <a href="adv-or-mapping.html#adv-or-mapping-s1-10">Bidirectional Associations</a></dt><dt>5.1.11. <a href="adv-or-mapping.html#adv-or-mapping-s1-11">Ternary Associations</a></dt><dt>5.1.12. <a href="adv-or-mapping.html#adv-or-mapping-s1-12">Collection Example</a></dt></dl></dd><dt>5.2. <a href="adv-or-mapping.html#adv-or-mapping-s2">Components</a></dt><dd><dl><dt>5.2.1. <a href="adv-or-mapping.html#adv-or-mapping-s2-1">As Dependent Objects</a></dt><dt>5.2.2. <a href="adv-or-mapping.html#adv-or-mapping-s2-2">In Collections</a></dt><dt>5.2.3. <a href="adv-or-mapping.html#adv-or-mapping-s2-2b">As a Map Index</a></dt><dt>5.2.4. <a href="adv-or-mapping.html#adv-or-mapping-s2-3">As Composite Identifiers</a></dt></dl></dd><dt>5.3. <a href="adv-or-mapping.html#adv-or-mapping-s3">Cache</a></dt><dd><dl><dt>5.3.1. <a href="adv-or-mapping.html#adv-or-mapping-s3-1">Mapping</a></dt><dt>5.3.2. <a href="adv-or-mapping.html#adv-or-mapping-s3-2">Read Only Cache</a></dt><dt>5.3.3. <a href="adv-or-mapping.html#adv-or-mapping-s3-3">Read / Write Cache</a></dt></dl></dd><dt>5.4. <a href="adv-or-mapping.html#adv-or-mapping-s4">Proxies for Lazy Initialization</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="adv-or-mapping-s1"></a>5.1. Collections</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>5.1.1. <a href="adv-or-mapping.html#adv-or-mapping-s1-1">Persistent Collection Styles</a></dt><dt>5.1.2. <a href="adv-or-mapping.html#adv-or-mapping-s1-2">Toplevel and Nested Collections</a></dt><dt>5.1.3. <a href="adv-or-mapping.html#adv-or-mapping-s1-3">Mapping a Collection</a></dt><dt>5.1.4. <a href="adv-or-mapping.html#adv-or-mapping-s1-4">Mapping a Property to a Toplevel Collection</a></dt><dt>5.1.5. <a href="adv-or-mapping.html#adv-or-mapping-s1-5">Collections of Values and Many To Many Associations</a></dt><dt>5.1.6. <a href="adv-or-mapping.html#adv-or-mapping-s1-6">One To Many Associations</a></dt><dt>5.1.7. <a href="adv-or-mapping.html#adv-or-mapping-s1-7">Lazy Initialization</a></dt><dt>5.1.8. <a href="adv-or-mapping.html#adv-or-mapping-s1-8">Sorted Collections</a></dt><dt>5.1.9. <a href="adv-or-mapping.html#adv-or-mapping-s1-9">Garbage Collection</a></dt><dt>5.1.10. <a href="adv-or-mapping.html#adv-or-mapping-s1-10">Bidirectional Associations</a></dt><dt>5.1.11. <a href="adv-or-mapping.html#adv-or-mapping-s1-11">Ternary Associations</a></dt><dt>5.1.12. <a href="adv-or-mapping.html#adv-or-mapping-s1-12">Collection Example</a></dt></dl></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-1"></a>5.1.1. Persistent Collection Styles</h3></div></div><p> This section does not contain much example Java code. We assume you already know how to use Java's collections framework. If so, theres not really anything more --- 1,5 ---- <html><head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> ! <title>Chapter 5. Advanced O/R Mapping</title><link rel="stylesheet" href="'../style.css'" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.49"><link rel="home" href="index.html" title="Hibernate Reference Documentation"><link rel="up" href="index.html" title="Hibernate Reference Documentation"><link rel="previous" href="or-mapping.html" title="Chapter 4. Basic O/R Mapping"><link rel="next" href="manipulating-data.html" title="Chapter 6. Manipulating Persistent Data"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 5. Advanced O/R Mapping</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="or-mapping.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="manipulating-data.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="adv-or-mapping"></a>Chapter 5. Advanced O/R Mapping</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="adv-or-mapping.html#adv-or-mapping-s1">Collections</a></dt><dd><dl><dt><a href="adv-or-mapping.html#adv-or-mapping-s1-1">Persistent Collection Styles</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s1-2">Toplevel and Nested Collections</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s1-3">Mapping a Collection</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s1-4">Mapping a Property to a Toplevel Collection</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s1-5">Collections of Values and Many To Many Associations</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s1-6">One To Many Associations</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s1-7">Lazy Initialization</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s1-8">Sorted Collections</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s1-9">Garbage Collection</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s1-10">Bidirectional Associations</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s1-11">Ternary Associations</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s1-12">Collection Example</a></dt></dl></dd><dt><a href="adv-or-mapping.html#adv-or-mapping-s2">Components</a></dt><dd><dl><dt><a href="adv-or-mapping.html#adv-or-mapping-s2-1">As Dependent Objects</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s2-2">In Collections</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s2-2b">As a Map Index</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s2-3">As Composite Identifiers</a></dt></dl></dd><dt><a href="adv-or-mapping.html#adv-or-mapping-s3">Cache</a></dt><dd><dl><dt><a href="adv-or-mapping.html#adv-or-mapping-s3-1">Mapping</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s3-2">Read Only Cache</a></dt><dt><a href="adv-or-mapping.html#adv-or-mapping-s3-3">Read / Write Cache</a></dt></dl></dd><dt><a href="adv-or-mapping.html#adv-or-mapping-s4">Proxies for Lazy Initialization</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="adv-or-mapping-s1"></a>Collections</h2></div></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-1"></a>Persistent Collection Styles</h3></div></div><p> This section does not contain much example Java code. We assume you already know how to use Java's collections framework. If so, theres not really anything more *************** *** 47,51 **** </p><p> Collections may contain any other Hibernate type. All collection types except ! <tt>Set</tt> and bag have an <span class="emphasis"><em>index</em></span> - an array or list index or map key. The index of a <tt>Map</tt> may be of any basic type, an entity type or even a composite type (it may not be a collection). --- 47,51 ---- </p><p> Collections may contain any other Hibernate type. All collection types except ! <tt>Set</tt> and bag have an <span class="emphasis"><i>index</i></span> - an array or list index or map key. The index of a <tt>Map</tt> may be of any basic type, an entity type or even a composite type (it may not be a collection). *************** *** 55,62 **** schema generation tool to get a feeling for how various mapping declarations translate to database tables. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-2"></a>5.1.2. Toplevel and Nested Collections</h3></div></div><p> All collections require an identifier. The identifier is never exposed to the ! application. A <span class="emphasis"><em>nested</em></span> collection is one whose identifier ! is assigned from its containing object. A <span class="emphasis"><em>toplevel</em></span> collection's identifier is generated by a Hibernate ID generator. Toplevel collections require an extra column in the table of the owning class (holding --- 55,62 ---- schema generation tool to get a feeling for how various mapping declarations translate to database tables. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-2"></a>Toplevel and Nested Collections</h3></div></div><p> All collections require an identifier. The identifier is never exposed to the ! application. A <span class="emphasis"><i>nested</i></span> collection is one whose identifier ! is assigned from its containing object. A <span class="emphasis"><i>toplevel</i></span> collection's identifier is generated by a Hibernate ID generator. Toplevel collections require an extra column in the table of the owning class (holding *************** *** 67,71 **** The role name is the name of a property of that class or component and collections of that role may only be referenced by that property. This is intended to be the ! most common use of collections. However, nested collections may <span class="emphasis"><em>not</em></span> be contained in other collections.....Hibernate won't even let you declare such a mapping. Nested collections do not distinguish between a null collection --- 67,71 ---- The role name is the name of a property of that class or component and collections of that role may only be referenced by that property. This is intended to be the ! most common use of collections. However, nested collections may <span class="emphasis"><i>not</i></span> be contained in other collections.....Hibernate won't even let you declare such a mapping. Nested collections do not distinguish between a null collection *************** *** 77,81 **** <tt>native</tt> ID generation). Toplevel collections may be contained in other collections. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-3"></a>5.1.3. Mapping a Collection</h3></div></div><p> Collections are declared by the <tt><set></tt>, --- 77,81 ---- <tt>native</tt> ID generation). Toplevel collections may be contained in other collections. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-3"></a>Mapping a Collection</h3></div></div><p> Collections are declared by the <tt><set></tt>, *************** *** 121,125 **** that define the iteration order of the <tt>Map</tt>, <tt>Set</tt> or bag, together with an optional <tt>asc</tt> or <tt>desc</tt>. ! </p></li></ul></div></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-4"></a>5.1.4. Mapping a Property to a Toplevel Collection</h3></div></div><p> The <tt><collection></tt> and <tt><subcollection></tt> elements map a property to a --- 121,125 ---- that define the iteration order of the <tt>Map</tt>, <tt>Set</tt> or bag, together with an optional <tt>asc</tt> or <tt>desc</tt>. ! </p></li></ul></div></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-4"></a>Mapping a Property to a Toplevel Collection</h3></div></div><p> The <tt><collection></tt> and <tt><subcollection></tt> elements map a property to a *************** *** 145,157 **** Note that enabling cascades for a collection will force operations to cascade all the way down a heirarchy of subcollections to the leaf entity objects. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-5"></a>5.1.5. Collections of Values and Many To Many Associations</h3></div></div><p> Most collection roles require a table of their own. This includes any collection of values and any collection of entities that has the natural semantics for a Java collection. The table requires an identifier column, an element column (or ! column<span class="emphasis"><em>s</em></span> if it is a collection of components) and possibly an index column. </p><p> A collection of entities with its own table corresponds to the relational notion ! of <span class="emphasis"><em>many-to-many association</em></span>. A many to many association is the most natural mapping of a Java collection but is not always the best relational model. </p><p> --- 145,157 ---- Note that enabling cascades for a collection will force operations to cascade all the way down a heirarchy of subcollections to the leaf entity objects. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-5"></a>Collections of Values and Many To Many Associations</h3></div></div><p> Most collection roles require a table of their own. This includes any collection of values and any collection of entities that has the natural semantics for a Java collection. The table requires an identifier column, an element column (or ! column<span class="emphasis"><i>s</i></span> if it is a collection of components) and possibly an index column. </p><p> A collection of entities with its own table corresponds to the relational notion ! of <span class="emphasis"><i>many-to-many association</i></span>. A many to many association is the most natural mapping of a Java collection but is not always the best relational model. </p><p> *************** *** 198,205 **** <property name="serialNumber" column="serial_no" type="string"/> </composite-element> ! </list></pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-6"></a>5.1.6. One To Many Associations</h3></div></div><p> ! A <span class="emphasis"><em>one to many association</em></span> links the tables of two classes ! <span class="emphasis"><em>directly</em></span>, with no intervening collection table. ! (This implements a <span class="emphasis"><em>one-to-many</em></span> relational model.) This model has higher performance but loses some of the semantics of Java collections: --- 198,205 ---- <property name="serialNumber" column="serial_no" type="string"/> </composite-element> ! </list></pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-6"></a>One To Many Associations</h3></div></div><p> ! A <span class="emphasis"><i>one to many association</i></span> links the tables of two classes ! <span class="emphasis"><i>directly</i></span>, with no intervening collection table. ! (This implements a <span class="emphasis"><i>one-to-many</i></span> relational model.) This model has higher performance but loses some of the semantics of Java collections: *************** *** 228,232 **** The <tt>one-to-many</tt> tag does not need to declare any columns. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-7"></a>5.1.7. Lazy Initialization</h3></div></div><p> Collections (other than arrays) may be lazily initialized, meaning they load their state from the database only when the application needs to access it. --- 228,232 ---- The <tt>one-to-many</tt> tag does not need to declare any columns. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-7"></a>Lazy Initialization</h3></div></div><p> Collections (other than arrays) may be lazily initialized, meaning they load their state from the database only when the application needs to access it. *************** *** 259,263 **** <key column="group_id"/> <element column="NAME" type="string"/> ! </set></pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-8"></a>5.1.8. Sorted Collections</h3></div></div><p> Hibernate supports collections implementing <tt>java.util.SortedMap</tt> and --- 259,263 ---- <key column="group_id"/> <element column="NAME" type="string"/> ! </set></pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-8"></a>Sorted Collections</h3></div></div><p> Hibernate supports collections implementing <tt>java.util.SortedMap</tt> and *************** *** 277,281 **** Sorted collections actually behave like <tt>java.util.TreeSet</tt> or <tt>java.util.TreeMap</tt>. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-9"></a>5.1.9. Garbage Collection</h3></div></div><p> Collections are automatically persisted when referenced by a persistent object and automatically deleted when unreferenced. If a collection is passed from one --- 277,281 ---- Sorted collections actually behave like <tt>java.util.TreeSet</tt> or <tt>java.util.TreeMap</tt>. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-9"></a>Garbage Collection</h3></div></div><p> Collections are automatically persisted when referenced by a persistent object and automatically deleted when unreferenced. If a collection is passed from one *************** *** 283,299 **** another. You shouldn't have to worry much about any of this. Just use Hibernate's collections the same way you use ordinary Java collections. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-10"></a>5.1.10. Bidirectional Associations</h3></div></div><p> ! A <span class="emphasis"><em>bidirectional association</em></span> allows navigation from both "ends" of the association. Two kinds of bidirectional association are supported: </p><div class="variablelist"><dl><dt><span class="term">one-to-many</span></dt><dd><p> Set valued at one end, single-valued at the other ! </p></dd><br><dt><span class="term">many-to-many</span></dt><dd><p> Set / bag valued at both ends ! </p></dd><br></dl></div><p> You may specify a bidirectional many-to-many association simply by mapping two nested, many-to-many sets/bags to the same database table and declaring one end as ! <span class="emphasis"><em>readonly</em></span>. Heres an example of a bidirectional many-to-many ! association from a class back to <span class="emphasis"><em>itself</em></span>: </p><pre class="programlisting"><class name="eg.Node"> <id name="id" column="id"/> --- 283,299 ---- another. You shouldn't have to worry much about any of this. Just use Hibernate's collections the same way you use ordinary Java collections. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-10"></a>Bidirectional Associations</h3></div></div><p> ! A <span class="emphasis"><i>bidirectional association</i></span> allows navigation from both "ends" of the association. Two kinds of bidirectional association are supported: </p><div class="variablelist"><dl><dt><span class="term">one-to-many</span></dt><dd><p> Set valued at one end, single-valued at the other ! </p></dd><dt><span class="term">many-to-many</span></dt><dd><p> Set / bag valued at both ends ! </p></dd></dl></div><p> You may specify a bidirectional many-to-many association simply by mapping two nested, many-to-many sets/bags to the same database table and declaring one end as ! <span class="emphasis"><i>readonly</i></span>. Heres an example of a bidirectional many-to-many ! association from a class back to <span class="emphasis"><i>itself</i></span>: </p><pre class="programlisting"><class name="eg.Node"> <id name="id" column="id"/> *************** *** 308,312 **** </bag> </class></pre><p> ! Changes made to the readonly end of the association are <span class="emphasis"><em>not</em></span> persistent. </p><p> --- 308,312 ---- </bag> </class></pre><p> ! Changes made to the readonly end of the association are <span class="emphasis"><i>not</i></span> persistent. </p><p> *************** *** 327,331 **** .... <many-to-one name="parent" class="eg.Parent" column="parent_id"/> ! </class></pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-11"></a>5.1.11. Ternary Associations</h3></div></div><p> There are two possible approaches to mapping a ternary association. One approach is to use composite elements (discussed below). Another is to use a <tt>Map</tt> with an --- 327,331 ---- .... <many-to-one name="parent" class="eg.Parent" column="parent_id"/> ! </class></pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-11"></a>Ternary Associations</h3></div></div><p> There are two possible approaches to mapping a ternary association. One approach is to use composite elements (discussed below). Another is to use a <tt>Map</tt> with an *************** *** 339,343 **** <index-many-to-many column="node2_id" class="Node"/> <many-to-many column="connection_id" class="Connection"/> ! </map></pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-12"></a>5.1.12. Collection Example</h3></div></div><p> The previous sections are pretty confusing. So lets look at an example. This class: --- 339,343 ---- <index-many-to-many column="node2_id" class="Node"/> <many-to-many column="connection_id" class="Connection"/> ! </map></pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-12"></a>Collection Example</h3></div></div><p> The previous sections are pretty confusing. So lets look at an example. This class: *************** *** 439,444 **** create table child ( id bigint not null primary key, name varchar(255) ) create table childset ( id bigint, child_id bigint ) ! alter table childset add constraint childsetfk0 (child_id) references child</pre></div></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="adv-or-mapping-s2"></a>5.2. Components</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>5.2.1. <a href="adv-or-mapping.html#adv-or-mapping-s2-1">As Dependent Objects</a></dt><dt>5.2.2. <a href="adv-or-mapping.html#adv-or-mapping-s2-2">In Collections</a></dt><dt>5.2.3. <a href="adv-or-mapping.html#adv-or-mapping-s2-2b">As a Map Index</a></dt><dt>5.2.4. <a href="adv-or-mapping.html#adv-or-mapping-s2-3">As Composite Identifiers</a></dt></dl></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s2-1"></a>5.2.1. As Dependent Objects</h3></div></div><p> ! A <span class="emphasis"><em>component</em></span> is a contained object persisted to the same table as its owner. The term "component" refers to the object-oriented notion of composition (not to architecture-level components). For example, you might --- 439,444 ---- create table child ( id bigint not null primary key, name varchar(255) ) create table childset ( id bigint, child_id bigint ) ! alter table childset add constraint childsetfk0 (child_id) references child</pre></div></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="adv-or-mapping-s2"></a>Components</h2></div></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s2-1"></a>As Dependent Objects</h3></div></div><p> ! A <span class="emphasis"><i>component</i></span> is a contained object persisted to the same table as its owner. The term "component" refers to the object-oriented notion of composition (not to architecture-level components). For example, you might *************** *** 516,520 **** </p><p> Like all value types, components do not support shared references. The null ! value semantics of a component are <span class="emphasis"><em>ad hoc</em></span>. When reloading the containing object, Hibernate will assume that if all component columns are null, then the entire component is null. This should be okay for most purposes. --- 516,520 ---- </p><p> Like all value types, components do not support shared references. The null ! value semantics of a component are <span class="emphasis"><i>ad hoc</i></span>. When reloading the containing object, Hibernate will assume that if all component columns are null, then the entire component is null. This should be okay for most purposes. *************** *** 522,526 **** The properties of a component may be of any Hibernate type (nested and toplevel collections, many-to-one associations, other components, etc). Nested components ! should <span class="emphasis"><em>not</em></span> be considered an exotic usage. Hibernate is intended to support a very fine-grained object model. </p><p> --- 522,526 ---- The properties of a component may be of any Hibernate type (nested and toplevel collections, many-to-one associations, other components, etc). Nested components ! should <span class="emphasis"><i>not</i></span> be considered an exotic usage. Hibernate is intended to support a very fine-grained object model. </p><p> *************** *** 528,532 **** subelement that maps a property of the component class as a reference back to the containing entity. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s2-2"></a>5.2.2. In Collections</h3></div></div><p> Collections of components are supported (eg. an array of type <tt>Name</tt>). Declare your component collection by --- 528,532 ---- subelement that maps a property of the component class as a reference back to the containing entity. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s2-2"></a>In Collections</h3></div></div><p> Collections of components are supported (eg. an array of type <tt>Name</tt>). Declare your component collection by *************** *** 580,589 **** </composite-element> </set> ! </class></pre><p>Composite element properties may not appear in a query, unfortunately.</p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s2-2b"></a>5.2.3. As a Map Index</h3></div></div><p> The <tt><composite-index></tt> element lets you map a component class as the key of a <tt>Map</tt>. Make sure you override <tt>hashCode()</tt> and <tt>equals()</tt> correctly on the component class. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s2-3"></a>5.2.4. As Composite Identifiers</h3></div></div><p> You may use a component as an identifier of an entity class. Your component class must satisfy certain requirements: --- 580,589 ---- </composite-element> </set> ! </class></pre><p>Composite element properties may not appear in a query, unfortunately.</p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s2-2b"></a>As a Map Index</h3></div></div><p> The <tt><composite-index></tt> element lets you map a component class as the key of a <tt>Map</tt>. Make sure you override <tt>hashCode()</tt> and <tt>equals()</tt> correctly on the component class. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s2-3"></a>As Composite Identifiers</h3></div></div><p> You may use a component as an identifier of an entity class. Your component class must satisfy certain requirements: *************** *** 646,650 **** <element column="foo_date" type="date"/> </set> ! </class></pre></div></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="adv-or-mapping-s3"></a>5.3. Cache</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>5.3.1. <a href="adv-or-mapping.html#adv-or-mapping-s3-1">Mapping</a></dt><dt>5.3.2. <a href="adv-or-mapping.html#adv-or-mapping-s3-2">Read Only Cache</a></dt><dt>5.3.3. <a href="adv-or-mapping.html#adv-or-mapping-s3-3">Read / Write Cache</a></dt></dl></div><p> A Hibernate <tt>Session</tt> is a transaction-level cache of persistent data. It is possible to configure a <tt>SessionFactory</tt>-level cache on a class-by-class --- 646,650 ---- <element column="foo_date" type="date"/> </set> ! </class></pre></div></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="adv-or-mapping-s3"></a>Cache</h2></div></div><p> A Hibernate <tt>Session</tt> is a transaction-level cache of persistent data. It is possible to configure a <tt>SessionFactory</tt>-level cache on a class-by-class *************** *** 656,660 **** exists but is now semi-deprecated. Please see the JCS documentation for information on how to configure data expiry, in-memory caching, disk caching, etc. ! </p><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s3-1"></a>5.3.1. Mapping</h3></div></div><p> The <tt><jcs-cache></tt> element of a class or collection mapping has the following form: --- 656,660 ---- exists but is now semi-deprecated. Please see the JCS documentation for information on how to configure data expiry, in-memory caching, disk caching, etc. ! </p><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s3-1"></a>Mapping</h3></div></div><p> The <tt><jcs-cache></tt> element of a class or collection mapping has the following form: *************** *** 663,667 **** (<tt>read-write</tt>, <tt>read-only</tt>) ! </p></li></ul></div></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s3-2"></a>5.3.2. Read Only Cache</h3></div></div><p> If your application needs to read but never modify instances of a persistent class, a <tt>read-only</tt> cache may be used. This is the only style of cache that --- 663,667 ---- (<tt>read-write</tt>, <tt>read-only</tt>) ! </p></li></ul></div></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s3-2"></a>Read Only Cache</h3></div></div><p> If your application needs to read but never modify instances of a persistent class, a <tt>read-only</tt> cache may be used. This is the only style of cache that *************** *** 671,675 **** .... <jcs-cache usage="read-only"/> ! </class></pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s3-3"></a>5.3.3. Read / Write Cache</h3></div></div><p> If the application occasionally needs to update data, a <tt>read-write</tt> cache might be appropriate. This cache should never be used in a clustered environment --- 671,675 ---- .... <jcs-cache usage="read-only"/> ! </class></pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s3-3"></a>Read / Write Cache</h3></div></div><p> If the application occasionally needs to update data, a <tt>read-write</tt> cache might be appropriate. This cache should never be used in a clustered environment *************** *** 687,691 **** .... </set> ! </class></pre></div></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="adv-or-mapping-s4"></a>5.4. Proxies for Lazy Initialization</h2></div></div><p> Hibernate implements lazy initializing proxies for persistent objects using runtime bytecode enhancement. --- 687,691 ---- .... </set> ! </class></pre></div></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="adv-or-mapping-s4"></a>Proxies for Lazy Initialization</h2></div></div><p> Hibernate implements lazy initializing proxies for persistent objects using runtime bytecode enhancement. *************** *** 745,749 **** type <tt>ICat</tt>, not <tt>Cat</tt>. </p><p> ! Certain operations do <span class="emphasis"><em>not</em></span> require proxy initialization </p><div class="itemizedlist"><ul type="disc"><li><p> <tt>equals()</tt>, if the persistent class does not override --- 745,749 ---- type <tt>ICat</tt>, not <tt>Cat</tt>. </p><p> ! Certain operations do <span class="emphasis"><i>not</i></span> require proxy initialization </p><div class="itemizedlist"><ul type="disc"><li><p> <tt>equals()</tt>, if the persistent class does not override *************** *** 763,765 **** Exceptions that occur while initializing a proxy are wrapped in a <tt>LazyInitializationException</tt>. ! </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="or-mapping.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="manipulating-data.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 4. Basic O/R Mapping </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 6. Manipulating Persistent Data</td></tr></table></div></body></html> \ No newline at end of file --- 763,765 ---- Exceptions that occur while initializing a proxy are wrapped in a <tt>LazyInitializationException</tt>. ! </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="or-mapping.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="manipulating-data.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 4. Basic O/R Mapping </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 6. Manipulating Persistent Data</td></tr></table></div></body></html> \ No newline at end of file Index: architecture.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/reference/html/architecture.html,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** architecture.html 27 Oct 2002 11:48:37 -0000 1.9 --- architecture.html 25 Nov 2002 21:01:46 -0000 1.10 *************** *** 1,5 **** <html><head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> ! <title>Chapter 1. Architecture</title><link rel="stylesheet" href="../style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.52.1"><link rel="home" href="index.html" title="Hibernate Reference Documentation"><link rel="up" href="index.html" title="Hibernate Reference Documentation"><link rel="previous" href="index.html" title="Hibernate Reference Documentation"><link rel="next" href="session-configuration.html" title="Chapter 2. SessionFactory Configuration"><link rel="chapter" href="architecture.html" title="Chapter 1. Architecture"><link rel="chapter" href="session-configuration.html" title="Chapter 2. SessionFactory Configuration"><link rel="chapter" href="persistent-classes.html" title="Chapter 3. Persistent Classes"><link rel="chapter" href="or-mapping.html" title="Chapter 4. Basic O/R Mapping"><link rel="chapter" href="adv-or-mapping.html" title="Chapter 5. Advanced O/R Mapping"><link rel="chapter" href="manipulating-data.html" title="Chapter 6. Manipulating Persistent Data"><link rel="chapter" href="query-language.html" title="Chapter 7. Hibernate Query Language"><link rel="chapter" href="transactions.html" title="Chapter 8. Transactions And Concurrency"><link rel="chapter" href="examples.html" title="Chapter 9. Examples"><link rel="chapter" href="best-practices.html" title="Chapter 10. Best Practices"><link rel="section" href="architecture.html#architecture-s1" title="1.1. Overview"><link rel="section" href="architecture.html#architecture-s2" title="1.2. Persistent Object Identity"><link rel="section" href="architecture.html#architecture-s3" title="1.3. JMX Integration"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 1. Architecture</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="index.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="session-configuration.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="architecture"></a>Chapter 1. Architecture</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>1.1. <a href="architecture.html#architecture-s1">Overview</a></dt><dt>1.2. <a href="architecture.html#architecture-s2">Persistent Object Identity</a></dt><dt>1.3. <a href="architecture.html#architecture-s3">JMX Integration</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="architecture-s1"></a>1.1. Overview</h2></div></div><p> A (very) high-level view of the Hibernate architecture: </p><div class="mediaobject"><img src="../images/overview.gif" align="center"></div><p> --- 1,5 ---- <html><head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> ! <title>Chapter 1. Architecture</title><link rel="stylesheet" href="'../style.css'" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.49"><link rel="home" href="index.html" title="Hibernate Reference Documentation"><link rel="up" href="index.html" title="Hibernate Reference Documentation"><link rel="previous" href="index.html" title="Hibernate Reference Documentation"><link rel="next" href="session-configuration.html" title="Chapter 2. SessionFactory Configuration"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 1. Architecture</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="index.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="session-configuration.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="architecture"></a>Chapter 1. Architecture</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="architecture.html#architecture-s1">Overview</a></dt><dt><a href="architecture.html#architecture-s2">Persistent Object Identity</a></dt><dt><a href="architecture.html#architecture-s3">JMX Integration</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="architecture-s1"></a>Overview</h2></div></div><p> A (very) high-level view of the Hibernate architecture: </p><div class="mediaobject"><img src="../images/overview.gif" align="center"></div><p> *************** *** 34,69 **** A threadsafe (immutable) cache of compiled mappings. A factory for <tt>Session</tt>. A client of <tt>ConnectionProvider</tt>. ! </p></dd><br><dt><span class="term">Session</span></dt><dd><p> A single-threaded, short-lived object representing a conversation between the application and the persistent store. Wraps a JDBC connection. Factory for <tt>Transaction</tt>. Manages persistent objects to the application. ! </p></dd><br><dt><span class="term">Persistent Objects and Collections</span></dt><dd><p> Short-lived, single threaded objects containing persistent state and business function. These might be ordinary JavaBeans, the only special thing about them is that they are currently associated with (exactly one) <tt>Session</tt>. ! </p></dd><br><dt><span class="term">Transient Objects and Collections</span></dt><dd><p> Instances of persistent classes that are not currently associated with a <tt>Session</tt>. They may have been instantiated by the application and not (yet) persisted or they may have been instantiated by a closed <tt>Session</tt>. ! </p></dd><br><dt><span class="term">Transaction</span></dt><dd><p> ( Optional ) A single-threaded, short-lived object used by the application to specify atomic units of work. Abstracts application from underlying JDBC, JTA or CORBA transaction. A <tt>Session</tt> might span several <tt>Transaction</tt>s. ! </p></dd><br><dt><span class="term">ConnectionProvider</span></dt><dd><p> ( Optional ) A factory for JDBC connections. Abstracts application from underlying <tt>Datasource</tt> or <tt>DriverManager</tt>. Not exposed to application. ! </p></dd><br><dt><span class="term">TransactionFactory</span></dt><dd><p> ( Optional ) A factory for <tt>Transaction</tt>. Not exposed to the application. ! </p></dd><br></dl></div><p> Given a "lite" architecture, the application bypasses the <tt>Transaction</tt> / <tt>TransactionFactory</tt> and / or <tt>ConnectionProvider</tt> APIs to talk to JTA or JDBC directly. ! </p></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="architecture-s2"></a>1.2. Persistent Object Identity</h2></div></div><p> The application may concurrently access the same persistent state in two different sessions. However, an instance of a persistent class is never shared --- 34,69 ---- A threadsafe (immutable) cache of compiled mappings. A factory for <tt>Session</tt>. A client of <tt>ConnectionProvider</tt>. ! </p></dd><dt><span class="term">Session</span></dt><dd><p> A single-threaded, short-lived object representing a conversation between the application and the persistent store. Wraps a JDBC connection. Factory for <tt>Transaction</tt>. Manages persistent objects to the application. ! </p></dd><dt><span class="term">Persistent Objects and Collections</span></dt><dd><p> Short-lived, single threaded objects containing persistent state and business function. These might be ordinary JavaBeans, the only special thing about them is that they are currently associated with (exactly one) <tt>Session</tt>. ! </p></dd><dt><span class="term">Transient Objects and Collections</span></dt><dd><p> Instances of persistent classes that are not currently associated with a <tt>Session</tt>. They may have been instantiated by the application and not (yet) persisted or they may have been instantiated by a closed <tt>Session</tt>. ! </p></dd><dt><span class="term">Transaction</span></dt><dd><p> ( Optional ) A single-threaded, short-lived object used by the application to specify atomic units of work. Abstracts application from underlying JDBC, JTA or CORBA transaction. A <tt>Session</tt> might span several <tt>Transaction</tt>s. ! </p></dd><dt><span class="term">ConnectionProvider</span></dt><dd><p> ( Optional ) A factory for JDBC connections. Abstracts application from underlying <tt>Datasource</tt> or <tt>DriverManager</tt>. Not exposed to application. ! </p></dd><dt><span class="term">TransactionFactory</span></dt><dd><p> ( Optional ) A factory for <tt>Transaction</tt>. Not exposed to the application. ! </p></dd></dl></div><p> Given a "lite" architecture, the application bypasses the <tt>Transaction</tt> / <tt>TransactionFactory</tt> and / or <tt>ConnectionProvider</tt> APIs to talk to JTA or JDBC directly. ! </p></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="architecture-s2"></a>Persistent Object Identity</h2></div></div><p> The application may concurrently access the same persistent state in two different sessions. However, an instance of a persistent class is never shared *************** *** 75,79 **** <tt>foo==bar</tt> </td></tr></table><p> ! Then for objects returned by a <span class="emphasis"><em>particular</em></span> <tt>Session</tt>, the two notions are equivalent. However, while the application might concurrently access the "same" (persistent identity) business object in two different sessions, the two --- 75,79 ---- <tt>foo==bar</tt> </td></tr></table><p> ! Then for objects returned by a <span class="emphasis"><i>particular</i></span> <tt>Session</tt>, the two notions are equivalent. However, while the application might concurrently access the "same" (persistent identity) business object in two different sessions, the two *************** *** 84,90 **** single thread per <tt>Session</tt>) or object identity (within a session the application may safely use <tt>==</tt> to compare objects). ! </p></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="architecture-s3"></a>1.3. JMX Integration</h2></div></div><p> JMX is the J2EE standard for management of Java components. Hibernate may be managed via a JMX standard MBean but because most application servers do not yet support JMX, Hibernate also affords some non-standard configuration mechanisms. ! </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="index.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="session-configuration.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Hibernate Reference Documentation </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 2. SessionFactory Configuration</td></tr></table></div></body></html> \ No newline at end of file --- 84,90 ---- single thread per <tt>Session</tt>) or object identity (within a session the application may safely use <tt>==</tt> to compare objects). ! </p></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="architecture-s3"></a>JMX Integration</h2></div></div><p> JMX is the J2EE standard for management of Java components. Hibernate may be managed via a JMX standard MBean but because most application servers do not yet support JMX, Hibernate also affords some non-standard configuration mechanisms. ! </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="index.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="session-configuration.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Hibernate Reference Documentation </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 2. SessionFactory Configuration</td></tr></table></div></body></html> \ No newline at end of file Index: best-practices.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/reference/html/best-practices.html,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** best-practices.html 27 Oct 2002 11:48:37 -0000 1.7 --- best-practices.html 25 Nov 2002 21:01:47 -0000 1.8 *************** *** 1,32 **** <html><head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> ! <title>Chapter 10. Best Practices</title><link rel="stylesheet" href="../style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.52.1"><link rel="home" href="index.html" title="Hibernate Reference Documentation"><link rel="up" href="index.html" title="Hibernate Reference Documentation"><link rel="previous" href="examples.html" title="Chapter 9. Examples"><link rel="chapter" href="architecture.html" title="Chapter 1. Architecture"><link rel="chapter" href="session-configuration.html" title="Chapter 2. SessionFactory Configuration"><link rel="chapter" href="persistent-classes.html" title="Chapter 3. Persistent Classes"><link rel="chapter" href="or-mapping.html" title="Chapter 4. Basic O/R Mapping"><link rel="chapter" href="adv-or-mapping.html" title="Chapter 5. Advanced O/R Mapping"><link rel="chapter" href="manipulating-data.html" title="Chapter 6. Manipulating Persistent Data"><link rel="chapter" href="query-language.html" title="Chapter 7. Hibernate Query Language"><link rel="chapter" href="transactions.html" title="Chapter 8. Transactions And Concurrency"><link rel="chapter" href="examples.html" title="Chapter 9. Examples"><link rel="chapter" href="best-practices.html" title="Chapter 10. Best Practices"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 10. Best Practices</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="examples.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> </td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="best-practices"></a>Chapter 10. Best Practices</h2></div></div><div class="variablelist"><dl><dt><span class="term">Write fine-grained classes and map them using <tt><component></tt> or <tt>&l... [truncated message content] |
From: <tu...@us...> - 2002-11-25 20:57:38
|
Update of /cvsroot/hibernate/Hibernate/doc/reference/pdf In directory sc8-pr-cvs1:/tmp/cvs-serv29431/doc/reference/pdf Modified Files: hibernate_reference.pdf Log Message: Updated to current (using the new scripts and styles) Index: hibernate_reference.pdf =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/reference/pdf/hibernate_reference.pdf,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 Binary files /tmp/cvsgueUpF and /tmp/cvsTdOBP2 differ |