Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Teneo gmf: adding obj with containment relationship causes constraint violation
Teneo gmf: adding obj with containment relationship causes constraint violation [message #421879] Fri, 15 August 2008 16:19 Go to next message
Tom is currently offline TomFriend
Messages: 22
Registered: July 2009
Junior Member
Martin et al.,

I fixed my datastore initialization problem by making my own hibernate
plugin. Thanks!

Now I can add some objects to the diagram and persist it, except when I
drop an object inside another object -- the dropped object being
"contained" by the dropee. Once I do that, I can no longer save the
diagram.

Here is the database error:

Caused by: java.sql.BatchUpdateException: ORA-02291: integrity constraint
(CATADMIN.CAMPAIGNSTEP_EVIDENCEGENERATED) violated - parent key not found

I have seen that there have been some changes to containment handling, so
I updated to the latest milestone build of teneo, and I also tried this in
my StoreController class:

props.setProperty(PersistenceOptions.CASCADE_POLICY_ON_CONTA INMENT,
"REMOVE,REFRESH,PERSIST,MERGE"); props.setProperty(PersistenceOptions.SET_CASCADE_ALL_ON_CONT AINMENT,
"false");

This happens on a fresh database no matter what these properties are. Here
is more of the stack trace:

Hibernate: update "evidence" set "cmpignstep_evidencegenerted_id"=?,
"cmpignstp_evidencegenerted_idx"=? where e_id=?
org.hibernate.exception.ConstraintViolationException: Could not execute
JDBC batch update
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateCo nverter.java:71)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExce ptionHelper.java:43)
at
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatc her.java:253)
at
org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:92)
at
org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
at
org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:222)
at
org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
at
org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:25 0)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:234)
...


