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

fix duplicated literal code smell #25179

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import <%= entityAbsolutePackage %>.domain.<%= persistClass %>;
* Utility repository to load bag relationships based on https://vladmihalcea.com/hibernate-multiplebagfetchexception/
*/
public class <%= entityClass %>RepositoryWithBagRelationshipsImpl implements <%= entityClass %>RepositoryWithBagRelationships {

private static final String <%= primaryKey.name.toUpperCase() %>_PARAMETER = "<%= primaryKey.name %>";
private static final String <%= entityInstancePlural.toUpperCase() %>_PARAMETER = "<%= entityInstancePlural %>";

@PersistenceContext
private EntityManager entityManager;

Expand Down Expand Up @@ -73,7 +77,7 @@ public class <%= entityClass %>RepositoryWithBagRelationshipsImpl implements <%=
"select <%= entityInstance %> from <%= persistClass %> <%= entityInstance %> left join fetch <%= entityInstance %>.<%= relationship.relationshipFieldNamePlural %> where <%= entityInstance %>.<%= primaryKey.name %> = :<%= primaryKey.name %>",
<%= persistClass %>.class
)
.setParameter("<%= primaryKey.name %>", result.get<%= primaryKey.nameCapitalized %>())
.setParameter(<%= primaryKey.name.toUpperCase() %>_PARAMETER, result.get<%= primaryKey.nameCapitalized %>())
.getSingleResult();
}

Expand All @@ -86,7 +90,7 @@ public class <%= entityClass %>RepositoryWithBagRelationshipsImpl implements <%=
"select <%= entityInstance %> from <%= persistClass %> <%= entityInstance %> left join fetch <%= entityInstance %>.<%= relationship.relationshipFieldNamePlural %> where <%= entityInstance %> in :<%= entityInstancePlural %>",
<%= persistClass %>.class
)
.setParameter("<%= entityInstancePlural %>", <%= entityInstancePlural %>)
.setParameter(<%= entityInstancePlural.toUpperCase() %>_PARAMETER, <%= entityInstancePlural %>)
.getResultList();
Collections.sort(result, (o1, o2) -> Integer.compare(order.get(o1.get<%= primaryKey.nameCapitalized %>()), order.get(o2.get<%= primaryKey.nameCapitalized %>())));
return result;
Expand Down
Loading