0

In my project I am using oracle sql function to generate the primary keys (our client provides the Database and we are not allowed to change them) the generated id are something like this

prefix-1001, prefix-1002 and so on.

The problem is hibernate only support sequences to generate the PKs. I have taken the reference of Oracle functions using Hibernate but at last it didn't work. I know I can achieve this using Native Sql query but is there any less complex way to do it. I am writing the entity code like this

@Id
@Formula("GETCATEGORYID()")
private int id;
private String name;
Community
  • 1
  • 1
Vivek Singh
  • 646
  • 3
  • 10
  • 25
  • 1
    Possible duplicate of [Hibernate: How specify custom sequence generator class name using annotations?](http://stackoverflow.com/questions/11631800/hibernate-how-specify-custom-sequence-generator-class-name-using-annotations) – krokodilko Feb 04 '17 at 12:50
  • You didn't understand the question I want to use sql function to generate ID in hibernate – Vivek Singh Feb 05 '17 at 02:33

0 Answers0