multiple database support for same JPA classs

后端 未结 2 1521
迷失自我
迷失自我 2020-12-12 03:59

We using MYSQL and Hibernate for our project.

JPA is used to persist object in DB.

We have Multiple class with similar code

@Entity
@Table(n         


        
相关标签:
2条回答
  • 2020-12-12 04:16
    @Id
        @SequenceGenerator(name="admin_seq", sequenceName="unique_id")
        @GeneratedValue(strategy=GenerationType.AUTO, generator="admin_seq")
        private Long id
    

    worked for me , thanks for all your answers

    0 讨论(0)
  • 2020-12-12 04:18

    The AUTO strategy should work on Oracle as well. The difference with MySQL is that it will use a sequence instead of relying on an auto_increment ID.

    You can even control the sequence name per entity if desired: see Hibernate sequence on oracle, @GeneratedValue(strategy = GenerationType.AUTO).

    0 讨论(0)
提交回复
热议问题