Opened 10 years ago

Closed 10 years ago

#706 closed task (fixed)

Update LabEnv to use BASE database capabilties instead of SQLite

Reported by: Nicklas Nordborg Owned by: Nicklas Nordborg
Priority: major Milestone: LabEnv v1.3
Component: net.sf.basedb.labenv Keywords:
Cc:

Description (last modified by Nicklas Nordborg)

The LabEnv extension currently uses an SQLite database for storing measurements.

BASE 3.4 will include a new feature that allows extensions to get access to part of the database for their own storage needs. See http://base.thep.lu.se/ticket/1892

I think we should drop the SQLite implementation and switch to what BASE provides.

Basically this means we use Hibernate and HQL and configure the LabEnvironmentData and an @Entity and then replace SQLite-related functionality in LabEnvironmentStorageUtil class to use Hibernate instead.

It would also be nice if we could automatically import the existing SQLite database to BASE automatically. But this means we will need to keep SQLite around for an extra release.

Change History (10)

comment:1 by Nicklas Nordborg, 10 years ago

Description: modified (diff)

comment:2 by Nicklas Nordborg, 10 years ago

Description: modified (diff)

comment:3 by Nicklas Nordborg, 10 years ago

Milestone: LabEnv v1.3LabEnv v1.x

comment:4 by Nicklas Nordborg, 10 years ago

Milestone: LabEnv v1.xLabEnv v1.3
Owner: changed from olle to Nicklas Nordborg
Status: newassigned

comment:5 by Nicklas Nordborg, 10 years ago

(In [3014]) References #706: Update LabEnv to use BASE database capabilties instead of SQLite

Moving around some of the existing code so that it is possible to get access to the ServiceSessionControl that is supplied by BASE.

comment:6 by Nicklas Nordborg, 10 years ago

(In [3017]) References #706: Update LabEnv to use BASE database capabilties instead of SQLite

Adding entity class SensorData which is the bridge between objects and the database. It is mapped with Java Persistence API annotations that are read by Hibernate and converted to a database table.

The LabEnvironment.start() method uses the supplied ServiceSessionControl from BASE to configure the mapping to the database and create whatever is needed in the "labenv" schema.

The LabEnvironmentStorageUtil.updateLabEnvDb() method has been updated to use a SensorData instance and save that to a Hibernate session instead of using direct SQL.

NOTE! There is currently no transfer of values from an existing SQLite database to PostgreSQL and the query functionality is still on SQLite.

comment:7 by Nicklas Nordborg, 10 years ago

(In [3018]) References #706: Update LabEnv to use BASE database capabilties instead of SQLite

The LabEnvironmentStorageUtil.queryLabEnvDb() method has been updated to query with Hibernate and SensorData instead of SQLite. For compatibility reasons it still returns LabEnvironmentData objects.

comment:8 by Nicklas Nordborg, 10 years ago

(In [3021]) References #706: Update LabEnv to use BASE database capabilties instead of SQLite

Added LabEnvironmentStorageUtil.migrateIfOldDataExists() method which will migrate existing data from an SQLite database. If the migration is successful, the database file is deleted.

comment:9 by Nicklas Nordborg, 10 years ago

(In [3022]) References #706: Update LabEnv to use BASE database capabilties instead of SQLite

Updated installation documentation.

Delayed the migration so that it takes place the first time the scheduled timer is run. It takes about 30 seconds to process the current production database.

Migraion progress is now written directly to stdout since the logger is most likely configured to not write INFO-level messages.

comment:10 by Nicklas Nordborg, 10 years ago

Resolution: fixed
Status: assignedclosed

Have tested this for some time now and it seems to be ok.

Note: See TracTickets for help on using tickets.