Hi Bob, The reason Cayenne wants the entity class is to determine the proper DataNode to use to route the query to the correct database channel. If you only have one DataNode (which is probably the case), then any entity class should be fine. I'd stick with the SQLTemplate for now and just give it any entity that resides in the database you are trying to back up. Be sure you use a non-selecting query, too:
dataContext.performNonSelectingQuery(template); mrg On Mon, Sep 3, 2012 at 8:55 PM, Bob Harner <[email protected]> wrote: > Hey everybody, > > In a web app that uses Cayenne 3.0.1 with an embedded Derby database, I > need to perform a Derby-specific SQL query to do a database backup: > > CALL SYSCS_UTIL.SYSCS_BACKUP_DATABASE('D:/dbbackups/'); > > How would I do that using Cayenne APIs? I looked at SQLTemplate ( > http://cayenne.apache.org/doc/sqltemplate-basics.html), but it wants an > entity class to use as a root, which doesn't seem applicable here. > > Alternatively, how can I get access to the database connection so I can run > straight JDBC? > > private void backUpDatabase(Connection conn) throws SQLException > { > String sqlstmt = "CALL SYSCS_UTIL.SYSCS_BACKUP_DATABASE(?)"; > CallableStatement cs = conn.prepareCall(sqlstmt); > cs.setString(1,"D:/dbbackups/"); > cs.execute(); > cs.close(); > }
