cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <>
Subject Re: Executing raw SQL
Date Tue, 04 Sep 2012 02:17:18 GMT
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:



On Mon, Sep 3, 2012 at 8:55 PM, Bob Harner <> 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:
> How would I do that using Cayenne APIs? I looked at SQLTemplate (
>, 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
> {
> CallableStatement cs = conn.prepareCall(sqlstmt);
> cs.setString(1,"D:/dbbackups/");
> cs.execute();
> cs.close();
> }

View raw message