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
1
vote
1 answer

Hibernate 4: HQL and Inheritance - fetching collections and javassist

I'm having this scenario: parent class Person, children classes: Individual and Enterprise. I'm mapping this classes with joined-subclass strategy like this:
vladiastudillo
  • 407
  • 1
  • 10
  • 23
1
vote
0 answers

Hibernate joined-subclass with child transient getter and setter

I'm trying to add hibernate inheritance in existing structure. So, I need to add parent class which should generalize 3 entities. The problem is that now I need to get inherited fields in HQL from child. Something like…
Anatoly
  • 1,551
  • 4
  • 21
  • 40
1
vote
0 answers

Trying to use a TreeMap in a subclass entitiy

I have found help for subclassing of a mapped superclass, and I have found help on how to map a TreeMap. However, I can not find anything that covers using a TreeMap in a subclass at all. Here is the situation: I am adding a function to a…
Bob Ruth
  • 11
  • 1
1
vote
1 answer

using class in where-condition of HQL-Query

I have a Entity Contact which has three joined-subclass (Person, Company, Branch). When I do a select-query on Contact where I should only get the Person's, Companies or Branches, I can do select from Contact a where a.class = Person this is…
BennoDual
  • 5,865
  • 15
  • 67
  • 153
0
votes
1 answer

ADO.NET Entity Framework and a Joined Subclass

Can you do a Joined Subclass in the Entity Framework version 1? How do you approach the issue? Joined…
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
0
votes
2 answers

NHibernate: JoinedSubclass, HasMany

I use FluentNHibernate (Automapping) for mapping, NHibernate 3.2 for data access and SchemaExport to generate my database. I have a class Principal which is the base class for User and Usergroup. Principal has a property CommonThing of type…
0
votes
1 answer

NHibernate cascading deletes in associated joined subclasses

I'm currently working on a small PoC project and decided to take NHibernate for a spin for the persistence part. I have defined the following domain entities: Location: abstract class representing a location (root of the location…
0
votes
1 answer

Nhibernate multiple levels hierarchy mapped as joined subclasses fails to work with base class property

I have following hierarchy: ClassA->ClassB->ClassC->ClassD ClassB has PropertyA. All classes are mapped as joined subclasses with table per-class. Mapping is parsed with no errors but I get an error when I try to run a query: ICriteria crit…
Nikolay R
  • 957
  • 2
  • 11
  • 22
0
votes
1 answer

Fluent NHibernate - mixing table-per-subclass and table-per-class-hierarchy

Give the following structure, MyBaseClass { public int Id {get; private set;} } MySubclassWithDiscriminator : MyBaseClass { } MySubclass : MyBaseClass { public string SomeThing {get; set;} } How would I use Fluent NH to map these correctly,…
rbellamy
  • 5,683
  • 6
  • 38
  • 48
0
votes
1 answer

is there a way to do a bidirectionnal relationship with entity inheritance.joined in JPA with discrimanator value?

I have a ValuedCustomer and Order and I want to do a bidirectional relationship in hibernate. How do I do this? Thanks @Entity @Table(name="VCUST") @DiscriminatorValue("VCUST") @PrimaryKeyJoinColumns({ …
0
votes
4 answers

Java Subclass $

I am new to Java and might be asking a basic question which might sound silly to some. After I compile my Main Java class most of the subclasses are displayed as $ in the folder. I copy the complied classes and put it on another location to execute.…
Nick
  • 3
  • 1
0
votes
1 answer

Joining to a subclass of a Table per Class hierarchy in NHibernate

I'm using the table per subclass mapping inheritance in NHibernate. I have a parent Attribute table and a child AccountAttribute table. The child AccountAttribute table has another foreign key in it to a CustomerProfile table. The CustomerProfile…
Kyle Novak
  • 425
  • 6
  • 15
0
votes
1 answer

NHibernate within or Alternative

I'm pretty new to NHibernate and I have this problem where I need two columns from an extension table to be present on a in my NHibernate mapping, but I'm having the hardest time finding the appropriate implementation. Below is a…
0
votes
1 answer

NHiberate Joined Subclass Invalid Property

I'm trying to work through this issue where the subclass contains a set of properties however two of the properties do not exist in the referenced table. These two properties exist in an Extension table that has FKs back to the base table. I'm…
Mike Anderson
  • 597
  • 3
  • 7
  • 21
0
votes
2 answers

Hibernate: Getting org.hibernate.InstantiationException While Fetching polymorphic Collections in onetomany association

I am trying to use JOINED inheritance strategy in Hibernate using JPA annotations. My Base class is abstract and have Many to One association with other entities. However I am getting Hibernate Exception: Cannot instantiate abstract class or…
Ankit
  • 113
  • 1
  • 7