Grails throws Table “xxx” not found

后端 未结 2 755
野的像风
野的像风 2020-12-21 13:20

In Grails I can create domain objects to a H2 in memory dataSource in BootStrap and get results back ok, but once the app is up (eg query from GSP or contro

相关标签:
2条回答
  • 2020-12-21 13:53

    H2 closes the database when the last connection is closed. For an in-memory database, closing the connection means the data is lost...

    So if you keep one connection open all the time, then you should be fine. You could call this a 'sentinel' connection.

    Another option is to use a persistent database (database URL jdbc:h2:~/test/app_data;MVCC=TRUE)

    0 讨论(0)
  • 2020-12-21 13:55

    most inmemory database tie the database to the connection used. Hibernate opens a connection for each session so only the session with the SchemaExport has the database with the correct schema and is disposed immediatly. to solve this you have to use the same connection for all sessions which access the inmemory database.

    connection = session.getConnection();
    
    sessionfactory.openSession(connection);
    
    0 讨论(0)
提交回复
热议问题