我有两个 Java 应用程序manager和server,它们使用共享库domain。Hibernate 映射是通过域源中的注释定义的。
我想要完成的是将服务器的缓存策略覆盖为某些性能测试的“只读”缓存策略。在注释文档之后,我来到了我尝试的地方:
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings
xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
version="2.0">
<entity class="com.example.data.Entity" metadata-complete="false">
<cache usage="read-only"/>
</entity>
...
</entity-mappings>
尝试镜像注释标记,将其与这些说明混合。问题是, entity没有允许的元素缓存,我得到:
Error parsing XML (line66 : column 108): cvc-complex-type.2.4.a: Invalid content was found starting with element 'cache'. One of '{"http://java.sun.com/xml/ns/persistence/orm":description, "http://java.sun.com/xml/ns/persistence/orm":table, "http://java.sun.com/xml/ns/persistence/orm":secondary-table, "http://java.sun.com/xml/ns/persistence/orm":primary-key-join-column, "http://java.sun.com/xml/ns/persistence/orm":id-class, "http://java.sun.com/xml/ns/persistence/orm":inheritance, "http://java.sun.com/xml/ns/persistence/orm":discriminator-value, "http://java.sun.com/xml/ns/persistence/orm":discriminator-column, "http://java.sun.com/xml/ns/persistence/orm":sequence-generator, "http://java.sun.com/xml/ns/persistence/orm":table-generator, "http://java.sun.com/xml/ns/persistence/orm":named-query, "http://java.sun.com/xml/ns/persistence/orm":named-native-query, "http://java.sun.com/xml/ns/persistence/orm":sql-result-set-mapping, "http://java.sun.com/xml/ns/persistence/orm":exclude-default-listeners, "http://java.sun.com/xml/ns/persistence/orm":exclude-superclass-listeners, "http://java.sun.com/xml/ns/persistence/orm":entity-listeners, "http://java.sun.com/xml/ns/persistence/orm":pre-persist, "http://java.sun.com/xml/ns/persistence/orm":post-persist, "http://java.sun.com/xml/ns/persistence/orm":pre-remove, "http://java.sun.com/xml/ns/persistence/orm":post-remove, "http://java.sun.com/xml/ns/persistence/orm":pre-update, "http://java.sun.com/xml/ns/persistence/orm":post-update, "http://java.sun.com/xml/ns/persistence/orm":post-load, "http://java.sun.com/xml/ns/persistence/orm":attribute-override, "http://java.sun.com/xml/ns/persistence/orm":association-override, "http://java.sun.com/xml/ns/persistence/orm":attributes}' is expected.
当我尝试返回hibernate-core XML 标记时,我得到了<class>定义不完整的错误,而且我似乎找不到元数据完整的模拟。有谁知道我正在尝试做的事情是否可行?如果是这样,我将必须采取哪些步骤?谢谢!