openjpa

How to disable the lock system of JPA?

谁说我不能喝 提交于 2019-12-01 19:37:26
I'm using OpenJPA and I have a lock problem. I already understand what's an OptimisticLockException and when it's thrown. But how can I deal with it ? Below*, you can find a small paragraph about the optimistic lock exceptions. In a nutshell, how I can totally disable the lock manager ? In my persistent.xml, I have the following xml code but it does not work. Why ? ... <properties> <property name="openjpa.LockManager" value="none" /> </properties> ... *According to the wikibooks about the Java Persistent : Handling optimistic lock exceptions Unfortunately programmers can frequently be too

Does OpenJPA work well with Glassfish?

十年热恋 提交于 2019-12-01 18:02:43
Is anyone successfully using OpenJPA with Glassfish? I'm trying to use OpenJPA 2.1 with Glassfish 3.1 Open Source. I've followed the instructions to integrate the two here -> http://weblogs.java.net/blog/ss141213/archive/2006/07/using_openjpa_a.html I have a very simple EJB project in Eclipse Indigo with the following: com.rares.test.Person - @Entity com.rares.test.PersonManager - interface com.rares.test.PersonDao - @Stateless However, when I try to deploy I get a ClassNotFoundException on my Person @Entity. The complaint seems to be the Person parm on a create method that's being implemented

OpenJPA merging/persisting is very slow

倖福魔咒の 提交于 2019-12-01 06:52:07
问题 I use OpenJPA 2.2.0 on WebSphere Application Server 8 with a MySQL 5.0 DB. I have a list of objects which I want to merge into the DB. it's like: for (Object ob : list) { Long start = Calendar.getInstance().getTimeInMillis(); em = factory.createEntityManager(); em.getTransaction().begin(); em.merge(ob); em.getTransaction().commit(); em.close(); Long end = Calendar.getInstance().getTimeInMillis(); Long diff = end - start; LOGGER.info("Time: " + diff); } When I run this loop I need about 300

Am I supposed to call EntityManager.clear() often to avoid memory leaks?

天大地大妈咪最大 提交于 2019-12-01 03:57:01
I'm new to JPA/OpenJPA and I noticed that if I don't call EntityManager.clear() after i persist entities I get an OutOfMemoryError (I keep adding new entities in a loop). I'm not sure if this is the expected behavior or it's just and OpenJPA 1.2.1 glitch. So, am I required to explicitly detach the entities myself? If I'm not, it's a good practice anyway? I don't have much experience with JPA. However this'll be useful - In JPA you must either: - Create a new EntityManager for each transaction. - Call clear() after each transaction to clear the persistence context. Depends how many objects you

Am I supposed to call EntityManager.clear() often to avoid memory leaks?

五迷三道 提交于 2019-12-01 00:41:20
问题 I'm new to JPA/OpenJPA and I noticed that if I don't call EntityManager.clear() after i persist entities I get an OutOfMemoryError (I keep adding new entities in a loop). I'm not sure if this is the expected behavior or it's just and OpenJPA 1.2.1 glitch. So, am I required to explicitly detach the entities myself? If I'm not, it's a good practice anyway? 回答1: I don't have much experience with JPA. However this'll be useful - In JPA you must either: - Create a new EntityManager for each

Logging JPA SQL with Weblogic 10.3

大憨熊 提交于 2019-11-30 23:08:04
By looking into the Open JPA website i've found that i can log the generated SQL by using the following: <property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO"/> If i try to add the above property to my persistence.xml i get the following warning from weblogic: <Warning> <J2EE> <BEA-160202> <You have specified a ope njpa.Log setting in your configuration for persistence unit services.ear#services-ejb.jar#exp#exp. This setting will be ignored, and all log messages will be sent to the WebLogic logging subsystem. Trace-level logging is controlle d by the various JPA

why EntityManager is null?

旧街凉风 提交于 2019-11-30 20:08:44
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 get null. When I make it by: @Override protected EntityManager getEntityManager() {

To initialize or not initialize JPA relationship mappings?

一笑奈何 提交于 2019-11-30 17:29:09
In one to many JPA associations is it considered a best practice to initialize relationships to empty collections? For example. @Entity public class Order { @Id private Integer id; // should the line items be initialized with an empty array list or not? @OneToMany(mappedBy="order") List<LineItem> lineItems = new ArrayList<>(); } In the above example is it better to define lineItems with a default value of an empty ArrayList or not? What are the pros and cons? JPA itself doesn't care whether the collection is initialized or not. When retrieving an Order from the database with JPA, JPA will

Logging JPA SQL with Weblogic 10.3

旧街凉风 提交于 2019-11-30 17:20:11
问题 By looking into the Open JPA website i've found that i can log the generated SQL by using the following: <property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO"/> If i try to add the above property to my persistence.xml i get the following warning from weblogic: <Warning> <J2EE> <BEA-160202> <You have specified a ope njpa.Log setting in your configuration for persistence unit services.ear#services-ejb.jar#exp#exp. This setting will be ignored, and all log messages will

What's the lazy strategy and how does it work?

拈花ヽ惹草 提交于 2019-11-30 09:08:07
问题 I have a problem. I'm learning JPA. I'm using embedded OpenEJB container in unit tests, but only working is @OneToMany(fetch=EAGER) . Otherwise is the collection allways null. I haven't found, how the lazy strategy works, how the container fills the data and in which circumstances triggers the container the loading action? I have read, that the action triggers when the getter is being called. But when I have the code: @OneToMany(fetch = LAZY, mappedBy="someField") private Set<AnotherEntities>