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 3341868
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:46:20+00:00 2026-05-18T00:46:20+00:00

I read this article: https://www.ibm.com/developerworks/java/library/j-javadev2-8/index.html The abstract class Model in Listing 2. have static

  • 0

I read this article:
https://www.ibm.com/developerworks/java/library/j-javadev2-8/index.html

The abstract class Model in Listing 2. have static variable datastore.

abstract class Model {
 static def datastore = DatastoreServiceFactory.datastoreService
  ...

The class Race in Listing 3. extends the abstract class Model.

class Race extends Model {
 public Race(params){
  super(params)
 }
}

In Listing 5. and Listing 6.use the author no-static variable datastore (this.datastore) in static method. I suppose, the static method is in class Race.

static def findByName(name){
     def query = new Query(Race.class.simpleName)
     query.addFilter("name", Query.FilterOperator.EQUAL, name)
     def preparedQuery = this.datastore.prepare(query)
     if(preparedQuery.countEntities() > 1){
      return new Race(preparedQuery.asList(withLimit(1))[0])
     }else{
      return new Race(preparedQuery.asSingleEntity())
     }
    }

How is it possible? Thanks for explanation.
Tom

  • 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-18T00:46:20+00:00Added an answer on May 18, 2026 at 12:46 am

    EDIT — you were right, I was on the complete wrong track before. The answer is simple, in groovy, you can use the ‘this’ keyword in static methods.

    http://groovy.codehaus.org/Differences+from+Java

    When used like that, ‘this’ refers to the class, not an instance. Groovy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read this article, the parts of Intellisense and Generated Code: http://www.charlespetzold.com/etc/DoesVisualStudioRotTheMind.html Do you
I'm implementing a Announcement system that is loosely based on this article: https://web.archive.org/web/20211020111733/https://www.4guysfromrolla.com/articles/110409-1.aspx One
I read This article and i found it interesting. To sum it up for
I read in this article that a company has created a software capable of
I did some timing tests and also read some articles like this one (last
I read this PHP RegEx page , but either I'm missing something, misreading something,
I read this answer and its comments and I'm curious: Are there any reasons
I read this post last night, and I noticed it was from 2006. I
I have read this post about how to test private methods. I usually do
Update: Please read this question in the context of design principles, elegance, expression of

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.