Skip to content

EntityManagerFactory startup failure in deferred mode is only available on first use #26093

@DredderGun

Description

@DredderGun

Hello everyone!
Recently I observed a strange behavior while starting a simple project with Spring-boot + Hibernate that confuse me a lot.
I wrote a simple JPA entity and tried to start the project, but no entity wrote to a database. After long time searching why I accidentally had seen that the app after around 1-2 minute of correct working shut down with exit code 0 and the answer of my question appeared in a console: nested exception is org.hibernate.MappingException: Could not instantiate id generator [entity-name=null]
But why the app keeps silent before that moment and doesn`t show me any information about entity creation process? I think this is not trivial and confusing.

My application.properties for reproduction

spring.session.store-type=jdbc
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL10Dialect
spring.datasource.url= jdbc:postgresql://localhost:5432/***
spring.datasource.username=***
spring.datasource.password=***
spring.jpa.properties.hibernate.default_schema=demo
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create

And a simple JPA entity with error:

@Entity
public class Item {
    @Id
    public Long id;

    @ElementCollection
    @CollectionTable(name = "IMAGE")
    @Column(name = "FILENAME")
    @CollectionId(
            columns = @Column(name = "IMAGE_ID"),
            type = @Type(type = "long"),
            generator = "SEQUENCE" <<<<< NOT CORRECT
    )
    protected List<String> images = new ArrayList<>();
}

Now if you try to start a project then you will not see any error message for almost a one or two minutes and you doesn`t get what the problem. When you fix the error the entity writes to DB without problems

Srping-boot version: v2.3.5.RELEASE

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions