Compass的SearchableReference

Class Entry
@Searchable(alias="entry")
{
@SearchableId
String id...}
@Searchable(alias="comment")
Class Comment
{@SearchableId
String id
...
@SearchableReference(refAlias="entry")
private Entry entry;
}

如上,按照我的理解,当检索到一个Comment对象时,Compass会把这条Comment对应的Entry也取出来。因为在SearchableReference的doc中有这么一句
[quote]A searchable reference is a class field/property that reference another class, and the relationship need to be stored by Compass so it can be traversed when getting the class from the index. [/quote]
然而,当我用Compass为数据库建立索引时,收到一个异常
[quote]cannot marshall a null id[/quote]

但是通过cpm.xml文件配置,建立索引,检索都没有问题,配置文件如下,难道被我发现了一个bug? :o

//Entry.cpm.xml
<?xml version="1.0"?>
<!DOCTYPE compass-core-mapping PUBLIC
"-//Compass/Compass Core Mapping DTD 1.0//EN"
"http://www.opensymphony.com/compass/dtd/compass-core-mapping.dtd">

<compass-core-mapping package="xxx.xxx.pojos">
<class name="Entry" alias="entry">
<id name="id" />
...
<property name="title">
<meta-data>title</meta-data>
</property>
<property name="content">
<meta-data>content</meta-data>
</property>
</class>
</compass-core-mapping>



//Comment.cpm.xml
<?xml version="1.0"?>
<!DOCTYPE compass-core-mapping PUBLIC
"-//Compass/Compass Core Mapping DTD 1.0//EN"
"http://www.opensymphony.com/compass/dtd/compass-core-mapping.dtd">

<compass-core-mapping package="com.gln.bloger.pojos">
<class name="Comment" alias="comment">
<id name="id" />
...
<property name="content">
<meta-data>content</meta-data>
</property>

<reference name="entry"/>
</class>
</compass-core-mapping>
阅读更多
文章标签: iBATIS XML
个人分类: Java
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