[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] UDPATE: Cascading object occasionally dont update/merge, but throw exception. Eclipselink or my bug?
|
Turn on SQL logging to get an idea of what is occurring. Also include the
SQL trace for a failed operation. You should also trun batch writing off to
help debugging.
If you remove the @PrivateOwned from A's bList, does the issue still occur?
My guess as to what is occurring is that because the bList is marked as
@PrivateOwned, when you clear of remove from it the B will be deleted. But
the B's nextA is not private owned, so it will not be deleted, so the next
insert of the B with the same A will give you the error.
Maybe also mark nextA as @PrivateOwned.
Raven McSmith wrote:
>
> This is the errormessage:
>
> Internal Exception: java.sql.BatchUpdateException:
> The statement was aborted because it would have caused a duplicate key
> value in a unique or primary key constraint or unique index identified
> by 'SQLxxxxxxxxxxxxxxx' defined on 'A'.
> Error Code: 20000
> Query: UpdateObjectQuery(a)
>
>
> On Fri, Apr 23, 2010 at 8:24 AM, Raven McSmith
> <ravenmcsmith@xxxxxxxxxxxxxx> wrote:
>> Hi,
>>
>> I am having the problem that my object from a cascaded class model
>> _sometimes_ don't update/merge but throw an exception.
>> This only happens after objects have been persisted and are now (to a
>> bigger extend) updated, changed, modified. Small modifications will
>> work fine.
>> I will give an descriptive example after the model.
>>
>> My model looks almost like his:
>>
>> class a
>>
>> @Entity
>> public class A implements Serializable {
>> @Id
>> @GeneratedValue(strategy = GenerationType.TABLE)
>> private int id;
>> private String name;
>> @OneToMany(cascade=CascadeType.ALL)
>> @PrivateOwned
>> private List bList = new ArrayList();
>> ....
>> }
>>
>> class b
>>
>> @Entity
>> public class B implements Serializable {
>> @Id
>> @GeneratedValue(strategy = GenerationType.TABLE)
>> private int id;
>> ...
>> @OneToOne(cascade=CascadeType.ALL)
>> private A nextA;
>> ....
>> }
>>
>> My program code makes sure that there is never a cycle in the objects.
>> Meaning that no nextA will have an entry of object A where it is self
>> defined.
>> My problem is not adding objects but deleting/modifying them.
>>
>> Example:
>> When I have several of these object persisted and I am now changing
>> one instance of A which had 4 entries in bList, and I am going to
>> clear bList and try to merge(), flush() the object, I will get an
>> exception, saying that there are duplicate entries for the key ID from
>> object A.
>> If I just remove one object from the list and the merge() or flush()
>> the object with Eclipselink the operation works fine.
>> Similarly I think is the situation when changing entries in bList.
>> This is really hard to debug, so I just can guess. If I change many
>> things (excluding adding), then sometimes the merge(), flush()
>> operation throws an exception, but it is just sometimes, so really
>> hard to debug.
>>
>> Do you know any solution to this problem?
>> Is it my fault or did I find a bug in Eclipselink?
>>
>> Thanks
>>
>> Raven
>>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>
>
-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://old.nabble.com/UDPATE%3A-Cascading-object-occasionally-dont-update-merge%2C-but-throw-exception.-Eclipselink-or-my-bug--tp28337999p28378779.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.