|2 inserts for same row of Unidirectional ManyToOne after upgrade to 1.1 [message #387034]
||Wed, 08 April 2009 12:08
| Matthew Smart
Registered: July 2009
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
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:
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.
Powered by FUDForum
. Page generated in 0.06711 seconds