java - How to make Hibernate to use SequenceHiLoGenerator for JPA GenerationType.AUTO on Oracle? -


i have table id below, hibernate uses org.hibernate.id.sequencegenerator instead of sequencehilogenerator generationtype.auto, how can tell hibernate use sequencehilogenerator?

@id @sequencegenerator(name="admin_seq", sequencename="unique_id") @generatedvalue(strategy=generationtype.auto, generator="admin_seq") private long id 

if use generationtype.sequence, hibernate use sequencehilogenerator, need use generationtype.auto compatibility mysql.

i have tried using @genericgenerator, works oracle complained mysql: org.hibernate.dialect.mysqldialect not support sequences.

@genericgenerator(name = "admin_seq", strategy = "org.hibernate.id.sequencehilogenerator",         parameters = {                 @parameter(name = "sequence", value = "unique_id"),                 @parameter(name = "max_lo", value = "50") }) @generatedvalue(strategy=generationtype.auto, generator="admin_seq") private long id 

i tried using sequencestylegenerator setting hibernate.id.new_generator_mappings=true in hibernate properties. doesn't work either.

strategy = generationtype.auto should work against mysql identity column though you've configured sequence too. sequencegenerator used when running against oracle, ignored when running against mysql.

in persistence.xml should switch hibernate.dialect property between correct values oracle dialect , mysql dialect.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -