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

  • Home
  • SEARCH
  • 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 4252746
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:50:10+00:00 2026-05-21T04:50:10+00:00

I would like to build a web interface to present logdata. This should be

  • 0

I would like to build a web interface to present logdata. This should be a nice opportunity to try to build a little web app using Grails, which I have been wanting to try out for quite a while, but I am having some trouble understanding how I can “translate” the manual sql queries of today into something usable for Grails.

I have not found too much info on retrofitting existing data tables onto domain classes in the book Grails In Action. So I am bringing it here for some clarification 🙂

This is basically the schema for the log table I am logging to today:

LOG(id,method,timestamp,millis_used,username,hostname,...etc)

I can see myself doing something like creating domain classes User and Host with mappings like hasMany = { logs: Log } and a Log class with belongsTo = { user: User }, but not how I can use this in a effective way to query my data, especially if dealing with hundred of thousands of log rows. I am usually doing queries on the data like "find the average time used for method='fooBar' and user='john_doe' the last 30 days" or "count the number of rows where method='fooBaz' and host='localhost' from May to December".

How would you go about to retrieve info like this? Would you just forget about mapping the log entries and just use some kind of direct SQL (HQL?) queries on the tables or can this (unknown to me) GORM beast be used for stuff like this?

  • 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-21T04:50:11+00:00Added an answer on May 21, 2026 at 4:50 am

    First, I agree with Ted’s response. Check out Burt’s presentation before you setup your GORM domains.

    Second, I recommend you take a look at Criterias. The grails DSL for the Hibernate Criteria functionality makes for a very clean and maintainable codebase. Here are some examples:

    Example Criteria:

    def avg = Log.createCriteria().get {
        projections {
            avg 'duration'
        }
        user {
            eq 'userName', 'user1'
        }
    }
    println("Average = ${avg}")
    

    Example Domain Objects:

    class User {
    
        String userName
        String firstName
        String lastName
    
        static constraints = {
            userName nullable:false, maxSize:32
            firstName nullable:false, maxSize:50
            lastName nullable:false, maxSize:50
        }
    
    }
    
    class Host {
    
        String hostname
    
        static mapping = {
            version false
        }
    
        static constraints = {
            hostname nullable:false, maxSize:64
        }
    }
    
    class Log {
    
        Host host
        User user
        String method
        String logMessage
        Date dateCreated
        long duration
    
        static mapping = {
            autoTimestamp true  //Note: this will automatically update dateCreated and lastUpdate
            version false
        }
    
        static constraints = {
            host nullable:false
            user nullable:false
            method nullable:false, maxSize:50
            logMessage nullable:false, maxSize:255
            duration nullable:false
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to build an application that will run on a web, this
I would like to hear other people's advice on when one should build a
I have this idea for a small-medium web application that I would like to
I would like to build a regexp in Java that would be passed in
Basically, I would like to build a list comprehension over the cartesian product of
Inspired by Eric Sink's interview on the stackoverflow podcast I would like to build
I would like to do remote deployment from my build machine onto a server.
I would like to ask you which automated build environment you consider better, based
I would like to implement a post build event that performs the following actions
I would like to be able to build test applications (e.g. the nightly Minefield/Firefox)

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.