-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate Search: Embedded Entity Not Accessible
PostPosted: Fri Feb 13, 2009 4:23 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
I have an object model where I have an abstract superclass called Recipient which is extended by concrete subclasses called Customer and Contact. Recipient contains an entity called Address, and as a result, Customer and Contact both contain Address. Customer also contains a collection of Contacts.

Here is some code to help clarify:

Code:
@MappedSuperclass
public abstract class Recipient {
   private Address address;

   @ManyToOne(fetch= FetchType.LAZY, cascade= CascadeType.PERSIST)
   @JoinColumn(name = "ADDRESS_ID", nullable = false)
   @IndexedEmbedded
   public Address getAddress() {
      return address;
   }

   public void setAddress(Address address) {
      this.address = address;
   }
}

----------------------------


@Entity
@Table(name = "ADDRESS")
@Indexed
public class Address {
.
.
.
}


----------------------------


@Entity
@Table(name = "CONTACT")
@Indexed
public class Contact extends Recipient {
.
.
.
}



----------------------------



@Entity
@Table(name = "CUSTOMER")
@Indexed
public class Customer extends Recipient {
.
.
.
  @OneToMany(fetch= FetchType.LAZY, cascade= CascadeType.PERSIST)
   @JoinColumn(name = "CUSTOMER_ID", nullable = false)
   @IndexedEmbedded
   public List<Contact> getContacts() {
      return contacts;
   }

   public void setContacts(List<Contact> contacts) {
      this.contacts = contacts;
   }
.
.
.
}




As you can see, both Customer and Contact inherit an Address from Recipient, and Customer has a collection of Contacts.

The problem is that I cannot access the Contact's Address from the Customer. In other words, the mapping as I have it now does not allow me to make a query like contacts.address.city:Philadelphia from the Customer index. Yet I can still access other Contact items inherited from Recipient like phoneNumber, and I can certainly access the Customer's own address through address.city.

Please let me know how I need to alter my mappings to generate the indexes for Address from the Contact level.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 16, 2009 4:57 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

unfortunately you are leaving a lot of gaps in your mappings. It would especially be interesting to see the fully mapped (including all @Field annotations) Address and Recipient entities.

Have you tried to inspect your index using Luke. This way you can exactly see which properties make it into the index.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 18, 2009 10:03 am 
Newbie

Joined: Wed Feb 18, 2009 9:55 am
Posts: 2
Hi,

I have the same problem!
I have a mapping whith result in a field "keywordses.keyword" in a document index. Looking into it with Luke I see all the data stored in tehe field but if I try to access the field with projection I always get NULL.

-- Sushi


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.