java - Dropwizard for Hibernate 中的 SQLite 方言

标签 java web-services hibernate dropwizard dialect

我正在使用 dropwizard 和 SQLight 作为 hibernate 的数据库,为裁缝系统创建一个项目作为 RESTful Web 服务。问题是 hibernate 没有 SQLight 的方言,因此通过搜索获得了 SQLightDialect 的类代码。

现在我必须添加 SQLightDialect 类供 hibernate 使用,但不知道如何在 dropwizard 中执行此操作。

请帮忙。

最佳答案

通过添加解决

Map<String,String> s=new HashMap<String, String>();
    s.put("hibernate.dialect","Hibernate.SQLightDialect.SQLiteDialect");
    dbconfigurations.setProperties(s);

public class databaseConfiguration extends Configuration {

@Valid
@NotNull
@JsonProperty
DatabaseConfiguration dbconfigurations = new DatabaseConfiguration();

public DatabaseConfiguration getDatabaseConfiguration() {
    //return dbconfigurations;
    Map<String,String> s=new HashMap<String,String>();
    s.put("hibernate.dialect","Hibernate.SQLightDialect.SQLiteDialect");
    dbconfigurations.setProperties(s);
    return dbconfigurations;
}
}

另一个解决方案请阅读 Web将其添加到 yml 文件中,例如:

database:
# the name of your JDBC driver
driverClass: org.postgresql.Driver
# the username
user: username
# the password
password: password
# the JDBC URL
url: jdbc:postgresql://localhost:5432/gis_database
properties:
hibernate.dialect: org.hibernate.spatial.dialect.postgis.PostgisDialect

关于java - Dropwizard for Hibernate 中的 SQLite 方言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21230220/

相关文章:

java - Hibernate 延迟加载 - 获取列表中的列表项

java - 线程局部变量

java - java中来自服务器的错误

java - 如何将数据从一个网络服务发送到另一个网络服务?

java - 对象数据库与经典 MySQL

java - hibernate JPA 2.1 : OUT REF CURSOR in position other than first?

java - hashCode() 可以有动态变化的内容吗?

java - "No such operation" Axis 网络服务错误

wcf - 保存 SoapUI 项目时如何保存响应

java - 如何在同一个 Hibernate 事务中运行原生 SQL 查询?