JPA without persistence.xml

后端 未结 3 1255
无人共我
无人共我 2021-01-03 11:40

I\'m trying to get started with using Guice Persist and JPA, which recommends using configuration via persistence.xml. Coming from a native Hibernate background where confi

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-03 12:12

    Depending on what you want to achieve and in what context (ApplicationServer vs CLI, CMT transactions vs EntityTransactions), it may be possible to use JPA without a persistence.xml. I did this in a CLI Java application, where I had different databases with the same structure. For that I constructed the EntityManagerFactory manually.

    PS: The config file is there to make your life easier, so if you can, just use it.

提交回复
热议问题