Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java -_Java_Mysql_Maven_Spring Boot_Entitymanager - Fatal编程技术网

Java -

Java -,java,mysql,maven,spring-boot,entitymanager,Java,Mysql,Maven,Spring Boot,Entitymanager,如果我删除了Adao.java类中的启用过滤器,那么它可以正常工作 另一种情况是,如果我使用SessionFactory而不是entitymanager,结果是相同的 如何解决此问题?基本上,DynamicFilterAliasGenerator存在一个问题,它不尊重hibernate.default\u schema(它知道有表P_AENTITY,但由于没有关于默认方案的信息,因此无法将运行时表名myschema.P_AENTITY与它拥有的表名进行比较) 因此,如果需要快速修复,只需从hib

如果我删除了Adao.java类中的启用过滤器,那么它可以正常工作

另一种情况是,如果我使用SessionFactory而不是entitymanager,结果是相同的


如何解决此问题?

基本上,
DynamicFilterAliasGenerator
存在一个问题,它不尊重
hibernate.default\u schema
(它知道有表
P_AENTITY
,但由于没有关于默认方案的信息,因此无法将运行时表名
myschema.P_AENTITY
与它拥有的表名进行比较)

因此,如果需要快速修复,只需从hibernate配置中删除
hibernate.default\u模式,并在
jdbc.url
上进行中继。 因此,与其有这样的东西

properties.put("hibernate.default_schema", "myschema");
DriverManagerDataSource ds = new DriverManagerDataSource();
....
ds.setUrl("jdbc:mysql://localhost:3306/myschema");
....
JDBCURL中的模式如下所示

properties.put("hibernate.default_schema", "myschema");
DriverManagerDataSource ds = new DriverManagerDataSource();
....
ds.setUrl("jdbc:mysql://localhost:3306/myschema");
....

首先,您可以检查您的hibernate配置是否具有以下属性:

hibernate.dialect=org.hibernate.dialect.MySQLDialect  //you should use mysql dialect from pom I see that you use mysql
#hibernate.default_schema=myCustomName                //commented out in case you want use default schema, else you can use this property to create your custom schema
hibernate.show_sql=true                               //this will help so see what queries are executed
hibernate.format_sql=true                             //this will print formatted sql
hibernate.hbm2ddl.auto=create                         //this will generate database tables if they don't exist in DB, also you can change to "update" this property then database will get updates.
第二件事我怀疑引号可能有问题,它们是JPA样式的,但在hibernate try中没有(是否有理由在过滤器中使用大写状态?)


谢谢你的回答,这很有效。如果这是一个快速解决方案,那么这种情况的真正解决方案是什么?真正的解决方案将是查看hibetnate来源,解决那里的问题,创建一个公共关系并帮助社区。)
properties.put("hibernate.default_schema", "myschema");
DriverManagerDataSource ds = new DriverManagerDataSource();
....
ds.setUrl("jdbc:mysql://localhost:3306/myschema");
....
hibernate.dialect=org.hibernate.dialect.MySQLDialect  //you should use mysql dialect from pom I see that you use mysql
#hibernate.default_schema=myCustomName                //commented out in case you want use default schema, else you can use this property to create your custom schema
hibernate.show_sql=true                               //this will help so see what queries are executed
hibernate.format_sql=true                             //this will print formatted sql
hibernate.hbm2ddl.auto=create                         //this will generate database tables if they don't exist in DB, also you can change to "update" this property then database will get updates.
@Entity
@Table(name = DataSourceContext.DB_PREFIX + "AENTITY")
@FilterDef(name = "statusFilter", defaultCondition = "`status` = :status ", parameters = @ParamDef(name = "status", type = "string"))
@Filter(name = "statusFilter", condition = "`status` = :status")
public class Aentity implements Serializable {
    private Long id;
    private EntityStatus status;
    private Date createdDate;
    private Date updatedDate;
    private Date deletedDate;
    private Long version;

    // getters and setter with column annotations.
}