persistence

How to do proper database testing (TDD) on Rails 3 using MongoDB and Mongoid

為{幸葍}努か 提交于 2019-12-09 04:20:20
问题 How would go about writing proper unit testing (and integration testing for that matter) using MongoDB through Mongoid on Rails ? I am asking, because to the opposite of using let's say SQLite3, even when running tests, everything I do does persists. So for the moment I am writing the creation test and then I manually delete everything I do. But it's getting annoying and even complicated to do for integration testing. Sample of what I do: before(:each) do @user = User.create!(@attr) end after

Refresh and fetch an entity after save (JPA/Spring Data/Hibernate)

妖精的绣舞 提交于 2019-12-09 04:05:32
问题 I've these two simple entities Something and Property . The Something entity has a many-to-one relationship to Property , so when I create a new Something row, I assign an existing Property . Something: @Entity @Table(name = "something") public class Something implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(name = "name") private String name; @Column(name = "owner") private String owner

Remember window positions in swing

时光总嘲笑我的痴心妄想 提交于 2019-12-09 02:51:40
问题 I have a pretty big swing application and i want to make it remember sizes of all windows, jframes etc. So if user resized window how he likes, next time the window looks exact the same way. Do i have a better option to solve it, but manually write the position/size of each window in Preferences? Is there any convinient way to store the order of columns in JTable? May be some framework? Just don't want to write boilerplate. Serialization of the whole big app is unfortunately not an option.

Android Persist Data After Uninstall

杀马特。学长 韩版系。学妹 提交于 2019-12-09 00:30:43
问题 I have to persist 2 strings for my application even after the application is uninstalled. Regarding that the end users don't have SD cards for their devices and they don't have internet connection, how could I persist those 2 strings even after the app is uninstalled? I would highly appreciate any response. Thanks 回答1: Unless you're targeting VERY old phones, you don't need to worry about not having external storage. As long as you use Environment.getExternalStorageDirectory() as your

In Ruby on Rails how can I persist objects in memory between sessions

送分小仙女□ 提交于 2019-12-08 23:13:08
问题 I'm trying to build something (ultimately a gem but for now an application) that works as follows. Suppose for example the DB records are breeds of dog. There's a Dog parent class and a child class for each breed. The actual breeds aren't known until runtime. When the server begins it will load up records from the DB and instantiate instances of classes based on the records, e.g. I may have two beagles and poodle. When someone comes to the server they may want to access one of those dog

Stable/repeatable random sort (MySQL, Rails)

本秂侑毒 提交于 2019-12-08 20:18:12
问题 I'd like to paginate through a randomly sorted list of ActiveRecord models (rows from MySQL database). However, this randomization needs to persist on a per-session basis, so that other people that visit the website also receive a random, paginate-able list of records. Let's say there are enough entities (tens of thousands) that storing the randomly sorted ID values in either the session or a cookie is too large, so I must temporarily persist it in some other way (MySQL, file, etc.).

JPA - defining multi-column unique constraints

╄→гoц情女王★ 提交于 2019-12-08 17:43:28
问题 Is it possible using JPA to define multiple unique constraints. @Entity class Foo { long id; String name; MyEnum type; } Foo.id should be unique as should combinations of {Foo.name, Foo.type}. Ex. id, name, type 1, "name1", "type1" 2, "name1", "type2" 3, "name1", "type1" // error duplicate of id = 1 How do I achieve this using JPA annotations? Thanks 回答1: With the uniqueConstraints attribute of the Table annotation: @Table(name = "FOO", uniqueConstraints={ @UniqueConstraint(columnNames = {

Windows Phone 7 Data Persistence

浪尽此生 提交于 2019-12-08 13:25:11
问题 I'm would like some advice on the best data persistence solution to use for an application that will run on the desktop (WPF) and on Windows Phone 7, sharing data between both applications. Ideally I would like to use the Entity Framework. I have considered the following technologies: Sync Framework 4.0 - only CTP at the moment but has the big advantage of offline use. However it is an immature framework that does not allow me to use Entity Framework and seems not to be very mainstream,

How are these methods allowing / causing data to be lost on disk?

北战南征 提交于 2019-12-08 12:37:42
问题 I have a program that writes its settings and data out to disk every so often (15 seconds or so). If the program is running and the computer is shut off abruptly -- for example, with the power being cut at the wall -- somehow all of my data files on disk are changed to empty files. Here is my code, which I thought I designed to protect against this failure, but based on testing the failure still exists: SaveAllData -- Called every so often, and also when JavaFX.Application.stop() is called.

AIR 2 - Data Persistence?

半腔热情 提交于 2019-12-08 12:35:16
问题 what is the best way to include data persistence in an AIR 2 application? is it creating your own read/write file with flash.filesystem, or is there a new way with AIR 2? 回答1: it seems that adobe wrote a library for saving preferences in AIR years ago, but have never added it to the official library? now i'm curious why they would not have done so, since data persistance is key for desktop applications. adobe's AIR Preferences library ("as3preferenceslib"), consisting of 3 classes, can be