ormlite

Can not find deserialize for non-concrete Collection type

喜欢而已 提交于 2019-11-29 16:40:13
I'm using the jackson library to map JSON into objects. I've simplified the problem a lot , this is what happens: public class MyObject{ public ForeignCollection<MySecondObject> getA(){ return null; } public ForeignCollection<MyThirdObject> getB(){ return null; } } I'm parsing the an empty JSON string: ObjectMapper mapper = new ObjectMapper(); mapper.readValue("{}", MyObject.class); On readValue , I get this Exception: com.fasterxml.jackson.databind.JsonMappingException: Can not find a deserializer for non-concrete Collection type [collection type; class com.j256.ormlite.dao.ForeignCollection,

createOrUpdate() always creates a new entry in the database with ORMLite

时光毁灭记忆、已成空白 提交于 2019-11-29 12:16:26
问题 In my Android project, ORMLite is functioning as a cache. I'm downloading data from a web server and placing it in the database. I'm calling createOrUpdate on my objects, but duplicates are appearing in the database. The database entries are identical except for the primary key (which is simply an auto incremented integer). I think that since my second object doesn't yet have a primary key, ORMLite considers the two as being different, even though every other field is identical. Does anyone

Creating foreign key constraints in ORMLite under SQLite

时光毁灭记忆、已成空白 提交于 2019-11-29 12:01:53
问题 As it is not possible to add foreign keys using an "ALTER TABLE" statement in SQLite, I am stuck on how to configure my database to enforce valid foreign keys, or perform cascaded deletes without explicit code overhead. Anybody got an idea how to accomplish this with ORMLite under SQLite? 回答1: how to configure my database to enforce valid foreign keys, or perform cascaded deletes without explicit code overhead. ORMLite supports a columnDefinition="..." field in the @DatabaseFiled annotation

Ormlite DAO in android getting really slow when querying more than few thousand results

被刻印的时光 ゝ 提交于 2019-11-29 08:43:14
Have a problem with querying data via Ormlite DAO, when there are few thousand results. Code: List<Point> pl = db.getPointsDAO().queryBuilder().where(). eq("route_id", croute).query(); When I want to get a large list of points List<Point> pl for current Route croute I have to wait like 40 sec for 40.000 points. where Point.class is: @DatabaseTable(tableName = "points") public class Point extends BaseEntity { @DatabaseField(generatedId = true) private Integer point_id; @DatabaseField(canBeNull = false) ... @DatabaseField(canBeNull = false) private Double dose; @DatabaseField(dataType=DataType

Application crash with “android.app.Application cannot be cast to”

你。 提交于 2019-11-29 07:17:37
I'm disovering ORMlite. So, I have this DAO Factory class public class DtoFactory extends Application { private SharedPreferences preferences; private DatabaseHelper databaseHelper = null; private Dao<ReleveEntity, Integer> releveDAO = null; @Override public void onCreate() { super.onCreate(); preferences = PreferenceManager.getDefaultSharedPreferences(this); databaseHelper = new DatabaseHelper(this); } public SharedPreferences getPreferences() {return preferences;} public Dao<ReleveEntity, Integer> getReleveDao() throws SQLException, java.sql.SQLException { if (releveDAO == null) { releveDAO

Multiple, combined OR conditions in ORMLite

杀马特。学长 韩版系。学妹 提交于 2019-11-29 06:13:42
I like to have a query like this: select data from table where (x > 1 and x < 100) or (x > 250 and x < 300) In ORMlite, that's possible using this code: final QueryBuilder<Data,Integer> qb = queryBuilder(); final Where<Data, Integer> w = qb.where(); w.or( w.gt("x", 1).and().lt("x", 100), w.gt("x", 250).and().lt("x", 300) ) While thats great if one knows the conditions beforehand & at the time of coding, I need the conditions to be dynamically added. Basically that method public com.j256.ormlite.stmt.Where<T,ID> or(com.j256.ormlite.stmt.Where<T,ID> left, com.j256.ormlite.stmt.Where<T,ID> right,

What is the best way to implement many-to-many relationships using ORMLite?

不羁岁月 提交于 2019-11-29 02:13:21
问题 I'm currently playing with ORMlite to make a model with tables and relationships. One relationship is a many-to-many relationship. What's the best way to implement that? To be more concrete: Let's say I've got these two tables Product id brand Purchase id A purchase can have several products and one products can be in several purchases. Using ORMLite I could have a @ForeignCollectionField in each model but I don't think it would work. The only valid solution I see is to make a third table

JavaFX, Casting ArrayList to ObservableList

不问归期 提交于 2019-11-28 22:03:28
问题 Is there a way to cast ArrayList to ObservableList ? I would like to do it without iterating through ArrayList . To be more specific, I am using ORMLite to get data from database, and I need ObservableList as an output of the method fetching data from DB. Currently I am doing something like this: ArrayList<Stavka> listStavaka = new ArrayList<>(); Dao<Stavka, Integer> stavkaDao = DaoManager.createDao(connection, Stavka.class); listStavaka = (ArrayList<Stavka>) stavkaDao.queryForAll();

Collections in ORMLite

痞子三分冷 提交于 2019-11-28 21:52:16
Hello I want persist some collections data with ORMlite in my android app. For example : class Person { @DatabaseField(generatedId=true) private int id; @DatabaseField private String name; @DatabaseField private String surname; @ForeignCollectionField private Collections<Phone> phones; } class Phone { @DatabaseField(generatedId=true) private int id; @DatabaseField private String number; @DatabaseField private String type; } How i should do it to persist this collection. EDIT I use ForeignCollectionField as you told me. But now i have another question - is possible construction like that (I

Green DAO vs ORM lite vs Active Android [closed]

拈花ヽ惹草 提交于 2019-11-28 16:24:49
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . Which is the best ORM tool available for Android? I am seeing ORMlite and ActiveAndroid are the most discussed across and a friend of