Which preposition follows "persist"?

Which of the following is correct?

  1. The program persists the data in the database.
  2. The program persists the data to the database.

In feels a little more natural to me, but I have no particular basis for that.


Solution 1:

The program persists the data in the database.

Here is what I would say in general:

  • save the object in the database
  • update the object in the database
  • persist the object in the database (same as save or update)
  • load the object from the database
  • write the object to a file
  • read the object from a file

Solution 2:

Despite RegDwight's comment that persist can be transitive with a direct object, which I didn't know either, I'd suggest that such usage is unusual.

With regard to the actual question, the use of persist suggests that the data was in the database before, and that the program doesn't change that; hence in should be used here.

So I would write:

The program causes the data to persist in the database.

EDIT: In light of the comments below, note this answer applies to persist in its normal, non-programming, contexts. For its use in a programming context, in is still correct, but the verb can be used transitively, as in the question.