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

Localize Order By in AchievableSkill Repository #110

Open
Weltraumschaf opened this issue Jun 8, 2022 · 0 comments
Open

Localize Order By in AchievableSkill Repository #110

Weltraumschaf opened this issue Jun 8, 2022 · 0 comments
Labels
backend bug Something isn't working

Comments

@Weltraumschaf
Copy link
Member

First implementation approach was to use JPA's Sort API (
use_sort_interface.patch.zip).

Problems arose:

  • The column name to order by is due to the joining of two tables named "s.titleEN" or "s.titleDE". Using Sort.by(s.titleEN) raises an exception.
  • Possible solution is to alias the name in the SELECT: s.titleEN as skillTitleEN, but this does not work with constructor reference in SELECT clause.
  • I tried to remove the constructor reference bc JPA should be able to convert the JPATuples into the according VO via bean-instantiation and the return type of the repo metho. But this does not work bc the used VO is not an managed entity, due to the fact that we cross join two managed entities into an artifical entity (the VO AchievableSkill).
  • I tried to "convince" JPA to map the JPATuples into this VO with @NamedNativeQuery and @SqlResultSetMapping, but these annoations seem to work only on managed entities as target 🤪

Possible solution:

We do not use an autogenerated JPA repository and implement the repository completely by hand and generate the JPQL dynmically with JPA criteria API and convert the resuylt also by hand into the VO. Problem here: There are no tests for the repository (CustomAchievableSkillRepository) and only very view tests for the service (CustomAchievableSkillServiceImpl).

Originally posted by @Weltraumschaf in #107 (comment)

@Weltraumschaf Weltraumschaf added bug Something isn't working backend labels Jun 8, 2022
@rseedorff rseedorff changed the title Loclaize Order By in AchievableSkill Repository Localize Order By in AchievableSkill Repository Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant