ormlite

How to get ForeignCollection Field into Cursor in Ormlite

牧云@^-^@ 提交于 2019-12-08 04:16:20
I have a ForeignCollection field in my table below : @DatabaseTable(tableName = "json_main") public class JsonMain { @DatabaseField( id = true) int _id; @DatabaseField int likes_count; @DatabaseField String protected_visibility; @ForeignCollectionField ForeignCollection<JsonUser> jsonUser = null; } And Reference of this table here : @DatabaseTable (tableName = "json_main_user") public class JsonUser { @DatabaseField(generatedId = true) public int _id; @DatabaseField(foreign = true, foreignAutoRefresh = true, columnName = "parent_id") private JsonMain jsonMain; } I'm Building My Query to get

Better pattern to handle DAO creation for POJO using SQLite

血红的双手。 提交于 2019-12-08 03:33:03
问题 I'm working on an Android App that use SQLCipher , ORMLite for Android to handle to POJO storing with SQLite and Jackson for parsing. I'm wondering if there would be a better pattern that the one i'm using (Recommended by stayforit) to get the DAO corresponding to the Entity class given. I have over 30 Entity class and I keep adding some over the time and each time, I have to create a DAO class that looks exactly the same as the previous one. How could I generalize using a generic class? Here

Save a list of objects to ORMLite database

你说的曾经没有我的故事 提交于 2019-12-08 02:54:09
问题 I am looking for a way to save a list of objects to the database with ORMLite and read upon this question: Best way to store several ArrayLists in ORMLite for ApplicationSettings And the accepted answer makes sense to me: public class YourClass { @GeneratedId private int id; @ForeignCollectionField private Collection<MyString> bunchOfStrings = new ArrayList<MyString>(); } public class MyString{ @DatabaseField(canBeNull = true, foreign = true) private YourClass yourClass; @DatabaseField

Cannot make a LazyForeignCollection become eager collection

。_饼干妹妹 提交于 2019-12-08 02:53:54
问题 I'm getting this error when trying to read a foreign collection from my POJO AndroidRuntime(589): Caused by: java.lang.IllegalStateException: Internal DAO object is null. Lazy collections cannot be used if they have been deserialized. The offending collection is answers1 which i have marked as 'eager' @ForeignCollectionField (eager=true) private ForeignCollection<TextAnswer> answers1; Why then when I debug the method below public List<TextAnswer> getAnswers() { return new ArrayList<TextAnswer

ORMLite - Parenthesis in join where clauses

百般思念 提交于 2019-12-07 18:52:15
问题 I would like to join three tables using QueryBuilder.join and QueryBuilder.joinor but I want parenthesis in the where clause something like this: WHERE first_table_where AND (second_table_where OR third_table_where) but it seems that is not possible. Perhaps I am missing something. Any help would be appreciated. 回答1: I guess that is a part of the doc you have been looking for... If you want to do complex queries linearly, you can even use Reverse Polish Notation (of all things). There is a

Storing List of objects using DataType.SERIALIZABLE in ormlite android

我们两清 提交于 2019-12-07 13:26:11
问题 How to save an ArrayList using ORMlite in android my model is as follows class Model{ @DatabaseField public String type = ""; @DatabaseField public String name = ""; @DatabaseField public Date dateTime = null; @DatabaseField ArrayList<Item> items = null; } And Item class has class Item{ @DatabaseField String itemName; ... } I am getting the following exception : java.sql.SQLException: ORMLite can't store unknown class class java.util.ArrayList for field 'items'. Serializable fields must

(Gradle and OrmLite config) How to add resource file after Java has been compiled but before .apk is generated?

﹥>﹥吖頭↗ 提交于 2019-12-07 09:56:56
问题 NOTE: I have already accepted an answer and awarded the bounty, BUT, have in the end decided that my approach to this issue was far from optimal. After further thought I have come to the conclusion that modifying the .apk during the build process is probably not the safest or most sustainable way to accomplish this and keep it working long term. I have added an alternative approach to the very bottom of this question, which accomplishes the same thing in the end. This approach I opted to use

Releasing ORMLite helper on @Singleton

大城市里の小女人 提交于 2019-12-07 07:23:51
问题 I have a @Singleton class where I've injected an instance of OrmLiteSqliteOpenHelper . Do I actually ever need to call the OpenHelperManager.releaseHelper() ? In case I do, where and how should it be done as the class doesn't extend any Android base class where I could get to the onDestroy ? 回答1: There is an ORMLite example Android project which demonstrates this called HelloAndroidNoBase. I'd check it out. The relevant code section from the main Activity is included below. You'll need to

Obfuscating ORMLite model classes with Proguard

纵饮孤独 提交于 2019-12-07 06:13:48
问题 I have a few models that I want to obfuscate in my code. I know that I could just ignore the whole model package but I don't want to do that. I tried a few proguard tweaks and checked all relevant posts to no avail. ORMlite keeps throwing java.lang.RuntimeException: Unable to create application ...App: java.lang.IllegalArgumentException: Foreign field class ....f.p does not have id field . I checked that the annotation is still there with dex2jar and jd, and it is still there. I have this

Ormlite Android bulk inserts

こ雲淡風輕ζ 提交于 2019-12-06 22:35:23
问题 can anyone explain why my inserts are taking so long in Ormlite? Doing 1,700 inserts in one sqlite transaction on the desktop takes less than a second. However, when using Ormlite for Android, it's taking about 70 seconds, and I can see each insert in the debugging messages. When I try and wrap the inserts into one transaction it goes at exactly the same speed. I understand that there is overhead both for Android and for Ormlite, however, I wouldn't expect it to be that great. My code is