Questions tagged [table-per-class]

Table per class or also called as "Table per concrete type" is a strategy used for mapping inherited entities supported by Entity Framework code first.

53 questions
10
votes
2 answers

how to achieve table per concrete class when base class is abstract in fluent nhibernate?

i have the following scenario public abstract class BaseClass { public virtual int Id {get; set}; public virtual string Name {get; set;} } public class FirstSubClass : BaseClass { //properties and behaviour here } public class…
9
votes
1 answer

JPA Table per Class Inheritance with different Id names

I have the following mapping: @Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public abstract class Vehicle { @Id @GeneratedValue Long id; } @Entity @Table(name = "car") @AttributeOverride(name = "id", column =…
StasKolodyuk
  • 4,256
  • 2
  • 32
  • 41
6
votes
3 answers

Hibernate inheritance with different primary key

I'm trying to create a inheritance with TABLE_PER_CLASS strategy, but i want to have different primary key for each table is it possible? I've one class Register which has millions of instances, some of these instances are "special" and have…
Rafael Lima
  • 3,079
  • 3
  • 41
  • 105
6
votes
2 answers

JPA TABLE_PER_CLASS inheritance: How to only SELECT superclass entries?

I'm using EclipseLink as the JPA provider. Further I'm using the following TABLE_PER_CLASS inheritance structure @javax.persistence.Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @NamedQueries({ …
gerry
  • 763
  • 3
  • 15
  • 23
6
votes
0 answers

JPA: Why GenerationType.AUTO could not be used with InheritanceType.TABLE_PER_CLASS strategy

Could somebody explain why InheritanceType.TABLE_PER_CLASS could not use the GenerationType.AUTO strategy for primary key value generation when mapping inheritance?
skip
  • 12,193
  • 32
  • 113
  • 153
6
votes
2 answers

How to ensure data integrity when using Table Per Subclass?

I am using the table per subclass strategy in Grails by setting the tablePerHierarchy property of the static mapping field in my superclass to false. This way, Grails creates one table for my superclass and one additional table for each of my…
Stephan B
  • 837
  • 1
  • 16
  • 41
5
votes
1 answer

EntityFramework (CodeFirst) inheritance mapping: mix of TPT and TPC

We are making an EntityFramework CodeFirst DAL over a legacy database (which means that we are mostly stuck with whatever design errors it has). Domain model is (pretty) simple: we have abstract Card, subtyped into HomeCard, CarCard, OwnerCard and…
Sergei Rogovtcev
  • 5,804
  • 2
  • 22
  • 35
4
votes
2 answers

Why can't NHibernate use Identity in union-subclass Table per Concrete Class mapping?

Several sources state that NHibernate can not use identity with table per concrete class and union-subclasses. Is this true, and what is the exact reason behind this ?
4
votes
1 answer

Hibernate TABLE_PER_CLASS with @MappedSuperclass won't create UNION query

I am trying to create a series of objects that all are stored in separate tables, but that there is a set of fields in common on all these tables. I want Hibernate to do a UNION of all these tables, but NOT INCLUDE the superclass as a table. When I…
4
votes
1 answer

Java/Hibernate JPA: InheritanceType.TABLE_PER_CLASS and IDs

I'm using Hibernate JPA. Suppose I have these classes: AbstractPerson |--> ConcreteEmployee |--> ConcreteCustomer Is there any way to make the concrete classes have independent IDs? I'm using InheritanceType.TABLE_PER_CLASS.
Mike
  • 55
  • 1
  • 1
  • 5
4
votes
2 answers

Table per-subclass strategy when populating a large tree from a database using NHibernate

I am using NHibernate to load a large tree of objects of different types. Mapping is implemented using table-per-subclass strategy. I defined a base class "Node" that has only a few fields (NodeId, ParentId, NodeType) and several subclasses that…
Vagif Abilov
  • 9,835
  • 8
  • 55
  • 100
3
votes
1 answer

How-to: Mapping (NHibernate) multiple classes with different business logic from the same table?

I am currently working with a brownfield database which contains a table which holds data for 3 different sorts of business. It has to do with SalesOrders and orderlines. In the old application, we were able to add 3 types of orderlines to each…
TedOnTheNet
  • 1,082
  • 1
  • 8
  • 23
3
votes
0 answers

Override column name in InheritanceType.TABLE_PER_CLASS

Is there any way to override column name when TABLE_PER_CLASS inheritance is used? The doc says: "The limitation of this approach is that if a property is mapped on the superclass, the column name must be the same on all subclass tables."…
Paweł Kaczorowski
  • 1,502
  • 2
  • 14
  • 25
3
votes
0 answers

Entity Framework cannot map relationship between classes

I have gone through many posts, but never found a problem similar to mine For some reason I cannot correctly map relationship between classes while creating database using EF Code First The classes are - Order abstract class public abstract class…
Bartosz
  • 4,542
  • 11
  • 43
  • 69
3
votes
1 answer

Entity listener on a @MappedSuperclass does not work?

Background I am using EclipseLink (version 2.3.2.v20111125-r10461, implementation provider for the JPA 2.0 specification). Consider this @MappedSuperclass, called Person: @MappedSuperclass @EntityListeners({Listener.class}) public abstract class…
1
2 3 4