ormlite

Using enum property as ormlite column value instead of ordinal. is it possible?

落花浮王杯 提交于 2019-12-06 16:10:15
@DatabaseField(dataType=DataType.ENUM_STRING,columnName=TIPO_FIELD_NAME) private TipoPedido tipo; public enum TipoPedido { REGISTARNOTIFICACAORESPOSTA("Registar Notificação Resposta",SIGLA_TIPO_REGISTARNOTIFICATIORESPOSTA); private String tipoName; private String tipoValue; TipoPedido(String tipoName,String tipoValue){ this.tipoName=tipoName; this.tipoValue=tipoValue; } public String getTipoName(){ return tipoName; } public String getTipoValue(){ return tipoValue; } } Is it possible to use the tipoValue enum property as the value for the column instead of the ordinal? Edit:here's what i did:

Android SQLite相关框架工具

*爱你&永不变心* 提交于 2019-12-06 14:48:57
我是一个Android新手,以前做的Web应用,公司需要,我转了Android,最近发现SQLite数据库代码开发工作量很大,颠来倒去就是创建表、删除表、查询、更新等操作,所以想找个工具(像Hibernate Tool)可以直接生成表对象(Dao)以及查询更新操作(方法)。去百度了一下找到了一下三种jar包: <1>androiddataframework http://code.google.com/p/androiddataframework/ <2>ormlite http://ormlite.com/sqlite_java_android_orm.shtml <3>AHibernate http://www.cnblogs.com/zlja/archive/2012/04/13/2446561.html 由于我先看的第二个ormlite,那就先说ormlite,后续会补上androiddataframework和AHibernate。 Ormlite ormlite的最新jar包可以从上面的下载,我从这个网页上了解一下ormlite的相关知识,总结如下: <1>对于Android开发来说需要下载ormlite-android-4.45.jar and ormlite-core- 4.45.jar,运行环境要求是JDK1.5以上 <2>此工具不能自动Model

数据持久化框架(ORMLite)的使用

自古美人都是妖i 提交于 2019-12-06 14:48:28
#数据持久化框架(ORMLite)的使用 ##1. ormlite jar下载 http://ormlite.com/releases android 只需要下载其中两个jar就可以了 ormlite-android-4.48.jar ormlite-core-4.48.jar ##2. ormlite jar使用实例(原作者提供) examples ##3. 中文的参考网站 较好的参考文章: http://blog.csdn.net/oo8_8oo/article/details/7302156 http://blog.csdn.net/oo8_8oo/article/details/7302335 其中 如果在android工程中运行java main()方法,可以参考文章 http://josh-persistence.iteye.com/blog/2011989 Android ormlite 多对多关联映射笔记 http://my.oschina.net/u/1012890/blog/123500 Android ormlite 一对多关联映射笔记 http://my.oschina.net/u/1012890/blog/122965 来源: oschina 链接: https://my.oschina.net/u/66835/blog/262376

ORMLite - Parenthesis in join where clauses

元气小坏坏 提交于 2019-12-06 09:09:38
I would like to join three tables using QueryBuilder.join and QueryBuilder.joinor but I want parenthesis in the where clause something like this: WHERE first_table_where AND (second_table_where OR third_table_where) but it seems that is not possible. Perhaps I am missing something. Any help would be appreciated. Daber I guess that is a part of the doc you have been looking for... If you want to do complex queries linearly, you can even use Reverse Polish Notation (of all things). There is a Where.or(int) and Where.and(int) methods which do the operation on the previous number of specified

ORMLite - force read objects to have same identity

不打扰是莪最后的温柔 提交于 2019-12-06 06:10:26
I'm reading a hierarchy of objects with ORMLite. It is shaped like a tree, parents have a @ForeignCollection of 0+ children, and every child refers to its parent with @DatabaseField(foreign=true) . I'm reading and saving the whole hierarchy at once. As I'm new to ORM in general, and to ORMLite as well, I didn't know that when objects with the same ID in the database are read, they won't be created as the actually same object with the same Identity , but as several duplicates having the same ID . Meaning, I'm now facing the problem that (let's say "->" stands for "refers to") A -> B -> C != C -

Problems saving Collection using ORMLite on Android

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 06:09:03
问题 I have two class: public class Questionnaire { @DatabaseField(generatedId=true, useGetSet=true) private Long id; @DatabaseField private int type; @DatabaseField private String title; @DatabaseField private String description; @ForeignCollectionField(eager = true) private Collection<Question> questions; // Get and Set omitted and public class Question { @DatabaseField(generatedId=true, useGetSet=true) private Long id; @DatabaseField private int type; @DatabaseField private String description;

Cannot make a LazyForeignCollection become eager collection

旧巷老猫 提交于 2019-12-06 05:49:08
I'm getting this error when trying to read a foreign collection from my POJO AndroidRuntime(589): Caused by: java.lang.IllegalStateException: Internal DAO object is null. Lazy collections cannot be used if they have been deserialized. The offending collection is answers1 which i have marked as 'eager' @ForeignCollectionField (eager=true) private ForeignCollection<TextAnswer> answers1; Why then when I debug the method below public List<TextAnswer> getAnswers() { return new ArrayList<TextAnswer>(answers1); } That it tells me the collection is a LazyForeignCollection? I am puzzled. I have no prob

Save a list of objects to ORMLite database

 ̄綄美尐妖づ 提交于 2019-12-06 05:44:31
I am looking for a way to save a list of objects to the database with ORMLite and read upon this question: Best way to store several ArrayLists in ORMLite for ApplicationSettings And the accepted answer makes sense to me: public class YourClass { @GeneratedId private int id; @ForeignCollectionField private Collection<MyString> bunchOfStrings = new ArrayList<MyString>(); } public class MyString{ @DatabaseField(canBeNull = true, foreign = true) private YourClass yourClass; @DatabaseField private String text; } And the only thing that I don't understand is this line private Collection<MyString>

Problems with ORMLite and lazy collections

邮差的信 提交于 2019-12-06 02:36:32
问题 I am using ormlite in my android project. I have two classes @DatabaseTable(tableName = "usershows") public class UserShow { @DatabaseField(id = true) private Integer showId; @ForeignCollectionField(eager = false) private ForeignCollection<Episode> episodes; ... } @DatabaseTable(tableName = "episodes") public class Episode { @DatabaseField(id = true) private Integer episodeId; @DatabaseField(foreign = true) private UserShow show; ... } I am saving my UserShows objects like in example UserShow

Storing List of objects using DataType.SERIALIZABLE in ormlite android

不想你离开。 提交于 2019-12-06 01:02:58
How to save an ArrayList using ORMlite in android my model is as follows class Model{ @DatabaseField public String type = ""; @DatabaseField public String name = ""; @DatabaseField public Date dateTime = null; @DatabaseField ArrayList<Item> items = null; } And Item class has class Item{ @DatabaseField String itemName; ... } I am getting the following exception : java.sql.SQLException: ORMLite can't store unknown class class java.util.ArrayList for field 'items'. Serializable fields must specify dataType=DataType.SERIALIZABLE But when i specify my field as @DatabaseField(dataType = DataType