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
67
votes
4 answers

When to use DiscriminatorValue annotation in hibernate

What and when is the best scenario to use DiscriminatorValue annotation in hibernate?
czetsuya
  • 4,773
  • 13
  • 53
  • 99
64
votes
14 answers

The import javax.persistence cannot be resolved

I'm currently working on a project that requires EntityManager EntityManagerFacotry and Persistence each from the javax.persistence package. It seems to be for the database service, but the current code is not very well documented. By searching…
Matt
  • 5,408
  • 14
  • 52
  • 79
62
votes
6 answers

Is it possible to detach Hibernate entity, so that changes to object are not automatically saved to database?

I have Hibernate entity that I have to convert to JSON, and I have to translate some values in entity, but when I translate values, these values are instantly saved to database, but I don't want to save these changes to database. Is there any…
newbie
  • 24,286
  • 80
  • 201
  • 301
58
votes
2 answers

Making data persistent in android

In my application,there are some application specific settings, which should be available to me , next time when my application starts up. In other words i want the data to be available across the sessions of an application cycle. Can this be…
Girish
  • 605
  • 2
  • 7
  • 10
57
votes
4 answers

Solve Hibernate Lazy-Init issue with hibernate.enable_lazy_load_no_trans

I have been suffering from infamous hibernate exception org.hibernate.LazyInitializationException: could not initialize proxy - no Session Now the community is cheering over saying…
Sachin Verma
  • 3,712
  • 10
  • 41
  • 74
57
votes
3 answers

PersistenceUnit vs PersistenceContext

In few project I have been successfully using @PersistenceUnit(unitName = "MiddlewareJPA") EntityManagerFactory emf; ... EntityManager entityManager = emf.createEntityManager(); to obtain EntityManager for Database connection, but some days ago I…
user2377971
  • 1,442
  • 4
  • 21
  • 30
56
votes
7 answers

Persistent DB Connections - Yea or Nay?

I'm using PHP's PDO layer for data access in a project, and I've been reading up on it and seeing that it has good innate support for persistent DB connections. I'm wondering when/if I should use them. Would I see performance benefits in a…
Brian Warshaw
  • 22,657
  • 9
  • 53
  • 72
55
votes
4 answers

What is the difference between a session and a transaction in JPA 2.0?

I just begin my JPA 2.0 studies, and I have this piece of code: em = SessionFactory.startSession(); tx = em.getTransaction(); My problem is: I'm not sure if I completly understand the difference between the use of a session and the use of a…
user645579
55
votes
3 answers

Persist variable changes between tests in unittest?

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…
A T
  • 13,008
  • 21
  • 97
  • 158
54
votes
10 answers

Passing empty list as parameter to JPA query throws error

If I pass an empty list into a JPA query, I get an error. For example: List municipalities = myDao.findAll(); // returns empty list em.createQuery("SELECT p FROM Profile p JOIN p.municipality m WHERE m IN (:municipalities)") …
Tuukka Mustonen
  • 4,722
  • 9
  • 49
  • 79
53
votes
15 answers

alternative to memcached that can persist to disk

I am currently using memcached with my java app, and overall it's working great. The features of memcached that are most important to me are: it's fast, since reads and writes are in-memory and don't touch the disk it's just a key/value store…
Mike W
  • 747
  • 2
  • 7
  • 10
52
votes
5 answers

How to persist an enum using NHibernate

Is there a way to persist an enum to the DB using NHibernate? That is have a table of both the code and the name of each value in the enum. I want to keep the enum without an entity, but still have a foreign key (the int representation of the enum)…
Meidan Alon
  • 3,074
  • 7
  • 45
  • 63
48
votes
1 answer

One-To-Many Relationship with Join Table

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,…
Hosam Aly
  • 41,555
  • 36
  • 141
  • 182
46
votes
2 answers

How can you replicate Hibernate's saveOrUpdate in JPA?

In JPA, is there any way you can replicate Hibernate's saveOrUpdate behavior, saveOrUpdate public void saveOrUpdate(Object object) throws HibernateException Either save(Object) or update(Object) the given instance, depending…
James McMahon
  • 48,506
  • 64
  • 207
  • 283
45
votes
2 answers

Object persistence terminology: 'repository' vs. 'store' vs. 'context' vs. 'retriever' vs. (...)

I'm not sure how to name data store classes when designing a program's data access layer (DAL). (By data store class, I mean a class that is responsible to read a persisted object into memory, or to persist an in-memory object.) It seems reasonable…