persistence

A JTA EntityManager cannot use getTransaction()

有些话、适合烂在心里 提交于 2019-11-28 08:14:30
How do I have the following code in my non-ejb application. The code works. @Override public void saveItems(Collection<T> items) { synchronized (em) { EntityTransaction tx = em.getTransaction(); try { tx.begin(); for (T item : items) { saveItem_((Class<T>) null, item); } tx.commit(); } finally { if (tx.isActive()) { tx.rollback(); } } } } In a new application I'm using EJB3 + JSF and would like to re-use the library containing the code above. My peristence unit for the new application looks like this: <persistence-unit name="myApp" transaction-type="JTA"> <provider>org.hibernate.ejb

Core Data Store included in App Bundle

蹲街弑〆低调 提交于 2019-11-28 07:48:41
I can't find a clear description of these steps in Apple docs... I have a xcdatamodeld in my xcode project At launch time, my app parses a XML (project resource) to fill the Core Data Store (SQLLite) During lifetime of my app, I add, remove, update data of that Store Now, I want to stop doing that heavy XML parsing process on device and directly include a Store containing the required data. I have some questions regarding this : Can I fill a store with a OS X app and then include this store in my XCode-iOs project ? My store does not appear in Xcode. In fact it is created at run time. How can

How to store persistent data client side

我们两清 提交于 2019-11-28 07:44:51
I need to programmatically store data on the client side without having to transfer the data from the server on every page load. I considered generating a dynamic JavaScript file with the needed data for the current session of the user and make sure it is cached, but that seems really messy and there are a few drawbacks I can think of to such an approach. How can I go about storing persistent data on the client side? You may store data in window.name , which can hold up to 2MB of data (!). /* on page 1 */ window.name = "Bla bla bla"; /* on page 2 */ alert(window.name); // alerts "Bla bla bla"

On using Terracotta as a persistence solution

我是研究僧i 提交于 2019-11-28 07:38:12
Would it be a good idea to use Terracotta as a persistence solution (replacing a database)? I'm specifically wondering about data integrity issues and support for transactional systems. Terracotta is transactional (synchronized blocks form transactions of modified objects) but is not and doesn't want to be JTA-compliant. There is a fairly lengthy discussion of transactions and some common misconceptions about Terracotta here . I wrote a blog post about data lifetimes and how that should frame your thinking about identifying opportunities for the use of Terracotta. In short, Terracotta's sweet

How can I get the filtered model?

好久不见. 提交于 2019-11-28 07:20:26
问题 I'm working with JTables to display information that users can filter, and if the user saves after filtering I want to save the filtered table to a textfile for persistence (meaning anything that got filtered out will not be saved to the textfile). For filtering I just followed the filtering part of this tutorial: http://download.oracle.com/javase/tutorial/uiswing/components/table.html#sorting and it works fine, but I'm not sure of any way that I can get a model of the current display as

Hibernate @OneToMany with mappedBy (parent-child) relationship and cache problem

拟墨画扇 提交于 2019-11-28 06:36:59
I have this problem for a long time now, I have searched the web and SO in and out and didn't find a solution yet. I hope you can help me on that. I have a parent-child relationship between two entities like the following: @Entity public class Parent { // ... @OneToMany(mappedBy = "parent", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) private Set<Child> children = new HashSet<Child>(); // ... } @Entity public class Child { // ... @ManyToOne(fetch = FetchType.LAZY) private Parent parent; // ... } The thing is that when I create a new child and assign it to a parent, the parent doesn't

One-To-Many Relationship with Join Table

我只是一个虾纸丫 提交于 2019-11-28 06:15:26
I have a one-to-many relationship modeled using join table: create table t1 (id int primary key, name varchar(10) /*...*/); create table t2 (id int primary key, name varchar(10) /*...*/); create table t1_t2 (t1_id int, t2_id int, primary key (t1, t2)); The tables are supposed to model the relationship of one t1 to many t2. What is the right way to model these tables using JPA? The typical table for one T1 to many T2 is to have a foreign key on T2 pointing toward T1. The T1_T2 table is usually not needed. The JPA structure would then be a One-To-Many, possibly two-way. There could be some

Persist variable changes between tests in unittest?

混江龙づ霸主 提交于 2019-11-28 06:12:38
How do I persist changes made within the same object inheriting from TestCase in unitttest? from unittest import TestCase, main as unittest_main class TestSimpleFoo(TestCase): foo = 'bar' def setUp(self): pass def test_a(self): self.assertEqual(self.foo, 'bar') self.foo = 'can' def test_f(self): self.assertEqual(self.foo, 'can') if __name__ == '__main__': unittest_main() I.e.: I want those two tests above to pass As some comments have echoed, structuring your tests in this manner is probably a design flaw in the tests themselves and you should consider restructuring them. However, if you want

java.lang.NoClassDefFoundError: javax/persistence/Persistence

痴心易碎 提交于 2019-11-28 05:10:55
问题 i'm using Netbeans 6.8 and build simple Maven web application project. create Entity and main file for persist Entity [also create persist unit] and use EclipsLink. but when i run main file get this error : Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/Persistence at Main.main(Main.java:34) Caused by: java.lang.ClassNotFoundException: javax.persistence.Persistence at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController

NSCoding VS Core data

帅比萌擦擦* 提交于 2019-11-28 04:24:05
I've been searching for an article that explains NSCoding (NSKeyedArchiver...) advantages and disadvantages over use of CoreData (SQLite....). There's a lot of options, I can implement my own custom binary reader/writer, or use plists/xml/json... or use SQLite or NSCoding. I'm kind of lost right now. Can any body explain what's the difference between the MAIN features? It depends which kind of data you want to save and whether you will use it only internally or you have to exchange the data with an external service. NSCoding is generally speaking a data serializer. A lot of built-in objects