Skip to content

Commit 0a6501d

Browse files
committed
Update Row class and increase version in pom.xml
Updated the Row.java class to enhance the readability of the code, primarily adjusting commenting style and method simplifications. Also, the MySQL API version has been incremented from 5.6 to 5.7 in pom.xml.
1 parent ae58d62 commit 0a6501d

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>de.goldendeveloper</groupId>
77
<artifactId>MYSQL-Api</artifactId>
8-
<version>5.6</version>
8+
<version>5.7</version>
99
<packaging>jar</packaging>
1010
<url>https://github.com/Golden-Developer/MYSQL-Api</url>
1111

src/main/java/de/goldendeveloper/mysql/entities/Row.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public class Row implements QueryHelper {
2222

2323
/**
2424
* Represents a row in a database table.
25-
*
25+
* <p>
2626
* The Row class contains methods to retrieve and modify data in the corresponding row of the table.
2727
*
28-
* @param table The Table object representing the table the row belongs to.
28+
* @param table The Table object representing the table the row belongs to.
2929
* @param column The Column object representing the column in the row.
30-
* @param mysql The MYSQL object representing the connection to the database.
31-
* @param item The value of the column in the row.
30+
* @param mysql The MYSQL object representing the connection to the database.
31+
* @param item The value of the column in the row.
3232
*/
3333
public Row(Table table, Column column, MYSQL mysql, String item) {
3434
this.db = table.getDatabase();
@@ -51,13 +51,11 @@ public HashMap<String, SearchResult> getData() {
5151
exportMap = executeQuery(query, rs -> {
5252
HashMap<String, SearchResult> map = new HashMap<>();
5353
ResultSetMetaData rsMetaData = rs.getMetaData();
54-
if (rs.next()) {
55-
for (int i = 1; i <= rsMetaData.getColumnCount(); i++) {
56-
if (rs.getString(rsMetaData.getColumnName(i)) != null) {
57-
map.put(rsMetaData.getColumnName(i), new SearchResult(rs.getString(rsMetaData.getColumnName(i))));
58-
} else {
59-
map.put(rsMetaData.getColumnName(i), null);
60-
}
54+
for (int i = 1; i <= rsMetaData.getColumnCount(); i++) {
55+
if (rs.getString(rsMetaData.getColumnName(i)) != null) {
56+
map.put(rsMetaData.getColumnName(i), new SearchResult(rs.getString(rsMetaData.getColumnName(i))));
57+
} else {
58+
map.put(rsMetaData.getColumnName(i), null);
6159
}
6260
}
6361
return map;
@@ -79,7 +77,7 @@ public void setExportMap(HashMap<String, SearchResult> newMap) {
7977
* Sets the value of a specific item in the column.
8078
*
8179
* @param column The Column object representing the column to set the value for.
82-
* @param item The new value to set for the column.
80+
* @param item The new value to set for the column.
8381
*/
8482
public void set(Column column, Object item) {
8583
executeUpdate("UPDATE `" + this.getTable().getName() + "` SET `" + column.getName() + "` = '" + item.toString() + "' WHERE `" + this.column.getName() + "` = '" + this.item + "';", mysql);
@@ -134,7 +132,7 @@ public int getId() {
134132
* Deletes the row from the database table associated with this object.
135133
* The deletion is performed based on the value of the column in the row.
136134
* The SQL query executed is as follows:
137-
* DELETE FROM `tableName` WHERE `columnName` = 'columnValue';
135+
* DELETE FROM `tableName` WHERE `columnName` = 'columnValue';
138136
*
139137
* @see Row#getTable() to retrieve the table associated with this row
140138
* @see Row#column to retrieve the column associated with this row

src/main/java/de/goldendeveloper/mysql/entities/Table.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ public boolean existsColumn(String name) {
225225
*/
226226
public boolean existsRow(Column column, String item) {
227227
String query = "SELECT EXISTS(SELECT * FROM `" + this.getName() + "` WHERE `" + column.getName() + "` = '" + item + "')";
228-
Boolean exists = executeQuery(query, rs -> rs.next() && rs.getBoolean(1), mysql);
228+
Boolean exists = executeQuery(query, rs -> rs.getBoolean(1), mysql);
229+
System.out.println("229: existsRow : " + exists );
229230
return exists != null && exists;
230231
}
231232

0 commit comments

Comments
 (0)