<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Hibernate: Use a Base Class to Map Common Fields</title> <atom:link href="http://ocpsoft.com/java/hibernate-use-a-base-class-to-map-common-fields/feed/" rel="self" type="application/rss+xml" /><link>http://ocpsoft.com/java/hibernate-use-a-base-class-to-map-common-fields/</link> <description>&#34;Simple Software&#34;</description> <lastBuildDate>Wed, 10 Mar 2010 15:23:38 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>By: Derek</title><link>http://ocpsoft.com/java/hibernate-use-a-base-class-to-map-common-fields/comment-page-1/#comment-216</link> <dc:creator>Derek</dc:creator> <pubDate>Thu, 26 Feb 2009 23:29:54 +0000</pubDate> <guid
isPermaLink="false">http://ocpsoft.com/?p=8#comment-216</guid> <description>I know recently Lincoln used Spring&#039;s interceptor to do something similiar with created on date.  I&#039;ll make sure he speaks to that since I don&#039;t have many of the details.But do you have to have the date set at insert compared to setting it using Java. i.e. bean.setCreatedOn(new Date());?</description> <content:encoded><![CDATA[<p>I know recently Lincoln used Spring&#8217;s interceptor to do something similiar with created on date.  I&#8217;ll make sure he speaks to that since I don&#8217;t have many of the details.</p><p>But do you have to have the date set at insert compared to setting it using Java. i.e. bean.setCreatedOn(new Date());?</p> ]]></content:encoded> </item> <item><title>By: Josh</title><link>http://ocpsoft.com/java/hibernate-use-a-base-class-to-map-common-fields/comment-page-1/#comment-215</link> <dc:creator>Josh</dc:creator> <pubDate>Thu, 26 Feb 2009 22:38:02 +0000</pubDate> <guid
isPermaLink="false">http://ocpsoft.com/?p=8#comment-215</guid> <description>I&#039;m trying to find an answer to this problem. I want to do what you are doing in the code by having a Version and Timestamp of any updates to the object, however, we want to use xml mappings. This seems to be limited by the DTD which forces the xml mappings to have either a Version OR a Timestamp but not both.On a side note (seems like as good a place as any to ask this question). I also want a Timestamp for the creation date. The column this is bound is described like the following:But for this to work. I need to assign the current date upon execution of Insert on this object. Any suggestions? Thanks.</description> <content:encoded><![CDATA[<p>I&#8217;m trying to find an answer to this problem. I want to do what you are doing in the code by having a Version and Timestamp of any updates to the object, however, we want to use xml mappings. This seems to be limited by the DTD which forces the xml mappings to have either a Version OR a Timestamp but not both.</p><p>On a side note (seems like as good a place as any to ask this question). I also want a Timestamp for the creation date. The column this is bound is described like the following:</p><p>But for this to work. I need to assign the current date upon execution of Insert on this object. Any suggestions? Thanks.</p> ]]></content:encoded> </item> <item><title>By: Florent</title><link>http://ocpsoft.com/java/hibernate-use-a-base-class-to-map-common-fields/comment-page-1/#comment-119</link> <dc:creator>Florent</dc:creator> <pubDate>Wed, 19 Nov 2008 16:02:22 +0000</pubDate> <guid
isPermaLink="false">http://ocpsoft.com/?p=8#comment-119</guid> <description>I also use a superclass to map commons fields between all my persistent objects. It seemed to work well until I faced the problem to change inheritance mapping strategy (table per concrete class, table per class hierarchy, table per subclass...) for a part of the hierarchy. The problem is that it seems to be impossible to mix inheritance strategies inside the same hierarchy. Since all objects are members of the same hierarchy it is impossible to change the strategy without changing all strategies.
Does anybody encountered this kind of problem?</description> <content:encoded><![CDATA[<p>I also use a superclass to map commons fields between all my persistent objects. It seemed to work well until I faced the problem to change inheritance mapping strategy (table per concrete class, table per class hierarchy, table per subclass&#8230;) for a part of the hierarchy. The problem is that it seems to be impossible to mix inheritance strategies inside the same hierarchy. Since all objects are members of the same hierarchy it is impossible to change the strategy without changing all strategies.<br
/> Does anybody encountered this kind of problem?</p> ]]></content:encoded> </item> <item><title>By: Lincoln</title><link>http://ocpsoft.com/java/hibernate-use-a-base-class-to-map-common-fields/comment-page-1/#comment-54</link> <dc:creator>Lincoln</dc:creator> <pubDate>Sun, 12 Oct 2008 13:54:30 +0000</pubDate> <guid
isPermaLink="false">http://ocpsoft.com/?p=8#comment-54</guid> <description>I&#039;m not sure you can completely remove a mapped field because that would seem to go against inheritance rules (See Liskov Substitution Principle&quot; but I do think there&#039;s something that may help. Try the @ AnnotationOverride property. This might help you convert that field into something at least more useful... It will still be there though...Search for @ AttributeOverride</description> <content:encoded><![CDATA[<p>I&#8217;m not sure you can completely remove a mapped field because that would seem to go against inheritance rules (See Liskov Substitution Principle&#8221; but I do think there&#8217;s something that may help. Try the @ AnnotationOverride property. This might help you convert that field into something at least more useful&#8230; It will still be there though&#8230;</p><p>Search for @ AttributeOverride</p> ]]></content:encoded> </item> <item><title>By: neodarko</title><link>http://ocpsoft.com/java/hibernate-use-a-base-class-to-map-common-fields/comment-page-1/#comment-53</link> <dc:creator>neodarko</dc:creator> <pubDate>Sun, 12 Oct 2008 13:25:18 +0000</pubDate> <guid
isPermaLink="false">http://ocpsoft.com/?p=8#comment-53</guid> <description>Hi,Suppose I have a status field in the superclass. And I have annotated it properly because I need the field to be persistent.Now, in one of the the subclasses I feel that I would rather have that property as a Transient field - so I override the getters/setters and annotate it with @Transient.The rest of the scenario is just as you have described.Will this work ? I haven&#039;t been able to do so. Am I missing something here ? Shouldn&#039;t hibernate honor the annotation on the subclass-getter-method ?</description> <content:encoded><![CDATA[<p>Hi,</p><p>Suppose I have a status field in the superclass. And I have annotated it properly because I need the field to be persistent.</p><p>Now, in one of the the subclasses I feel that I would rather have that property as a Transient field &#8211; so I override the getters/setters and annotate it with @Transient.</p><p>The rest of the scenario is just as you have described.</p><p>Will this work ? I haven&#8217;t been able to do so. Am I missing something here ? Shouldn&#8217;t hibernate honor the annotation on the subclass-getter-method ?</p> ]]></content:encoded> </item> <item><title>By: Lincoln</title><link>http://ocpsoft.com/java/hibernate-use-a-base-class-to-map-common-fields/comment-page-1/#comment-30</link> <dc:creator>Lincoln</dc:creator> <pubDate>Fri, 22 Aug 2008 12:43:54 +0000</pubDate> <guid
isPermaLink="false">http://ocpsoft.com/?p=8#comment-30</guid> <description>Hey, how does the equals method look now?</description> <content:encoded><![CDATA[<p>Hey, how does the equals method look now?</p> ]]></content:encoded> </item> <item><title>By: cherouvim</title><link>http://ocpsoft.com/java/hibernate-use-a-base-class-to-map-common-fields/comment-page-1/#comment-26</link> <dc:creator>cherouvim</dc:creator> <pubDate>Tue, 19 Aug 2008 16:28:25 +0000</pubDate> <guid
isPermaLink="false">http://ocpsoft.com/?p=8#comment-26</guid> <description>The problem with using id for hashcode/equals means that as soon as the pojo gets an id, then it&#039;s a different pojo.Also, if you use the version for this, the above will keep happening whenever you change anything on the pojo. You&#039;ll not be able to merge() it as well.Have a look at: http://www.hibernate.org/hib_docs/reference/en/html/transactions.html#transactions-basics-identity
11.1.3. Considering object identity
&quot;Never use the database identifier to implement equality, use a business key, a combination of unique, usually immutable, attributes. The database identifier will change if a transient object is made persistent. If the transient instance (usually together with detached instances) is held in a Set, changing the hashcode breaks the contract of the Set. Attributes for business keys don&#039;t have to be as stable as database primary keys, you only have to guarantee stability as long as the objects are in the same Set.&quot;</description> <content:encoded><![CDATA[<p>The problem with using id for hashcode/equals means that as soon as the pojo gets an id, then it&#8217;s a different pojo.</p><p>Also, if you use the version for this, the above will keep happening whenever you change anything on the pojo. You&#8217;ll not be able to merge() it as well.</p><p>Have a look at: <a
href="http://www.hibernate.org/hib_docs/reference/en/html/transactions.html#transactions-basics-identity" rel="nofollow">http://www.hibernate.org/hib_docs/reference/en/html/transactions.html#transactions-basics-identity</a><br
/> 11.1.3. Considering object identity<br
/> &#8220;Never use the database identifier to implement equality, use a business key, a combination of unique, usually immutable, attributes. The database identifier will change if a transient object is made persistent. If the transient instance (usually together with detached instances) is held in a Set, changing the hashcode breaks the contract of the Set. Attributes for business keys don&#8217;t have to be as stable as database primary keys, you only have to guarantee stability as long as the objects are in the same Set.&#8221;</p> ]]></content:encoded> </item> <item><title>By: Lincoln</title><link>http://ocpsoft.com/java/hibernate-use-a-base-class-to-map-common-fields/comment-page-1/#comment-24</link> <dc:creator>Lincoln</dc:creator> <pubDate>Tue, 19 Aug 2008 03:31:12 +0000</pubDate> <guid
isPermaLink="false">http://ocpsoft.com/?p=8#comment-24</guid> <description>cherouvim &gt;&gt; I&#039;m wondering... I don’t believe they are broken for the purposes of this example, but they will definitely need to be overridden for any class with a business key that is not the ‘id’ primary key. What do you think?ashish &gt;&gt; I&#039;ll try to get back to you on that, but I am pretty sure it is possible to override superclass annotations.</description> <content:encoded><![CDATA[<p>cherouvim >> I&#8217;m wondering&#8230; I don’t believe they are broken for the purposes of this example, but they will definitely need to be overridden for any class with a business key that is not the ‘id’ primary key. What do you think?</p><p>ashish >> I&#8217;ll try to get back to you on that, but I am pretty sure it is possible to override superclass annotations.</p> ]]></content:encoded> </item> <item><title>By: ashish</title><link>http://ocpsoft.com/java/hibernate-use-a-base-class-to-map-common-fields/comment-page-1/#comment-22</link> <dc:creator>ashish</dc:creator> <pubDate>Mon, 18 Aug 2008 21:16:36 +0000</pubDate> <guid
isPermaLink="false">http://ocpsoft.com/?p=8#comment-22</guid> <description>I also tried using super class for annotations based hibernate POJOs. First problem i faced is that, if your child class uses different kind of primary key or that class is join class. How you can override your annotations defined in base class? I guess not</description> <content:encoded><![CDATA[<p>I also tried using super class for annotations based hibernate POJOs. First problem i faced is that, if your child class uses different kind of primary key or that class is join class. How you can override your annotations defined in base class? I guess not</p> ]]></content:encoded> </item> <item><title>By: James</title><link>http://ocpsoft.com/java/hibernate-use-a-base-class-to-map-common-fields/comment-page-1/#comment-21</link> <dc:creator>James</dc:creator> <pubDate>Mon, 18 Aug 2008 11:41:37 +0000</pubDate> <guid
isPermaLink="false">http://ocpsoft.com/?p=8#comment-21</guid> <description>I would favor composition over inheritance for this problem.Also, for auditing, pl/sql is sometimes a better way of handling it if there are &gt;1 data access path to the tables. pl/sql can still be used to get the user id with connection pooling.Also, I don&#039;t think your hash/equals are going to work very well in particular circumstances. If you disconnect and reconnect objects, or you have multiple new objects in a collection (set) without id&#039;s.</description> <content:encoded><![CDATA[<p>I would favor composition over inheritance for this problem.</p><p>Also, for auditing, pl/sql is sometimes a better way of handling it if there are &gt;1 data access path to the tables. pl/sql can still be used to get the user id with connection pooling.</p><p>Also, I don&#8217;t think your hash/equals are going to work very well in particular circumstances. If you disconnect and reconnect objects, or you have multiple new objects in a collection (set) without id&#8217;s.</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Served from: apache2-blow.brewers.dreamhost.com @ 2010-03-13 14:02:40 by W3 Total Cache -->