Thanks,
Tom D
Re: Teneo gmf: adding obj with containment relationship causes constraint violation [message #421894 is a reply to message #421879] Sun, 17 August 2008 02:50 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Tom,
Afaics hibernate sets a value in cmpignstep_evidencegenerted_id which does not correspond to the id
of the parent.
This type of situation can occur in case of multiple inheritance (which is not really supported by
hibernate). For example assume that a type A inherits from P1 and P2 and you have a reference to P2
(which can hold an instance of A), or P2 holds the containment relation, then this goes wrong.
Hibernate will for A create a record in the P1 table and the A table but not in the P2 table. Then
when dropping the dropped into the droppee a reference to P2 is created which does not exist.

Does this apply to your situation?
Depending on the hierarchy it can help to use single_table inheritance (then if P1 and P2 have a
common supertype they will be stored in the same table).
If this does not help then there is no real solution other than changing the order of the supertypes
of A (set P2 first) or move this containment relation to a higher supertype common for both P1 and
P2 (if one exists).

For some more details you can set debugging on:
http://www.elver.org/hibernate/troubleshooting.html#runtime
and then look in the log to see which values are bound to the update statement parameters and check
what the real id of the parent is.

gr. Martin

Tom wrote:
> Martin et al.,
>
> I fixed my datastore initialization problem by making my own hibernate
> plugin. Thanks!
>
> Now I can add some objects to the diagram and persist it, except when I
> drop an object inside another object -- the dropped object being
> "contained" by the dropee. Once I do that, I can no longer save the
> diagram.
>
> Here is the database error:
> Caused by: java.sql.BatchUpdateException: ORA-02291: integrity
> constraint (CATADMIN.CAMPAIGNSTEP_EVIDENCEGENERATED) violated - parent
> key not found
>
> I have seen that there have been some changes to containment handling,
> so I updated to the latest milestone build of teneo, and I also tried
> this in my StoreController class:
>
> props.setProperty(PersistenceOptions.CASCADE_POLICY_ON_CONTA INMENT,
> "REMOVE,REFRESH,PERSIST,MERGE");
> props.setProperty(PersistenceOptions.SET_CASCADE_ALL_ON_CONT AINMENT,
> "false");
>
> This happens on a fresh database no matter what these properties are.
> Here is more of the stack trace:
>
> Hibernate: update "evidence" set "cmpignstep_evidencegenerted_id"=?,
> "cmpignstp_evidencegenerted_idx"=? where e_id=?
> org.hibernate.exception.ConstraintViolationException: Could not execute
> JDBC batch update
> at
> org.hibernate.exception.SQLStateConverter.convert(SQLStateCo nverter.java:71)
>
> at
> org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExce ptionHelper.java:43)
>
> at
> org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatc her.java:253)
> at
> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:92)
>
> at
> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
>
> at
> org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:222)
>
> at
> org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
>
> at
> org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
>
> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:25 0)
> at
> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:234)
> ...
>
>
> Thanks,
> Tom D
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Teneo gmf: adding obj with containment relationship causes constraint violation [message #422030 is a reply to message #421894] Wed, 20 August 2008 14:24 Go to previous messageGo to next message
Tom is currently offline TomFriend
Messages: 22
Registered: July 2009
Junior Member
Martin,

Comments below

Martin Taal wrote:

> Hi Tom,
> Afaics hibernate sets a value in cmpignstep_evidencegenerted_id which does
not correspond to the id
> of the parent.
> This type of situation can occur in case of multiple inheritance (which is
not really supported by
> hibernate). For example assume that a type A inherits from P1 and P2 and you
have a reference to P2
> (which can hold an instance of A), or P2 holds the containment relation,
then this goes wrong.
> Hibernate will for A create a record in the P1 table and the A table but not
in the P2 table. Then
> when dropping the dropped into the droppee a reference to P2 is created
which does not exist.

> Does this apply to your situation?
> Depending on the hierarchy it can help to use single_table inheritance (then
if P1 and P2 have a
> common supertype they will be stored in the same table).
> If this does not help then there is no real solution other than changing the
order of the supertypes
> of A (set P2 first) or move this containment relation to a higher supertype
common for both P1 and
> P2 (if one exists).


That does seem to be the case, so I changed the inheritance order.
Although I no longer get an error when I save, I now don't see the dropped
objects when the diagram is re-loaded. Immediately on load, the diagram is
"dirty" so somewhere this difference is detected, though there is no
indication in the console or anywhere. Also, when I close the application
and re-start, the saved diagram is not found at all, and a new empty
diagram is created.

> For some more details you can set debugging on:
> http://www.elver.org/hibernate/troubleshooting.html#runtime
> and then look in the log to see which values are bound to the update
statement parameters and check
> what the real id of the parent is.


Regarding debug output, I can see the sql statements in the console using
the log4j.properties file on elver.org, but I can't always see what
variables are passed in (I don't think), nor can I ever see the results.
Is there a way to turn this level of logging on, as I have my levels set
to ALL in the properties file already? Or when you say "look in the log",
is there a log file with this info in it? The Window -> Show View -> Error
Log window doesn't have any of this output.

Maybe I should start with a completely fresh gmf project, perhaps with a
simpler model, and work up from there?

Thanks,
Tom D
Re: Teneo gmf: adding obj with containment relationship causes constraint violation [message #422056 is a reply to message #422030] Thu, 21 August 2008 05:24 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Tom,
I would check the contents of the database to see if the diagram is there. One reason that the
diagram is not there in the resource can be related to how the resource content is queried. You can
set breakpoints on the resource load methods to check this out further.
The same for the dirty checking of the diagram. I would search where the diagram dirty flag is set
and put a breakpoint there to check out what's causing it.

This log4j statement:
log4j.logger.org.hibernate.type=debug

tells hibernate to show the bind information, normally the value of the sql parameters is shown
directly after the sql statement itself with a string such as : parameter 1 bound to value '5' (I
don't recall the exact wording but it is something like this).

The log4j output is the most detailed you can get.

gr. Martin

Tom wrote:
> Martin,
>
> Comments below
>
> Martin Taal wrote:
>
>> Hi Tom,
>> Afaics hibernate sets a value in cmpignstep_evidencegenerted_id which
>> does
> not correspond to the id
>> of the parent.
>> This type of situation can occur in case of multiple inheritance
>> (which is
> not really supported by
>> hibernate). For example assume that a type A inherits from P1 and P2
>> and you
> have a reference to P2
>> (which can hold an instance of A), or P2 holds the containment relation,
> then this goes wrong.
>> Hibernate will for A create a record in the P1 table and the A table
>> but not
> in the P2 table. Then
>> when dropping the dropped into the droppee a reference to P2 is created
> which does not exist.
>
>> Does this apply to your situation?
>> Depending on the hierarchy it can help to use single_table inheritance
>> (then
> if P1 and P2 have a
>> common supertype they will be stored in the same table).
>> If this does not help then there is no real solution other than
>> changing the
> order of the supertypes
>> of A (set P2 first) or move this containment relation to a higher
>> supertype
> common for both P1 and
>> P2 (if one exists).
>
>
> That does seem to be the case, so I changed the inheritance order.
> Although I no longer get an error when I save, I now don't see the
> dropped objects when the diagram is re-loaded. Immediately on load, the
> diagram is "dirty" so somewhere this difference is detected, though
> there is no indication in the console or anywhere. Also, when I close
> the application and re-start, the saved diagram is not found at all, and
> a new empty diagram is created.
>> For some more details you can set debugging on:
>> http://www.elver.org/hibernate/troubleshooting.html#runtime
>> and then look in the log to see which values are bound to the update
> statement parameters and check
>> what the real id of the parent is.
>
>
> Regarding debug output, I can see the sql statements in the console
> using the log4j.properties file on elver.org, but I can't always see
> what variables are passed in (I don't think), nor can I ever see the
> results. Is there a way to turn this level of logging on, as I have my
> levels set to ALL in the properties file already? Or when you say "look
> in the log", is there a log file with this info in it? The Window ->
> Show View -> Error Log window doesn't have any of this output.
>
> Maybe I should start with a completely fresh gmf project, perhaps with a
> simpler model, and work up from there?
>
> Thanks,
> Tom D
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:setting uml2 namespaces
Next Topic:[Teneo] Not all referers computed when using idbag
Goto Forum:
  


Current Time: Mon Sep 23 04:44:12 GMT 2024

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

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

Back to the top