persistence

How to use NSUserDefaults to store an array of dictionaries

走远了吗. 提交于 2019-12-02 08:03:29
Trying to store an array of dictionaries with NSUserDefaults . var theTasks: [[String:Any]] = [["num":1,"title":"example","colour":"red"]] let defaults = NSUserDefaults.standardUserDefaults() defaults.setObject(theTasks, forKey: "myTasks") defaults.synchronize() let selected = theTasks[1] Gives error: Cannot convert value of type '[[String:Any]]' to expected argument of type 'AnyObject?' Swift 3.x In Swift 3 it has changed so now it needs to be saved as [Any] Any Array and use UserDefaults array(forKey:) method to load it: let theTasks: [Any] = [["num": 1, "title": "example", "colour": "red"]]

one to one mapping using primary key join column

牧云@^-^@ 提交于 2019-12-02 08:02:34
I have employee and employee detail classes mapped (bi directional) using primary key join column (employee_id) @Entity @Table(name="employee") public class Employee { @Id @GeneratedValue @Column(name="employee_id") private Long employeeId; @Column(name="firstname") private String firstname; @Column(name="lastname") private String lastname; @Column(name="birth_date") @Temporal(value = TemporalType.DATE ) private Date birthDate; @Column(name="cell_phone") private String cellphone; @OneToOne(mappedBy="empl", cascade=CascadeType.ALL) private EmployeeDetail employeeDetail; ... } @Table(name=

Saving user settings from GUI

帅比萌擦擦* 提交于 2019-12-02 07:49:02
问题 I am currently coding an application, which has an option frame JDialog . This frame contains various checkboxes and text fields that the user can configure. I want to save the changes the user made to the options. What is the best way of doing so? My first thought was implementing it by saving it in a file with the format of e.g. checkBox1=value; textArea1="value"; By using the following I could get the field, but I would need to do something like (for the checkbox) myField.isSelected();

iOS : Objective-C : Firebase : Is it possible to read the cached data first for any reference?

本秂侑毒 提交于 2019-12-02 07:27:54
@Description: I have data already exists at some endpoint(friends_list) so this is my reference : https://xxxxxx.firebaseio.com/friends_list Now, I have enabled disk persistence i.e., i am allowed to cache the data as well as using the below code: [FIRDatabase database].persistenceEnabled = YES; Now, I have loaded the application and I have cached the data to disk by using the following code: FIRDatabaseReference *globalRef = [[FIRDatabase database] reference]; FIRDatabaseReference *ref = [globalRef child:@"friends_list"]; [ref keepSynced:YES]; //here comes : other stuff for listeners

MappingException: No persister for - NHibernate - Persisting an Adapter [duplicate]

孤街醉人 提交于 2019-12-02 07:09:34
This question already has an answer here: NHibernate.MappingException: No persister for: XYZ 15 answers Well, I googled a lot, and found the same advices all there (set hbm as Embedded Resource, add hbm at hibernate.cfg, etc..), and despite of them, I still not get it. Let me explain: I wrote a Communication Dll for a ticket gate device, and there I have a configuration model class, that I use to configure that device through TCP/IP. But now, I have to persist this object on DB, so I wrote an Adapter inside my model which glues one into another. This way, I have an Adapter for my configuration

How to delete data from org.hibernate.collection.PersistentBag? | Hibernate (Jpa)

不羁的心 提交于 2019-12-02 03:27:45
问题 The List<String> Mylist is org.hibernate.collection.PersistentBag ... and i want to delete this Mylist ... How i can do it?? QriteriaBuilder criteriaBuilder = em.getCriteriaBuilder(); CriteriaQuery<A_entity> criteriaQuery = criteriaBuilder.createQuery(A_entity.class); criteriaQuery.from(A_entity.class); Query query = em.createQuery(criteriaQuery); List<A_entity> queryList = query.getResultList(); for (A_entity a:queryList) { if(....) { List<String> Mylist = a.func(); ???How delete Mylist????

JPA not receiving updated data

心已入冬 提交于 2019-12-02 03:10:34
I use a managedBean that goes into the db and defines the bean properties with db data. However when I update the db the data I receive in my bean is not updated. The query in db is like this: private static final String JPQL_FIND_BY_ID = "SELECT c FROM Category c WHERE c.idcategory=:id"; @Override public Category findCatById(int id) { Query query = em.createQuery(JPQL_FIND_BY_ID, Category.class); query.setParameter("id", id); Category cat = null; try { cat = (Category) query.getSingleResult(); } catch (Exception e) { e.printStackTrace(); } return cat; } The managed bean I use to get the

Firebase database for Android - write events when offline, using persistence

ⅰ亾dé卋堺 提交于 2019-12-02 03:10:06
As stated in the title, I am using the Firebase Realtime Database, with persistence enabled . As stated in the guide, By enabling persistence, any data that the Firebase Realtime Database client would sync while online persists to disk and is available offline, even when the user or operating system restarts the app. This means your app works as it would online by using the local data stored in the cache. Listener callbacks will continue to fire for local updates . While this happens with the ValueEventListeners and every read listener, I can't find a way to make it work with write operations

JPA and many-to-many relations in google app engine

*爱你&永不变心* 提交于 2019-12-02 02:42:34
I have entities A and B, and A can have set of B. The same instance of B can belong to several A. So there is classical many-to-many relation here. In GAE there is no direct support of many-to-many relations, instead they're offering an ability to use sets of keys for related relations. So in A I will maintain set of keys of records in B. Now the problem is - how can I query for objects of type B belonging to given object of type A and matching certain criteria? In plain SQL I would do that like: select B.* from B inner join A on B.A_ID=A.ID where B.property0=criteria1 and B.property1

Variable persistence in PHP

我怕爱的太早我们不能终老 提交于 2019-12-02 02:34:01
i have a php page, on that page i have text boxes and a submit button, this button runs php in a section: if(isset($_POST['Add'])){code} This works fine here and in that section $name,$base,$location etc are calculated and used. but that section of code generates another submit button that drives another section of code. it is in this second section of code that i wish to add data to the DB. Now i already know how to do this, the problem is that the variables $name and so forth have a value of NULL at this point.. but they can only be called after the first code section has been run where they