Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » 2 inserts for same row of Unidirectional ManyToOne after upgrade to 1.1
2 inserts for same row of Unidirectional ManyToOne after upgrade to 1.1 [message #387034] Wed, 08 April 2009 16:08 Go to next message
Matthew Smart is currently offline Matthew SmartFriend
Messages: 2
Registered: July 2009
Junior Member
This same setup works fine in 1.0.2 but will not work in 1.1.0. Any Ideas?

Unidirectional manytoone mapping between Tables called INCIDENT and
LOCATION.
An incident has a location. A location can be associated with multiple
incidents (and with some other objects), but we do not store a collection
of incidents inside the location object. So the tables look like this:
INCIDENT
PK INCIDENT_ID
FK LOCATION_ID

LOCATION
PK LOCATION_ID

The incident object has an annotation on its location like this:
@ManyToOne(optional = false)
@JoinColumn(name = "LOCATION_ID", referencedColumnName = "LOCATION_ID",
nullable = false)
private Location location;

There is nothing in the Location object that references the Incident
object and we are not defining a cascade. The joinColumn is needed since
our DB tables and columns are all in caps (annoying, I know).


The problem is that we have a method that creates a new location, persists
it, and then associates that location with an incident. The code that
creates the new location is used in numerous areas in the codebase for
location creation since locations can exists without being associated with
any incident and are associated with some other objects.

This triggers 2 db inserts, one when we persist the location, and one when
we call the incident's setLocation() function (which has no annotations).
This same code works fine in 1.0.2.

Any ideas? Thanks for the help.
Re: 2 inserts for same row of Unidirectional ManyToOne after upgrade to 1.1 [message #387064 is a reply to message #387034] Thu, 09 April 2009 13:16 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

That is odd, make sure you don't have two different copies of the same
Location object. What is the Id of the Location, how is it generated?
Also, please include the code from an isolated test that recreates the
issue and the SQL log on finest.

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html


James : Wiki : Book : Blog : Twitter
Re: 2 inserts for same row of Unidirectional ManyToOne after upgrade to 1.1 [message #387365 is a reply to message #387064] Sat, 18 April 2009 20:50 Go to previous message
Matthew Smart is currently offline Matthew SmartFriend
Messages: 2
Registered: July 2009
Junior Member
Found the issue. I had a couple errant
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
annotations that were getting cross-mojinated. Got rid of them and
everything works perfectly.

Thanks,
Matthew Smart
Previous Topic:TopLink issue 3868 fixed in EclipseLink?
Next Topic:Refreshing objects with @Transient fields
Goto Forum:
  


Current Time: Thu Apr 25 08:02:35 GMT 2024

Powered by FUDForum. Page generated in 0.03452 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top