Skip to content

Commit

Permalink
Merge pull request #13495 from mshima/skip_ci_fixes
Browse files Browse the repository at this point in the history
Minor fixes.
  • Loading branch information
mshima committed Jan 14, 2021
2 parents 027f40b + ba839e5 commit e277b40
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ _%>
}
<%_ } else { _%>
<%_ if (pagination === 'no') { _%>
public <% if (reactive) { %>Mono<<% } %>List<<%= instanceType %>><% if (reactive) { %>><% } %> getAll<%= entityClassPlural %>(<% if (fieldsContainNoOwnerOneToOne) { %>@RequestParam(required = false) String filter<% } %><% if (fieldsContainOwnerManyToMany && fieldsContainNoOwnerOneToOne) { %>,<% } %><% if (relationshipsContainEagerLoad) { %>@RequestParam(required = false, defaultValue = "false") boolean eagerload<% } %>) {<%- include('get_all_stream_template', {viaService: viaService}); -%>
public <% if (reactive) { %>Mono<<% } %>List<<%= instanceType %>><% if (reactive) { %>><% } %> getAll<%= entityClassPlural %>(<% if (fieldsContainNoOwnerOneToOne) { %>@RequestParam(required = false) String filter<% } %><% if (relationshipsContainEagerLoad && fieldsContainNoOwnerOneToOne) { %>,<% } %><% if (relationshipsContainEagerLoad) { %>@RequestParam(required = false, defaultValue = "false") boolean eagerload<% } %>) {<%- include('get_all_stream_template', {viaService: viaService}); -%>
log.debug("REST request to get all <%= entityClassPlural %>");
<%_ if (viaService) { _%>
return <%= entityInstance %>Service.findAll()<% if (reactive) { %>.collectList()<% } %>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import org.springframework.data.cassandra.repository.CassandraRepository;
import org.springframework.stereotype.Repository;
<%_
if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') {
let importList = fieldsContainOwnerManyToMany;
let importList = relationshipsContainEagerLoad;
for (r of relationships) {
if (r.relationshipType === 'many-to-one' && r.otherEntityName === 'user') {
importList = true;
Expand Down Expand Up @@ -89,20 +89,20 @@ public interface <%= entityClass %>Repository extends <% if (databaseType === 's
@Query(value = "select distinct <%= entityInstance %> from <%= asEntity(entityClass) %> <%= entityInstance %><%
for (const relationship of relationships) {
if (relationship.relationshipEagerLoad) { %> left join fetch <%= entityInstance %>.<%= relationship.relationshipFieldNamePlural %><% }
if (relationship.relationshipEagerLoad) { %> left join fetch <%= entityInstance %>.<%= relationship.reference.name %><% }
 } %>",
countQuery = "select count(distinct <%= entityInstance %>) from <%= asEntity(entityClass) %> <%= entityInstance %>")
Page<<%= asEntity(entityClass) %>> findAllWithEagerRelationships(Pageable pageable);
@Query("select distinct <%= entityInstance %> from <%= asEntity(entityClass) %> <%= entityInstance %><%
for (const relationship of relationships) {
if (relationship.relationshipEagerLoad) { %> left join fetch <%= entityInstance %>.<%= relationship.relationshipFieldNamePlural %><% }
if (relationship.relationshipEagerLoad) { %> left join fetch <%= entityInstance %>.<%= relationship.reference.name %><% }
 } %>")
List<<%= asEntity(entityClass) %>> findAllWithEagerRelationships();
@Query("select <%= entityInstance %> from <%= asEntity(entityClass) %> <%= entityInstance %><%
for (const relationship of relationships) {
if (relationship.relationshipEagerLoad) { %> left join fetch <%= entityInstance %>.<%= relationship.relationshipFieldNamePlural %><% }
if (relationship.relationshipEagerLoad) { %> left join fetch <%= entityInstance %>.<%= relationship.reference.name %><% }
 } %> where <%= entityInstance %>.id =:id")
Optional<<%= asEntity(entityClass) %>> findOneWithEagerRelationships(@Param("id") <%= primaryKey.type %> id);
<%_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public interface <%= entityClass %>Mapper extends EntityMapper<<%= asDto(entityC
<%_ /***** Id mapping *****/
const otherIdReferences = otherDtoReferences.filter(r => !r.relatedReference || r.relatedReference.id);
if (!embedded && otherIdReferences.length > 0) {
if (otherIdReferences.some(r => !r.collection)) { %>
if (otherIdReferences.some(r => !r.collection)) { _%>
@Named("<%= primaryKey.name %>")
@BeanMapping(ignoreByDefault = true)
Expand All @@ -89,9 +89,9 @@ public interface <%= entityClass %>Mapper extends EntityMapper<<%= asDto(entityC
<%_ } _%>
<%_ if (renMapAnotEnt === true) { _%>
<%= asDto(entityClass) %> toDtoId(<%= asEntity(entityClass) %> <%= asEntity(entityInstance) %>);
<%_ } %>
<%_ } %>
<%_ if (otherIdReferences.some(r => r.collection)) { %>
<%_ } _%>
<%_ } _%>
<%_ if (otherIdReferences.some(r => r.collection)) { _%>
@Named("<%= primaryKey.name %>Set")
@BeanMapping(ignoreByDefault = true)
Expand All @@ -102,16 +102,16 @@ public interface <%= entityClass %>Mapper extends EntityMapper<<%= asDto(entityC
<%_ } _%>
<%_ if (renMapAnotEnt === true) { _%>
Set<<%= asDto(entityClass) %>> toDtoIdSet(Set<<%= asEntity(entityClass) %>> <%= asEntity(entityInstance) %>);
<%_ } %>
<%_ } %>
<%_ } %>
<%_ } _%>
<%_ } _%>
<%_ } _%>
<%_ if (!embedded) {
// DTO -> entity mapping
var renMapAnotDto = false; //Render Mapping Annotation during DTO to Entity conversion?
if(idFields.length > 1) {
renMapAnotDto = true;
idFields.map(field => field.reference).forEach(reference => { _%>
@Mapping(target = "id.<%= reference.name %>", source = "<%= buildReferencePath(reference) %>")
<%_ })
}
Expand Down
5 changes: 2 additions & 3 deletions utils/relationship.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ function prepareRelationshipForTemplates(entityWithConfig, relationship, generat
_.defaults(relationship, {
// let ownerSide true when type is 'many-to-one' for convenience.
// means that this side should control the reference.
ownerSide:
relationship.relationshipType !== 'one-to-many' && (relationship.ownerSide || relationship.relationshipType === 'many-to-one'),
ownerSide: relationship.ownerSide || relationship.relationshipType === 'many-to-one',
});

relationship.otherSideReferenceExists = false;
Expand Down Expand Up @@ -294,7 +293,7 @@ function relationshipToReference(entity, relationship, pathPrefix = []) {
},
path: [...pathPrefix, name],
idReferences: relationship.otherEntity.idFields ? relationship.otherEntity.idFields.map(field => field.reference) : [],
valueReference: relationship.otherEntityField && relationship.otherEntityField.reference,
valueReference: relationship.relatedField && relationship.relatedField.reference,
};
return reference;
}
Expand Down

0 comments on commit e277b40

Please sign in to comment.