Jackson + SugarOrm id error
Asked Answered
M

2

7

I use jackson and sugar orm and i have some errors when parsing. The id field is located in the json constantly 0. What can I do to fix it?

This example my class:

@JsonIgnoreProperties(ignoreUnknown = true)
public class JsonScienceEvent extends SugarRecord<JsonScienceEvent>{

    @JsonProperty("id")
    private String eventId;

public JsonScienceEvent()

public JsonScienceEvent(String eventId){
    this.eventId = eventId;
}

public String getEventId(){
    return eventId;
}
Melanite answered 3/4, 2016 at 1:58 Comment(2)
Post the error stackThulium
also post the json that you are trying to parseGully
E
0

the fieldid is inherited from the super class SugarRecord<T> along with the setter and getter methods setId(Long id) and getId(). You can override the id field generated by the Sugar library, but as far as i can remember it uses Long type so if you can change from String identifier to Long all should be fine and, this way you can force the library to use the id you're setting with the setter setId(Long id),

Eltonelucidate answered 10/6, 2016 at 23:22 Comment(0)
E
0

Sugar ORM actually creates its own ID field to maintain. If you're not inserting a value into the eventId field when creating a record, then your column is empty.

Try using "getId()" to get the auto incremented ID from the record. Don't forget to cast to a string if that's what you want back!

Epagoge answered 19/4, 2016 at 14:55 Comment(0)
E
0

the fieldid is inherited from the super class SugarRecord<T> along with the setter and getter methods setId(Long id) and getId(). You can override the id field generated by the Sugar library, but as far as i can remember it uses Long type so if you can change from String identifier to Long all should be fine and, this way you can force the library to use the id you're setting with the setter setId(Long id),

Eltonelucidate answered 10/6, 2016 at 23:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.