Git Product home page Git Product logo

Comments (2)

mp911de avatar mp911de commented on July 1, 2024

Care to provide the UserId type? Ideally, you would provide a minimal reproducer as GitHub repo or zip file (attached to this issue) so that we have an exact reproducer.

One more thing: Looking at your dependency versions, it seems that you're using Spring Boot 3.0.4 that uses Spring Data Commons 3.0.4.

Kotlin value class support was introduced in a later version 3.2, as I'd anticipate inline/value class usage here.

from spring-data-mongodb.

gasabr avatar gasabr commented on July 1, 2024

Providing minimal working example would take some time, because project is a bit messy rn, so here are the classes

internal class UserId(val id: String) {

    companion object {
        fun fromString(eventId: String?): UserId {
            if (eventId == null) {
                throw RuntimeException("UserId can not be null.")
            }
            return UserId(eventId)
        }

        fun createNew(): UserId = UserId("user-" + getRandomString(15))
    }
    // skipped toString, equals, hashCode, which I generated trying to find the root cause
}

Converters

@WritingConverter
internal class UserIdToStringConverter : Converter<UserId, String> {
    override fun convert(source: UserId): String {
        return source.id
    }
}

@ReadingConverter
internal class StringToUserIdConverter : Converter<String, UserId> {
    override fun convert(source: String): UserId {
        return UserId.fromString(source)
    }
}

Thanks for the ticket link, didn't know value classes were not supported yet, I'll pack the minimal reproducable example later today, but from the debugging I've done, it's not the "value" class, because UserId object is being restored correctly, the problem lies in parameters list having 3 values instead of 2, where first 2 are real parameters and the last one is null.

from spring-data-mongodb.

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.