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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:55:28+00:00 2026-05-13T19:55:28+00:00

I’m facing a problem with Hibernate. My current project is a little game. In

  • 0

I’m facing a problem with Hibernate.
My current project is a little game. In this game you have a Board which has many Fields each with a Token.
I can make a select on an empty database without any problems but if I put one object into it (saving works without any exceptions and after it the database values looks good) I’m getting exceptions.
The interesting part in the Board class:

@OneToMany(fetch=FetchType.EAGER)
@MapKey(name = "point")
public Map<Point, Field> getGameMatrix() {
     return gameMatrix;
}

My query for getting the boards:

return getHibernateTemplate().loadAll(Board.class);

The log now comes up with this:

Hibernate: select this_.id as id0_2_,
this_.uniqueClassName as
uniqueCl3_0_2_, this_.borderDimension
as borderDi4_0_2_, this_.dimension as
dimension0_2_, this_.TYPE as TYPE0_2_,
gamematrix2_.Board_id as Board1_4_,
field3_.id as gameMatrix2_4_, (select
a11.point from Field a11 where
a11.id=gamematrix2_.gameMatrix_id) as
formula0_4_, field3_.id as id1_0_,
field3_.point as point1_0_,
field3_.token_id as token3_1_0_,
token4_.id as id2_1_, token4_.name as
name2_1_, token4_.uniqueClassName as
uniqueCl4_2_1_, token4_.TYPE as
TYPE2_1_ from Board this_ left outer
join Board_Field gamematrix2_ on
this_.id=gamematrix2_.Board_id left
outer join Field field3_ on
gamematrix2_.gameMatrix_id=field3_.id
left outer join Token token4_ on
field3_.token_id=token4_.id

Until there it looks good, but then Hibernate does the following:

Hibernate: delete from Board_Field where Board_id=?  
Hibernate: insert into Board_Field (Board_id, gameMatrix_id) values (?, ?)

And I got this exception:

Exception in thread “AWT-EventQueue-0”
org.springframework.dao.InvalidDataAccessApiUsageException:
object references an unsaved transient
instance – save the transient instance
before flushing: Field; nested
exception is
org.hibernate.TransientObjectException:
object references an unsaved transient
instance – save the transient instance
before flushing: Field

I’m not understanding why it makes the delete statement.
Any ideas?
thanks

  • 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-13T19:55:28+00:00Added an answer on May 13, 2026 at 7:55 pm

    A workmate of mine had a similar problem. He’s not now but the thing was related to database integrity.

    It seems Hibernate had more constraints defined that the database. When it loaded some data, Hibernate saw that some record in the database must not exist, and tried to delete it.

    Try to check if some should-be-but-not-defined foreign key is being violated and try to make consistent the data.

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

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.