Prasad
Prasad

Reputation: 71

Sequence generation for Oracle and MYSQL with same code base with Hibernate persistence provider

in my project we are using Oracle and we want to give support for MYSQL also. In POJOs/Domains we used sequence generator annotation. Oracle have sequence support but MYSQL don't have. How to handle with same code base? can any help me here out please.

NOTE: We dont want to change out existing code using IDENTITY annotation @GeneratedValue(strategy=GenerationType.IDENTITY)

Ex:
Class POJO{
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqgenerator")
@SequenceGenerator(--,--,--)
------
-------
}

Upvotes: 0

Views: 604

Answers (1)

hasnae
hasnae

Reputation: 2183

To support both oracle and mysql, use AUTO generated type As:

@GeneratedValue(strategy=GenerationType.AUTO)

Upvotes: 0

Related Questions