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
0
votes
1 answer

How do I specify the name of the PK in the subclass table when using SubClass in FluentNHibernate?

I am attempting a subclass mapping in Fluent NHibernate. In the parent class mapping, I have to specify the ID column name to prevent FNH guessing incorrectly: Id(x => x.Id).Column("UserId"); I also need to specify the ID (or foreign key if you…
David
  • 15,750
  • 22
  • 90
  • 150
0
votes
1 answer

simple joined-subclass example tries to update the identity column of the base table

I must be missing something very important in the concept to get this error so any help appreciated. I get ----> System.Data.SqlClient.SqlException : Cannot update identity column 'ProductID'. when i run this var tblEvent =…
Tariq
  • 51
  • 4
0
votes
0 answers

How to set a join-subclass to be always updated (even if only the ancestor changed) in hibernate?

I have an update trigger on the joined-subclass in the database. It should run every time the data changed even if the changed fields are all in the ancestor class. But hibernate doesn't update the subclass. Is there a way to make it update it even…
gal
  • 113
  • 3
0
votes
2 answers

JPA - Override bean validation in joined-strategy inheritance

I have three JPA entities: A, B and C. B and C inherit A with joined strategy. Is it possible to override a Bean Validation constraint in the subclasses? For example, I would like B to have a @NotNull constraint in one field and C to have a @Null…
Aliuk
  • 1,249
  • 2
  • 17
  • 32
0
votes
1 answer

Why hibernate selects entities before persisting entities mapped by joined_subclass inheritance type?

I have superclass Person and two subclasses - Parent and Child. They are mapped with JOINED_TABLE inheritance type. Parent and Child have bidirectional one-to-many relationship. Person.hbm.xml contains all configuration:
Volodymyr Levytskyi
  • 3,364
  • 9
  • 46
  • 83
0
votes
1 answer

EntityExistsException persisting a second entity with @MapsId while a sibling-class is in the persistence context

I've got a curious problem I can't really work out. It's this exception: javax.persistence.EntityExistsException: a different object with the same identifier value was already associated with the session: [com.mycompany.Employee#101] at…
mabi
  • 5,279
  • 2
  • 43
  • 78
0
votes
0 answers

Hibernate: Change order of insert for base-class / sub-class

I'm using Hibernate with "Table per subclass" method. But unfortunately with slightly different table definition than the "best practices" which are described for the subclass-method. This is because the database administrator won't accept the…
fklappan
  • 3,259
  • 2
  • 17
  • 18
0
votes
1 answer

Nhibernate associate entity already saved in the database with a new item in a joined-subclass

The situation is as follows: I own a table called "Entidade" in the database, and a table "Medico". The table "Medico" is a joined-subclass entity in the table as below:
0
votes
1 answer

Creating alias in Hibernate to reference subclass issue

I am trying to create some aliases to build a criteria to search by properties of many subclasses. Here is my model: public abstract class Entity { protected int id; protected PartyBasicGroup partyBasicGroup; } public class Person extends Entity…
0
votes
0 answers

How do I access superclass properties in a Hibernate criteria

I'm using basic table-per-class polymorphism in Hibernate. So I have:
Paul W Homer
  • 2,728
  • 1
  • 19
  • 25
1 2 3 4
5