Meaningless Drivel is fun!
The moose likes Object Relational Mapping and the fly likes double-entries in table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "double-entries in table" Watch "double-entries in table" New topic

double-entries in table

Marshall Levin

Joined: Nov 29, 2004
Posts: 4
I'm stumped by a JPA issue. I have a simple timesheet application.

I have a class Timesheet and a class TimesheetRow, which contains the detail. I've omitted some details, but here's the basic structure:

I've got MySQL tables like this:

Then I've got some JPA code like this:

I am getting entries in the timesheet table and associated entries in the timesheet_detail table, but I seem to be getting additional "dummy" entries in the timesheet table (one with the real data and an additional one with missing data for each timesheet row I have).

So after inserting a timesheet with one timesheet row, I have data like this:

What the heck am I doing wrong? I'm completely baffled.

Any suggestions would be appreciated!
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

"ML", please check your private messages for an important administrative matter.

[Asking smart questions] [About Bear] [Books by Bear]
Marshall Levin

Joined: Nov 29, 2004
Posts: 4
I should mention that it's the "new timesheet" path that is giving me trouble (when an existing one isn't found) -- I haven't even gotten to the other path yet.

Also, in case it was not obvious, my database examples are just dumps of MySQL, so the "insert" statements are just to show what rows I'm ending up with.
Marshall Levin

Joined: Nov 29, 2004
Posts: 4
Well, I managed to solve my own problem. I remembered that MyEclipse has a JPA reverse-engineering function, so I just pointed it at my tables :-)
I agree. Here's the link:
subject: double-entries in table
It's not a secret anymore!