[hibernate-issues] [Hibernate-JIRA] Created: (HSEARCH-1050) DocumentId ignored in case of EmbeddedId

Marc Schipperheyn (JIRA) noreply at atlassian.com
Thu Feb 16 21:11:10 EST 2012


DocumentId ignored in case of EmbeddedId
----------------------------------------

                 Key: HSEARCH-1050
                 URL: https://hibernate.onjira.com/browse/HSEARCH-1050
             Project: Hibernate Search
          Issue Type: Bug
          Components: engine
    Affects Versions: 4.1.0.Beta2, 4.0.0.Final
            Reporter: Marc Schipperheyn
            Priority: Blocker


When a class contains both a @DocumentId and an @EmbeddedId set at different fields, Hibernate Search should use the DocumentId field. 
However, I'm noticing in 4.1.0Beta2 that in this case, the EmbeddedId field is used. In my case this leads to a 


org.hibernate.search.bridge.BridgeException: Exception while calling bridge#objectToString
	class: nl.project.model.NetworkCandidateLink
	field bridge: id
	at org.hibernate.search.bridge.util.impl.ContextualExceptionBridge.buildBridgeException(ContextualExceptionBridge.java:78)
	at org.hibernate.search.bridge.util.impl.ContextualException2WayBridge.objectToString(ContextualException2WayBridge.java:84)
	at org.hibernate.search.batchindexing.impl.EntityConsumerLuceneWorkProducer.index(EntityConsumerLuceneWorkProducer.java:164)
	at org.hibernate.search.batchindexing.impl.EntityConsumerLuceneWorkProducer.indexAllQueue(EntityConsumerLuceneWorkProducer.java:134)
	at org.hibernate.search.batchindexing.impl.EntityConsumerLuceneWorkProducer.run(EntityConsumerLuceneWorkProducer.java:105)
	at org.hibernate.search.batchindexing.impl.OptionallyWrapInJTATransaction.run(OptionallyWrapInJTATransaction.java:112)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: nl.project.model.NetworkCandidateLinkId cannot be cast to java.lang.String
	at org.hibernate.search.bridge.builtin.StringBridge.objectToString(StringBridge.java:39)
	at org.hibernate.search.bridge.builtin.impl.TwoWayString2FieldBridgeAdaptor.objectToString(TwoWayString2FieldBridgeAdaptor.java:48)
	at org.hibernate.search.bridge.util.impl.ContextualException2WayBridge.objectToString(ContextualException2WayBridge.java:77)
	... 7 more

I'm failry certain this was working correctly in 3.x

The class configuration is as follows:
@Entity
@Table
@AssociationOverrides({
	@AssociationOverride(name = "pk.network", 
		joinColumns = @JoinColumn(name = "nwId")),
	@AssociationOverride(name = "pk.candidate", 
		joinColumns = @JoinColumn(name = "cId"))
})
@Indexed
public class NetworkCandidateLink implements Serializable{

	private NetworkCandidateLinkId pk = new NetworkCandidateLinkId();


	@EmbeddedId
	public NetworkCandidateLinkId getPk() {
		return pk;
	}

	public void setPk(NetworkCandidateLinkId pk) {
		this.pk = pk;
	}

	@DocumentId
	@Transient
	public String getId(){
		return pk.getCandidate().getId() + "_" + pk.getNetwork().getId();
	}


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list