如何在ormlite中将两个字段作为一个主键?

时间:2016-08-03 10:18:15

标签: android sql orm sqlite ormlite

create table temp(id int,userId int,query text,createdOn text,primary key(id,userId));

如何使用ormlite创建id和UserId作为一个主键?

@DatabaseField(columnName = "_id",id = true,generatedId = true)
private long _id;
@DatabaseField(columnName = "userId")
private String userId;
@DatabaseField(columnName = "query")
public String query;
@DatabaseField(columnName = "createdOn")
public String createdOn;

1 个答案:

答案 0 :(得分:1)

@DatabaseField(columnName = "_id",id = true,generatedId = true)
private long _id;

_id当你使用generatedId = true;

时它是主键