I have an spring boot applicaion that should be run on mysql in development environment and on sql server on production environment.
so i want to set @GeneratedValue(strategy = GenerationType.IDENTITY)
when application is running with prod
profile and set to @GeneratedValue(strategy = GenerationType.AUTO)
when application is running with dev
profile.
I have BaseEntity
class that all of the entities are extended from it:
@MappedSuperclass
public abstract class BaseEntity<T> implements Serializable {
@Id
@Column(name = "id", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO) // how to chagne this dynamically?
private T id;
}
So how can i implement this requirement? should i change .yml
files or implements some class and change some configurations to achieve this goal?
UPDATE
I don't want to use sequence
for both SQL Server and MYSQL, i want to use identity
feature of sql server, and sequence in mysql.