• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to manage empty entities and/or entities with no tables using discriminators/inheritance

 
Nimmy Chip
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've asked a few times on other sites but I figure I would try in this one because I really haven't found an answer. I'm sorta new to hibernate, and I'm scared of posting in hibernate's forums. I'm using mainly JPA annotations but running Hibernate 3.6.

I have the following schema:



So basically this is a legacy DB. Nomination is the central table, and I have 4 specific types of Nominations:

1) Coworker (which only uses NOMINATION table columns as attributes)
2) Team (tables NOMINATION + TEAM_NOM)
3) Idea (tables NOMINATION + IDEA_NOM)
4) Success (tables NOMINATION + SUCCESS_NOM)

So what I've done is use a discriminator (and inheritance) to establish their entities. For example:

Nomination


And here's how I do Team, Idea and Success


Now for Coworker I did the following:


As you can see I have a big problem. Hibernate is looking for a table called "CoworkerNom", but I don't have any in our DB. I have tried putting in "Nomination" as table because I was out of ideas, but logically it gives me a circularity dependency error.

So how do I approach this entity which has no table and no attributes? The other Entities are working fine obviously.
 
Nimmy Chip
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I resolved this by making an empty table called COWORKER_NOM and passing only IDs to it (it's also recommended since you can expand that particular nomination by having a table). Hopefully this helps someone else on this predicament.
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might look at the three strategies used for inheritance mapping in JPA here.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic