apache-cayenne

is it possible in Apache Cayenne to prepopulate an ObjectContext without a database?


I am evaluating Cayenne for some new projects.

I wonder if it is possible (for unit tests) to use Cayenne without a database and instead somehow prepopulate an ObjectContext from data I obtain from a file to reach an identical state as if it was read from the database?


Solution

  • In theory yes, but practically this is too much trouble to implement. A much easier approach is to use an in-memory DB like Apache Derby. Frameworks like Bootique.io provide assistance with starting/stopping Derby and populating it with data, but this can be done on your own as well with a bit of effort.