Looks like HSQLDB caching data in memory bites a bunch of users (there were more comments on CAY-790). I have a solution that we are using in CayenneModeler (see comment below)... Wonder where we can put it in the docs? What would be a good place though?

Andrus


Begin forwarded message:
From: "Andrus Adamchik (JIRA)" <dev@cayenne.apache.org>
Date: June 28, 2007 7:24:27 PM GMT+03:00
To: [EMAIL PROTECTED]
Subject: [JIRA] Commented: (CAY-790) commitChanges() doesn't imply commit in db ?


[ https://issues.apache.org/cayenne/browse/CAY-790? page=com.atlassian.jira.plugin.system.issuetabpanels:comment- tabpanel#action_12361 ]

Andrus Adamchik commented on CAY-790:
-------------------------------------

Doing search on Google, looks like HSQLDB keeps some data in memory , without flushing it down to the storage file (unless some limit is reached I guess). Here is a trick that might help you. When your application is about to exit, run the following command to shut down HSQLDB:


DataContext context = DataContext.createDataContext();
context
.performGenericQuery(new SQLTemplate (Someclass.class, "SHUTDOWN"));

Could you please report whether this worked or not?

Otherwise I don't see a Cayenne-level fix... But we need to confirm that it works and document the workaround somewhere.



 commitChanges() doesn't imply commit in db ?
---------------------------------------------

                Key: CAY-790
                URL: https://issues.apache.org/cayenne/browse/CAY-790
            Project: Cayenne
         Issue Type: Bug
         Components: CayenneModeler GUI
Environment: Winxp, Eclipse SDK Version: 3.2.2 Build id: M20070212-1330, Cayenne, Version: 2.0.2 (January 14 2007),
           Reporter: K. Wood
           Assignee: Andrus Adamchik
           Priority: Blocker

have been reading the mail archives and didn't see where this problem ever got fixed.
I am have the exact same thing going on with HSQLDB.
I have the latest versions of that and Cayenne, etc.
Everythign looks hunkey dorey no runtime errors & such, until you access the db with Squirrel SQL. Nothing is there at all!! No commits. This is just the little demo program with the artists and paintings I'm sure you've seen a zillion times. ( got too many imports, for testing things atm.)
Nothing I have tried works at all.
I even tried with Derby..which I haven't been able to get to work without compiler errors as yet., (the Cayenne GUI Modeler creates the empty db but this same code wont compile) anyway... After reading all the other mail, I think there is a widespread problem here.
Hope you can shed some light on this.
See what you think:
Code:
package cayenne.tutorial;
import org.apache.cayenne.query.SQLTemplate;
import org.apache.cayenne.query.SelectQuery;
import org.apache.cayenne.query.UpdateQuery;
import org.apache.cayenne.access.DataContext;
import java.util.List;
import java.util.*;
import org.apache.cayenne.exp.Expression;
import org.apache.cayenne.exp.ExpressionFactory;
import org.apache.cayenne.exp.ExpressionParameter;
import org.apache.cayenne.query.SelectQuery;
public class up_dt {
        public static void main(String[] args) {
                
                DataContext ctxt = DataContext.createDataContext();
                
                Artist picasso = (Artist) ctxt.newObject(Artist.class);
                
                
                picasso.setName("Pablo Picasso");
                picasso.setDateOfBirthString("18811025");
                Gallery metropolitan = (Gallery) ctxt.newObject(Gallery.class);
                metropolitan.setName("Metropolitan Museum of Art");
                
Painting selfPortrait = (Painting) ctxt.createAndRegisterNewObject(Painting.class);
                selfPortrait.setName("Self-portrait");
                selfPortrait.setYear(new Integer(1907));
                selfPortrait.setArtist(picasso);
                metropolitan.addToPaintings(selfPortrait);
                
Painting theDream = (Painting) ctxt.createAndRegisterNewObject (Painting.class);
                theDream.setName("The Dream");
                theDream.setYear(new Integer(1932));
                theDream.setArtist(picasso);    
                metropolitan.addToPaintings(theDream);
// Set artist on both paintings; as a side effect this will automatically
//               add these paintings to the Artist's paintings collection.
        
//              theDream.setArtist(picasso);
                
        
//              Painting girl = (Painting) ctxt.newObject(Painting.class);
//              girl.setName("Girl Reading at a Table");

                
//              Painting stein = (Painting) ctxt.newObject(Painting.class);
//              stein.setName("Gertrude Stein");
//              picasso.addToPaintings(girl);
//              picasso.addToPaintings(stein);
        
//              girl.setGallery(metropolitan);
//              stein.setGallery(metropolitan);
                
                ctxt.commitChangesToParent();  // not committing the updates.  
Why?
                
                        
//      
                }
}
Heres the log:
INFO QueryLogger: Created connection pool: jdbc:hsqldb:C:/db_area/ cayenne/testdb
        Driver class: org.hsqldb.jdbcDriver
        Min. connections in the pool: 1
        Max. connections in the pool: 1
INFO QueryLogger: Opening connection: jdbc:hsqldb:C:/db_area/ cayenne/testdb
        Login: sa
        Password: *******
INFO  QueryLogger: +++ Connecting: SUCCESS.
INFO QueryLogger: Detected and installed adapter: org.apache.cayenne.dba.hsqldb.HSQLDBAdapter
INFO  QueryLogger: --- will run 2 queries.
INFO  QueryLogger: --- transaction started.
INFO QueryLogger: SELECT NEXT_ID FROM AUTO_PK_SUPPORT WHERE TABLE_NAME = 'GALLERY'
INFO  QueryLogger: === returned 1 row. - took 32 ms.
INFO QueryLogger: UPDATE AUTO_PK_SUPPORT SET NEXT_ID = NEXT_ID + 20 WHERE TABLE_NAME = 'GALLERY'
INFO  QueryLogger: === updated 1 row.
INFO  QueryLogger: --- will run 2 queries.
INFO QueryLogger: SELECT NEXT_ID FROM AUTO_PK_SUPPORT WHERE TABLE_NAME = 'ARTIST'
INFO  QueryLogger: === returned 1 row. - took 0 ms.
INFO QueryLogger: UPDATE AUTO_PK_SUPPORT SET NEXT_ID = NEXT_ID + 20 WHERE TABLE_NAME = 'ARTIST'
INFO  QueryLogger: === updated 1 row.
INFO  QueryLogger: --- will run 2 queries.
INFO QueryLogger: SELECT NEXT_ID FROM AUTO_PK_SUPPORT WHERE TABLE_NAME = 'PAINTING'
INFO  QueryLogger: === returned 1 row. - took 0 ms.
INFO QueryLogger: UPDATE AUTO_PK_SUPPORT SET NEXT_ID = NEXT_ID + 20 WHERE TABLE_NAME = 'PAINTING'
INFO  QueryLogger: === updated 1 row.
INFO  QueryLogger: --- will run 3 queries.
INFO QueryLogger: INSERT INTO GALLERY (ID, NAME) VALUES (?, ?) INFO QueryLogger: [bind: 200, 'Metropolitan Museum of Art'] INFO QueryLogger: === updated 1 row. INFO QueryLogger: INSERT INTO ARTIST (DATE_OF_BIRTH, ID, NAME) VALUES (?, ?, ?) INFO QueryLogger: [bind: '1881-10-25 00:00:00.0', 200, 'Pablo Picasso'] INFO QueryLogger: === updated 1 row. INFO QueryLogger: INSERT INTO PAINTING (ARTIST_ID, GALLERY_ID, ID, NAME, YEAR) VALUES (?, ?, ?, ?, ?) INFO QueryLogger: [bind: 200, 200, 200, 'The Dream', 1932] INFO QueryLogger: === updated 1 row. INFO QueryLogger: [bind: 200, 200, 201, 'Self-portrait', 1907] INFO QueryLogger: === updated 1 row.
INFO  QueryLogger: +++ transaction committed.
***** end *****

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



Reply via email to