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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:51:56+00:00 2026-06-02T18:51:56+00:00

I am new to Play framework and yml notation, and know just the basics

  • 0

I am new to Play framework and yml notation, and know just the basics for Hibernate. I am trying to set up some test data by using a .yml file. I try to define several Question objects and an ActiveCompetition object that refer to the same Competition object. My .yml file looks like this (I have removed what I think is not relevant):

ActiveCompetition(1): &myactivecompetition
    activeCompetition: &mycompetition
        name: Name of the competition

Question(11):
    title: Title 1
    competition: *mycompetition

Question(12):
    title: Title 2
    competition: *mycompetition

Question(13):
    title: Title 3
    competition: *mycompetition

I works, but it seems that Hibernate saves *mycompetition 4 times.

In the java beans the attributes for javax.persistence are set as follows:

@Entity
@Transactional
public class ActiveCompetition extends Model {

   @Required
   @OneToOne(cascade= CascadeType.ALL)
   private Competition activeCompetition;
}

@Entity
@Transactional
public class Question extends Model {

    ...

    @Required
    @OneToOne(cascade= CascadeType.ALL)
    private Competition competition;
}

How do I make Hibernate understand that *mycompetition should be stored only once in the database? Should I write the database id on the .yml file? If so, how do I do this? I have tried already to add for example ‘id: 99’ under activeCompetition but it doesn’t help.

  • 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-06-02T18:51:58+00:00Added an answer on June 2, 2026 at 6:51 pm

    There are two possible issues:

    First one is that you are declaring the relatiosn OneToOne, but then in your YAML file you create a ManyToOne relation. OneToOne means that each ActiveCompetition has, at most, one question, and each Question relates to, at most, one ActiveCompetition.

    What you you want is a ManyToOne relation where an ActiveCompetition has many Question. You should update your Java code.

    Second one is that you are defining your ActiveCompetition as:

    ActiveCompetition(1)
    

    In YAML, AFAIK, you reference other entities in the file by the reference provided with the entity (or that’s how I did it). In the declaration above the reference is the number 1 between ().

    So you should change your file to:

    Question(13):
        title: Title 3
        competition: 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create an initial-data.yml file for a Play! Framework application. Part
I've just started with the Play Framework and I'm running into some problems using
I'm new to Play framework. I'm trying to configure MySQL database as a datasource
I'm new to the Entities Framework, and am just starting to play around with
I am brand new to the Play framework, but I am trying to use
I'm trying to save a record with JsonObjectField (using lift-mongo- record in Play framework)
I am new to using the Play! framework and was following the tutorial on
I'm trying to port some code from Play Framework Java to Play Framework Scala
Writing a Java application using the Play framework and need some HTTP-Live streaming. I
After running a new Play-framework 2.0 based project, i failed to clean it -

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.