Which of the following is correct?
- The program persists the data in the database.
- The program persists the data to the database.
In feels a little more natural to me, but I have no particular basis for that.
The program persists the data in the database.
Here is what I would say in general:
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.