我正在寻找一种方法来保存 DateTime 对象和 Duration 作为我的值对象的一部分。
这是我的价值对象:
@DatabaseTable(tableName = DrivingRecord.TableName)
public class DrivingRecord {
public final static String TableName = "drivingRecord";
public final static String DRIVING_TASK_COLUMN_NAME = "drivingTask";
@DatabaseField(foreign = true, columnName = DRIVING_TASK_COLUMN_NAME)
private DrivingTask drivingTask;
@DatabaseField(generatedId = true)
private int id;
@DatabaseField(dataType = DataType.LONG)
private DateTime startTime;
@DatabaseField
private Duration durationOfDriving;
}
我得到以下异常:
java.lang.IllegalArgumentException: Field class org.joda.time.Duration for field FieldType:name=durationOfDriving,class=DrivingRecord is not valid for type com.j256.ormlite.field.types.LongType@41223060, maybe should be long
尝试为 DateTime 创建条目时,我也遇到了同样的异常