Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is Hibernate Smart Enough to Handle Concrete Parent Classes?

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

Client --> CLIENT_TABLE
|
-- 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??

Thanks.
[ September 22, 2004: Message edited by: Ogi Kavazovic ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic