object-persistence

Implements save (or commit) and rollback methods to a Map

萝らか妹 提交于 2021-02-11 13:05:01
问题 I'm searching for a fast and convenient way to add save() and rollback() to a standard Map. Let's say i have an object 'table' of class Table which in turn has a private Map called 'rows'. What I'm trying to achieve is a fast and without memory waste method for Row to do something like: row = new Row(); table.addRow(row).setValue("col1", "foo").setValue("col2", "bar").save(); row.setValue("col2", "beer"); System.out.println(table.getRows()); // 1. col1=foo, col2=bar row.save(); System.out

Implements save (or commit) and rollback methods to a Map

跟風遠走 提交于 2021-02-11 13:04:21
问题 I'm searching for a fast and convenient way to add save() and rollback() to a standard Map. Let's say i have an object 'table' of class Table which in turn has a private Map called 'rows'. What I'm trying to achieve is a fast and without memory waste method for Row to do something like: row = new Row(); table.addRow(row).setValue("col1", "foo").setValue("col2", "bar").save(); row.setValue("col2", "beer"); System.out.println(table.getRows()); // 1. col1=foo, col2=bar row.save(); System.out

With Python, can I keep a persistent dictionary and modify it?

空扰寡人 提交于 2020-01-20 03:55:19
问题 So, I want to store a dictionary in a persistent file. Is there a way to use regular dictionary methods to add, print, or delete entries from the dictionary in that file? It seems that I would be able to use cPickle to store the dictionary and load it, but I'm not sure where to take it from there. 回答1: If your keys (not necessarily the values) are strings, the shelve standard library module does what you want pretty seamlessly. 回答2: Use JSON Similar to Pete's answer, I like using JSON because

cPickle class with data save to file

谁说胖子不能爱 提交于 2020-01-16 18:17:16
问题 I've big class in Python it's "DataBase-like" class. I want to save it to file - all including data. This is input(example to show the issue, in script database is like 10000 records): import cPickle # DataBase-like class class DataBase: class Arrays: pass class Zones: pass class Nodes: class CR: pass class Links: class CR: pass class Turns: class CR: pass class OrigConnectors: pass class DestConnectors: pass class Paths: pass pass # some basic input into database DataBase.Arrays.Data=[] for

JPA: persisting object, parent is ok but child not updated

会有一股神秘感。 提交于 2020-01-05 09:04:27
问题 I have my domain object, Client , I've got a form on my JSP that is pre-populated with its data, I can take in amended values, and persist the object. Client has an abstract entity called MarketResearch , which is then extended by one of three more concrete sub-classes. I have a form to pre-populate some MarketResearch data, but when I make changes and try to persist the Client , it doesn't get saved, can someone give me some pointers on where I've gone wrong? My 3 domain classes are as

JPA: persisting object, parent is ok but child not updated

微笑、不失礼 提交于 2020-01-05 09:04:07
问题 I have my domain object, Client , I've got a form on my JSP that is pre-populated with its data, I can take in amended values, and persist the object. Client has an abstract entity called MarketResearch , which is then extended by one of three more concrete sub-classes. I have a form to pre-populate some MarketResearch data, but when I make changes and try to persist the Client , it doesn't get saved, can someone give me some pointers on where I've gone wrong? My 3 domain classes are as

Storing context object in Request object, is it disposed of?

半腔热情 提交于 2019-12-24 09:49:42
问题 I am writing a MVC3 application, using NInject DI and repository pattern. Ninject is set up so that the repositories have a per-request lifetime. I am putting the context object into the Http Request object, using the following code: public static MessengerEntities GetContext() { if (!HttpContext.Current.Items.Contains("_db_context")) { HttpContext.Current.Items.Add("_db_context", new MessengerEntities()); } return (MessengerEntities)HttpContext.Current.Items["_db_context"]; } Then each

Object persistence strategy for desktop application

大兔子大兔子 提交于 2019-12-23 18:32:49
问题 I am developing a Java based desktop application. There are some data generated from the application object model that I need to persist (preferably to a file). There is also a requirement to protect the persisted file so that others can't derive the object model details from the data. What's the best strategy for doing these? I was in the impression that these requirements are very common for desktop apps. However, I haven't been able to found much useful info on it. Any suggestion

JPA and unique fields

六月ゝ 毕业季﹏ 提交于 2019-12-21 21:33:17
问题 I have two persistence objects in my app: Things and tags attached to things. The app can generate collections of things with tags attached. Tag objects have a unique name (it doesn't make sense to tag something twice with the same tag). When inserting a Thing (with tag objects attached) some of these tag objects with the same name maybe already exist in the db. Now here is the part I don't recall about JPA, is there a way to tell JPA that it should not try to add the corresponding objects to

*large* python dictionary with persistence storage for quick look-ups

一个人想着一个人 提交于 2019-12-17 22:46:45
问题 I have a 400 million lines of unique key-value info that I would like to be available for quick look ups in a script. I am wondering what would be a slick way of doing this. I did consider the following but not sure if there is a way to disk map the dictionary and without using a lot of memory except during dictionary creation. pickled dictionary object : not sure if this is an optimum solution for my problem NoSQL type dbases : ideally want something which has minimum dependency on third