Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple @CreatedBy does not register authenticated user in database #1704

Open
michaeldesigaud opened this issue May 15, 2024 · 2 comments
Open

Comments

@michaeldesigaud
Copy link

michaeldesigaud commented May 15, 2024

Expected Behavior

The @CretaedBy should insert the authenticated user name in database for all entities and their relations

Actual Behaviour

I have 3 entities , Project,Lessor and Housing :

@MappedEntity(value = "project")
@Introspected
public record ProjectEntity(
    @AutoPopulated
    @Id UUID id,
  @MappedProperty("housing_id")
    @Relation(value = Relation.Kind.ONE_TO_ONE, cascade = Relation.Cascade.ALL)
    HousingEntity housing,
    @MappedProperty("lessor_id")
    @Relation(value = Relation.Kind.ONE_TO_ONE, cascade = Relation.Cascade.ALL)
    LessorEntity lessor,
    @CreatedBy
    @MappedProperty("created_by")
    String createdBy
) {}
@MappedEntity(value = "lessor")
@Introspected
public record LessorEntity(
    @AutoPopulated
    @Id UUID id,
    @Nullable @MappedProperty("first_name")
    String firstName,
    @CreatedBy
    @MappedProperty("created_by")
    String createdBy
) {}
@MappedEntity(value = "housing")
@Introspected
public record HousingEntity(
    @AutoPopulated
    @Id UUID id,
    @MappedProperty("street_address")
    String streetAddress,
    @CreatedBy
    @MappedProperty("created_by")
    String createdBy
) {} 

When i save a project (with a lessor and a housing inside), the createdBy of the Housing entity is null in database (but both project and lessor are ok)

If i invert the declaration order of lessor and housing relations in ProjectEntity then the createdBy of the Lessor entity is null in database (but both project and housing are ok)

Steps To Reproduce

No response

Environment Information

  • Operating system: ubuntu
  • JDK: 21
  • Micronaut 4.7.0

Example Application

No response

Version

4.7.0

@michaeldesigaud
Copy link
Author

any idea how to solve this ?

@graemerocher
Copy link
Contributor

you could assign it manually as a workaround I guess. Otherwise please provide a reproducer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants