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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:21:01+00:00 2026-05-24T06:21:01+00:00

For more dynamism, I would like to add a random part on my app.

  • 0

For more dynamism, I would like to add a random part on my app.
Here is what I would have done in other techs, and what is not working in play :

long id = JPA.execute("select id from Realisation r order by RANDOM() LIMIT 1");

And here is the stack :

unexpected token: LIMIT near line 1, column 55

Comments :

  • Either in app or database, makes no difference to me.
  • About hundred “realisations” in database.
  • All I need is there ID, no need for full object.
  • MySQL database behind it all.

EDIT

After a little investigation, here is how I’ve done it :

  • Define jpa.dialect in application.conf : jpa.dialect=org.hibernate.dialect.MySQLDialect
  • Fetch a complete object instead of just id with classic Model utilities :

Realisation r = Realisation.find("order by RAND()").first();

  • 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-24T06:21:02+00:00Added an answer on May 24, 2026 at 6:21 am

    After a little investigation, here is how I’ve done it. Define jpa.dialect in application.conf :

    jpa.dialect=org.hibernate.dialect.MySQLDialect

    Fetch a complete object instead of just id with classic Model utilities :

    Realisation r = Realisation.find("order by RAND()").first();
    

    Not the best way possible, since I only need the ID and not the complete object. Anyway, I have no other solution. If anyone has one for just the ID I will take it.

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

Sidebar

Related Questions

More out of interest than anything else, but can you compile a DirectX app
More than about LINQ to [insert your favorite provider here], this question is about
More particularly - I have a window handle of another running application. This application
More times than I'd like to admit I've had people new to a project
More specifically, if I have: public class TempClass : TempInterface { int TempInterface.TempProperty {
More often than I'd have hoped I seem to come across method/property definitions in
More specifically, for a random class with two public properties, in C# you can
More of a theoretical question, but wouldn't it make more sense to have only
More specifically making HTML, Java, and python more readable? Does anyone have suggestions for
More information about what I want to do here; http://www.studiodust.com/riffmp3.html I want a way

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.