Skip to content

Commit

Permalink
Added error warning to inform user about major Issue.
Browse files Browse the repository at this point in the history
Removed debug information.
  • Loading branch information
DxsSucuk committed Dec 12, 2022
1 parent 7064617 commit 61a11fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/main/java/de/presti/ree6/webinterface/sql/SQLSession.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package de.presti.ree6.webinterface.sql;

import de.presti.ree6.webinterface.Server;
import de.presti.ree6.webinterface.bot.BotWorker;
import jakarta.persistence.Table;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
Expand Down Expand Up @@ -54,8 +56,12 @@ public static SessionFactory buildSessionFactory(String username, String passwor
properties.put("hibernate.connection.password", password);
properties.put("hibernate.hikari.maximumPoolSize", String.valueOf(maxPoolSize));
properties.put("hibernate.dialect", Server.getInstance().getSqlConnector().getDatabaseTyp().getHibernateDialect());
properties.put("hibernate.show_sql", true);
properties.put("hibernate.format_sql", true);

if (BotWorker.getVersion().isDebug()) {
properties.put("hibernate.show_sql", true);
properties.put("hibernate.format_sql", true);
}

properties.put("hibernate.hbm2ddl.auto", "update");
properties.put("jakarta.persistence.schema-generation.database.action", "update");

Expand All @@ -70,7 +76,10 @@ public static SessionFactory buildSessionFactory(String username, String passwor

classSet.forEach(configuration::addAnnotatedClass);

System.out.println(classSet);
if (classSet.isEmpty()) {
log.error("No SQL-Entity classes found!");
log.error("Note that this means that the SQL Mapping will fail and you will not be able to retrieve the correct data!");
}

ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/presti/ree6/webinterface/sql/SQLWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ public GuildCommandStats getStatsCommand(String guildId, String command) {
* @return all the Command-Stats related to the given Guild.
*/
public List<GuildCommandStats> getStats(String guildId) {
return (List<GuildCommandStats>) getEntityList(new GuildCommandStats(), "SELECT * FROM GuildStats WHERE gid=:gid ORDER BY CAST(uses as INT) DESC LIMIT 5", Map.of("gid", guildId));
return getEntityList(new GuildCommandStats(), "SELECT * FROM GuildStats WHERE gid=:gid ORDER BY CAST(uses as INT) DESC LIMIT 5", Map.of("gid", guildId));
}

/**
Expand All @@ -1543,7 +1543,7 @@ public List<GuildCommandStats> getStats(String guildId) {
* @return all the Command-Stats globally.
*/
public List<CommandStats> getStatsGlobal() {
return (List<CommandStats>) getEntityList(new CommandStats(), "SELECT * FROM CommandStats ORDER BY CAST(uses as INT) DESC LIMIT 5", null);
return getEntityList(new CommandStats(), "SELECT * FROM CommandStats ORDER BY CAST(uses as INT) DESC LIMIT 5", null);
}

/**
Expand Down

0 comments on commit 61a11fa

Please sign in to comment.