Author: andrei_exadel
Date: 2009-03-03 08:37:23 -0500 (Tue, 03 Mar 2009)
New Revision: 12800
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/SearchAction.java
Log:
Fix for the search
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/SearchAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/SearchAction.java 2009-03-03
13:37:15 UTC (rev 12799)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/SearchAction.java 2009-03-03
13:37:23 UTC (rev 12800)
@@ -56,9 +56,9 @@
}
public List<Image> searchByUsers(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) {
- StringBuilder b = new StringBuilder("from User u where u.name=:name");
+ StringBuilder b = new StringBuilder("select distinct u from User u, Album a where
u.login=:name");
if (searchInShared) {
- b.append(" and u.childAlbums.shared=true");
+ b.append(" and a.owner=u and a.shared=true");
}
Query query = em.createQuery(b.toString());
@@ -69,20 +69,9 @@
public List<Image> searchByTags(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) {
StringBuilder b = new StringBuilder("from MetaTag t where t.tag=:name");
- if (searchInShared) {
- b.append(" and t.albums.shared=true");
- }
- if (searchInMyAlbums) {
- b.append(" and t.albums.owner.login=:login");
- }
-
Query query = em.createQuery(b.toString());
query.setParameter("name", searchQuery);
- if (searchInMyAlbums) {
- query.setParameter("login", user.getLogin());
- }
-
return query.getResultList();
}
Show replies by date