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 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 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
having a little architectural trouble here. In C++, we have the notion of 'friends,'
I have a little dilemma that maybe you can help me sort out. I've
I have a little problem with a Listview. I can load it with listview
I have a small task in Flash, that I'm having a little trouble with.
I have a little trouble understanding scope and lifetime using javaScript and jQuery. I
I am having a little bit trouble with the following. I have multiple form
I have little knowledge of Flash but for a little Flash game I have
i have little problem with boost::asio library. My app receive and process data asynchronously,

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.