| Apache Cayenne > Index > Cayenne FAQ > HSQLDB Shutdown |
An in-process HSQLDB may cache committed data in-memory, so after a Java application exits, you may end up losing your committed data. Some users who tried Cayenne tutorials with HSQLDB ended up with empty database, even though the application reported committing a number of objects.
The solution is to explicitly shut down HSQLDB when the application exits. For instance in a command-line application main method may look like this:
public static void main(String[] args) { ObjectContext context = DataContext.createDataContext(); .... DataMap map = (DataMap) context.getEntityResolver().getDataMaps() .iterator().next(); context.performGenericQuery(new SQLTemplate(map, "SHUTDOWN")); }