How to implement custom "find" methods in GWT+roo scaffolding app

58 views
Skip to first unread message

Zed

unread,
Feb 25, 2011, 9:00:59 AM2/25/11
to Google Web Toolkit
Hellow everyone, I started to deal with GWT+roo scaffolding ap and
found the idea very cool. Thank you guys!
But I found it hard for me to understanf how to implement custom
"find" methods like for example - findAllEmployeesByName.
I looked all the documentations and it's written there that I can add
this method to Entity object itself like this:

@RooJavaBean
@RooToString
@RooEntity
public class Employee {

.....

@NotNull
private String displayName;

@SuppressWarnings("unchecked")
public static List<Employee> findAllEmployeesByName(String name){
return entityManager().createQuery("select ....... from Employee
o").getResultList();
}
}
I added it but nothing happend. No code generation started.
I see all finder methods are in Aspects which are generated by Roo
itself and I can't put my code there.
Can you guys give me some hint please.

With respect
Andrew Efremov

Zed

unread,
Mar 1, 2011, 4:50:00 AM3/1/11
to Google Web Toolkit
At the moment I moved forward. In ROO-931 its says us "At the moment
the gwt setup command generates request objects for all finder
methods" (from here
https://jira.springsource.org/browse/ROO-931?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#issue-tabs).
I added 'finder' using Roo shell command: finder add
findEmployeesByDepartmentEquals
After that Roo generated me an Aspect:

privileged aspect Employee_Roo_Finder {

public static Query
Employee.findEmployeesByDepartmentEquals(String department) {
if (department == null || department.length() == 0) throw new
IllegalArgumentException("The department argument is required");
EntityManager em = Employee.entityManager();
Query q = em.createQuery("SELECT Employee FROM Employee AS
employee WHERE employee.department = :department");
q.setParameter("department", department);
return q;
}

and added anotation to Employee.java: @RooEntity(finders =
{"findEmployeesByDepartmentEquals"})
but no request objects generated. My EmployeeRequest.java (generated
and maintained by Roo) looks as follows (I can't see finder methods
there):

@RooGwtMirroredFrom("org.springsource.roo.extrackgae.server.domain.Employee")
@ServiceName("org.springsource.roo.extrackgae.server.domain.Employee")
public interface EmployeeRequest extends RequestContext {

abstract Request<java.lang.Long> countEmployees();

abstract
Request<java.util.List<org.springsource.roo.extrackgae.client.managed.request.EmployeeProxy>>
findAllEmployees();

abstract
Request<java.util.List<org.springsource.roo.extrackgae.client.managed.request.EmployeeProxy>>
findEmployeeEntries(int firstResult, int maxResults);

abstract
Request<org.springsource.roo.extrackgae.client.managed.request.EmployeeProxy>
findEmployee(Long id);

abstract
InstanceRequest<org.springsource.roo.extrackgae.client.managed.request.EmployeeProxy,
java.lang.Void> remove();

abstract
InstanceRequest<org.springsource.roo.extrackgae.client.managed.request.EmployeeProxy,
java.lang.Void> persist();
}

Tell me please where I'm wrong? How to make finder methods works?
Message has been deleted

Zed

unread,
Mar 2, 2011, 7:26:31 AM3/2/11
to Google Web Toolkit
As far as I see no one is going to answer me.
I found https://jira.springsource.org/browse/ROO-1595 and if I got
them right there is NO custom finder methods available at this time
(it's still openned).
Without them I can't use generated Request object and possibly all
over stuff.
If you don't want to explain just say am I right or not. If I can't
use custom finder methods I just leave roo and do everything by hands.

On 1 мар, 12:50, Zed <zed...@gmail.com> wrote:
> At the moment I moved forward. In ROO-931 its says us "At the moment
> the gwt setup command generates request objects for all finder
> methods" (from herehttps://jira.springsource.org/browse/ROO-931?page=com.atlassian.jira....).

Zed

unread,
Mar 4, 2011, 1:42:50 AM3/4/11
to Google Web Toolkit
http://forum.springsource.org/showthread.php?t=104652

On 2 мар, 15:26, Zed <zed...@gmail.com> wrote:
> As far as I see no one is going to answer me.
> I foundhttps://jira.springsource.org/browse/ROO-1595and if I got
Reply all
Reply to author
Forward
0 new messages