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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:31:02+00:00 2026-05-20T07:31:02+00:00

i have a little trouble while making my first play application. I got a

  • 0

i have a little trouble while making my first play application.

I got a class Meal which can have one or more MealEntries in it. One meal entry can be used by several meals (i.e if u eat 2 eggs for more than one meal). But im getting a exception.

I can understand why i get the exception, but i cant figure how i can cure it.

This is my exception:

Caused by: java.sql.BatchUpdateException: Duplicate entry '4' for key 'mealEntries_id'
    at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2020)
    at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1451)
    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
    ... 12 more

Meal Class:

public class Meal extends Model {
public String name;
public Date consumed;

@OneToMany
public List<MealEntry> mealEntries;
}

MealEntry Class:

public class MealEntry extends Model {
public int amount;

@OneToOne
public Unit unit;

@OneToOne
public FoodType type;

@OneToOne
public MealEntry with;
}

Thanks in advance

Edit:
Tried to create a testcase, but ran into some other error.
I’ll try to explain:
The exception happens when i try to create a second meal, using MealEntries that are also used by the first Meal.

  • 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-20T07:31:03+00:00Added an answer on May 20, 2026 at 7:31 am

    Thanks for the feedback, but i figured it out.

    I changed my Meal to MealEntry relation to @ManyToMany and it solved the problem.

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

Sidebar

Related Questions

I have a little trouble deciding which way to go for while designing the
I have just made my first proper little desktop GUI application that basically wraps
This problem is making me crazy. Actually I have multiple problems. First one: Why
I have a little problem, I hope U can help me;) Trouble is, that
having a little architectural trouble here. In C++, we have the notion of 'friends,'
I'm a jQuery newbie, and I have trouble with a little script I created.
I have a little trouble with a progress bar since iOS 5 came out.
I'm having a little bit of trouble implementing the following method while handling the
I have a little bit of trouble creating a menu in Rails. In ApplicationController
I'm having a little trouble defining my question. Here's what I have. A mailto

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.