sugarorm

SugarORM error or missing database

拈花ヽ惹草 提交于 2019-12-10 23:09:35
问题 I have tried to get an Android Project working with SugarORM. However, I am running into the following error: Caused by: android.database.sqlite.SQLiteException: no such table: DOCUMENT (code 1): , while compiling: INSERT OR REPLACE INTO DOCUMENT(ID,CREATED) VALUES (?,?) ################################################################# Error Code : 1 (SQLITE_ERROR) Caused By : SQL(query) error or missing database. (no such table: DOCUMENT (code 1): , while compiling: INSERT OR REPLACE INTO

Parsing a String id with SugarORM and GSON

喜你入骨 提交于 2019-12-10 02:21:31
问题 I'm using GSON to create a SugarRecord object from a json response. The API I'm using returns a field called "id", but the type of "id" is a string, not a long (the backend is using mongo). Below is the code I'm using: Gson gson = new Gson(); // Or use new GsonBuilder().create(); NutritionPlan target = gson.fromJson(jsonObject.getJSONObject("nutrition_day").toString(), NutritionPlan.class); Below is my json response: { "nutrition_day": { "id": "5342b4163865660012ab0000", "start_on": "2014-04

Sugar ORM for Android cant find my column name

╄→尐↘猪︶ㄣ 提交于 2019-12-09 05:44:09
问题 Well I'm trying to select all entities where entitie_id = *some id* I do this with this rule: List<NodeSugar> nodesugars = NodeSugar.find(NodeSugar.class, "entitie_id = ? ", String.valueOf(nodeid)); I know I should get some results back and I get an error. this error: E/SQLiteLog﹕ (1) no such column: entitie_id I know the column exists because I can set it in a different part of code. Where am I going wrong? 回答1: You should be able to query with "entitieid". Sugar ORM does some conversion

SugarORM query from multiple tables?

旧城冷巷雨未停 提交于 2019-12-07 16:11:57
问题 I am using SugarORM for my Android application. In my project I have couple of tables and I was wondering is there a way to to join them into another Class Object that has columns from multiple tables? If yes, then example would be very helpful. 回答1: SugarORM provides a Query Builder object for simple queries. Since it doesn't provide supporto for joins, you can directly execute a raw query and store the result into an object created ad-hoc. So, build your custom raw query renaming the fields

Retrofit data persistence

不羁的心 提交于 2019-12-06 15:20:15
问题 How do I persist the data that has been parsed from the server using Retrofit library. So that users can view it when there is no internet connection. final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.post_recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(this)); ApiInterface apiService = ApiClient.getClient().create(ApiInterface.class); Call<ArrayList<Post>> call = apiService.getAllPosts(); call.enqueue(new Callback<ArrayList<Post>>() { @Override public

SugarORM query from multiple tables?

泄露秘密 提交于 2019-12-05 18:21:19
I am using SugarORM for my Android application. In my project I have couple of tables and I was wondering is there a way to to join them into another Class Object that has columns from multiple tables? If yes, then example would be very helpful. SugarORM provides a Query Builder object for simple queries. Since it doesn't provide supporto for joins, you can directly execute a raw query and store the result into an object created ad-hoc. So, build your custom raw query renaming the fields in the SELECT part CustomOBJ.executeQuery("SELECT tableA.fieldA as field1, tableA.fieldB as field2, tableB

Persisting objects in SugarORM

有些话、适合烂在心里 提交于 2019-12-04 05:54:52
问题 I have a Book class: public class Book extends SugarRecord { private String mBookName; private String mAuthorName; private List<Page> mPageList; public Book() { } public Book(String bookname, String authorName) { mBookName = bookname; mAuthorName = authorName; mPageList = new ArrayList<>(); } public String getAuthorName() { return mAuthorName; } public void setAuthorName(String authorName) { mAuthorName = authorName; } public String getBookName() { return mBookName; } public void setBookName

Persisting objects in SugarORM

◇◆丶佛笑我妖孽 提交于 2019-12-02 08:46:26
I have a Book class: public class Book extends SugarRecord { private String mBookName; private String mAuthorName; private List<Page> mPageList; public Book() { } public Book(String bookname, String authorName) { mBookName = bookname; mAuthorName = authorName; mPageList = new ArrayList<>(); } public String getAuthorName() { return mAuthorName; } public void setAuthorName(String authorName) { mAuthorName = authorName; } public String getBookName() { return mBookName; } public void setBookName(String bookName) { mBookName = bookName; } public void addPage(Page page) { mPageList.add(page); } }

retrofit and orm library throw StackOverflow

空扰寡人 提交于 2019-12-02 04:40:39
I try to use 2 libraries: square/Retrofit - Rest client satyan/sugar - db orm retrofit use gson , so do class public class Book{ String name; public Book(String name) { this.name = name; } } ok, retrofit succesfully get data from server and put in our Book class. now i want save this data. for use orm need extend parent class public class Book extends SugarRecord<Book>{ String name; public Book(String name) { this.name = name; } } but after extend the parent class, retrofit cannot parse json. so we get an error: java.lang.RuntimeException: An error occured while executing doInBackground() ...

Testing with SugarORM and Robolectric

↘锁芯ラ 提交于 2019-12-01 09:24:59
I trying to setup an testing environment for my android project. The basic Robolectric setup is done. I used this nice tutorial . If I comment out SugarORM in my Manifest.xml, all test works fine. But If I want to use it with SugarORM I always get this error: java.lang.NullPointerException at dalvik.system.DexFile$DFEnum.hasMoreElements(DexFile.java:239) at com.orm.SugarDb.getDomainClasses(SugarDb.java:37) at com.orm.SugarDb.createDatabase(SugarDb.java:104) at com.orm.SugarDb.onCreate(SugarDb.java:100) at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252) at