mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Allow configuring database in config.properties.
This commit is contained in:
parent
e6711b197f
commit
1c39359279
2 changed files with 10 additions and 5 deletions
|
@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.StreamingService;
|
|||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import me.kavin.piped.utils.PageMixin;
|
||||
|
||||
public class Constants {
|
||||
|
@ -39,6 +40,8 @@ public class Constants {
|
|||
|
||||
public static final ObjectMapper mapper = new ObjectMapper().addMixIn(Page.class, PageMixin.class);
|
||||
|
||||
public static final Object2ObjectOpenHashMap<String, String> hibernateProperties = new Object2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
|
@ -51,6 +54,11 @@ public class Constants {
|
|||
CAPTCHA_BASE_URL = prop.getProperty("CAPTCHA_BASE_URL");
|
||||
CAPTCHA_API_KEY = prop.getProperty("CAPTCHA_API_KEY");
|
||||
PUBLIC_URL = prop.getProperty("API_URL");
|
||||
prop.forEach((_key, _value) -> {
|
||||
String key = String.valueOf(_key), value = String.valueOf(_value);
|
||||
if (key.startsWith("hibernate"))
|
||||
hibernateProperties.put(key, value);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.hibernate.Session;
|
|||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
import me.kavin.piped.consts.Constants;
|
||||
import me.kavin.piped.utils.obj.db.Channel;
|
||||
import me.kavin.piped.utils.obj.db.User;
|
||||
import me.kavin.piped.utils.obj.db.Video;
|
||||
|
@ -16,11 +17,7 @@ public class DatabaseSessionFactory {
|
|||
|
||||
final Configuration configuration = new Configuration();
|
||||
|
||||
configuration.setProperty("hibernate.connection.url", "jdbc:postgresql://");
|
||||
configuration.setProperty("hibernate.connection.driver_class", "org.postgresql.Driver");
|
||||
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.CockroachDB192Dialect");
|
||||
configuration.setProperty("hibernate.connection.username", "piped");
|
||||
configuration.setProperty("hibernate.connection.password", "@8LQuf7JUabCker$zQYS");
|
||||
Constants.hibernateProperties.forEach((key, value) -> configuration.setProperty(key, value));
|
||||
configuration.setProperty("hibernate.temp.use_jdbc_metadata_defaults", "false");
|
||||
configuration.configure();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue