-->
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.  [ 1 post ] 
Author Message
 Post subject: Accessing properties in superclass
PostPosted: Thu Jun 27, 2013 10:41 am 
Newbie

Joined: Thu Jun 27, 2013 10:21 am
Posts: 1
I'm having problems constructing a query in an inheritance hierarchy. Here's a schematic of the classes involved (non-relevant annotations omitted):

Code:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
class BasicEntity { 
  @Id
  private int id;
}

@Entity
@Indexed
class Person extends BasicEntity { 
  @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
  private String name;
}

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(...)
class EntityRelation<O extends BasicEntity> {
  @Id
  private int id;
  @IndexedEmbedded
  @OneToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST}, fetch = FetchType.EAGER)
  @JoinColumn(...)
  private BasicEntity owner;
}

@Indexed
@Entity
@DiscriminatorValue(...)
class Insurant extends EntityRelation<Person> {
  @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
  private String insuranceNumber;
}


Now I would like to find an Insurant using the name of its inherited owner (a BasicEntity). But I can't get this to work, no matter whether I use the Lucene Query API or the Hibernate DSL API. Here's the sort of thing I've been trying:

Code:
    FullTextSession session = org.hibernate.search.Search.getFullTextSession(getSession());
   
    QueryBuilder qb1 = session.getSearchFactory().buildQueryBuilder().forEntity(Insurant.class).get();
    org.apache.lucene.search.Query query1 =
        qb1.keyword().
        onField("owner.name").
        matching("Bill").
        createQuery();
   
    FullTextQuery ftq = session.createFullTextQuery(query1);
    List result = ftq.list();


The above code gets an exception:

Quote:
org.hibernate.search.SearchException: Unable to find field owner in my.class.Insurant


I've also tried any number of variations of the above, including indexing the superclasses.
Is there any way of accomplishing this?


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

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.