0% found this document useful (0 votes)
41 views1 page

Cheat Sheet - Inheritance Mappings

The document discusses inheritance mappings in object-relational mapping (ORM) with a focus on different strategies such as Table per Class, Mapped Superclass, and Joined inheritance. It highlights the trade-offs between performance and consistency in these strategies. The document also includes code examples illustrating the use of annotations for defining these inheritance types.

Uploaded by

consulvation
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views1 page

Cheat Sheet - Inheritance Mappings

The document discusses inheritance mappings in object-relational mapping (ORM) with a focus on different strategies such as Table per Class, Mapped Superclass, and Joined inheritance. It highlights the trade-offs between performance and consistency in these strategies. The document also includes code examples illustrating the use of annotations for defining these inheritance types.

Uploaded by

consulvation
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Inheritance Mappings

Polymorphic queries or
associations?

No, but stay flexible No Yes

Table per Class Mapped Superclass Performance or


consistency?
@Entity @MappedSuperclass

@Inheritance(strategy = public abstract class Publication { … } Consistency Performance

InheritanceType.TABLE_PER_CLASS)

public abstract class Publication { … } @Entity(name = "Book")


Single Table
public class Book extends Publication { … }
@Entity(name = "Book")
@Entity
public class Book extends Publication { … }
@Inheritance(strategy =
Joined
InheritanceType.SINGLE_TABLE)

@Entity @DiscriminatorColumn(name =

@Inheritance(strategy = "Publication_Type")

[Link]) @DiscriminatorValue("Publication")

public abstract class Publication { … } public class Publication { … }

@Entity(name = "Book") @Entity(name = "Book")

public class Book extends Publication { … } @DiscriminatorValue("Book"

public class Book extends Publication { … }

[Link]

You might also like