persistence.xml

Is there a way to scan JPA entities not to declare persistent classes in a persistence.xml file?

可紊 提交于 2019-11-27 01:54:12
问题 I would like to take advantage of JPA @Entity annotations not to declare class entities a J2SE persistence.xml file. What I'd like to avoid : <persistence-unit name="test" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <class>com.mycompany.entities.Class1</class> <class>com.mycompany.entities.Class2</class> <class>com.mycompany.entities.Class3</class> </persistence-unit> and here is what my actual persistence.xml look alike <persistence-unit

Why do I need to configure the SQL dialect of a data source?

霸气de小男生 提交于 2019-11-26 22:01:53
When we configure a data source using Hibernate, we should add the hibernate.dialect property (or eclipselink.target-database if you are using EclipseLink). I want to know what is the meaning of dialect ? I configure this property according to the documentation of Hibernate but I don't know what's the meaning of it. Dialect means "the variant of a language". Hibernate, as we know, is database agnostic. It can work with different databases. However, databases have proprietary extensions/native SQL variations, and set/sub-set of SQL standard implementations. Therefore at some point hibernate has

No Persistence provider for EntityManager named X

血红的双手。 提交于 2019-11-26 21:02:54
I am developing a JavaSE application using JPA. Unfortunately, I get null after calling: Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME); Below you will find: A snippet of my code that invokes EntityManagerFactory and unexpectedly returns null My persistence.xml file My project structure Snippet of my code: public class Main { private static final String PERSISTENCE_UNIT_NAME = "MeineJpaPU"; private static EntityManagerFactory factory; public static void main(String[] args) { // I get null on this line!!! factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);

Create JPA EntityManager without persistence.xml configuration file

江枫思渺然 提交于 2019-11-26 19:29:23
Is there a way to initialize the EntityManager without a persistence unit defined? Can you give all the required properties to create an entity manager? I need to create the EntityManager from the user's specified values at runtime. Updating the persistence.xml and recompiling is not an option. Any idea on how to do this is more than welcomed! Arthur Ronald Is there a way to initialize the EntityManager without a persistence unit defined? You should define at least one persistence unit in the persistence.xml deployment descriptor. Can you give all the required properties to create an

persistence.xml different transaction-type attributes

徘徊边缘 提交于 2019-11-26 12:49:39
问题 In the persistence.xml JPA configuration file, you can have a line like: <persistence-unit name=\"com.nz_war_1.0-SNAPSHOTPU\" transaction-type=\"JTA\"> or sometimes: <persistence-unit name=\"com.nz_war_1.0-SNAPSHOTPU\" transaction-type=”RESOURCE_LOCAL”> My question is: What is the difference between transaction-type=\"JTA\" and transaction-type=”RESOURCE_LOCAL” ? I also noticed some persistence.xml files with the transaction-type missing. Is it correct? 回答1: Defaults Default to JTA in a

Changing Persistence Unit dynamically - JPA

笑着哭i 提交于 2019-11-26 10:54:00
问题 Persistence units in persistence.xml are created during building the application. As I want to change the database url at runtime, is there any way to modify the persistence unit at runtime? I supposed to use different database other than pre-binded one after distributed. I\'m using EclipseLink (JPA 2.1) 回答1: Keep the persistence unit file (Persistence.xml) as it's. You can override the properties in it as follows. EntityManagerFactory managerFactory = null; Map<String, String> persistenceMap

Why do I need to configure the SQL dialect of a data source?

吃可爱长大的小学妹 提交于 2019-11-26 08:05:35
问题 When we configure a data source using Hibernate, we should add the hibernate.dialect property (or eclipselink.target-database if you are using EclipseLink). I want to know what is the meaning of dialect ? I configure this property according to the documentation of Hibernate but I don\'t know what\'s the meaning of it. 回答1: Dialect means "the variant of a language". Hibernate, as we know, is database agnostic. It can work with different databases. However, databases have proprietary extensions

No Persistence provider for EntityManager named X

半世苍凉 提交于 2019-11-26 07:48:00
问题 I am developing a JavaSE application using JPA. Unfortunately, I get null after calling: Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME); Below you will find: A snippet of my code that invokes EntityManagerFactory and unexpectedly returns null My persistence.xml file My project structure Snippet of my code: public class Main { private static final String PERSISTENCE_UNIT_NAME = \"MeineJpaPU\"; private static EntityManagerFactory factory; public static void main(String[] args) {