我在 Win 7 平台上使用 Eclipse Helios。我有这个道课
package com.example.hello;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
@DatabaseTable(tableName = "accounts")
public class Account {
// for QueryBuilder to be able to find the fields
public static final String NAME_FIELD_NAME = "name";
public static final String PASSWORD_FIELD_NAME = "passwd";
@DatabaseField(generatedId = true)
private int id;
@DatabaseField(columnName = NAME_FIELD_NAME, canBeNull = false)
private String name;
@DatabaseField(columnName = PASSWORD_FIELD_NAME)
private String password;
Account() {
// all persisted classes must define a no-arg constructor with at least package visibility
}
public Account(String name) {
this.name = name;
}
public Account(String name, String password) {
this.name = name;
this.password = password;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public int hashCode() {
return name.hashCode();
}
@Override
public boolean equals(Object other) {
if (other == null || other.getClass() != getClass()) {
return false;
}
return name.equals(((Account) other).name);
}
}
我的 DatabaseConfigUtil 如下,
package com.example.hello;
import java.io.IOException;
import java.sql.SQLException;
import com.j256.ormlite.android.apptools.OrmLiteConfigUtil;
/**
* Database helper class used to manage the creation and upgrading of your database. This class also usually provides
* the DAOs used by the other classes.
*/
public class DatabaseConfigUtil extends OrmLiteConfigUtil {
public static void main(String[] args) throws SQLException, IOException {
writeConfigFile("ormlite_config.txt");
}
}
我的问题是,如果我尝试生成它在 res/raw 文件夹中成功生成的原始数据库配置文件,但文件中没有添加任何内容,除了
#
# generated on 2013/06/26 05:18:40
#
为什么我的数据库字段不是在这里自动生成的?