persistence.xml

JPA/Hibernate: create database schema and import data on first run, update schema on subsequent runs

落爺英雄遲暮 提交于 2019-12-22 13:58:19
问题 In my projects I often use JPA/Hibernate stack for database. When defining persistence.xml you have couple options you can set hibernate.hbm2ddl.auto . If set to create tables will be recreated on every application run (persisted data will be lost of course). It is also possible to import initial data by setting db fixture with hibernate.hbm2ddl.import_files . When set to update only tables for new entities will be created (persisted data in existing tables will be preserved). The thing is

C3P0: unreturnedConnectionTimeout in production?

匆匆过客 提交于 2019-12-22 06:56:37
问题 The parameter unreturnedConnectionTimeout times out unreturned connections after a given period of time. I'm trying to decide whether I should use this in my production persistence.xml ? A big plus of using this is that the Connection Pool will be able to recover from leaky connections. A big minus is that leaky connections will be very difficult to detect. Should I use unreturnedConnectionTimeout in production applications? If yes, what should its value be? Are there any other pros/cons I

JPA and toplink create-table on if they don't already exist?

本秂侑毒 提交于 2019-12-19 18:14:04
问题 Looks like jpa is something which makes me ask a lot of questions. Having added this <property name="toplink.ddl-generation" value="create-tables"/> my JPA application always creates tables when running, which results in exceptions in case the tables already exist. I would like JPA to check if the tables already exist and if not create them, however I could not find a value for the property above which does this. So if I just turn it off, is there a way to tell JPA manually at some point to

JPA and toplink create-table on if they don't already exist?

限于喜欢 提交于 2019-12-19 18:13:09
问题 Looks like jpa is something which makes me ask a lot of questions. Having added this <property name="toplink.ddl-generation" value="create-tables"/> my JPA application always creates tables when running, which results in exceptions in case the tables already exist. I would like JPA to check if the tables already exist and if not create them, however I could not find a value for the property above which does this. So if I just turn it off, is there a way to tell JPA manually at some point to

JPA and toplink create-table on if they don't already exist?

白昼怎懂夜的黑 提交于 2019-12-19 18:13:04
问题 Looks like jpa is something which makes me ask a lot of questions. Having added this <property name="toplink.ddl-generation" value="create-tables"/> my JPA application always creates tables when running, which results in exceptions in case the tables already exist. I would like JPA to check if the tables already exist and if not create them, however I could not find a value for the property above which does this. So if I just turn it off, is there a way to tell JPA manually at some point to

why EntityManager is null?

江枫思渺然 提交于 2019-12-18 23:39:08
问题 In my web applicaton I use OpenJPA on Apache Tomcat (TomEE)/7.0.37 server. I use Netbeans to auto generate class ("Entity Class from database..." and "Session Beans From Entity Class..."). At SessionBean (for example UserFacade) i want to get EntityManager: @Stateless public class UserFacade extends AbstractFacade<User> { @PersistenceContext(unitName = "CollDocPU") private EntityManager em; @Override protected EntityManager getEntityManager() { return em; } } but when i get it by above way I

why EntityManager is null?

帅比萌擦擦* 提交于 2019-12-18 23:39:08
问题 In my web applicaton I use OpenJPA on Apache Tomcat (TomEE)/7.0.37 server. I use Netbeans to auto generate class ("Entity Class from database..." and "Session Beans From Entity Class..."). At SessionBean (for example UserFacade) i want to get EntityManager: @Stateless public class UserFacade extends AbstractFacade<User> { @PersistenceContext(unitName = "CollDocPU") private EntityManager em; @Override protected EntityManager getEntityManager() { return em; } } but when i get it by above way I

Persistence.xml where to put in eclipse project

匆匆过客 提交于 2019-12-18 13:08:30
问题 Simple question... I have a few projects in Eclipse enviroment MainApp(Enterprise Application Project) which "includes" WebController (EJB Project) WebModel (JPA Project) WebView(Dynamic Web Project) Problem is where to put persistance.xml file? Getting exception: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName DataModel 回答1: The JPA 2.0 specification in section 8.2 states the requirements for packaging. It says A persistence unit is defined by a

Where to put persistence.xml in library jar using maven?

扶醉桌前 提交于 2019-12-18 10:48:15
问题 At work we have an entity library which is used by several clients for the library (several servlets, a desktop application, etc.). The entity library consists of JPA-Annotated classes and most prominently a persistence.xml. All projects are configured using maven. Where should a persistence.xml file be put? It needs to be located inside the jar file of that entity library and I'm not sure how to configure this using maven. (We are just splitting up a project into several smaller projects) ''

Create JPA EntityManager without persistence.xml configuration file

馋奶兔 提交于 2019-12-17 03:46:21
问题 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! 回答1: Is there a way to initialize the EntityManager without a persistence unit defined? You should define at least one persistence unit in the