aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate, Inheritance of entities.. One table too much.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate, Inheritance of entities.. One table too much.." Watch "Hibernate, Inheritance of entities.. One table too much.." New topic
Author

Hibernate, Inheritance of entities.. One table too much..

Jeroen Bs
Greenhorn

Joined: Sep 25, 2009
Posts: 9
I'm trying generate a database schema but I end up with an extra table I don't want. My creation looks like this (well its a bit (much ?) simplified):



contactProcess.java (Extends from myProcess)


CreateContactProcess.java(Extends from ContactProcess)


This all works as expected but there is one thing I don't like about it. Because the CreateContactProcess contains the @Entity annotation, a table in the database is created with the name CreateContactProcess. This table contains one column and thats the id column. Is there a way to prevent hibernate to create the CreateContactProcess ?
Removing the @Entity annotation lets hibernate generate the right tables but as expected breaks my code and prevents me to persist my entities.

I'm trying to find a solution for problem for a couple of days and can't find a solution.. so any hibernate guru around here who know how to fix it ? (Without me having to patch hibernate itself )
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

If you specify the inheritance strategy mapping for ContactProcess it should work I think.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jeroen Bs
Greenhorn

Joined: Sep 25, 2009
Posts: 9
Paul Sturrock wrote:If you specify the inheritance strategy mapping for ContactProcess it should work I think.

I tried all the possible settings for InheritanceType
  • @Inheritance(strategy = InheritanceType.JOINED)
  • @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
  • @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)

  • in ContactProcess but it doesn't change a thing how hibernate generates the tables. I dropped the entire DB for every try and it still creates the CreateContactProcess table.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Hibernate, Inheritance of entities.. One table too much..