Skip to content

Commit

Permalink
code optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
car031 committed Jan 10, 2025
1 parent 639afc7 commit f596694
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ private static String getParameterName(String query, int currentPosition) {
int j = currentPosition + 2;
while (j < query.length() && Character.isJavaIdentifierPart(query.charAt(j)))
j++;
String name = query.substring(currentPosition + 1, j);
return name;
return query.substring(currentPosition + 1, j);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
*/
public class HibernateDocumentNoteDAO extends HibernatePersistentObjectDAO<DocumentNote> implements DocumentNoteDAO {

private static final String DELETED_0 = ".deleted=0";

private static final String DOC_ID_DOC_ID_AND = ".docId = :docId and ";

private static final String DOC_ID = "docId";
Expand Down Expand Up @@ -117,23 +119,23 @@ public List<DocumentNote> findByDocIdAndTypes(long docId, String fileVersion, Co
params.put("types", types);

return findByWhere(
ENTITY + DOC_ID_DOC_ID_AND + ENTITY + ".type in (:types) and " + ENTITY + ".deleted=0", params,
ENTITY + DOC_ID_DOC_ID_AND + ENTITY + ".type in (:types) and " + ENTITY + DELETED_0, params,
null, null);
}
} else if (types == null || types.isEmpty()) {
Map<String, Object> params = new HashMap<>();
params.put(DOC_ID, docId);
params.put("fileVersion", fileVersion);
return findByWhere(
ENTITY + DOC_ID_DOC_ID_AND + ENTITY + ".fileVersion = :fileVersion and " + ENTITY + ".deleted=0",
ENTITY + DOC_ID_DOC_ID_AND + ENTITY + ".fileVersion = :fileVersion and " + ENTITY + DELETED_0,
params, null, null);
} else {
Map<String, Object> params = new HashMap<>();
params.put(DOC_ID, docId);
params.put("fileVersion", fileVersion);
params.put("types", types);
return findByWhere(ENTITY + DOC_ID_DOC_ID_AND + ENTITY + ".fileVersion = :fileVersion and " + ENTITY
+ ".type in (:types) and " + ENTITY + ".deleted=0", params, null, null);
+ ".type in (:types) and " + ENTITY + DELETED_0, params, null, null);
}
}

Expand Down

0 comments on commit f596694

Please sign in to comment.