Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7659529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:20:41+00:00 2026-05-31T13:20:41+00:00

How to call method in file .aj in spring roo project? e.g. How to

  • 0

How to call method in file .aj in spring roo project?

e.g. How to call method “Employee.findAllEmployees()” in Employee_Roo_Jpa_ActiveRecord.aj from method callMethod() in Employee.java?

file: Employee.java

  1 package com.tap.domain;
  2 
  3 import java.text.SimpleDateFormat;
  4 import java.util.ArrayList;
  5 import java.util.Calendar;
  6 
  7 import javax.validation.constraints.Max;
  8 import javax.validation.constraints.Min;
  9 
 10 import org.aspectj.lang.annotation.Aspect;
 11 import org.springframework.beans.factory.annotation.Value;
 12 import org.springframework.roo.addon.javabean.RooJavaBean;
 13 import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;
 14 import org.springframework.roo.addon.tostring.RooToString;
 15 import org.springframework.stereotype.Component;
 16 
 17 @RooJavaBean
 18 @RooToString
 19 @RooJpaActiveRecord
 20 @Component("employee")
 21 public class Employee {
 22 
 23     private long id;
 24 
 25     private String name;
 26 public void callMethod() {
...
...
 30 }

file:Employee_Roo_Jpa_ActiveRecord.aj

  6 import java.util.List;
  7 import javax.persistence.EntityManager;
  8 import javax.persistence.PersistenceContext;
  9 import org.springframework.transaction.annotation.Transactional;
 10 import com.tap.domain.Employee;
 11 
 12 privileged aspect Employee_Roo_Jpa_ActiveRecord {
 13 
 14     @PersistenceContext
 15     transient EntityManager Employee.entityManager;
...
 27     public static List<Employee> Employee.findAllEmployees() {
 28         return entityManager().createQuery("SELECT o FROM Employee o", Emplo    yee.class).getResultList();
 29     }
...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:20:42+00:00Added an answer on May 31, 2026 at 1:20 pm

    The mechanism Roo uses is AspectJ’s inter-type declaration.

    Basically: your employee class will have the findAllEmployees() method at runtime, so you can just call it:

    public void callMethod() {
        List<Employee> allEmployees = findAllEmployees();
        // now do something with the employees
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to call a ruby method from erb file. This method takes
In my .m file I call a method that is inside the same .m
I want to call a static method in my jsp file using scriptlet and
I'm trying to call method from .jar But when I want to declare array
Can I call public method from within private one: var myObject = function() {
I am trying to build a Spring controller to serve a file from a
How can I call a method on a form from a method called from
I am trying to call method that creates a file, however I am calling
I'm trying to reference another object I've defined in a Spring config file from
I'm trying to call this method of my .svc file: [WebGet] public List<Request> GetRequestFilteredForUser(string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.