avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From S G <sg.online.em...@gmail.com>
Subject How to handle entities with type-parameters
Date Fri, 22 Aug 2014 18:45:49 GMT
Hi,

Does anyone know how I can avoid an exception for the following code:

-------------------------------------------------------------------
public class EntityWrapper<T>
{
    T obj;
}

public class Entity
{
    Integer a = 1;
    String b = "Foo";
}

EntityWrapper<Entity> en = new EntityWrapper<Entity>();
en.obj = new Entity();
ReflectData.getSchema(en.getClass());
-------------------------------------------------------------------


And the exception is:


org.apache.avro.AvroTypeException: Unknown type: T

at org.apache.avro.specific.SpecificData.createSchema(SpecificData.java:260)

at org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:542)

at
org.apache.avro.reflect.ReflectData.createFieldSchema(ReflectData.java:645)

at
org.apache.avro.reflect.ReflectData$AllowNull.createFieldSchema(ReflectData.java:78)

at org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:500)

at org.apache.avro.specific.SpecificData.getSchema(SpecificData.java:194)



Thx - Sachin

Mime
View raw message