Skip to content

Spring Boot: Extending User with composed type leads to: cannot find symbol - method setUser #29901

@mux-R

Description

@mux-R
Overview of the issue

I followed the instructions for extending a user from this page in the docs: https://www.jhipster.tech/user-entity/
In my case I'm adding 2 composed types but the same issue occurs with 1 composed type.

entity ModeratorUser {
  organization String
}
entity RegularUser {
  fullName String
}
relationship OneToOne {
  ModeratorUser{internalUser(login)} to @OnDelete("CASCADE") @Id User with builtInEntity
  RegularUser{internalUser(login)} to @OnDelete("CASCADE") @Id User with builtInEntity
}

The code generation itself is successful, However, compiling the generated source code fails:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/username/projects/bug-showcase2/src/test/java/com/mycompany/buguserresourceit/web/rest/ModeratorUserResourceIT.java:[181,25] cannot find symbol
  symbol:   method setUser(com.mycompany.buguserresourceit.domain.User)
  location: variable updatedModeratorUser of type com.mycompany.buguserresourceit.domain.ModeratorUser
[ERROR] /home/username/projects/bug-showcase2/src/test/java/com/mycompany/buguserresourceit/web/rest/RegularUserResourceIT.java:[181,27] cannot find symbol
  symbol:   method setUser(com.mycompany.buguserresourceit.domain.User)
  location: variable updatedRegularUser of type com.mycompany.buguserresourceit.domain.RegularUser
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

The issue is that it's trying to call setUser(User) on ModeratorUser and RegularUser. However, the method is actually called setInternalUser(User) because the property is called internalUser.

JHipster JDL

bugUserResourceIT.jdl

JDL definitions
application {
  config {
    applicationType monolith
    authenticationType jwt
    baseName bugUserResourceIT
    buildTool maven
    cacheProvider ehcache
    clientFramework angular
    clientTheme none
    databaseType sql
    devDatabaseType postgresql
    enableHibernateCache true
    enableTranslation true
    jhipsterVersion "8.11.0"
    languages [en]
    microfrontends []
    nativeLanguage en
    packageName com.mycompany.buguserresourceit
    prodDatabaseType postgresql
    reactive false
    testFrameworks [gatling]
    withAdminUi true
  }

entities ModeratorUser, RegularUser
}

entity ModeratorUser {
organization String
}
entity RegularUser {
fullName String
}
relationship OneToOne {
ModeratorUser{internalUser(login)} to @OnDelete("CASCADE") @Id User with builtInEntity
RegularUser{internalUser(login)} to @OnDelete("CASCADE") @Id User with builtInEntity
}

  • JDL is mandatory for bug reports. This will allow us to use automated tests and genarate the broken sample using jhipster from-issue command.
Motivation for or Use Case

I want to extend the User type because I want to have different kinds of users and I want each type to have different fields/properties/columns.

Reproduce the error

I'm creating a new application using:

jhipster jdl bugUserResourceIT.jdl

Then I run:

./mvnw
Related issues

#9100 seems to be related to Hibernate persistence.
#29413 is about a warning.
(More info in the PR)

Suggest a Fix

I have already prepared a fix and am creating a PR.

JHipster Version(s)

8.11.0
I don't know if it's a regression. I'm new to JHipster.

Browsers and Operating System

openjdk version "21.0.7" 2025-04-15 LTS
OpenJDK Runtime Environment Temurin-21.0.7+6 (build 21.0.7+6-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.7+6 (build 21.0.7+6-LTS, mixed mode, sharing)

git version 2.43.0

node: v22.15.0
npm: 10.9.2

Docker version 28.3.0, build 38b7060

  • Tickets opened without reproduction steps or that doesn't follows the template recommendation will be closed.
  • Checking this box is mandatory (this is just to show you read everything)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions