Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple references to database sequence [hibernate_sequence] were encountered

I'm getting this error when building my JHipster application:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Multiple references to database sequence [hibernate_sequence] were encountered attempting toset conflicting values for 'increment size'. Found [1] and [50]

I see the 50 here, but I don't know where the 1 is coming from.

Since the last time it worked, I have added a few new entities defined in these Kotlin files.

I'm working on adding the Thinkster conduit demo as one feature into my application. On its own the demo builds and runs without any problems. To get where I am now, I copied the code from the demo into my app and adjusted a few things, mostly related to the User entity. Since JHipster doesn't let you add fields to User, I created an Author entity with a 1:1 relationship to it. That in itself probably doesn't have anything to do with this error. I figure that something in this new code must be trying to create a sequence and the default increment size is one.

like image 854
Dan Cancro Avatar asked Mar 08 '23 05:03

Dan Cancro


1 Answers

You're probably missing a few tags that are required since JHipster makes a lot of assumptions about project setup. This is what was necessary to get my project working:

@Entity
@Table(name = "tags")
public class Tag {
  @Id
  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
  @SequenceGenerator(name = "sequenceGenerator")
  private int id;
}

Standard hibernate would let you get away without specifying the strategy or generator, but since it was configured already you need to match.

like image 186
Abraham Sturman Avatar answered Apr 27 '23 17:04

Abraham Sturman