persistence

Unable to configure EntityManagerFactory from runnable jar

早过忘川 提交于 2019-12-24 00:08:33
问题 I'm developing a JPA-2.0 application using Hibernate3. It runs fine from eclipse, but if run it from a generated runnable jar, it gives a javax.persistence.PersistenceException: Unable to configure EntityManagerFactory: Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke

Composite Primary key in JPA

扶醉桌前 提交于 2019-12-24 00:06:01
问题 The EmbeddedId or IdClass annotation is used to denote a composite primary key. How can i use composite primary key without ( EmbeddedId or IdClass ) ? If it is possible to use composite primary key without ( EmbeddedId or IdClass ) then how can i use EntityManager.find( Entity Class , Object primaryKey) method to find entity in case of composite primary key (Multiple Primarykey) (because of no IdClass or EmbeddedId) . EclipseLink take List of pk in the find() operation but if composite pk

JPA merge does not appear to work

[亡魂溺海] 提交于 2019-12-23 22:26:39
问题 I'm running the following code to update the database according to the data I read from CSV file. I've tried to debug, and check the console and it's running through the whole 800 records. I don't get any error, but only the first record is inserted. If I'm using persist instead of merge, I got "Cannot persist detached object" error. for (String[] data : dataList) { log.debug("Reading data no " + (i++)); EntityManager em = PersistenceUtil.getAgisDbEntityManager(); EntityTransaction tr = em

Do annotations in Java result in compile-time transitive dependencies?

非 Y 不嫁゛ 提交于 2019-12-23 20:22:03
问题 A simple example where Ent.java uses annotations and is compiled with the necessary jar dependency after which Includer.java is compiled which in turn imports Ent.java . Ent.java: import javax.persistence.Entity; import javax.persistence.Table; @Entity @Table(name="securities") public class Ent {} Includer.java: public class Includer { public void f() { Ent s = new Ent(); } } Compiling this with... javac -cp C:/apache-tomcat-7.0.59/lib/javax.persistence_2.1.0.v201304241213.jar Ent.java javac

Does NSCache persist between launches?

大兔子大兔子 提交于 2019-12-23 17:56:03
问题 I'm looking into a fairly simple mechanism for caching and and currently using NSCache (for the reason of memory management). Question is - does the cache persist between launches? It seems like no to me. I get objects put in cache just fine and can take them out of the cache while the app is running no problem. But once I relaunch, seems like the cache is gone. So is there a way to make the cache persist between launches? If so, how would you re-sync the cache from previous session to the

Docker-compose v3 not persisting postgres database

纵饮孤独 提交于 2019-12-23 16:32:52
问题 I'm having difficulty persisting postgres data after a docker-compose v3 container is brought down and restarted. This seems to be a common problem, but after a lot of searching I have not been able to find a solution that works. My question is similar to here: How to persist data in a dockerized postgres database using volumes, but the solution does not work - so please don't close. I'm going to walk through all the steps below to replicate the problem. Here is my docker-compose file:

Python pandas persistent cache

人走茶凉 提交于 2019-12-23 15:48:19
问题 Is there an implementation for python pandas that cache the data on disk so I can avoid to reproduce it every time? In particular is there a caching method for get_yahoo_data for financial? A very plus would be: very few lines of code to write possibility to integrate the persisted series when new data is downloaded for the same source 回答1: There are many ways to achieve this, however probably the easiest way is to use the build in methods for writing and reading Python pickles. You can use

Saving Android application data on app exit

不问归期 提交于 2019-12-23 15:16:11
问题 It seems that there is a large amount of information about saving Activity state, but I have been unable to locate much on finding Application state. I am looking for some design ideas to solve a problem I have run into. I am developing a game that has a fairly large data model (1-2 MBytes). This model exists outside of any Activity, in fact there are numerous activities that all interact with it. These activities are transient, coming and going all the time. I currently keep a pointer to the

JPA transaction rollback fails with call to stateless bean

眉间皱痕 提交于 2019-12-23 12:54:40
问题 Inside a BMT (using a UserTransaction ) I call a method on another stateless EJB. When I rollback this transaction, the entity created in the EJB method is not rolled back. I use EJB 3.1 with JPA 2.0. The transaction begins in method doTheTransaction() : @Stateless @LocalBean @TransactionManagement(TransactionManagementType.BEAN) public class TaskExecutor { @Inject private SomeEntityFacade someEntityEJB; @Inject private RandomEJB randomEJB; @Resource private UserTransaction ut; @Asynchronous

Persisting & Restoring Current State in Spring Statemachine

喜欢而已 提交于 2019-12-23 10:59:19
问题 I'm introducing Spring Statemachine into an existing project, with the hope of amalgamating and clarifying our business logic. We have various JPA entities with interconnected states and I'm having some trouble with setting a persisted state as the current state of an existing state machine. I'm using a StateMachineFactory to create a new StateMachine instance for each entity instance. I'm storing the current state of the StateMachine in a separate field for Hibernate to persist and ideally