[JBoss Seam] - Re: Help!!! Seam with Hibernate Search problem
by ljp19820721
Here is the source code.
/**
*
* @author lv.jianping
*/
@Stateful
@Name(value = "search")
public class SearchBean implements SearchLocal, Serializable {
@PersistenceContext
private EntityManager em;
int pageSize = 15;
int currentPage = 0;
boolean hasMore = false;
int resultsNumber = 0;
String searchQuery;
@DataModel
List searchResults;
@DataModelSelection
@Out(required = false)
Content selectedContent;
public Content getSelectedContent() {
return selectedContent;
}
public void getSearchResults() {
doSearch();
}
public String getSearchQuery() {
return searchQuery;
}
public void setSearchQuery(String searchQuery) {
this.searchQuery = searchQuery;
}
public int getResultsNumber() {
return resultsNumber;
}
public String doSearch() {
currentPage = 0;
updateResults();
return "searchResults";
}
public void doIndex() {
FullTextEntityManager ftEm = Search.createFullTextEntityManager(em);
List contents = em.createQuery("select c from Content c where c.isdeleted='0' and c.contentstate='1' ").getResultList();
for (Object object : contents){
ftEm.index((Content)object);
}
}
public void nextPage() {
if (!isLastPage()) {
currentPage++;
updateResults();
}
}
public void prePage() {
if (!isFirstPage()) {
currentPage--;
updateResults();
}
}
public boolean isLastPage() {
return (searchResults != null) && !hasMore;
}
public boolean isFirstPage() {
return (searchResults != null) && (currentPage == 0);
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = 10;
}
private javax.persistence.Query searchQuery(String searchQuery) throws ParseException {
Map<String, Float> boostPerField = new HashMap<String, Float>();
boostPerField.put("contenttitle", 4f);
boostPerField.put("contentbody", 2f);
boostPerField.put("contentbodysms", 2f);
String[] contentFields = {"contenttitle", "contentbody", "contentbodysms"};
QueryParser parser = new MultiFieldQueryParser(contentFields, new StandardAnalyzer(), boostPerField);
parser.setAllowLeadingWildcard(true);
org.apache.lucene.search.Query luceneQuery = parser.parse(searchQuery);
FullTextEntityManager ftEm = Search.createFullTextEntityManager(em);
//********Here Exception is throwed out*************//
javax.persistence.Query query = ftEm.createFullTextQuery(luceneQuery, Content.class);
return query;
}
private void updateResults() {
Query query;
try {
query = searchQuery(searchQuery);
} catch (ParseException pe) {
return;
}
@SuppressWarnings(value = "unchecked")
List items = query.setMaxResults(pageSize + 1).setFirstResult(pageSize * currentPage).getResultList();
resultsNumber = items.size();
if (items.size() > pageSize) {
searchResults = new ArrayList(items.subList(0, pageSize));
hasMore = true;
} else {
searchResults = items;
hasMore = false;
}
}
@Destroy
@Remove
public void destroy() {
}
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098664#4098664
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098664
18Â years, 6Â months
[JBoss Tools (users)] - Re: Any maven-ish directory support planned? Team Web-Develo
by max.andersenï¼ jboss.com
What is the problem with the wtp directory structure ? Maven supports having multiple projects.
Anyway you can enable JSF support on normal projects too; just not sure all features will be enabled because arbitrary project structures won't contain all the information needed to work.
In any case, there is nothing magic about our tooling compared to eclipse - how would you do projects in a team with eclipse anyway ?
I do it by having multiple projects for each larger module (just like maven) and maven even supports generating WTP projects BUT unfortunately that doesn't enable our features so I recommend using the maven eclipse:eclipse generation initially and then use eclipse to adjust the project/classpath and settings that eclipse knows about.
But yes you will need to use ant or maven to write the build scripts - nothing different from normal eclipse.
Note: we will look into automating these things in the future, but for now we rely on that both ant and maven can work with Eclipse as is.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098662#4098662
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098662
18Â years, 6Â months
[JBoss Seam] - Help!!! Seam with Hibernate Search problem
by ljp19820721
Help!!!
I use seam1.2.1 and Hibernate Search3.0GA .The server is GlassfishV2.
I have saw the FullTextSession source code. And the "createFullTextQuery"
method is exactly exist.
Caused by: java.lang.NoSuchMethodError: org.hibernate.search.FullTextSession.createFullTextQuery(Lorg/apache/lucene/search/Query;[Ljava/lang/Class;)Lorg/hibernate/search/FullTextQuery;
at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.createFullTextQuery(FullTextEntityManagerImpl.java:61)
at com.feelingmobile.mobilestore.session.SearchBean.searchQuery(SearchBean.java:148)
at com.feelingmobile.mobilestore.session.SearchBean.updateResults(SearchBean.java:158)
at com.feelingmobile.mobilestore.session.SearchBean.doSearch(SearchBean.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4005)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:483)
at com.sun.ejb.Invocation.proceed(Invocation.java:498)
... 95 more
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098658#4098658
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098658
18Â years, 6Â months
[JBoss Seam] - Problem with EntityQuery, Design Question about it
by Eethyo
Hi,
I used Seam-gen to create a CRUD Application out of my database.
Works fine so far, but i now i, of course, need to customize it for my needs.
I need to run a query and i think i should use the package com.ccms30.entities;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import java.util.List;
import java.util.Arrays;
@Name("ccmsProductlineList")
| public class CcmsProductlineList extends EntityQuery {
|
| /**
| *
| */
| private static final long serialVersionUID = 1L;
|
| private static final String[] RESTRICTIONS = {
| "lower(ccmsProductline.name) like concat(lower(#{ccmsProductlineList.ccmsProductline.name}),'%')",
| "lower(ccmsProductline.description) like concat(lower(#{ccmsProductlineList.ccmsProductline.description}),'%')",};
|
| private CcmsProductline ccmsProductline = new CcmsProductline();
|
| @Override
| public String getEjbql() {
| return "select ccmsProductline from CcmsProductline ccmsProductline";
| }
|
| @Override
| public Integer getMaxResults() {
| return 25;
| }
|
| public CcmsProductline getCcmsProductline() {
| return ccmsProductline;
| }
|
| @Override
| public List<String> getRestrictions() {
| return Arrays.asList(RESTRICTIONS);
| }
|
| }
this Class for it.
So here are my questions:
- How should i run a query on an attribute? just, for example, set the name in object ccmsProductline and then run getResultList? or should i write an own class? how to design my own querys, which are nothing else than a list so far?
- Why can i just use this class if I inject it into my the Bean i call it from?
I cant create CcmsProductline ccmsProductline = new CcmsProductline(); and then use it... why? Would make things much more easy.
Thanks a lot.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098652#4098652
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098652
18Â years, 6Â months