Mapping Sub-Classes by Type Table (Many-To-One Hibernate)

Jochen Morent

Grünschnabel
I have to make the domain-layer of a collage project. We have few standards, like we have to use Hibernate and the database also is fix.

The relevant part of the database looks nearly like that:

BusEntitys (Table 1)
  • BusId
  • Bus specific information

BusType (Table 2)

  • BusTypeId
  • Seats
  • ...
  • SubClass Discriminator

The problem I have is that there are 2 types of buses in the domain-layer distinguish by the discriminator in the BusType-table:

Code:
@Entity
class Bus
{
   @Id
   int _id;
   ...
}

Code:
@Entity
class BusSubClass1 extends Bus
{
   ...
}

Code:
@Entity
class BusSubClass2 extends Bus
{
   ...
}

Is there a way to map something like this with Hibernate and JPA? Thanks for every answer.

Jochen Morent
 
Hi

please don´t post questions as new tutorial
(in order check it first, nobody but moderators will see your thread in that state)
I´ll move this...
 
Zurück