Reputation: 30305
I've created an Entity class that extends TableServiceEntity. My class has a single field called "value" of type Byte
:
public class TestEntity extends TableServiceEntity{
public Byte value;
public TestEntity(){
super("some_partition","somekey");
}
public Byte getValue() {
return value;
}
public void setValue(Byte value) {
this.value = value;
}
}
According to the documentation for TableServiceEntity, Byte
is one of the supported field types.
However when I try to store my entity, I get the following exception:
java.lang.IllegalArgumentException: Type class java.lang.Byte is not supported.
at com.microsoft.azure.storage.table.EntityProperty.<init>(EntityProperty.java:175)
at com.microsoft.azure.storage.table.PropertyPair.generateEntityProperty(PropertyPair.java:271)
at com.microsoft.azure.storage.table.TableServiceEntity.writeEntityWithReflection(TableServiceEntity.java:217)
at com.microsoft.azure.storage.table.TableServiceEntity.writeEntity(TableServiceEntity.java:470)
at com.microsoft.azure.storage.table.TableEntitySerializer.writeJsonEntity(TableEntitySerializer.java:317)
at com.microsoft.azure.storage.table.TableEntitySerializer.writeSingleJsonEntity(TableEntitySerializer.java:411)
at com.microsoft.azure.storage.table.TableEntitySerializer.writeSingleEntityToStream(TableEntitySerializer.java:74)
at com.microsoft.azure.storage.table.TableOperation.insertImpl(TableOperation.java:389)
at com.microsoft.azure.storage.table.TableOperation.performInsert(TableOperation.java:370)
...
The fault seems to be with the EntityProperty constructor (see source), which doesn't seem to support Byte
or byte
types, only Byte[]
and byte[]
:
protected EntityProperty(final String value, final Class<?> type) {
this.type = type;
this.value = value;
if (type.equals(byte[].class)) {
this.getValueAsByteArray();
this.edmType = EdmType.BINARY;
}
else if (type.equals(Byte[].class)) {
this.getValueAsByteObjectArray();
this.edmType = EdmType.BINARY;
}
...
Am I doing something wrong, or is this a documentation error?
Upvotes: 0
Views: 437
Reputation: 30305
It's a documentation bug. As Herve Roggero noted, the service model documentation states that Bytes aren't supported.
Upvotes: 0
Reputation: 5249
According to MSDN, the list of property types allowed for the Azure Table service does not include Edm.Byte, but does include Edm.Binary (which is byte[]). For a more in-depth understanding of the data types allowed and other limitations see Understanding the Table Service Data Model.
Upvotes: 1