[hibernate-issues] Hibernate search with manytoone association IndexedEmbedded doesnt work
Halil Ağın
halil.agin at gmail.com
Mon Jun 29 06:12:15 EDT 2009
Hello List;
I am trying to implement hibernate search with IndexedEmbedded on my pojos
which are associated with manytoone.
I have two pojo: Diary.java and User.java. the related code segments are
listed below:
=================Diary.java=======================
@Entity(name="tr.com.yazmanak.portal.dal.yazmanak.diary.Diary")
@Table(name="yazmanak_diary")
@Indexed
public class Diary extends BasePojo{
@ManyToOne
@JoinColumn(name="user_fk")
@IndexedEmbedded
private User user;
/* other columns and getter/setter functions omitted*/
}
=================User.java=======================
*/
@Entity(name="tr.com.yazmanak.portal.dal.user.User")
@Table(name="yazmanak_user")
@Indexed
public class User extends BasePojo {
@Column(name="name")
@Field(name="name",index=Index.TOKENIZED,store=Store.NO)
@FieldBridge(impl=StringBridge.class)
private String name;
@OneToMany(mappedBy="user",fetch=FetchType.LAZY,targetEntity=Diary.class)
@ContainedIn
private Set<Diary> diaries;
}
I want to search user name while searching on Diary class. My search test
class is below:
==================SearchTest.java===================
public class SearchTest{
public static List searchByKeyword2(FullTextSession fs) throws
org.apache.lucene.queryParser.ParseException {
org.apache.lucene.queryParser.QueryParser parser =
new QueryParser("id", new StandardAnalyzer() );
org.apache.lucene.search.Query luceneQuery = parser.parse(
"user.name:halil And content:veli");
org.hibernate.Query fullTextQuery = fs.createFullTextQuery(
luceneQuery,Diary.class );
List result = fullTextQuery.list(); //return a list of managed
objects
return result;
}
}
=====================end of codes========================
I want to do search with user.name whike querying onn Diary pojo. But i
couldnt. I search the net for 2 days. Some people encounter the same problem
and some solves also.
but i couldnt what is the problem? any help? By the way, i can search on
other columns but i couldnt search on associated columns such as manytone.
for example, above one.
thank you very much,
regards,
-Halil AĞIN
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20090629/67e5cd26/attachment.html
More information about the hibernate-issues
mailing list