-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Hibernate Search on Composite Ids
PostPosted: Fri Nov 02, 2007 1:45 pm 
Newbie

Joined: Fri Jul 27, 2007 4:24 pm
Posts: 5
Hi,

I have the following model:

Code:
@Entity
@IdClass(PersonId.class)
@Indexed(index="indexes/person")
public class Person implements Serializable {
   
    private long organizationId;
    private long personId;
    private String name;
   
    @Id
    public long getOrganizationId() {
        return organizationId;
    }
   
    public void setOrganizationId(long organizationId) {
        this.organizationId = organizationId;
    }
   
    @Id
    public long getPersonId() {
        return personId;
    }
   
    public void setPersonId(long personId) {
        this.personId = personId;
    }
   
    public String getName() {
        return name;
    }
   
    public void setName(String name) {
        this.name = name;
    }
}

@Embeddable
public class PersonId implements Serializable {
   
    private long organizationId;
    private long personId;
   
    public long getOrganizationId() {
        return organizationId;
    }
   
    public void setOrganizationId(long organizationId) {
        this.organizationId = organizationId;
    }
   
    public long getPersonId() {
        return personId;
    }
   
    public void setPersonId(long personId) {
        this.personId = personId;
    }
   
    // override equals/hashCode
}


When I do the search, I get the following error:
Code:
Caused by: java.lang.NumberFormatException: For input string: "com.test.entity.PersonId@e79f7c35"
   at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
   at java.lang.Long.parseLong(Long.java:403)
   at java.lang.Long.<init>(Long.java:671)
   at org.hibernate.search.bridge.builtin.LongBridge.stringToObject(LongBridge.java:14)
   at org.hibernate.search.bridge.TwoWayString2FieldBridgeAdaptor.get(TwoWayString2FieldBridgeAdaptor.java:32)
   at org.hibernate.search.engine.DocumentBuilder.getDocumentId(DocumentBuilder.java:626)
   at org.hibernate.search.engine.DocumentExtractor.extract(DocumentExtractor.java:30)
   at org.hibernate.search.engine.DocumentExtractor.extract(DocumentExtractor.java:40)
   at org.hibernate.search.query.FullTextQueryImpl.list(FullTextQueryImpl.java:241)
   at com.test.search.impl.SearchProviderImpl.searchPersons(SearchProviderImpl.java:52)
   ... 28 more


I'm I doing something wrong with the mappings?

Thanks,

Pavel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 02, 2007 2:18 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Today, Hibernate Search does not support IdClass mappings.
It supports @EmbeddedId but you need to write a custom field bridge.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: Hibernate Search on Composite Ids
PostPosted: Tue Jul 14, 2009 7:06 am 
Newbie

Joined: Tue Jul 14, 2009 6:13 am
Posts: 12
November 2007 has gone. we have July 2009 now.
Does Hibernate Search support IdClass mappings today?

#edit
Okay, I have challenged my complicated Composite Key with the TwoWayFieldBridge. My class to index still uses @IdClass. :)


Top
 Profile  
 
 Post subject: Re: Hibernate Search on Composite Ids
PostPosted: Wed Jul 15, 2009 8:41 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
If someone comes with a nice solution, we can add it to the codebase, but I tend to like the custom bridge approach.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.