Coder Social home page Coder Social logo

Comments (3)

beikov avatar beikov commented on July 18, 2024

This should work. Blaze-Persistence delegates the serialization process to Jackson after it created the object. Can you please share the exception that you're getting and an example?

from blaze-persistence.

billysoderlund avatar billysoderlund commented on July 18, 2024

The serialization part works, but "de"-serialization does not. I don't get an error, the properties just deserializes to null.

This also goes when adding custom to the object mapper builder. If I do something like this, the serializers works but the overridden function for deserializers is never called.

@Bean
fun jsonCustomizer(): Jackson2ObjectMapperBuilderCustomizer =
    Jackson2ObjectMapperBuilderCustomizer { it
        .serializers(LifeCycleStatusSerializer())
        .deserializers(LifeCycleStatusDeserializer())
        .propertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE)
    }

internal class LifeCycleStatusSerializer : StdSerializer<LifeCycleStatus>(LifeCycleStatus::class.java) {
    override fun serialize(status: LifeCycleStatus, generator: JsonGenerator, provider: SerializerProvider) {
        generator.writeNumber(status.value)
    }
}

internal class LifeCycleStatusDeserializer : StdDeserializer<LifeCycleStatus>(LifeCycleStatus::class.java) {
    override fun deserialize(jsonParser: JsonParser, context: DeserializationContext): LifeCycleStatus {
        val node: JsonNode = jsonParser.codec.readTree(jsonParser)
        return LifeCycleStatus.valueOf(node["life_cycle_status_id"].asInt())
    }
}

from blaze-persistence.

beikov avatar beikov commented on July 18, 2024

Ok, let me correct this

Blaze-Persistence delegates the serialization and deserialization process to Jackson after it created the object.

Can you maybe provide a reproducer for this in this test class? https://github.com/Blazebit/blaze-persistence/blob/main/integration/jackson/src/test/java/com/blazebit/persistence/integration/jackson/EntityViewAwareObjectMapperTest.java

from blaze-persistence.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.