ormlite

SQL exception preparing query with ORMLite

久未见 提交于 2019-12-01 11:20:11
I am using an ORM (ORMlite) and all my calls are going well until I get the following error. Exception in thread "main" org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement " SELECT * FROM ""STORIES"" WHERE ""TITLE"" = 'Deepcut case leads 'NOT FOLLOWED[*]'' "; SQL statement: SELECT * FROM Stories WHERE title = 'Deepcut case leads 'not followed'' [42000-152] at org.h2.message.DbException.getJdbcSQLException(DbException.java:327) at org.h2.message.DbException.get(DbException.java:167) at org.h2.message.DbException.get(DbException.java:144) at org.h2.message.DbException.getSyntaxError

Android ORMLite slow create object

点点圈 提交于 2019-12-01 08:33:18
I am using ormLite to store data on device. I can not understand why but when I store about 100 objects some of them stores too long time, up to second. Here is the code from DatabaseManager: public class DatabaseManager public void addSomeObject(SomeObject object) { try { getHelper().getSomeObjectDao().create(object); } catch (SQLException e) { e.printStackTrace(); } } } public class DatabaseHelper extends OrmLiteSqliteOpenHelper public Dao<SomeObject, Integer> getSomeObjectDao() { if (null == someObjectDao) { try { someObjectDao = getDao(SomeObject.class); } catch (Exception e) { e

Problems with escaping table and field names in Derby and Hsqldb

◇◆丶佛笑我妖孽 提交于 2019-12-01 06:56:29
I'm having a problem with my ORMLite package . When I generate the schema for a table, I thought it would be a good practice to escape all entity names. This would protect some Java class or field name from being a SQL reserved word: CREATE TABLE "footable" ("stuff" VARCHAR(255)) I'm now adding "raw" query support so that ORMLite can help users perform their own queries. However, I find that with Derby and Hsqldb, the entity names cannot be used without escaping. For example, the following query: SELECT * FROM footable generates the following errors: Derby: ERROR 42X05: Table/View 'FOOTABLE'

RoboSpice persist JSON array with OrmLite

删除回忆录丶 提交于 2019-12-01 06:05:14
I'm using RoboSpice with Spring for Android and would like to persist a JSON array of objects with OrmLite. GSON is used for the JSON marshalling. With the default caching everything works as expected. But OrmLite doesn't seem to like the array of objects. This is a simplified version of the JSON: [{"id": 1, "title": "Test 1"},{"id": 2, "title": "Test 3"},{"id": 3, "title": "Test 3"}] I would like to persist this in the following object: @DatabaseTable public class Foo { @DatabaseField(id = true) private int id; @DatabaseField private String title; // getters and setters ... } Based on the

ORMLite Select Distinct Fields

泪湿孤枕 提交于 2019-12-01 05:55:49
I have a SQLite table (on Android) that has numerous fields, but certain fields are repeated/denormalized. I would like to select a distinct set of this data and use them as actual objects. Example books table title summary author Little Johnny A funny kid Johnny Himself Big Johnny A funny adult Johnny Himself I would like to extract one author from this list ("Johnny Himself") and would expect I should be able to do this with ORMLite instead of manually with Java. I would like to select a distinct set of this data and use them as actual objects. I'm not 100% sure I understand your query here

Problems with escaping table and field names in Derby and Hsqldb

点点圈 提交于 2019-12-01 05:08:37
问题 I'm having a problem with my ORMLite package. When I generate the schema for a table, I thought it would be a good practice to escape all entity names. This would protect some Java class or field name from being a SQL reserved word: CREATE TABLE "footable" ("stuff" VARCHAR(255)) I'm now adding "raw" query support so that ORMLite can help users perform their own queries. However, I find that with Derby and Hsqldb, the entity names cannot be used without escaping. For example, the following

Thousands of ORMLite raw inserts taking several minutes on Android

∥☆過路亽.° 提交于 2019-12-01 04:23:50
I'm trying to pre-populate an Android SQLite database using ORMLite. The problem is that this operation is too slow. It takes several minutes. The code below show how it happens. RuntimeExceptionDao<Company, Integer> companyDao = ORMLiteHelper.getInstance(context).getCompanyRuntimeDao();AssetManager am = context.getAssets(); try { InputStream instream = am.open("companies.sqlite"); if (instream != null) { InputStreamReader inputreader = new InputStreamReader(instream); BufferedReader buffreader = new BufferedReader(inputreader); String line; try { while ((line = buffreader.readLine()) != null)

Ormlite - Constructor call failing when BaseDaoImpl is extended

那年仲夏 提交于 2019-12-01 04:18:14
问题 I have the following tables - @DatabaseTable(tableName="b", daoClass=B_DaoImpl.class) public class B { @DatabaseField public String b1 ; public B(){ // For Ormlite } } @DatabaseTable(tableName="a", daoClass=A_DaoImpl.class) public class A { @DatabaseField public String a1 ; @DatabaseField(foreign=true) public B b; public A(){ // For Ormlite } } For these tables, the associated Dao and DaoImpl are as follows public interface A_Dao extends Dao<A, String>{} public interface B_Dao extends Dao<B,

Decrease ORMlite's internal log verbosity or disable it

人走茶凉 提交于 2019-12-01 04:18:01
We're doing some heavy performance tuning in our app, hence we start using method tracing to find the bottlenecks. At first glance Ormlite was fine, but we found that for example in one query that takes 8ms, 6ms (75%) were needed by Ormlite's internal log. Futhermore those log call are in DEBUG level. At the moment I have tried (without success) setting log level to ERROR this way: with adb: adb shell setprop log.tag.ORMLite ERROR with logback: <logger name="com.j256.ormlite" level="ERROR"/> This are a few lines from the logcat I/System.out( 4207): 2014-10-01 10:50:14,702 [DEBUG]

Thousands of ORMLite raw inserts taking several minutes on Android

让人想犯罪 __ 提交于 2019-12-01 02:33:07
问题 I'm trying to pre-populate an Android SQLite database using ORMLite. The problem is that this operation is too slow. It takes several minutes. The code below show how it happens. RuntimeExceptionDao<Company, Integer> companyDao = ORMLiteHelper.getInstance(context).getCompanyRuntimeDao();AssetManager am = context.getAssets(); try { InputStream instream = am.open("companies.sqlite"); if (instream != null) { InputStreamReader inputreader = new InputStreamReader(instream); BufferedReader