我已经为android应用程序
创建了一个包含以下字段的bean@DatabaseField(generatedId=true)
private int id;
@DatabaseField
private String name;
@DatabaseField(unique=true)
private String emailId;
@DatabaseField
private String mobile;
@DatabaseField(unique=true)
private String loginName;
@DatabaseField
private String loginPassword;
@DatabaseField
private String confirmPassword;
@DatabaseField
private String securityQuestion;
@DatabaseField
private String securityPassword;
@DatabaseField
private String transactionPassword;
@DatabaseField
private String uac;
但是,当我在Eclipse IDE中使用Questoid SQLite Manager查看数据库表时,我没有看到以与bean中声明的顺序相同的顺序创建列,而是我看到如下所示的内容:
CREATE TABLE user (confirmPassword VARCHAR, emailId VARCHAR, uac VARCHAR,
loginPassword VARCHAR, mobile VARCHAR, name VARCHAR, securityPassword VARCHAR,
transactionPassword VARCHAR id INTEGER PRIMARY KEY AUTOINCREMENT);
从可读性和调试角度来看,此顺序非常困难。 有没有办法克服这个问题?
答案 0 :(得分:1)
如果你看一下ORMLite如何通过JDBC在Sqlite中配置类,你可以看到它直接匹配类的顺序:
public class AllTypes {
@DatabaseField
String stringField;
@DatabaseField
boolean booleanField;
@DatabaseField
Date dateField;
@DatabaseField
byte byteField;
@DatabaseField
short shortField;
@DatabaseField
int intField;
@DatabaseField
long longField;
@DatabaseField
float floatField;
@DatabaseField
double doubleField;
}
这是SQL:
CREATE TABLE `alltypes` (`stringField` VARCHAR , `booleanField` BOOLEAN ,
`dateField` TIMESTAMP , `byteField` TINYINT , `shortField` SMALLINT ,
`intField` INTEGER , `longField` BIGINT , `floatField` FLOAT ,
`doubleField` DOUBLE PRECISION )
所以这是Android唯一的问题。