From: <one...@us...> - 2002-11-07 16:24:43
|
Update of /cvsroot/hibernate/Hibernate/doc In directory usw-pr-cvs1:/tmp/cvs-serv26764 Modified Files: faq.aft faq.aft-TOC faq.html Log Message: new faqs Index: faq.aft =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/faq.aft,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** faq.aft 30 Oct 2002 15:28:04 -0000 1.26 --- faq.aft 7 Nov 2002 16:24:07 -0000 1.27 *************** *** 55,58 **** --- 55,96 ---- It doesn't. + *** I'm using a composite identifier and Hibernate causes a stack overfow! + + You _must_ override |equals()| and |hashCode()| correctly on your composite identifier class. This is quite critical. + + *** I'm seeing some strange behaviour with an embedded composite identifier or <key-many-to-one> when using proxies. + + It is actually surprisingly hard to get your implementation of |equals()| right when proxies are enabled. You must be prepared for the possibility that that a class instance is really a proxy for that class, so you can't access instance variables directly (use the accessors). + + And if you are using |<key-many-to-one>| you should compare entity equality by comparing identifiers instead of using |==|. + + *** My class has two one-to-many associations to different subclasses of the same root class, but Hibernate ignores the actual concrete class when loading the associations. + + This kind of mapping is unsupported: + + <class name="BalanceSheet"> + .... + <set role="purchases"> + <key ....> + <one-to-many class="Purchase" column="bsid"/> + </set> + <set role="sales"> + <key ....> + <one-to-many class="Sale" column="bsid"/> + </set> + </class> + + <class name="Transaction"> + .... + <subclass name="Purchase".../> + <subclass name="Sale".../> + </class> + + You must either + + 1. map each association to a different column of the |Transaction| table + 2. map a single association and use a collection filter to retrieve instances of a particular subclass + 3. use a table-per-concrete-class mapping strategy for the |Transaction| hierarchy + *** How can I count the number of query results without actually returning them? *************** *** 85,92 **** you will find it quite well documented. - - *** How can I use quoted SQL identifiers? - - You can't. Sorry. We will fix this at some stage.... *** What column should I map the index tag of an array or List to? --- 123,126 ---- Index: faq.aft-TOC =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/faq.aft-TOC,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** faq.aft-TOC 30 Oct 2002 15:28:05 -0000 1.17 --- faq.aft-TOC 7 Nov 2002 16:24:07 -0000 1.18 *************** *** 9,12 **** --- 9,15 ---- * {-Hibernate keeps deleting and recreating my collection!@Hibernate keeps deleting and recreating my collection!-} * {-How does readonly="true" affect the semantics of cascade="all"@How does readonly="true" affect the semantics of cascade="all"-} + * {-I'm using a composite identifier and Hibernate causes a stack overfow!@I'm using a composite identifier and Hibernate causes a stack overfow!-} + * {-I'm seeing some strange behaviour with an embedded composite identifier or <key-many-to-one> when using proxies.@I'm seeing some strange behaviour with an embedded composite identifier or <key-many-to-one> when using proxies.-} + * {-My class has two one-to-many associations to different subclasses of the same root class, but Hibernate ignores the actual concrete class when loading the associations.@My class has two one-to-many associations to different subclasses of the same root class, but Hibernate ignores the actual concrete class when loading the associations.-} * {-How can I count the number of query results without actually returning them?@How can I count the number of query results without actually returning them?-} * {-How can I find the size of a collection without initializing it?@How can I find the size of a collection without initializing it?-} *************** *** 14,18 **** * {-Are collections pageable?@Are collections pageable?-} * {-How do I specify the length of a column for the SchemExport tool? A unique column? A not-null column?@How do I specify the length of a column for the SchemExport tool? A unique column? A not-null column?-} - * {-How can I use quoted SQL identifiers?@How can I use quoted SQL identifiers?-} * {-What column should I map the index tag of an array or List to?@What column should I map the index tag of an array or List to?-} * {-What are bags for?@What are bags for?-} --- 17,20 ---- Index: faq.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/faq.html,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** faq.html 5 Nov 2002 08:04:00 -0000 1.39 --- faq.html 7 Nov 2002 16:24:08 -0000 1.40 *************** *** 30,33 **** --- 30,36 ---- <li> <a href="#Hibernate keeps deleting and recreating my collection!">Hibernate keeps deleting and recreating my collection!</a></li> <li> <a href="#How does readonly="true" affect the semantics of cascade="all"">How does readonly="true" affect the semantics of cascade="all"</a></li> + <li> <a href="#I'm using a composite identifier and Hibernate causes a stack overfow!">I'm using a composite identifier and Hibernate causes a stack overfow!</a></li> + <li> <a href="#I'm seeing some strange behaviour with an embedded composite identifier or <key-many-to-one> when using proxies.">I'm seeing some strange behaviour with an embedded composite identifier or <key-many-to-one> when using proxies.</a></li> + <li> <a href="#My class has two one-to-many associations to different subclasses of the same root class, but Hibernate ignores the actual concrete class when loading the associations.">My class has two one-to-many associations to different subclasses of the same root class, but Hibernate ignores the actual concrete class when loading the associations.</a></li> <li> <a href="#How can I count the number of query results without actually returning them?">How can I count the number of query results without actually returning them?</a></li> <li> <a href="#How can I find the size of a collection without initializing it?">How can I find the size of a collection without initializing it?</a></li> *************** *** 35,39 **** <li> <a href="#Are collections pageable?">Are collections pageable?</a></li> <li> <a href="#How do I specify the length of a column for the SchemExport tool? A unique column? A not-null column?">How do I specify the length of a column for the SchemExport tool? A unique column? A not-null column?</a></li> - <li> <a href="#How can I use quoted SQL identifiers?">How can I use quoted SQL identifiers?</a></li> <li> <a href="#What column should I map the index tag of an array or List to?">What column should I map the index tag of an array or List to?</a></li> <li> <a href="#What are bags for?">What are bags for?</a></li> --- 38,41 ---- *************** *** 126,129 **** --- 128,177 ---- </p> <!--End Section 3--> + <h4><a name="I'm using a composite identifier and Hibernate causes a stack overfow!">I'm using a composite identifier and Hibernate causes a stack overfow!</a></h4> + <p class="Body"> + You <strong>must</strong> override <tt>equals()</tt> and <tt>hashCode()</tt> correctly on your composite identifier class. This is quite critical. + </p> + <!--End Section 3--> + <h4><a name="I'm seeing some strange behaviour with an embedded composite identifier or <key-many-to-one> when using proxies.">I'm seeing some strange behaviour with an embedded composite identifier or <key-many-to-one> when using proxies.</a></h4> + <p class="Body"> + It is actually surprisingly hard to get your implementation of <tt>equals()</tt> right when proxies are enabled. You must be prepared for the possibility that that a class instance is really a proxy for that class, so you can't access instance variables directly (use the accessors). + </p> + <p class="Body"> + And if you are using <tt><key-many-to-one></tt> you should compare entity equality by comparing identifiers instead of using <tt>==</tt>. + </p> + <!--End Section 3--> + <h4><a name="My class has two one-to-many associations to different subclasses of the same root class, but Hibernate ignores the actual concrete class when loading the associations.">My class has two one-to-many associations to different subclasses of the same root class, but Hibernate ignores the actual concrete class when loading the associations.</a></h4> + <p class="Body"> + This kind of mapping is unsupported: + </p> + <pre> + <class name="BalanceSheet"> + .... + <set role="purchases"> + <key ....> + <one-to-many class="Purchase" column="bsid"/> + </set> + <set role="sales"> + <key ....> + <one-to-many class="Sale" column="bsid"/> + </set> + </class> + </pre> + <pre> + <class name="Transaction"> + .... + <subclass name="Purchase".../> + <subclass name="Sale".../> + </class> + </pre> + <p class="Body"> + You must either + </p> + <ol> + <li> map each association to a different column of the <tt>Transaction</tt> table</li> + <li> map a single association and use a collection filter to retrieve instances of a particular subclass</li> + <li> use a table-per-concrete-class mapping strategy for the <tt>Transaction</tt> hierarchy</li> + </ol> + <!--End Section 3--> <h4><a name="How can I count the number of query results without actually returning them?">How can I count the number of query results without actually returning them?</a></h4> <pre> *************** *** 163,171 **** <p class="Body"> you will find it quite well documented. - </p> - <!--End Section 3--> - <h4><a name="How can I use quoted SQL identifiers?">How can I use quoted SQL identifiers?</a></h4> - <p class="Body"> - You can't. Sorry. We will fix this at some stage.... </p> <!--End Section 3--> --- 211,214 ---- |