views:

265

answers:

6

Hi,

What does the term persistence mean when dealing with nHibernate?

What exactly is persistent?

+2  A: 

It means that an entity is associated with the database and changes will be written or 'persisted' to the database.

This is opposed to a transient object that only exists in memory.

g .
but you have to write the code to save/update the object correct?
I disagree. A object can be associated with the database via the session and still be transient.. It is only persisted once the session is flushed and transaction committed.
James L
You (TopBanana and g.) are both right. See my answer.
Stefan Steinegger
A: 

Persistence is when something is saved long-term, so a crash or power-loss won't affect it

James L
+3  A: 

The term persistence usually means that data is stored in a durable way, that it is still available after the program is terminated or the computer is turned off. When using a database for persistence, data is made persistent by writing it to the database and committing it.

Persistent is also a term in Nhibernate that refers to one of the instance states. It means that the object is synchronized by NH with the database. NH takes care that all the changes on a persistent object get stored to the database. The changes also need to be committed before they are actually persistent (durable).

Stefan Steinegger
A: 

Persistence is storing the state of existing data so that it can be retrieved and reused at a later time. Without it you wouldn't be able to reconstitute your objects between uses of your software.

mezoid
A: 

Most ORMs (of which NHibernate is one) expose SQL schemas/databases as objects. When you modify those objects, you need to "persist" those changes back to the database and this is commonly referred to as data persistence.

aleemb
A: 

In context of Data operations, Persisting is saving or updating the data back to the Database.

In terms of the Objectes, Persisted state means the iobject is synchronised with the DB.

We normally use the ISEssion >> SaveOrUpdate(object) method to persist the values.

Sree