aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/juick/server/TagQueries.java23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/main/java/com/juick/server/TagQueries.java b/src/main/java/com/juick/server/TagQueries.java
index 22839ad0..f3ab480e 100644
--- a/src/main/java/com/juick/server/TagQueries.java
+++ b/src/main/java/com/juick/server/TagQueries.java
@@ -18,6 +18,7 @@
package com.juick.server;
import com.juick.Tag;
+import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import java.sql.Connection;
@@ -52,15 +53,19 @@ public class TagQueries {
}
public static com.juick.Tag getTag(JdbcTemplate sql, String tag, boolean autoCreate) {
- Tag ret = sql.queryForObject("SELECT tag_id,synonym_id,name FROM tags WHERE name=?",
- new Object[]{tag}, (rs, rowNum) -> {
- Tag ret1 = new Tag();
- ret1.TID = rs.getInt(1);
- ret1.SynonymID = rs.getInt(2);
- ret1.Name = rs.getString(3);
- return ret1;
- });
-
+ Tag ret = null;
+ try {
+ ret = sql.queryForObject("SELECT tag_id,synonym_id,name FROM tags WHERE name=?",
+ new Object[]{tag}, (rs, rowNum) -> {
+ Tag ret1 = new Tag();
+ ret1.TID = rs.getInt(1);
+ ret1.SynonymID = rs.getInt(2);
+ ret1.Name = rs.getString(3);
+ return ret1;
+ });
+ } catch (EmptyResultDataAccessException e) {
+ // tag not found
+ }
if (ret == null && autoCreate) {
ret = new com.juick.Tag();
ret.TID = createTag(sql, tag);