greendao

Green Dao onUpdate. How can I add new columns to old tables?

柔情痞子 提交于 2019-12-11 14:37:32
问题 When using green dao there is some code customisation needed for updating from one schema to the next. For my earlier needs it was sufficient to add any new tables using code like this in DaoMaster.java: if(oldVersion==SCHEMA_VERSION_OLD_VERSION&& newVersion==SCHEMA_VERSION){ Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by adding language & checklist table"); boolean ifNotExists = true; NewTableDao.createTable(db, ifNotExists); NewTable2Dao

GreenDAO cannot access existed database after upgrading sqlcipher from 3.5.2 to 4.0.1

浪子不回头ぞ 提交于 2019-12-11 10:48:46
问题 I'm using GreenDAO with SQLCipher . After I upgrade SQLCipher from 3.5.2 to 4.0.1, my app cannot access the old encrypted database. I have already searched for a solution and found out that I need to run PRAGMA cipher_migrate in postKey of the SQLiteDatabaseHook to migrate my database. I tried like this, but nothing changes.: SQLiteDatabaseHook hook = new SQLiteDatabaseHook() { @Override public void preKey(SQLiteDatabase database) { } @Override public void postKey(SQLiteDatabase database) {

Clear Data From Cache Using GreenDAO

試著忘記壹切 提交于 2019-12-11 05:57:08
问题 In my app, there are 4 Activities starting from activities 1 to 4. Database creation takes place in activity1 and values are updated in activities 2, activities 3 etc.But when i moves back to activities using finish() from activities 3 to activities 2 ,it wont shown the updated value because of cache.(Cant able to show the updated value) i tried daosession.clear() ,but it is not clearing the data. So how to clear old cache and reload the data using GreenDAO . In all these activities , i used

Generate duplicate class in GreenADO in android

你离开我真会死。 提交于 2019-12-11 05:48:55
问题 why create duplicate package when generate library greenado? this is generator private static final String PROJECT_DIR = System.getProperty("user.dir"); public static void main(String[] args) { Schema schema = new Schema(1, "com.greenado.db"); schema.enableKeepSectionsByDefault(); addTables(schema); try{ DaoGenerator n=new DaoGenerator(); n.generateAll(schema,PROJECT_DIR+ "\\app\\src\\main\\java"); } catch (Exception e) { e.printStackTrace(); } } 回答1: If you are using greenDAO 3.x Comment out

greendao sessions with multiprocesses on android

不打扰是莪最后的温柔 提交于 2019-12-11 05:30:29
问题 I am working on a large project that involves many different applications communicating to the same database at the same time. I have been changing our system over to using greendao to see if it would give us performance improvements over Android ContentProvider . The question: Every time that an application needs to communicate with the database, i have it getting a new DaoSession and then performing the action. I am never re-using any DaoSessions . Would it be better if each application had

Transactions in GreenDao

可紊 提交于 2019-12-10 17:53:16
问题 I'm using GreenDao to store a lot of data, coming from a REST service . A lot of my entities are connected with relations. Everything works great, but tomorrow I have to implement a rocksolid workflow. When I load my data I have to check if an error occurs . If so, I have to make sure nothing is stored in the SQLite DB. Normally I would work with transactions and rollback in case of an exception, otherwise commit to the db. For now I just use insertordelete to save an entity, everytime I

GreenDAO: Entity is detached from DAO context

隐身守侯 提交于 2019-12-10 17:47:25
问题 I use GreenDAO. But, throws this exception: "de.greenrobot.dao.DaoException: Entity is detached from DAO context". In the generated code, i find this code. /** called by internal mechanisms, do not call yourself. */ public void __setDaoSession(DaoSession daoSession) { this.daoSession = daoSession; myDao = daoSession != null ? daoSession.getPeerGroupDao() : null; } Anyone know when the GreenDAO call it? Also, how to trigger it to call. Thanks. 回答1: I find solution. The greenDAO call _

Correct way to handle Bi directional 1:m in Green-DAO

二次信任 提交于 2019-12-10 14:12:35
问题 what is the correct way to insert a new object into a Green-DAO DB when dealing with a Bi Directional 1:m relation? Lets say, I have a chat application that has a conversation entity and a message Entity. every conversation has a list of messages, and every message has a parent conversation. what I do as of now is: Conversation conv = new Conversation(); ConversationDao.insert(conv); List<Message> list = conv.getMessageList(); Message msg = new Message(); MessageDao.insert(msg); msg.setParent

how to implement table inheritance in GreenDao

痴心易碎 提交于 2019-12-10 13:48:09
问题 I've been trying to create a database where all the tables inherit a certain element in order to have to possibility to have meta-data. there for I added in the model generator in all the table declarations this line: public Entity addSuperEntity(Schema schema) { Entity superEntity = schema.addEntity("superEntity"); superEntity.addIdProperty().primaryKey(); // SET RELATIONSHIP 1:m TO META DATA } public Entity addTable(Schema schema) { Entity mEntity = schema.addEntity("MyEntity"); mEntity

NoClassDefFoundError when trying to run DaoGenerator for GreenDAO

橙三吉。 提交于 2019-12-10 13:09:45
问题 I have an Android Project, using Android Studio 2.3, which uses GreenDAO to generate the classes to interact with the SQLite database. The DaoGenerator project always worked before... but today I just needed to add 2 columns/properties to an Entity and whenever I try to run the generator project, I get the following error: Exception in thread "main" java.lang.NoClassDefFoundError: org/greenrobot/greendao/generator/Schema at com.company.daogenerator.ProjectDaoGenerator.main(ProjectDaoGenerator