How to change the @Generatedvalue used by Spring through Spring’s Abstractpersistable class?

Asked

Viewed 70 times

2

I’d like to use the @GeneratedValue(strategy = GenerationType.SEQUENCE, ... ... when extending the class AbstractPersistable, but I don’t know if that’s possible.

From what I saw in the documentation the class AbstractPersistable has the attribute Id with the annotation @GeneratedValue but does not state what strategy is used by the annotation @GeneratedValue to create the sequence used by the Spring framework.

How do I use the GenerationType.SEQUENCE specifically extending the class AbstractPersistable to have greater productivity?

  • Only use SequenceGenerator in the entity that inherits from AbstractPersistable, No? Then you’d have to do it on all the ones you inherit from AbstractPersistable. To abstract this, create a AbstractPersistable own.

  • It’s true, some developers use this practice. You can demonstrate how to create an Abstractpersistable @Brunocesar;

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.