ormlite

ORMLite column with default

99封情书 提交于 2019-12-24 20:12:52
问题 I have a non null column defined with a default: @DatabaseField(dataType = DataType.TIME_STAMP, columnDefinition = "DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL") private Date createdDate; When trying to save a row with the createdDate field unset, I get the following error: [SQLITE_CONSTRAINT_NOTNULL] A NOT NULL constraint failed (NOT NULL constraint failed: ORMLite is probably trying to explicitly insert a NULL value into the field. Adding persisted = false to the annotation avoids this, but

ORMLite IllegalStateException when there are many records

旧巷老猫 提交于 2019-12-24 13:35:12
问题 I am using a queryBuilder with a where to do a select. It’s a table of POJOs and in general has been working well for many users for a long period of time. ArrayList<X> result = new ArrayList<X>(); QueryBuilder<X, Integer> queryBuilder = getXDao().queryBuilder(); Where<X, Integer> where = queryBuilder.where(); where.eq(X, x); queryBuilder.orderBy(X, true); result = (ArrayList<X>)getXDao().query(queryBuilder.prepare()); There is one particular who crashes every time they query this table due

How can I improve this method of loading objects with ORMLite on Android?

筅森魡賤 提交于 2019-12-24 02:25:23
问题 I am loading a set of objects (and their foreign objects) using ormlite 4.35 on Android. It takes (in the emulator) between 16 and 19 seconds for the timing in the getAllCragsWithLocation() method below. There are 590 Crags in the database and 40 don't have a location. There are several lines logged such as 03-19 11:03:54.441: I/dalvikvm(1156): Jit: resizing JitTable from 1024 to 2048 03-19 11:03:55.531: D/dalvikvm(1156): GC_CONCURRENT freed 544K, 37% free 5174K/8199K, external 731K/1109K,

dbhelper , ORMLite and fragments issues

萝らか妹 提交于 2019-12-23 18:56:31
问题 I've got problem with my database. Application sends link written by user and in response get short form of the link (that works fine). In my database I need to put both versions of the link - full , and short one and here we have a problem. I got error like this : java.lang.IllegalStateException: Could not construct instance of helper class class pl.bartos.task.DatabaseHelper at com.j256.ormlite.android.apptools.OpenHelperManager.constructHelper(OpenHelperManager.java:222) at com.j256

ORMLite not loading child foreign fields

别来无恙 提交于 2019-12-23 06:55:09
问题 I'm using ORMLite 4.42 for an Android app. I have an entity wich has foreign fields. These fields have foreign fields too. The problem is that when i get an element of the root entity, only the first level of foreign fields are loaded. The others levels are null. On the database every seems ok. The id is correct. Any help? Edit with models . The Equipment model is always null qhen I query by ID. But if I query the whole table, then it gives me access to everything. TABLE INCIDENT

OrmLite - save data before table upgrade

China☆狼群 提交于 2019-12-23 03:38:27
问题 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. 回答1: 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

Android OrmLite pre-populate database

隐身守侯 提交于 2019-12-22 04:45:08
问题 Is it possible with OrmLite to create a sql script file to easily populate the database with data? I did some searching and couldn't come up with anything easy. I know I can create some objects with data, I'm just looking for a cleaner method. I'm thinking create a script file, open a a reader at load, and process each file as raw SQL the executeRaw() method. Any thoughts? 回答1: Good one Joe. I think your idea of the executeRaw() is close but use updateRaw() instead. Update handles INSERT ,

How to do multiple column unique-constraint in ormlite ( SQLite )

别等时光非礼了梦想. 提交于 2019-12-22 04:32:16
问题 I'm using ormlite for Android and I'm trying to get a multiple column unique-constraint. As of now i'm only able to get a unique constraint on indiviudal columns like this: CREATE TABLE `store_group_item` (`store_group_id` INTEGER NOT NULL UNIQUE , `store_item_id` INTEGER NOT NULL UNIQUE , `_id` INTEGER PRIMARY KEY AUTOINCREMENT ); and what I want is CREATE TABLE `store_group_item` (`store_group_id` INTEGER NOT NULL , `store_item_id` INTEGER NOT NULL , `_id` INTEGER PRIMARY KEY AUTOINCREMENT,

Having a list of strings represented in a database using ORMLite

对着背影说爱祢 提交于 2019-12-21 20:44:44
问题 First of I am new to ORMLite. I would like my model class to have a field which is a list of strings, that would eventually hold a list of tags for my model object. Which ORMLite annotations should I use? Firstly I don't want to have a table of all tags, and then use the @ForeignCollectionField . Also I thought of using the @DatabaseField(dataType=DataType.SERIALIZABLE) annotation, but it turns out that List<String> doesn't implement the Serializable interface. What are your suggestions? 回答1:

ORMLITE ORDER_BY with multiple columns

本小妞迷上赌 提交于 2019-12-21 07:05:00
问题 I am using ormlite in my recent android project. I want to order by on a query on multiple columns in a table (say two columns). How can I achieve that?? Here is the code for a single order by... QueryBuilder<Visit, Integer> qb = getHelper().getVisitDao().queryBuilder(); qb.where().eq("FOREIGN_ID", id); qb.orderBy("VISIT_DATE", false); 回答1: I want to order by on a query on multiple columns in a table(say two columns). How can i achieve that?? All you need to do is to call orderBy(...)