Announcement Announcement Module
Collapse
No announcement yet.
Person_Roo_Entity.aj contains: countPeople() Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Person_Roo_Entity.aj contains: countPeople()

    Hi,

    as a roo starter I just set up a simple example and tried to follow the generation process just by using the roo shell and simple editor.

    So, I created a Person and gave some fields. After that I opened the related Person_Roo_Entity.aj and found some magic name marked bold in the code snippet:

    Code:
        public static long Person.countPeople() {
            return (Long) entityManager().createQuery("select count(o) from Person o").getSingleResult();
        }
        
        public static List<Person> Person.findAllPeople() {
            return entityManager().createQuery("select o from Person o").getResultList();
        }
    Could someone explain to me what magic happened here that roo knows that we are using people here? I tried, what happened when using a "Car" instead:

    Code:
        public static long Car.countCars() {
            return (Long) entityManager().createQuery("select count(o) from Car o").getSingleResult();
        }
        
        public static List<Car> Car.findAllCars() {
            return entityManager().createQuery("select o from Car o").getResultList();
        }

    That's my log file:

    Code:
    // Spring Roo 1.0.2.RELEASE [rev 638] log opened at 2010-09-28 13:30:05
    hint
    project --topLevelPackage com.myrootest
    hint
    persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY 
    hint
    entity --class ~.domain.Person --testAutomatically 
    hint
    field string --fieldName lastName
    field string --fieldName firstName
    field date --fieldName birthday --type java.util.Date --timeFormat SHORT 
    entity --class ~.domain.Car
    cheers,
    stefan

  • #2
    Roo uses the Inflector API from java.net to generate plurals of your entity class names.

    https://inflector.dev.java.net/

    Comment


    • #3
      Thanks for pointing out - of course that explains!

      Comment

      Working...
      X