Questions tagged [persistence]

Persistence in computer programming refers to the capability of saving data outside the application memory.

Persistence is the capability of saving data outside of application memory, and of retrieving it later for further processing.

Typically data can be stored into the file system, in flat files or in a database. But persistence can also involve sending data to external applications.

Often persistence is related to .

References.

5099 questions
88
votes
12 answers

Setting a JPA timestamp column to be generated by the database?

In my SQL Server 2000 database, I have a timestamp (in function not in data type) column of type DATETIME named lastTouched set to getdate() as its default value/binding. I am using the Netbeans 6.5 generated JPA entity classes, and have this in my…
James McMahon
  • 48,506
  • 64
  • 207
  • 283
87
votes
6 answers

Hibernate Vs iBATIS

For our new product re-engineering, we are in the process of selecting the best framework from Java. As the consideration is to go for database agnostic approach for model, we are working on options between Struts + Spring with iBATIS or Hibernate.…
user241394
83
votes
3 answers

Creating a composite Unique constraints on multiple columns

This is my model: class User {...} class Book { User author; int number; } Every book number starts at 1 per author and increments upwards. So we'll have Books 1,2,3 by John Grisham, Book 1..5 by George Martin, etc... Is there a unique…
ripper234
  • 222,824
  • 274
  • 634
  • 905
80
votes
10 answers

Best practices for using and persisting enums

I've seen several questions/discussions here about the best way to handle and persist enum-like values (e.g. Persisting data suited for enums , How to persist an enum using NHibernate ), and I'd like to ask what the general consenus is. In…
sleske
  • 81,358
  • 34
  • 189
  • 227
80
votes
2 answers

JPA 2 CriteriaQuery, using a limit

I am using JPA 2. For safety reasons, I am working type safe with CriteriaQuery's (and thus, I am not searching for any solutions to typed queries and so on). I recently came across an issue in which I needed to set a SQL-LIMIT. After a lot of…
Menno
  • 12,175
  • 14
  • 56
  • 88
78
votes
4 answers

Do I have to close() every EntityManager?

I have just started migrating my homegrown persistence framework to JPA. Given that the persistence frameworks hide a lot of the plumbing, I'm interested in knowing if NOT closing EntityManagers will create a resource leak, or if the frameworks will…
stevemac
  • 2,534
  • 5
  • 27
  • 36
76
votes
11 answers

Java: JSON -> Protobuf & back conversion

I have an existing system, which is using protobuf-based communication protocol between GUI and server. Now I would like to add some persistence, but at the moment protobuf messages are straight converted to a third-party custom objects. Is there a…
Denis Kulagin
  • 8,472
  • 17
  • 60
  • 129
74
votes
2 answers

How to persist data in Prometheus running in a Docker container?

I'm developing something that needs Prometheus to persist its data between restarts. Having followed the instructions $ docker volume create a-new-volume $ docker run \ --publish 9090:9090 \ --volume a-new-volume:/prometheus-data \ …
Matt
  • 9,068
  • 12
  • 64
  • 84
72
votes
14 answers

How to store a dictionary on a Django Model?

I need to store some data in a Django model. These data are not equal to all instances of the model. At first I thought about subclassing the model, but I’m trying to keep the application flexible. If I use subclasses, I’ll need to create a whole…
AticusFinch
  • 2,351
  • 3
  • 25
  • 32
70
votes
3 answers

React Context API - persist data on page refresh

Let's say we have a context provider set up, along with some initial data property values. Somewhere along the line, let's say a consumer then modifies those properties. On page reload, those changes are lost. What is the best way to persist the…
Cog
  • 1,545
  • 2
  • 15
  • 27
70
votes
5 answers

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

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…
Andrea Bevilacqua
  • 1,197
  • 3
  • 15
  • 27
69
votes
9 answers

How is HDF5 different from a folder with files?

I'm working on an open source project dealing with adding metadata to folders. The provided (Python) API lets you browse and access metadata like it was just another folder. Because it is just another folder. \folder\.meta\folder\somedata.json Then…
Marcus Ottosson
  • 3,241
  • 4
  • 28
  • 34
68
votes
3 answers

What's the difference between the name argument in @Entity and @Table when using JPA?

I'm using JPA2 and both @Entity and @Table have a name attribute, e. g.: @Entity(name="Foo") @Table (name="Bar") class Baz What should I use, which ones are optional? In my specific case I have a class User and a class Group, which have additional…
soc
  • 27,983
  • 20
  • 111
  • 215
68
votes
9 answers

Why can't environmental variables set in python persist?

I was hoping to write a python script to create some appropriate environmental variables by running the script in whatever directory I'll be executing some simulation code, and I've read that I can't write a script to make these env vars persist in…
physicsmichael
  • 4,793
  • 11
  • 35
  • 54
67
votes
3 answers

How do I encode enum using NSCoder in swift?

Background I am trying to encode a String-style enum using the NSCoding protocol, but I am running into errors converting to and back from String. I get the following errors while decoding and encoding: String is not convertible to Stage Extra…
kfmfe04
  • 14,936
  • 14
  • 74
  • 140