Skip to content

Spring Boot: fix test _entityClass_ResourceIT.java.ejs for composed types with OneToOne and @MapsId (eg when extending User) #29902

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mux-R
Copy link

@mux-R mux-R commented Jun 26, 2025

See Issue #29901

Suggested changes

In the file test _entityClass_ResourceIT.java.ejs, I noticed that it's generating the name of the setter with:

mapsIdAssoc.otherEntityNameCapitalized

It's using the class name from the other entity (in this case User) when generating the name for the setter method. Which only works if the field/setter has the same name as the class. However, in my case (and in the case shown in the documentation for extending a user https://www.jhipster.tech/user-entity/ ): The field is called internalUser and the class is called User.

I tried to find something containing InternalUser (case-sensitive) and found the following possibilities:

  • mapsIdAssoc.relationshipNameCapitalized
  • mapsIdAssoc.propertyNameCapitalized
  • mapsIdAssoc.propertyJavaBeanName
    All of these 3 options contained InternalUser. I'm not sure about the exact meanings of each.

My proposed fix is to use:

mapsIdAssoc.propertyNameCapitalized
Testing

I tested my changes from this commit locally (by using npm ci and setting an alias) and am now receiving Spring Boot (Java) code which compiles successfully. I started the application and verified that the entities are visible via the GUI. However, I haven't yet thoroughly tested my new composed types. I'm assuming that it works because it's something that's mentioned in the documentation. But I will be trying to use it (run-time) anyway in the near future because I want to use it.

I haven't written any automated test for it. I might look into that if it's required. However I'm not sure if I'm able to figure out where to put such a test or which kind of test to write.


Please make sure the below checklist is followed for Pull Requests.

When you are still working on the PR, consider converting it to Draft (below reviewers) and adding skip-ci label, you can still see CI build result at your branch.

Fix an issue for composed types which use @mapsid (e.g. when extending users) if the property name in the composed type doesn't match the class name.
@Tcharl
Copy link
Contributor

Tcharl commented Jun 29, 2025

I would have use beanname personally, but never worked on mapsid. @OmarHawk maybe?

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

Successfully merging this pull request may close these issues.

2 participants