• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is Hibernate Smart Enough to Handle Concrete Parent Classes?  RSS feed

Ogi K
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a table-per-subclass mapping strategy.

-- ClientTypeA --> CLIENT_A_TABLE ( joined on CLIENT_ID )
-- ClientTypeB --> CLIENT_B_TABLE ( joined on CLIENT_ID )
-- ClientTypeC --> CLIENT_C_TABLE ( joined on CLIENT_ID )

However, our Client class is NOT abstract because when we first insert the Client into the DB, we do not know which type of client it is. Later on, the user inputs more information which determines which type it is. At this point, we construct a ClientTypeX object from the Client object and want to update it.
Not too surprisingly, we get a StaleObjectStateException...the desired behavior is for Hibernate to be smart enough to update the Client table and insert into the joined-subclass table for the given Client type. Can Hibernate be configured to handle this??

[ September 22, 2004: Message edited by: Ogi Kavazovic ]
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!