jpa - How i can achieve relational data using Hibernate Search? -


i using jparepository, chose hibernate search implementing search functionality.

here link : http://hibernate.org/search/documentation/getting-started/

using entitymanager (jpa) rebuild index

fulltextentitymanager ftem = search.getfulltextentitymanager(entitymanager); ftem.createindexer().startandwait();

suppose have 2 entity classes company.java & employee.java.

employees(e_id) saved under company(c_id) , relation stored in table "company_employee".

i want implement search on employees(not employees of other companies) associated company account.

for eg: select e_id company_employee c_id = ?
assume getting 3 employees of company , want fetch record of these 3 employees , not others.

you fetch company , not employee :

querybuilder qb = fulltextentitymanager.getsearchfactory()     .buildquerybuilder().forentity(company.class).get(); 

in lucene query :

lucenequery = querybuilder.keyword().wildcard().onfields("employees.employeename").matching("m*").createquery()

employees field annotatted @indexedembedded.

public class company { ... @indexedembedded private list<employee> employees;  ... } 

you company employees , not employees. (i don't know if have use eager fetch or not) looking ?


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -