Skip to content

Commit 8bae5fd

Browse files
committed
Deprecated methods are now removed.
1 parent e16ea00 commit 8bae5fd

File tree

3 files changed

+2
-186
lines changed

3 files changed

+2
-186
lines changed

src/main/java/de/presti/ree6/sql/SQLConnector.java

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -143,118 +143,6 @@ public void runMigrations() {
143143

144144
//region Utility
145145

146-
/**
147-
* Query basic SQL Statements, without using the ORM-System.
148-
*
149-
* @param sqlQuery The SQL Query.
150-
* @param ignoreError If errors should not be printed into the console.
151-
* @param parameters The Parameters for the Query.
152-
* @return Either a {@link Integer} or the result object of the ResultSet.
153-
* @deprecated Use {@link #query(String, Map)} instead.
154-
*/
155-
@Deprecated(forRemoval = true)
156-
public Object querySQL(String sqlQuery, boolean ignoreError, Object... parameters) {
157-
return querySQL(sqlQuery, !sqlQuery.startsWith("SELECT"), ignoreError, parameters);
158-
}
159-
160-
/**
161-
* Query basic SQL Statements, without using the ORM-System.
162-
*
163-
* @param sqlQuery The SQL Query.
164-
* @param update If a executeUpdate should be used.
165-
* @param ignoreError If errors should not be printed into the console.
166-
* @param parameters The Parameters for the Query.
167-
* @return Either a {@link Integer} or the result object of the ResultSet.
168-
* @deprecated Use {@link #query(String, Map)} instead.
169-
*/
170-
@Deprecated(forRemoval = true)
171-
public Object querySQL(String sqlQuery, boolean update, boolean ignoreError, Object... parameters) {
172-
if (!isConnected()) {
173-
if (connectedOnce()) {
174-
connectToSQLServer();
175-
return querySQL(sqlQuery, update, parameters);
176-
} else {
177-
return null;
178-
}
179-
}
180-
181-
try (Connection connection = getDataSource().getConnection();
182-
PreparedStatement preparedStatement = connection.prepareStatement(sqlQuery, ResultSet.CONCUR_READ_ONLY)) {
183-
184-
if (parameters != null) {
185-
for (int i = 0; i < parameters.length; i++) {
186-
Object parameter = parameters[i];
187-
if (parameter == null) continue;
188-
189-
preparedStatement.setObject(i + 1, parameter);
190-
}
191-
}
192-
193-
if (update) {
194-
return preparedStatement.executeUpdate();
195-
} else {
196-
try (ResultSet resultSet = preparedStatement.executeQuery()) {
197-
if (resultSet.next()) {
198-
return resultSet;
199-
}
200-
201-
return null;
202-
}
203-
}
204-
} catch (Exception exception) {
205-
if (!ignoreError) {
206-
Sentry.captureException(exception);
207-
log.error("Failed to send SQL-Query: {}", sqlQuery, exception);
208-
}
209-
}
210-
211-
return null;
212-
}
213-
214-
/**
215-
* Send an SQL-Query to SQL-Server and get the response.
216-
*
217-
* @param <R> The Class entity.
218-
* @param r The class entity.
219-
* @param sqlQuery the SQL-Query.
220-
* @param parameters a list with all parameters that should be considered.
221-
* @return The Result from the SQL-Server.
222-
* @deprecated Use {@link #query(String, Map)} instead.
223-
*/
224-
@Deprecated(forRemoval = true)
225-
public <R> Query<R> querySQL(@NotNull R r, @NotNull String sqlQuery, @Nullable Map<String, Object> parameters) {
226-
227-
if (!isConnected()) {
228-
if (connectedOnce()) {
229-
connectToSQLServer();
230-
return querySQL(r, sqlQuery, parameters);
231-
} else {
232-
return null;
233-
}
234-
}
235-
236-
try (Session session = SQLSession.getSessionFactory().openSession()) {
237-
238-
session.beginTransaction();
239-
240-
Query<R> query = (Query<R>) session.createNativeQuery(sqlQuery, r.getClass());
241-
242-
if (parameters != null) {
243-
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
244-
query.setParameter(entry.getKey(), entry.getValue());
245-
}
246-
}
247-
248-
session.getTransaction().commit();
249-
250-
return query;
251-
} catch (Exception exception) {
252-
Sentry.captureException(exception);
253-
log.error("Failed to send SQL-Query: {}", sqlQuery, exception);
254-
throw exception;
255-
}
256-
}
257-
258146
/**
259147
* Query HQL-Statements without the need of a class Instance.
260148
*

src/main/java/de/presti/ree6/sql/SQLWorker.java

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,52 +1816,6 @@ public Mono<Boolean> hasSetting(long guildId, String settingName) {
18161816
return getEntity(new Setting(), "FROM Setting WHERE settingId.guildId =:gid AND settingId.name =:name", Map.of("gid", guildId, "name", settingName)).map(Optional::isPresent);
18171817
}
18181818

1819-
/**
1820-
* Check if there is an entry for the Setting, if not, create one for every Setting that doesn't have an entry.
1821-
*
1822-
* @param guildId the ID of the Guild.
1823-
* @param setting the Setting itself.
1824-
* @deprecated This will loop through every setting and sets them every single time a config is being received.
1825-
*/
1826-
@Deprecated(forRemoval = true, since = "3.0.0")
1827-
public void checkSetting(long guildId, Setting setting) {
1828-
checkSetting(guildId, setting.getName());
1829-
}
1830-
1831-
/**
1832-
* Check if there is an entry for the Setting, if not, create one for every Setting that doesn't have an entry.
1833-
*
1834-
* @param guildId the ID of the Guild.
1835-
* @param settingName the Identifier of the Setting.
1836-
* @deprecated This will loop through every setting and sets them every single time a config is being received.
1837-
*/
1838-
@Deprecated(forRemoval = true, since = "3.0.0")
1839-
public void checkSetting(long guildId, String settingName) {
1840-
// Check if the Setting exists in our Database.
1841-
hasSetting(guildId, settingName).subscribe(hasSetting -> {
1842-
// If not then creat every Setting that doesn't exist for the Guild.
1843-
if (!hasSetting) {
1844-
createSettings(guildId);
1845-
}
1846-
});
1847-
}
1848-
1849-
/**
1850-
* Create Settings entries for the Guild
1851-
*
1852-
* @param guildId the ID of the Guild.
1853-
* @deprecated This will loop through every setting and sets them every single time a config is being received.
1854-
*/
1855-
@Deprecated(forRemoval = true, since = "3.0.0")
1856-
public void createSettings(long guildId) {
1857-
SettingsManager.getSettings().forEach(setting -> hasSetting(guildId, setting).subscribe(hasSetting -> {
1858-
// If not, then create every Setting that doesn't exist for the Guild.
1859-
if (!hasSetting) {
1860-
setSetting(guildId, setting.getName(), setting.getDisplayName(), setting.getValue());
1861-
}
1862-
}));
1863-
}
1864-
18651819
/**
18661820
* Create Settings entries for the commands on the Guild
18671821
*
@@ -2232,20 +2186,6 @@ private String getHibernateQueryForId(Field[] fields) {
22322186

22332187
//region Entity-System
22342188

2235-
2236-
/**
2237-
* Update an Entity in the Database.
2238-
*
2239-
* @param <R> The Class-Entity.
2240-
* @param r The Class-Entity to update.
2241-
* @return the new update entity.
2242-
* @deprecated This method is only here to make it easier to find methods that need to be updated.
2243-
*/
2244-
@Deprecated(forRemoval = true, since = "3.0.0")
2245-
public <R> Mono<R> updateEntity(Optional<R> r) {
2246-
return r.map(this::updateEntity).orElseGet(Mono::empty);
2247-
}
2248-
22492189
/**
22502190
* Update an Entity in the Database.
22512191
*
@@ -2324,18 +2264,6 @@ private <R> long getNextId(R r) {
23242264
return maxId + 1;
23252265
}
23262266

2327-
/**
2328-
* Delete an entity from the database
2329-
*
2330-
* @param <R> The Class-Entity.
2331-
* @param r The Class-Entity to delete.
2332-
* @deprecated This method is only here to make it easier to find methods that need to be updated.
2333-
*/
2334-
@Deprecated(forRemoval = true, since = "3.0.0")
2335-
public <R> Mono<Void> deleteEntity(Optional<R> r) {
2336-
return r.map(this::deleteEntity).orElse(Mono.empty());
2337-
}
2338-
23392267
/**
23402268
* Delete an entity from the database
23412269
*

src/test/java/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ public static void main(String[] args) throws SQLException {
2525

2626
new SQLSession(sqlConfig);
2727

28-
if (sqlConfig.getTyp() == DatabaseTyp.SQLite) {
28+
/*if (sqlConfig.getTyp() == DatabaseTyp.SQLite) {
2929
SQLSession.getSqlConnector().querySQL("PRAGMA foreign_keys = ON;", true, (Object[]) null);
3030
3131
if (SQLSession.getSqlConnector().querySQL("PRAGMA foreign_keys;", false, (Object[]) null) instanceof ResultSet resultSet) {
3232
System.out.println(resultSet.getBoolean(1));
3333
}
34-
}
34+
}*/
3535

3636
WebhookYouTube hook = new WebhookYouTube(-1, "test", "test", -1, -1, "test");
3737
SQLSession.getSqlConnector().getSqlWorker().updateEntity(hook).block();

0 commit comments

Comments
 (0)