Skip to main content
1 of 2
Aman Sinha
  • 109
  • 3
  • 10

Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not instantiate id generator

I'm trying to build a repository with product class as entity. There seems to be something wrong with the Id generator.

Here's my product entity

Product.java

package com.example.repository.model; import org.hibernate.annotations.GenericGenerator; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @Entity public class Product { @Id @GeneratedValue(strategy = GenerationType.AUTO, generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid2") private Integer Id; private String name; private String type; private String description; private Double price; public Integer getId() { return Id; } public void setId(Integer id) { Id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getType() { return type; } public void setType(String type) { this.type = type; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public Double getPrice() { return price; } public void setPrice(Double price) { this.price = price; } } 

Here's my application.properties

Application.properties

spring.datasource.url=jdbc:h2:~/Products spring.datasource.username=sa spring.datasource.password= spring.datasource.driver-class-name=org.h2.Driver spring.h2.console.path=/h2 spring.h2.console.enabled=true spring.jpa.hibernate.ddl-auto = update spring.jpa.show-sql=true 

I'm totally new to spring and hibernate and have no idea how to solve this issue. Thanks in advance.

Aman Sinha
  • 109
  • 3
  • 10