I've got a class that's presently planned being an entity inside a database table using Hibernate. These kinds ought to be refactored into an abstract class that contains some area present with all its subclasses.

I am using annotations for mapping hibernate organizations/associations classes.

I'd like suggestions/variants regarding how to do that refactoring.

Also, a few recommendations regarding how to slowly move the data that's saved within the database (for future years abstract superclass) into among the concrete subclasses.

First, I'll produce the superclass and add the required annotations. You need to decide between:

  • Table per Class Strategy
  • Single Table per Class Hierarchy Strategy
  • Became a member of Subclass Strategy

I believe the Became a member of Subclass works here. You add the annotation:

@Entity
@Inheritance(strategy=InheritanceType.JOINED)

Towards the super class.

Second, I'll produce the table(s) that represent the sub classes. Remember these is only going to possess the posts which are unique towards the subclass, posts which are shared will stay within the super class. Then choose the rows in the super class' table owed in every subclass and slowly move the data.

I am unsure if you're searching for some thing specific? This article describes inheritance with Hibernate.