Hi,
I have a problem mapping entity with composite ID. Right now I'm using hibernate-search 3.4.2(would prefer to stay but don't mind upgrading if unevitable).
I have entity Execution that uses composite id(only combination of all 3 is unique in table). The id is embeded so it uses only 1 table. It is mapped using hbm.xml file:
Code:
<class name="com.myApp.model.Execution" table="EXECS" lazy="true">
<composite-id name="execId" class="com.myApp.model.ExecutionPK">
<key-property name="id" type="string" length="128"/>
<key-property name="execDate" type="date"/>
<key-property name="sourceSystem" type="string" length="128"/>
</composite-id>
<property name="rootId" type="string" length="128" />
<property name="accountID" type="string" length="128" index="idxExecAccountId"/>
</class>
What would be the correct mapping of the id if I need to be able to search by execDate(bridged by DAY)?
Documentation is not really clear in this. One of solutions would be to create a getter in Execution:
Code:
@Field(index = Index.UN_TOKENIZED, store = Store.YES)
@DateBridge(resolution = Resolution.DAY)
public Date getExecDate() {
return execId.getExecDate();
}
But how do I tell hibernate-search that private ExecutionPK execId; is ID? It doesn't know how to map iot back and forth. I guess I could use custom bridge(use smt like id.toString+execDate.toString()+sourceSystem.toString()) but how does hibernate-search then select this entity from DB if its composed key of 3 fields? Is there smt like bidirectional bridge?
Tried google but no luck so far. Documentation mentions how to map embedded entities but not how to deal with it if its composed PK.
Thanks
J.