[ 
https://issues.apache.org/jira/browse/AVRO-1568?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14347825#comment-14347825
 ] 

ASF GitHub Bot commented on AVRO-1568:
--------------------------------------

GitHub user sachingsachin opened a pull request:

    https://github.com/apache/avro/pull/20

    AVRO-1568: Allow Java polymorphism in Avro for third-party code

    The fix simply adds two APIs to ReflectData:
    1) setSchema (Class<?> clazz, Schema s);
    2) setSchema (Field field, Schema s);
    
    With these two APIs, clients can create UNION schemas for any class/field 
and set them accordingly.
    With the UNION schema, avro can easily handle derived objects' presence on 
base-class fields.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/sachingsachin/avro AVRO-1568

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/avro/pull/20.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #20
    
----
commit bd63678fae95ec218b7f2b758c02c5c208c9fbbf
Author: Sachin Goyal <[email protected]>
Date:   2015-03-05T00:15:57Z

    AVRO-1568: Allow Java polymorphism in Avro for third-party code
    
    The fix simply adds two APIs to ReflectData:
    1) setSchema (Class<?> clazz, Schema s);
    2) setSchema (Field field, Schema s);
    
    With these two APIs, clients can create UNION schemas for any class/field 
and set them accordingly.
    With the UNION schema, avro can easily handle derived objects' presence on 
base-class fields.

----


> Allow Java polymorphism in Avro for third-party code
> ----------------------------------------------------
>
>                 Key: AVRO-1568
>                 URL: https://issues.apache.org/jira/browse/AVRO-1568
>             Project: Avro
>          Issue Type: Improvement
>    Affects Versions: 1.7.6
>            Reporter: Sachin Goyal
>
> A large number of Java designs interacting with databases with 
> Hibernate/Couchbase (perhaps, even otherwise) have Java polymorphism of the 
> form:
> {code:java}
> class Base 
> {
>    Integer a = 5;
> }
> class Derived extends Base
> {
>     String b = "Foo";
> }
> class PolymorphicDO
> {
>    Base b = new Derived();
> }
> {code}
> Jackson handles this kind of field by using annotations such as:
> {code}
> @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = 
> JsonTypeInfo.As.PROPERTY, property = "@class”)
> {code}
> If such a thing can be added to Avro, all those Java designs could become 
> immediately usable with Avro. They would also become Hadoop compatible due to 
> AvroSerde.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to