Is this your whole Rule class? If so, then the issue is not the type of the field but that you haven't added a setter and getter for it.
On Tue, May 10, 2022 at 7:23 AM Tejas B <tejasub1...@gmail.com> wrote: > Hi, > I am trying to get flink schema evolution to work for me using POJO > serializer. But I found out that if an enum is present in the POJO then the > POJO serializer is not used. Example of my POJO is as follows : > > public class Rule { > String id;int val; > RuleType ruleType;//Newly added field//int val2 = 0; > public Rule() {} > public Rule(String id, int val, RuleType ruleType) { > this.id = id; > this.val = val; > this.ruleType = ruleType; > //this.val2 = val2; > } > public String getId() { > return id; > } > public void setId(String id) { > this.id = id; > } > public int getVal() { > return val; > } > public void setVal(int val) { > this.val = val; > } > public RuleType getRuleType() { > return ruleType; > } > public void setRuleType(RuleType ruleType) { > this.ruleType = ruleType; > } > //public int getVal2() {// return val2;//} > //public void setVal2(int val2) {// this.val2 = val2;//} > @Overridepublic boolean equals(Object o) { > if (this == o) return true; > if (o == null || getClass() != o.getClass()) return false; > Rule rule = (Rule) o; > return val == rule.val && id.equals(rule.id) && ruleType == rule.ruleType; > } > @Overridepublic int hashCode() { > return Objects.hash(id, val, ruleType); > } > @Overridepublic String toString() { > return "Rule{" + > "name='" + id + '\'' + > ", val=" + val + > ", ruleType=" + ruleType + > '}'; > } > > } > > RuleType is an enum class as follows : > > public enum RuleType { > X, > Y, > Z > > } > > Now for the Rule class the schema evolution (Adding a new field called > val2), works only if I write a custom typeFactory for this class. > > Is there a way that I can write typeFactory for the enum class ? Why does > the flink not recognize enum in a POJO class ? >