'Spring Boot: Abstracting Repository and Service

I have a similar entities and I use the following approach and use a base class:

@MappedSuperclass
public abstract class Dining {

    // constructors 

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "dining_gen")
    private long id;

    @Column(nullable = false)
    private UUID groupUuid;

    @Column(nullable = false)
    private String name;
}
@Entity
@SequenceGenerator(...)
@Table(...)
public class Room extends Dining {

    // constructors 
}
@Entity
@SequenceGenerator(...)
@Table(...)
public class Point extends Dining {

    // constructors 
}

I also use a base DTO, Request, etc. for these classes. However, I am wondering until which level I should apply abstraction. Should I use a generic base repository (Dining) and extend to Room and Point repositories?

What about services? I use Interface and its implementations in my Spring Bot app. In this scene, should I create a base interface or should I also create base service implementation and extend to Room and Point services?

If there is a good example as a best or proper practice, could you suggest me pls?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source