I try to atomatic generate entities by IntelliJ IDEA but not success.
error: Please choose presistence unit.
Help me generate entity and mapping files.
Right-click a module or a persistence unit, point to Generate Persistence Mapping and select By Database Schema. Select the source and output options and click OK.
Enable JPA support for an existing project Open the build file in the editor (pom. xml or build. gradle depending on the build tool that you use in your project). Press Ctrl+Shift+O to import the changes.
A persistence unit defines a set of all entity classes that are managed by EntityManager instances in an application. This set of entity classes represents the data contained within a single data store. Persistence units are defined by the persistence.xml configuration file.
xml should be put in the EJB JAR's META-INF directory. If you package the persistence unit as a set of classes in a WAR file, persistence. xml should be located in the WAR file's WEB-INF/classes/META-INF directory.
I've got the similar problem.Here is my solution.
add "JPA" facet.
open the "Project Structure" window -> click the "Facets" -> click the "add" button -> select "JPA"
add JPA persistence.xml.
click "persistence" -> right click your root item in the "persistence" toolbar -> "Generate Persistence Mapping" -> "By Database Schema".
you need add "hibernate.cfg.xml" first
Project Structure -> Modules -> Hibernate add hibernate.cfg.xml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With