<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://luminoussheep.net/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Persistence_Strategies</id>
	<title>Persistence Strategies - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://luminoussheep.net/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Persistence_Strategies"/>
	<link rel="alternate" type="text/html" href="https://luminoussheep.net/mediawiki/index.php?title=Persistence_Strategies&amp;action=history"/>
	<updated>2026-04-16T19:04:20Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://luminoussheep.net/mediawiki/index.php?title=Persistence_Strategies&amp;diff=61&amp;oldid=prev</id>
		<title>Martin: Created page with &quot;= Inheritance and persistence =  == Single Table == &#039;&#039;&#039;Default mechanism in EJB3 &#039;&#039;&#039; * Objects discriminated by extra column in table  ** specify mechanism: @Inheritance(Strat...&quot;</title>
		<link rel="alternate" type="text/html" href="https://luminoussheep.net/mediawiki/index.php?title=Persistence_Strategies&amp;diff=61&amp;oldid=prev"/>
		<updated>2021-09-14T21:29:33Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;= Inheritance and persistence =  == Single Table == &amp;#039;&amp;#039;&amp;#039;Default mechanism in EJB3 &amp;#039;&amp;#039;&amp;#039; * Objects discriminated by extra column in table  ** specify mechanism: @Inheritance(Strat...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Inheritance and persistence =&lt;br /&gt;
&lt;br /&gt;
== Single Table ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Default mechanism in EJB3 &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Objects discriminated by extra column in table &lt;br /&gt;
** specify mechanism: @Inheritance(Strategy=InheritanceType.SINGLE_TABLE)&lt;br /&gt;
** must specify the column name: @DiscriminatorColumn(name=&amp;quot;...&lt;br /&gt;
** Each entity must specify values: @DiscriminatorValue(value=&amp;quot;... - default = name of subclass&lt;br /&gt;
&lt;br /&gt;
=== Implications ===&lt;br /&gt;
* column for each field in every subclass&lt;br /&gt;
** can result in a lot of redundant columns&lt;br /&gt;
* unable to exploit constraints - null values may be required for some subclasses and not others&lt;br /&gt;
** can overcome with triggers&lt;br /&gt;
&lt;br /&gt;
== Joined Table ==&lt;br /&gt;
** specify mechanism: @Inheritance(Strategy=InheritanceType.JOINED)&lt;br /&gt;
* separate table for each entity in hierarchy&lt;br /&gt;
* core table with primary key and columns for common elements&lt;br /&gt;
* sub tables use same primary key as core table and include columns for additional attributes&lt;br /&gt;
* discriminator column used to easily identify subtype see [[#Single Table]]&lt;br /&gt;
* Also specify table join column @PrimaryKeyJoinColumn(name=&amp;quot;...&lt;br /&gt;
&lt;br /&gt;
=== Implications ===&lt;br /&gt;
* cleaner design - easy to enforce constraints&lt;br /&gt;
* worse performance than Single Table as requires joining tables&lt;br /&gt;
&lt;br /&gt;
== Table per Class ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Optional for providers to implement&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
** specify mechanism: @Inheritance(Strategy=InheritanceType.TABLE_PER_CLASS)&lt;br /&gt;
* All classes have unique tables&lt;br /&gt;
** No relationship exists between tables&lt;br /&gt;
* primary keys across all tables must be unique&lt;br /&gt;
* All inherited columns duplicated in each sub table&lt;br /&gt;
&lt;br /&gt;
=== Implications ===&lt;br /&gt;
* Poor OO design&lt;br /&gt;
* Poor performance&lt;br /&gt;
* data can be pulled from one table in single query&lt;br /&gt;
* poor support for polymorphic queries - queries must union all tables&lt;br /&gt;
&lt;br /&gt;
= Inheritance from non Entity classes =&lt;br /&gt;
Annotate with: @MappedSuperClass&lt;br /&gt;
* no associated table&lt;br /&gt;
&lt;br /&gt;
= Polymorphic associations =&lt;br /&gt;
Polymorphic associations work in JPA&lt;br /&gt;
* When base class has an association to another object&lt;br /&gt;
* Sub classes inherit this association&lt;/div&gt;</summary>
		<author><name>Martin</name></author>
	</entry>
</feed>