Questions tagged [joined-subclass]

Joined-subclass is a mapping strategy in Hibernate and NHibernate that is also known as "Table per subclass".

Joined-subclass mapping is a mapping strategy in Hibernate and NHibernate where a superclass A is mapped to its own table and all subclasses that extend A is mapped to their own table, but with a join to A's table. Only the properties defined at each level in the inheritance hierarchy will be stored in corresponding columns in each class' database table.

When selecting a derived class B from the database, Hibernate does a select on A with a left outer join on B as well as all other classes extending from A. Depending on which left outer join returns any data, Hibernate constructs a new instance of the correct class (in this case, B) and fills it with data from table A and B.

70 questions
13
votes
3 answers

Fluent Nhibernate 1.0 - Specify foreign key constraint name between class and joined subclass

I think this should be simple, but I can't figure out how to do it. Suppose I have the following maps: public class AnimalMap : ClassMap { Id( x => x.Id); } public class CatMap: SubclassMap { Extends(); Map(x =>…
10
votes
3 answers

How to access discriminator column in JPA

I have DisseminationArea as subcalss for Feature with the following code: @Entity @Table(name = "features") @Inheritance(strategy = InheritanceType.JOINED) @DiscriminatorColumn(name = "subtype_id", discriminatorType =…
Dims
  • 47,675
  • 117
  • 331
  • 600
10
votes
1 answer

Fluent NHibernate JoinedSubClass is obsolete

I wonder about something. I'm sitting here with a solution there I have 1 superclass that has 2 subclasses and I'm currently mapping this using JoinedSubClass, but I get that this method is obsolete, and says that I should ClassMap and SubClassMap,…
10
votes
2 answers

NHibernate Many-To-One on Joined Subclass with Filter

I have a class setup that looks something like this: public abstract class Parent { public virtual bool IsDeleted { get; set; } } public class Child : Parent { } public class Other { public virtual ICollection Children { get; set;…
Nathan Roe
  • 844
  • 1
  • 8
  • 22
10
votes
2 answers

Play Framework 2 Ebean and InheritanceType as JOINED

After some research on Google, I haven't found anyone who has my problem that's why I'm posting it here. In my application I have three entities : User (abstract), Customer, Agency. Customer and Agency extends User. Here is the code of User…
c4k
  • 4,270
  • 4
  • 40
  • 65
7
votes
2 answers

JPA @PrePersist and @PreUpdate order when using inheritance

Supposing the following code snippet which uses @PrePersist and @PreUpdate annotations and Joined-type inheritance: @Entity @Inheritance(strategy=InheritanceType.JOINED) public abstract class A { ... @PrePersist private void…
Aliuk
  • 1,249
  • 2
  • 17
  • 32
7
votes
0 answers

Multi-Level Inheritance in Joined Inheritance strategy using discriminator for each parent in hierarchy

Consider my classes below Product (Abstract Root class) @Entity @Table(name="PRODUCT") @Inheritance(strategy=InheritanceType.JOINED) @DiscriminatorColumn(name="PRODUCT_TYPE") public abstract class Product { @Id @GeneratedValue …
Jeff
  • 519
  • 1
  • 10
  • 18
6
votes
2 answers

NHibernate Discriminated Subclasses of a Joined-Subclass

Here's my heirarchy: class abstract Entity { /*members*/ } // mapped to entity table class abstract User : Entity { /*members*/ } // mapped to user table class Employee : User { /*no members*/ } // no table, discriminator = "E" class Contractor :…
Travis Heseman
  • 11,359
  • 8
  • 37
  • 46
6
votes
0 answers

Fluent nHibernate - DiscriminateSubClassesOnColumn with multiple tables?

I've been trying to wrap my head around subclasses and joined subclasses in Fluent nHibernate for a few days now without making any sort of headway. I've looked at the wiki but it doesn't seem to give me enough information, and googling returns me…
6
votes
2 answers

Avoiding outer joins across tables when using joined inheritance with Spring Data JPA

Consider the following classes in a Spring Data JPA (+ Hibernate) application: @Entity @Inheritance(strategy = InheritanceType.JOINED) @Table(name = "person") public class Person { } @Entity @Table(name = "customer") public class Customer extends…
manish
  • 19,695
  • 5
  • 67
  • 91
5
votes
1 answer

In a JPA entity hierarchy using InheritanceType.JOINED, all relationships with subclasses results in foreign key constraints on the superclass table

I have the following JPA 2.0 Entities @Entity @Inheritance(strategy= InheritanceType.JOINED) public abstract class BookKeepingParent implements Serializable { @Id protected Long Id; ... } @Entity public class Employee extends…
4
votes
0 answers

Fluent NHibernate automapping table-per-abstract-hierarchy / table-per-concrete-subclass

I have classes public abstract class Content : IContent { public virtual Guid Id { get; protected set; } public virtual IPage Parent { get; set; } public virtual DateTime Created { get; set; } /* ... */ } public abstract class Page :…
Mike Koder
  • 1,898
  • 1
  • 17
  • 27
4
votes
1 answer

Fluent NHibernate trying to map subclass of subclass using table-per-subclass

I am building an application with heavy inheritance and have a part where there exists classes, A, B and C with: class A class B : A class C : B I implemented subclass mapping as a table-per-subclass style for class B as follows: class BMap :…
4
votes
1 answer

NHibernate - Retrieve specific columns and count using criteria query

This is my mapping file: class name="CRMStradCommon.Entities.OportunidadEntity,CRMStradCommon" table="oportunidad">
3
votes
0 answers

Change column for joined class mapping in Fluent NHibernate Automapping

I have an inheritance public abstract class UserEntity : Entity { public virtual int Id { get; protected set; } } public class Employee : UserEntity { public virtual string Email { get; set; } } Entity is a standard for NH class where…
1
2 3 4 5