Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot: Export identifier encountered more than once

Following error occures

Caused by: org.hibernate.tool.schema.spi.SchemaManagementException:Export identifier [order_signal] encountered more than once

I have the following classes:

tradingbot.persistence.model.order.TransactionComponent

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class TransactionComponent {
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    @Column(name = "id", updatable = false, nullable = false)
    protected Long id;

    ...
}

tradingbot.persistence.model.order.OrderSignal

@Entity
@JsonRootName("OrderSignalDAO")
public class OrderSignal extends TransactionComponent {
    ...
}

tradingbot.persistence.model.order.TransferSignal

@Entity(name = "TransferSignal")
public class TransferSignal extends TransactionComponent {
    ....
}

In class OrderSignal there is no other @Id and there is no getter/setter for id in TransactionComponent as well.

Why does this error occures? What does it mean? How to fix it?

like image 333
R.Schaefer Avatar asked Oct 16 '25 04:10

R.Schaefer


1 Answers

One Scenario I came across in which the above issue happens is say the entity class would be as follows

`@Entity
 @Table(name = "universe")
 public class Universe {
    @GenericGenerator(
            name = "universeSequenceGenerator",
            strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
            parameters = {
                    @Parameter(name = "sequence_name", value = "universe"),
                    @Parameter(name = "initial_value", value = "1"),
                    @Parameter(name = "increment_size", value = "1")
            }
    )
    @Id
    @GeneratedValue(generator = "universeSequenceGenerator")
    private Integer id;
    private String name; 
    ....`

In above scenario the following error would be thrown Caused by: org.hibernate.tool.schema.spi.SchemaManagementException:Export identifier [universe] encountered more than once

It is because of @Parameter(name = "sequence_name", value = "universe") , when we change this to @Parameter(name = "sequence_name", value = "universeSeq") the error disappears. If the entity name matches anywhere in the parameter names or etc,. then this might occur.

like image 198
Hrudayanath Avatar answered Oct 17 '25 21:10

Hrudayanath