Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/394.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.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_Hibernate_Jpa_Caching - Fatal编程技术网

Java 休眠实体的二级缓存,获取所有实体的重复属性值

Java 休眠实体的二级缓存,获取所有实体的重复属性值,java,hibernate,jpa,caching,Java,Hibernate,Jpa,Caching,我有一个国家的经典实体,它是完全不可变的,而且很小,所以我决定用hibernate缓存实体,但是如果我在查询所有实体时启用实体缓存,我会得到除了重复id之外的其他属性(即,一个具有不同id但名称相同的列表,所有其他字段的值也相同) hibernate配置如下所示: hibernate.dialect=org.hibernate.spatial.dialect.mysql.MySQLSpatialDialect hibernate.format_sql=true hibernate.hbm2ddl

我有一个国家的经典实体,它是完全不可变的,而且很小,所以我决定用hibernate缓存实体,但是如果我在查询所有实体时启用实体缓存,我会得到除了重复id之外的其他属性(即,一个具有不同id但名称相同的列表,所有其他字段的值也相同)

hibernate配置如下所示:

hibernate.dialect=org.hibernate.spatial.dialect.mysql.MySQLSpatialDialect
hibernate.format_sql=true
hibernate.hbm2ddl.auto=update
hibernate.hbm2ddl.import_files=data-catalogs-create.sql,data-mysql-sample.sql
hibernate.hbm2ddl.import_files_sql_extractor=org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor
hibernate.implicit_naming_strategy=com.example.util.ImplicitNamingStrategy
hibernate.physical_naming_strategy=com.example.util.PhysicalNamingStrategyImpl
hibernate.show_sql=false
hibernate.cache.region.factory_class=org.hibernate.cache.redis.hibernate5.SingletonRedisRegionFactory
hibernate.cache.region_prefix=hibernate
hibernate.cache.use_second_level_cache=true
hibernate.cache.use_query_cache=true
hibernate.cache.use_structured_entries=true
hibernate.cache.provider_configuration_file_resource_path=hibernate-redis.properties
hibernate.generate_statistics=false
hibernate.search.default.directory_provider=filesystem
hibernate.search.default.indexBase=/var/lucene/indexes
equals/hashCode基于实体id,我对其进行了测试(guava测试),因此我放弃了一些与此相关的错误

当我删除/注释@Cacheable/@Cache注释时,问题就消失了

hibernate.dialect=org.hibernate.spatial.dialect.mysql.MySQLSpatialDialect
hibernate.format_sql=true
hibernate.hbm2ddl.auto=update
hibernate.hbm2ddl.import_files=data-catalogs-create.sql,data-mysql-sample.sql
hibernate.hbm2ddl.import_files_sql_extractor=org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor
hibernate.implicit_naming_strategy=com.example.util.ImplicitNamingStrategy
hibernate.physical_naming_strategy=com.example.util.PhysicalNamingStrategyImpl
hibernate.show_sql=false
hibernate.cache.region.factory_class=org.hibernate.cache.redis.hibernate5.SingletonRedisRegionFactory
hibernate.cache.region_prefix=hibernate
hibernate.cache.use_second_level_cache=true
hibernate.cache.use_query_cache=true
hibernate.cache.use_structured_entries=true
hibernate.cache.provider_configuration_file_resource_path=hibernate-redis.properties
hibernate.generate_statistics=false
hibernate.search.default.directory_provider=filesystem
hibernate.search.default.indexBase=/var/lucene/indexes