Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating JPA entities with IntelliJ without a persistence.xml or orm.xml

Is there a way to generate JPA entities with IntelliJ without a persistence.xml file? Or basically have IntelliJ recognize a persistance unit from Java Config? I have an existing (legacy) schema and the project is a rewrite, now using Java Config in Spring Boot. Per the Spring Boot docs, the persistence unit will be created by code:

@Bean
public LocalContainerEntityManagerFactoryBean customerEntityManagerFactory(
        EntityManagerFactoryBuilder builder) {
    return builder
            .dataSource(dataSource())
            .packages(com.abc.DomainThing.class)
            .persistenceUnit("abc")
            .build();
}
like image 531
Randy Avatar asked Aug 10 '15 22:08

Randy


1 Answers

I solved this by having a persistence.xml in the project and not really used by code or checked in. It just makes the IDE happy and I can bind a datasource to it to get the DB schema help in JPA Entity classes.

like image 142
Randy Avatar answered Nov 15 '22 01:11

Randy