Reputation: 2616
I created two objects. one extends the other.
The parent object has an ID as it written in the ObjectBox
documentation, but I can't build the project with the error of:
Error:[ObjectBox] Code generation failed: No ID property found for "Entity FastCacheData" (use @Id on a property of type long)
CacheData:
@Entity
public class CacheData {
@Id
private long id;
@Index
private String key;
@Index
private Date expirationDate;
private Date lastUpdated;
public CacheData(String key, Date expirationDate) {
this.lastUpdated = new Date();
this.key = key;
this.expirationDate = expirationDate;
}
}
FastCacheData:
@Entity
public class FastCacheData extends CacheData {
private String fullName;
private String thumbnailUrl;
private boolean isSpam;
@Convert(converter = DataSource.DataSourceConverter.class, dbType = Integer.class)
private DataSource photoDataSource;
@Convert(converter = DataSource.DataSourceConverter.class, dbType = Integer.class)
private DataSource nameDataSource;
public FastCacheData(String key, Date expirationDate, String fullName, DataSource nameDataSource, String thumbnailUrl, DataSource photoDataSource, boolean isSpam) {
super(key, expirationDate);
this.fullName = fullName;
this.nameDataSource = nameDataSource;
this.thumbnailUrl = thumbnailUrl;
this.photoDataSource = photoDataSource;
this.isSpam = isSpam;
}
}
Upvotes: 0
Views: 227
Reputation: 2616
Polymorphism of entities is not supported at this time, but there is a feature request.
Upvotes: 1