logo image

How to fix Found use of deprecated [org.hibernate.id.SequenceGenerator] sequence-based id generator; use org.hibernate.id.enhanced.SequenceStyleGenerator instead


I have following code in my POJO

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;

On startup Hibernate giving me the following warning

HHH90000014: Found use of deprecated [org.hibernate.id.SequenceGenerator] sequence-based id generator;
use org.hibernate.id.enhanced.SequenceStyleGenerator instead. 
See Hibernate Domain Model Mapping Guide for details.

1 Answer

2 years ago by

Start using GenericGenerator for sequence generation.

declare your GenericGenerator with the following code

	@GenericGenerator(
	        name = "userSequenceGenerator",
	        strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
	        parameters = {
	                @Parameter(name = "sequence_name", value = "userSequence"),
	                @Parameter(name = "initial_value", value = "1"),
	                @Parameter(name = "increment_size", value = "1")
	        }
	)

and start using it for your id field

@Id
	@GeneratedValue(generator = "userSequenceGenerator")
	private Long id;
2 years ago by Megamind