ormlite

Why ormlite has its own annotations?

北城以北 提交于 2019-12-08 20:47:28
From what I see in ormlite it has implemented its annotations as well as JPA standard annotations. First of all, what was the reason of designing new set of annotations? Secondly, how one can use standard annotation like @Entity , etc instead of ormlite specific annotations. Right now, I am getting not defined error for those entities. Do I need a jar file? DataNucleus Because it isn't a real JPA implementation, and just makes use of JPA annotations for convenience. Obviously, by using it, you lose the portability offered by JPA itself, but then it may have some advantages for very specific

CursorWindowAllocationException in standard ORMLite method

你说的曾经没有我的故事 提交于 2019-12-08 17:39:54
问题 I need save some objects in DB. I'm using this code in my Dao class. public void saveActions(List<Action> actionList) throws SQLException { for (Action action : actionList) { createOrUpdate(action); } } And sometimes I have CursorWindowAllocationException in createOrUpdate() function. Here is stacktrace of error. java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:300) at java.util.concurrent.FutureTask.finishCompletion

App on release crashes, while on debug doesn't

六月ゝ 毕业季﹏ 提交于 2019-12-08 17:36:14
问题 I'm developing an app using Android Studio, and when I switched from debug to release build variant, it began to crash. While on debug it doesn't happen anything at all. The real problem is that I can't find where is the true error, as every reference is renamed. Have you faced an error like this, that has happened only on release ? The printed stack is this: 04-11 08:28:42.756 5997-5997/com.korcholis.clothio E/ActivityThread﹕ Failed to inflate android.view.InflateException: Binary XML file

OrmLite - save data before table upgrade

醉酒当歌 提交于 2019-12-08 17:32:31
It is possible to save the data from a table before my model changes the database? For example i rename a column and will not lose the data. So i.e. i want to fetch all data from column c1, rename my column to c2 and write all data back. i want to fetch all data from column c1, rename my column to c2 and write all data back. Sqlite does not support the renaming of columns so this will not work under Android. You can certainly add an additional column however. There is some good documentation on schema changes under Android/ORMLite. See this page: http://ormlite.com/docs/upgrade-schema For

ORMLite query date format issue

我与影子孤独终老i 提交于 2019-12-08 14:32:20
I want to convert sqlite query to Ormlite query. SELECT * FROM Test where strftime('%m-%Y',Date)='11-2001' I could not format date column like above query. How to format Date column in Ormlite as MM-yyyy ? Thanks. If that is the exact SQL that you want to use then you can use the Where.raw(...) method: QueryBuilder<Test, Integer> qb = testDao.queryBuilder(); qb.where().raw("strftime('%m-%Y',Date) = '11-2001'"); List<Test> results = qb.query(); However, this only seems to work if the date field is stored as a DATE_STRING type: @DatabaseField(dataType = DataType.DATE_STRING) Date date; The issue

How to use Dao.setAutoCommit()?

耗尽温柔 提交于 2019-12-08 13:46:34
问题 I'm parsing JSON from a server, using ORMLite to persist objects to the database as I read them out. The files could get very large, so my thought is to commit objects one at a time as they are read, instead of reading hundreds of objects into memory and doing a mass commit (memory being scarce on smartphones, after all). However, each object will contain a collection with multiple values (I am attempting to use ForeignCollection for those values, so each value needs to be treated as a

How can I use OrmLite with Android's default SQLite

江枫思渺然 提交于 2019-12-08 08:54:16
问题 I have a big problem using the default SQLite database via JDBC driver.I would like to use ORMLite with this.Let me expose my code: String databaseUrl = "jdbc:sqlite:/data/data/my.package.name/db.sqlite"; Class.forName("SQLite.JDBCDriver"); DriverManager.getConnection(databaseUrl); dataSource = DatabaseTypeUtils.createSimpleDataSource(databaseUrl); databaseType = DatabaseTypeUtils.createDatabaseType(dataSource); databaseType.loadDriver(); UpDao = new UserProfileJdbcDao(databaseType); UpDao

ORMLite query date format issue

时光总嘲笑我的痴心妄想 提交于 2019-12-08 08:24:33
问题 I want to convert sqlite query to Ormlite query. SELECT * FROM Test where strftime('%m-%Y',Date)='11-2001' I could not format date column like above query. How to format Date column in Ormlite as MM-yyyy ? Thanks. 回答1: If that is the exact SQL that you want to use then you can use the Where.raw(...) method: QueryBuilder<Test, Integer> qb = testDao.queryBuilder(); qb.where().raw("strftime('%m-%Y',Date) = '11-2001'"); List<Test> results = qb.query(); However, this only seems to work if the date

Why ormlite has its own annotations?

独自空忆成欢 提交于 2019-12-08 06:27:58
问题 From what I see in ormlite it has implemented its annotations as well as JPA standard annotations. First of all, what was the reason of designing new set of annotations? Secondly, how one can use standard annotation like @Entity , etc instead of ormlite specific annotations. Right now, I am getting not defined error for those entities. Do I need a jar file? 回答1: Because it isn't a real JPA implementation, and just makes use of JPA annotations for convenience. Obviously, by using it, you lose

How to get ForeignCollection Field into Cursor in Ormlite

怎甘沉沦 提交于 2019-12-08 05:22:45
问题 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,