GithubHelp home page GithubHelp logo

Comments (5)

burtbeckwith avatar burtbeckwith commented on August 21, 2024

issue2968.zip

from micronaut-data.

dstepanov avatar dstepanov commented on August 21, 2024

Have you tried to have @GeneratedValue?

from micronaut-data.

radovanradic avatar radovanradic commented on August 21, 2024

It works with @AutoPopulated and @GeneratedValue if record initializer is removed. That is confusing app from creating new record with generated id, it seems. Changing record to this

@Serdeable
@MappedEntity
public record Pet(
        // This class uses an autopopulated UUID for the primary key
        @Id @AutoPopulated @Nullable UUID id,
        String name,
        // A relation is defined between Pet and Owner
        @Relation(Relation.Kind.MANY_TO_ONE)
        Owner owner,
        // Optional columns can be defined by specifying Nullable
        @Nullable
        PetType type) {

    // Secondary record constructors make it easier to construct instances
    public Pet(String name, Owner owner) {
        this(name, owner, null);
    }

    public Pet(String name, Owner owner, PetType type) {
        this(null, name, owner, type == null ? PetType.DOG : type);
    }

    public enum PetType {
        DOG,
        CAT
    }
}

seems to be working.

from micronaut-data.

graemerocher avatar graemerocher commented on August 21, 2024

note this is a regression as it used to work

from micronaut-data.

radovanradic avatar radovanradic commented on August 21, 2024

Yes, in 3.10.0 it worked. This is the difference when record is used. This method in DefaultEntityEventContext

@Override
    public <P> void setProperty(BeanProperty<T, P> property, P newValue) {
        if (property.hasSetterOrConstructorArgument()) { // in 3.10.0 this returns true and in 4.4.2 false
            if (property.isReadOnly()) {
                this.entity = property.withValue(entity, newValue);
            } else {
                property.set(entity, newValue);
            }
        }
    }

from micronaut-data.

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.