Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000
[CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870231] Mon, 07 May 2012 11:14 Go to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
I am getting the above error message when trying to persist a graphiti Diagram object.

I am not sure about this, but I think the sql mapper adds a constraint to the table in question "FOREIGN KEY SAME TABLE" which leads to this error message...

The constraint will be re-generated the next time the cdo server is started (if I drop the constraint)...

Any hints?
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870233 is a reply to message #870231] Mon, 07 May 2012 11:46 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
In case you would like to have a hint for further research:

EClass StyleContainer
 - styles : Style 0..*

EClass Style implements StyleContainer


So, adding the "FOREIGN KEY SAME TABLE" constraint does make sense, but in this case conflicts...
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870238 is a reply to message #870233] Mon, 07 May 2012 12:16 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Erdal,
Teneo will generate readable fk constraint names, this could in some special cases maybe result in name clashes (not
sure), in any case you can try to set this property/option to false:
teneo.naming.set_foreign_key_name

this should hopefully help.

If it doesn't can you post the generated hbm, or more specifically the part which defines the fk constraint? Is it maybe
generated twice?

gr. Martin

On 05/07/2012 01:46 PM, Erdal Karaca wrote:
> In case you would like to have a hint for further research:
>
> EClass StyleContainer
> - styles : Style 0..*
>
> EClass Style implements StyleContainer
>
> So, adding the "FOREIGN KEY SAME TABLE" constraint does make sense, but in this case conflicts...


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870244 is a reply to message #870238] Mon, 07 May 2012 12:36 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Thanks, Martin!

Setting the key to false helped!

Martin taal wrote on Mon, 07 May 2012 08:16
Hi Erdal,
Teneo will generate readable fk constraint names, this could in some special cases maybe result in name clashes (not
sure), in any case you can try to set this property/option to false:
teneo.naming.set_foreign_key_name

this should hopefully help.

If it doesn't can you post the generated hbm, or more specifically the part which defines the fk constraint? Is it maybe
generated twice?

gr. Martin

On 05/07/2012 01:46 PM, Erdal Karaca wrote:
> In case you would like to have a hint for further research:
>
> EClass StyleContainer
> - styles : Style 0..*
>
> EClass Style implements StyleContainer
>
> So, adding the "FOREIGN KEY SAME TABLE" constraint does make sense, but in this case conflicts...


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org

Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870413 is a reply to message #870244] Tue, 08 May 2012 05:26 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Martin, unfortunately, the problem still occurs... How can I get the generated hbm.xml?
Or where do I find it?

Though, this time, there are more foreign keys generated than not setting the key...
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870431 is a reply to message #870413] Tue, 08 May 2012 07:10 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
You can find the mapping by debugging into this method: TeneoHibernateMappingProvider.generateMapping

Or another way is generating it directly using a few lines of java, see this testcase for an example:
http://git.eclipse.org/c/cdo/cdo.git/tree/plugins/org.eclipse.emf.cdo.examples.hibernate.client/src/org/eclipse/emf/cdo/examples/hibernate/client/GenerateHBMTest.java

gr. Martin

On 05/08/2012 07:27 AM, Erdal Karaca wrote:
> Martin, unfortunately, the problem still occurs... How can I get the generated hbm.xml?
> Or where do I find it?
>
> Though, this time, there are more foreign keys generated than not setting the key...


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870434 is a reply to message #870431] Tue, 08 May 2012 07:50 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Is there a way to dump the hibernate Configuration object (org.eclipse.emf.cdo.server.hibernate.IHibernateStore.getHibernateConfiguration()) to an xml file? that seems to contain all relevant data... Then, we could provide a new cdo command to export the hbm mapping or configuration file...
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870439 is a reply to message #870434] Tue, 08 May 2012 08:35 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hmm, I can get to the configuration object, but how to dump it to a xml file, you have any idea?

gr. Martin

On 05/08/2012 09:51 AM, Erdal Karaca wrote:
> Is there a way to dump the hibernate Configuration object
> (org.eclipse.emf.cdo.server.hibernate.IHibernateStore.getHibernateConfiguration()) to an xml file? that seems to contain
> all relevant data... Then, we could provide a new cdo command to export the hbm mapping or configuration file...


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870441 is a reply to message #870439] Tue, 08 May 2012 09:00 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
I couldn't find a solution, there doesn't seem to be a save or the like in Configuration...

In the meantime, you can use the new Command Provider to allow to store the hibernate mapping to a file:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=378797
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870442 is a reply to message #870238] Tue, 08 May 2012 09:11 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
So, I have exported the generated hbm file... What do I have to look for? I am not familiar with hibernate...

Though, this is the table/Class with fk conflicts:

	<class entity-name="StyleContainer" abstract="true" lazy="true" discriminator-value="StyleContainer" table="`stylecontainer`">
		<meta attribute="eclassName">StyleContainer</meta>
		<meta attribute="epackage">http://eclipse.org/graphiti/mm</meta>
		<tuplizer entity-mode="pojo" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<tuplizer entity-mode="dynamic-map" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<id type="long" name="idcol" column="idcol" access="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOSyntheticIdPropertyHandler">
			<meta attribute="syntheticId">true</meta>
			<generator class="native"/>
		</id>
		<discriminator type="string">
			<column name="dtype" index="stylecontainerdtype" length="255" not-null="true"/>
		</discriminator>
		<property name="resourceID" type="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDUserType">
			<column name="resource_id"/>
		</property>
		<property name="containerID" type="string">
			<column name="container_id"/>
		</property>
		<property name="cdo_teneo_e_version" type="java.lang.Integer">
			<meta attribute="version">true</meta>
			<column name="e_version"/>
		</property>
		<property name="commit_TimeStamp" type="java.lang.Long"/>
		<bag name="styles" lazy="true" cascade="all,delete-orphan">
			<key update="true">
				<column name="`style_stylecontainer_e_id`" not-null="false" unique="false"/>
			</key>
			<one-to-many entity-name="Style"/>
		</bag>
	</class>


Martin taal wrote on Mon, 07 May 2012 08:16
Hi Erdal,
Teneo will generate readable fk constraint names, this could in some special cases maybe result in name clashes (not
sure), in any case you can try to set this property/option to false:
teneo.naming.set_foreign_key_name

this should hopefully help.

If it doesn't can you post the generated hbm, or more specifically the part which defines the fk constraint? Is it maybe
generated twice?

gr. Martin

On 05/07/2012 01:46 PM, Erdal Karaca wrote:
> In case you would like to have a hint for further research:
>
> EClass StyleContainer
> - styles : Style 0..*
>
> EClass Style implements StyleContainer
>
> So, adding the "FOREIGN KEY SAME TABLE" constraint does make sense, but in this case conflicts...


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org

Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870447 is a reply to message #870439] Tue, 08 May 2012 09:37 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 08.05.2012 10:35, schrieb Martin Taal:
> Hmm, I can get to the configuration object, but how to dump it to a xml file, you have any idea?
Why does it have to be an XML file? Why can't you just use that object's API to dump the useful information to the console?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870451 is a reply to message #870442] Tue, 08 May 2012 09:53 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hmm, I don't see unique constraint or something, I think the next step is to find out what constraint fails and on what
database columns it fails. Maybe this is present somewhere in the database log. Another thing can be to debug inside the
hibernate code, often a sql BatchUpdateException is thrown which has the underlying exception in a separate member, so
the real exception is not displayed in the stack trace.

gr. Martin

On 05/08/2012 11:11 AM, Erdal Karaca wrote:
> So, I have exported the generated hbm file... What do I have to look for? I am not familiar with hibernate...
>
> Though, this is the table/Class with fk conflicts:
>
>
> <class entity-name="StyleContainer" abstract="true" lazy="true" discriminator-value="StyleContainer"
> table="`stylecontainer`">
> <meta attribute="eclassName">StyleContainer</meta>
> <meta attribute="epackage">http://eclipse.org/graphiti/mm</meta>
> <tuplizer entity-mode="pojo" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
> <tuplizer entity-mode="dynamic-map" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
> <id type="long" name="idcol" column="idcol"
> access="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOSyntheticIdPropertyHandler">
> <meta attribute="syntheticId">true</meta>
> <generator class="native"/>
> </id>
> <discriminator type="string">
> <column name="dtype" index="stylecontainerdtype" length="255" not-null="true"/>
> </discriminator>
> <property name="resourceID" type="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDUserType">
> <column name="resource_id"/>
> </property>
> <property name="containerID" type="string">
> <column name="container_id"/>
> </property>
> <property name="cdo_teneo_e_version" type="java.lang.Integer">
> <meta attribute="version">true</meta>
> <column name="e_version"/>
> </property>
> <property name="commit_TimeStamp" type="java.lang.Long"/>
> <bag name="styles" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`style_stylecontainer_e_id`" not-null="false" unique="false"/>
> </key>
> <one-to-many entity-name="Style"/>
> </bag>
> </class>
>
>
> Martin taal wrote on Mon, 07 May 2012 08:16
>> Hi Erdal,
>> Teneo will generate readable fk constraint names, this could in some special cases maybe result in name clashes (not
>> sure), in any case you can try to set this property/option to false:
>> teneo.naming.set_foreign_key_name
>>
>> this should hopefully help.
>>
>> If it doesn't can you post the generated hbm, or more specifically the part which defines the fk constraint? Is it
>> maybe generated twice?
>>
>> gr. Martin
>>
>> On 05/07/2012 01:46 PM, Erdal Karaca wrote:
>> > In case you would like to have a hint for further research:
>> >
>> > EClass StyleContainer
>> > - styles : Style 0..*
>> >
>> > EClass Style implements StyleContainer
>> >
>> > So, adding the "FOREIGN KEY SAME TABLE" constraint does make sense, but in this case conflicts...
>>
>>
>> --
>>
>> 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@xxxxxxxx - mtaal@xxxxxxxx
>> Web: www.springsite.com - www.elver.org
>
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870485 is a reply to message #870451] Tue, 08 May 2012 12:07 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
This is the insert which is being executed...

Hibernate: insert into [stylecontainer] (resource_id, container_id, e_version, commit_TimeStamp, [color_background_e_id], [color_foreground_e_id], [linewidth], [linestyle], [filled], [linevisible], [renderingstyle_renderingstyle_e_id], [transparency], [id], [description], [font_font_e_id], [horizontalalignment], [verticalalignment], [angle], [stretchh], [stretchv], [proportional], [style_stylecontainer_e_id], dtype) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'Style')


fields parameter of org.hibernate.persister.entity.AbstractEntityPersister.insert(Object[], boolean[], String, Object, SessionImplementor):

[NULL, lhttp://eclipse.org/graphiti/mm/pictograms#Diagram#2_:_styleContainer, 1, 1336477583737, org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.HibernateMoveableListWrapper@52d37e, null, null, 2, SOLID, null, true, null, 0.0, COMMON-VALUES, null, null, UNSPECIFIED, UNSPECIFIED, null, null, null, null, Diagram@OID:http://eclipse.org/graphiti/mm/pictograms#Diagram#2:0v1]
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870511 is a reply to message #870485] Tue, 08 May 2012 13:43 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Okay and what constraint fails? A not-null, a unique or a fk constraint?
and on what field/column?

gr. Martin

On 05/08/2012 02:08 PM, Erdal Karaca wrote:
> This is the insert which is being executed...
>
>
> Hibernate: insert into [stylecontainer] (resource_id, container_id, e_version, commit_TimeStamp,
> [color_background_e_id], [color_foreground_e_id], [linewidth], [linestyle], [filled], [linevisible],
> [renderingstyle_renderingstyle_e_id], [transparency], [id], [description], [font_font_e_id], [horizontalalignment],
> [verticalalignment], [angle], [stretchh], [stretchv], [proportional], [style_stylecontainer_e_id], dtype) values (?, ?,
> ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'Style')
>
>
> fields parameter of org.hibernate.persister.entity.AbstractEntityPersister.insert(Object[], boolean[], String, Object,
> SessionImplementor):
>
>
> [NULL, lhttp://eclipse.org/graphiti/mm/pictograms#Diagram#2_:_styleContainer, 1, 1336477583737,
> org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.HibernateMoveableListWrapper@52d37e, null, null, 2, SOLID, null,
> true, null, 0.0, COMMON-VALUES, null, null, UNSPECIFIED, UNSPECIFIED, null, null, null, null,
> Diagram@OID:http://eclipse.org/graphiti/mm/pictograms#Diagram#2:0v1]
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870534 is a reply to message #870511] Tue, 08 May 2012 15:01 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
I think it is because of the rather "complex" inheritance hierarchy of graphiti:

I will try to provide a test case to demonstrate this or you could have a look at the graphiti.ecore meta-model:
http://git.eclipse.org/gitroot/gmp/org.eclipse.gmp.graphiti.git

And thanks very much for the support!
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #870558 is a reply to message #870534] Tue, 08 May 2012 17:35 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Erdal,
I think as a default single table inheritance mapping is used. It can make sense to use join table, see this option:
teneo.mapping.inheritance

you can try JOINED as a value.

See here for more information:
http://wiki.eclipse.org/Teneo/Hibernate/ModelRelational/Inheritance_Mapping

gr. Martin

On 05/08/2012 05:02 PM, Erdal Karaca wrote:
> I think it is because of the rather "complex" inheritance hierarchy of graphiti:
>
> I will try to provide a test case to demonstrate this or you could have a look at the graphiti.ecore meta-model:
> http://git.eclipse.org/gitroot/gmp/org.eclipse.gmp.graphiti.git
>
> And thanks very much for the support!


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #871514 is a reply to message #870558] Mon, 14 May 2012 10:02 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Just tried the JOINED inheritance mapping, but that did not solve the problem... I still get FK constraint errors. Let me try to provide an isolated test case...
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #871535 is a reply to message #871514] Mon, 14 May 2012 11:06 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
When using the JOINED inheritance mapping, I will get this hibernate mapping:

	<joined-subclass entity-name="Style" abstract="false" lazy="true" extends="StyleContainer" table="`style`">
		<meta attribute="eclassName">Style</meta>
		<meta attribute="epackage">http://eclipse.org/graphiti/mm/algorithms/styles</meta>
		<tuplizer entity-mode="pojo" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<tuplizer entity-mode="dynamic-map" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<key>
			<column name="`stylecontainer_e_id`"/>
		</key>
		<many-to-one name="background" entity-name="Color" lazy="false" cascade="merge,persist,save-update,lock,refresh" insert="true" update="true" not-null="false">
			<column not-null="false" unique="false" name="`color_background_e_id`"/>
		</many-to-one>
		<many-to-one name="foreground" entity-name="Color" lazy="false" cascade="merge,persist,save-update,lock,refresh" insert="true" update="true" not-null="false">
			<column not-null="false" unique="false" name="`color_foreground_e_id`"/>
		</many-to-one>
		<property name="lineWidth" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.Integer">
			<column not-null="false" unique="false" name="`linewidth`"/>
		</property>
		<property name="lineStyle" lazy="false" not-null="false" insert="true" update="true" unique="false">
			<column not-null="false" unique="false" name="`linestyle`"/>
			<type name="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOENumStringType">
				<param name="eclassifier">LineStyle</param>
				<param name="epackage">http://eclipse.org/graphiti/mm/algorithms/styles</param>
			</type>
		</property>
		<property name="filled" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.Boolean">
			<column not-null="false" unique="false" name="`filled`"/>
		</property>
		<property name="lineVisible" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.Boolean">
			<column not-null="false" unique="false" name="`linevisible`"/>
		</property>
		<many-to-one name="renderingStyle" entity-name="RenderingStyle" lazy="false" cascade="all" insert="true" update="true" not-null="false">
			<column not-null="false" unique="false" name="`renderingstyle_renderingstyle_e_id`"/>
		</many-to-one>
		<property name="transparency" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.Double">
			<column not-null="false" unique="false" name="`transparency`"/>
		</property>
		<property name="id" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String">
			<column not-null="true" unique="false" name="`id`"/>
		</property>
		<property name="description" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String">
			<column not-null="false" unique="false" name="`description`"/>
		</property>
		<many-to-one name="font" entity-name="Font" lazy="false" cascade="merge,persist,save-update,lock,refresh" insert="true" update="true" not-null="false">
			<column not-null="false" unique="false" name="`font_font_e_id`"/>
		</many-to-one>
		<property name="horizontalAlignment" lazy="false" not-null="false" insert="true" update="true" unique="false">
			<column not-null="false" unique="false" name="`horizontalalignment`"/>
			<type name="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOENumStringType">
				<param name="eclassifier">Orientation</param>
				<param name="epackage">http://eclipse.org/graphiti/mm/algorithms/styles</param>
			</type>
		</property>
		<property name="verticalAlignment" lazy="false" not-null="false" insert="true" update="true" unique="false">
			<column not-null="false" unique="false" name="`verticalalignment`"/>
			<type name="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOENumStringType">
				<param name="eclassifier">Orientation</param>
				<param name="epackage">http://eclipse.org/graphiti/mm/algorithms/styles</param>
			</type>
		</property>
		<property name="angle" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.Integer">
			<column not-null="false" unique="false" name="`angle`"/>
		</property>
		<property name="stretchH" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.Boolean">
			<column not-null="false" unique="false" name="`stretchh`"/>
		</property>
		<property name="stretchV" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.Boolean">
			<column not-null="false" unique="false" name="`stretchv`"/>
		</property>
		<property name="proportional" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.Boolean">
			<column not-null="false" unique="false" name="`proportional`"/>
		</property>
		<many-to-one name="styleContainer" entity-name="StyleContainer" lazy="false" cascade="merge,persist,save-update,lock,refresh" insert="true" update="true" not-null="false">
			<column not-null="false" unique="false" name="`style_stylecontainer_e_id`"/>
		</many-to-one>
	</joined-subclass>


I dont see any instructions to create foreign keys... but having a look at the databse table structure, there are 7 foreign key constraints for the table "style"...
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #871542 is a reply to message #871535] Mon, 14 May 2012 11:15 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Erdal,
That's a pity that did not help, to give more input from my side I would need to know what foreign key constraints on
what fields and what values they fail.

gr. Martin

On 05/14/2012 01:06 PM, Erdal Karaca wrote:
> When using the JOINED inheritance mapping, I will get this hibernate mapping:
>
>
> <joined-subclass entity-name="Style" abstract="false" lazy="true" extends="StyleContainer" table="`style`">
> <meta attribute="eclassName">Style</meta>
> <meta attribute="epackage">http://eclipse.org/graphiti/mm/algorithms/styles</meta>
> <tuplizer entity-mode="pojo" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
> <tuplizer entity-mode="dynamic-map" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
> <key>
> <column name="`stylecontainer_e_id`"/>
> </key>
> <many-to-one name="background" entity-name="Color" lazy="false" cascade="merge,persist,save-update,lock,refresh"
> insert="true" update="true" not-null="false">
> <column not-null="false" unique="false" name="`color_background_e_id`"/>
> </many-to-one>
> <many-to-one name="foreground" entity-name="Color" lazy="false" cascade="merge,persist,save-update,lock,refresh"
> insert="true" update="true" not-null="false">
> <column not-null="false" unique="false" name="`color_foreground_e_id`"/>
> </many-to-one>
> <property name="lineWidth" lazy="false" insert="true" update="true" not-null="false" unique="false"
> type="java.lang.Integer">
> <column not-null="false" unique="false" name="`linewidth`"/>
> </property>
> <property name="lineStyle" lazy="false" not-null="false" insert="true" update="true" unique="false">
> <column not-null="false" unique="false" name="`linestyle`"/>
> <type name="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOENumStringType">
> <param name="eclassifier">LineStyle</param>
> <param name="epackage">http://eclipse.org/graphiti/mm/algorithms/styles</param>
> </type>
> </property>
> <property name="filled" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.Boolean">
> <column not-null="false" unique="false" name="`filled`"/>
> </property>
> <property name="lineVisible" lazy="false" insert="true" update="true" not-null="false" unique="false"
> type="java.lang.Boolean">
> <column not-null="false" unique="false" name="`linevisible`"/>
> </property>
> <many-to-one name="renderingStyle" entity-name="RenderingStyle" lazy="false" cascade="all" insert="true" update="true"
> not-null="false">
> <column not-null="false" unique="false" name="`renderingstyle_renderingstyle_e_id`"/>
> </many-to-one>
> <property name="transparency" lazy="false" insert="true" update="true" not-null="false" unique="false"
> type="java.lang.Double">
> <column not-null="false" unique="false" name="`transparency`"/>
> </property>
> <property name="id" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String">
> <column not-null="true" unique="false" name="`id`"/>
> </property>
> <property name="description" lazy="false" insert="true" update="true" not-null="false" unique="false"
> type="java.lang.String">
> <column not-null="false" unique="false" name="`description`"/>
> </property>
> <many-to-one name="font" entity-name="Font" lazy="false" cascade="merge,persist,save-update,lock,refresh" insert="true"
> update="true" not-null="false">
> <column not-null="false" unique="false" name="`font_font_e_id`"/>
> </many-to-one>
> <property name="horizontalAlignment" lazy="false" not-null="false" insert="true" update="true" unique="false">
> <column not-null="false" unique="false" name="`horizontalalignment`"/>
> <type name="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOENumStringType">
> <param name="eclassifier">Orientation</param>
> <param name="epackage">http://eclipse.org/graphiti/mm/algorithms/styles</param>
> </type>
> </property>
> <property name="verticalAlignment" lazy="false" not-null="false" insert="true" update="true" unique="false">
> <column not-null="false" unique="false" name="`verticalalignment`"/>
> <type name="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOENumStringType">
> <param name="eclassifier">Orientation</param>
> <param name="epackage">http://eclipse.org/graphiti/mm/algorithms/styles</param>
> </type>
> </property>
> <property name="angle" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.Integer">
> <column not-null="false" unique="false" name="`angle`"/>
> </property>
> <property name="stretchH" lazy="false" insert="true" update="true" not-null="false" unique="false"
> type="java.lang.Boolean">
> <column not-null="false" unique="false" name="`stretchh`"/>
> </property>
> <property name="stretchV" lazy="false" insert="true" update="true" not-null="false" unique="false"
> type="java.lang.Boolean">
> <column not-null="false" unique="false" name="`stretchv`"/>
> </property>
> <property name="proportional" lazy="false" insert="true" update="true" not-null="false" unique="false"
> type="java.lang.Boolean">
> <column not-null="false" unique="false" name="`proportional`"/>
> </property>
> <many-to-one name="styleContainer" entity-name="StyleContainer" lazy="false"
> cascade="merge,persist,save-update,lock,refresh" insert="true" update="true" not-null="false">
> <column not-null="false" unique="false" name="`style_stylecontainer_e_id`"/>
> </many-to-one>
> </joined-subclass>
>
>
> I dont see any instructions to create foreign keys... but having a look at the databse table structure, there are 7
> foreign key constraints for the table "style"...


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #871912 is a reply to message #871542] Tue, 15 May 2012 06:08 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
This sql is executed...

Hibernate: insert into [style] ([color_background_e_id], [color_foreground_e_id], [linewidth], [linestyle], [filled], [linevisible], [renderingstyle_renderingstyle_e_id], [transparency], [id], [description], [font_font_e_id], [horizontalalignment], [verticalalignment], [angle], [stretchh], [stretchv], [proportional], [style_stylecontainer_e_id], [stylecontainer_e_id]) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)


Error message:

java.sql.SQLException: Die INSERT-Anweisung steht in Konflikt mit der FOREIGN KEY-Einschränkung 'FK68B1DB139541E86'. Der Konflikt trat in der '_TEST'-Datenbank, Tabelle 'dbo.stylecontainer', column 'idcol' auf.
	at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
	at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
	at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)
	at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:632)


I am not sure, but I think when the row is inserted the db checks whether the row already exists as it has a foreign key check to itself...

This is the table that is generated for the Style EClass...

CREATE TABLE [dbo].[style](
	[stylecontainer_e_id] [numeric](19, 0) NOT NULL,
	[color_background_e_id] [numeric](19, 0) NULL,
	[color_foreground_e_id] [numeric](19, 0) NULL,
	[linewidth] [int] NULL,
	[linestyle] [varchar](255) NULL,
	[filled] [tinyint] NULL,
	[linevisible] [tinyint] NULL,
	[renderingstyle_renderingstyle_e_id] [numeric](19, 0) NULL,
	[transparency] [float] NULL,
	[id] [varchar](255) NOT NULL,
	[description] [varchar](255) NULL,
	[font_font_e_id] [numeric](19, 0) NULL,
	[horizontalalignment] [varchar](255) NULL,
	[verticalalignment] [varchar](255) NULL,
	[angle] [int] NULL,
	[stretchh] [tinyint] NULL,
	[stretchv] [tinyint] NULL,
	[proportional] [tinyint] NULL,
	[style_stylecontainer_e_id] [numeric](19, 0) NULL,
PRIMARY KEY CLUSTERED 
(
	[stylecontainer_e_id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[style]  WITH CHECK ADD  CONSTRAINT [FK68B1DB139541E86] FOREIGN KEY([style_stylecontainer_e_id])
REFERENCES [dbo].[stylecontainer] ([idcol])
GO

ALTER TABLE [dbo].[style] CHECK CONSTRAINT [FK68B1DB139541E86]
GO

ALTER TABLE [dbo].[style]  WITH CHECK ADD  CONSTRAINT [FK68B1DB1405D6A0D] FOREIGN KEY([color_background_e_id])
REFERENCES [dbo].[color] ([idcol])
GO

ALTER TABLE [dbo].[style] CHECK CONSTRAINT [FK68B1DB1405D6A0D]
GO

ALTER TABLE [dbo].[style]  WITH CHECK ADD  CONSTRAINT [FK68B1DB17AB711A4] FOREIGN KEY([font_font_e_id])
REFERENCES [dbo].[font] ([idcol])
GO

ALTER TABLE [dbo].[style] CHECK CONSTRAINT [FK68B1DB17AB711A4]
GO

ALTER TABLE [dbo].[style]  WITH CHECK ADD  CONSTRAINT [FK68B1DB17D893549] FOREIGN KEY([style_stylecontainer_e_id])
REFERENCES [dbo].[diagram] ([containershape_e_id])
GO

ALTER TABLE [dbo].[style] CHECK CONSTRAINT [FK68B1DB17D893549]
GO

ALTER TABLE [dbo].[style]  WITH CHECK ADD  CONSTRAINT [FK68B1DB1CD6F9B18] FOREIGN KEY([color_foreground_e_id])
REFERENCES [dbo].[color] ([idcol])
GO

ALTER TABLE [dbo].[style] CHECK CONSTRAINT [FK68B1DB1CD6F9B18]
GO

ALTER TABLE [dbo].[style]  WITH CHECK ADD  CONSTRAINT [FK68B1DB1E7A93614] FOREIGN KEY([stylecontainer_e_id])
REFERENCES [dbo].[stylecontainer] ([idcol])
GO

ALTER TABLE [dbo].[style] CHECK CONSTRAINT [FK68B1DB1E7A93614]
GO

ALTER TABLE [dbo].[style]  WITH CHECK ADD  CONSTRAINT [FK68B1DB1F1E869A] FOREIGN KEY([renderingstyle_renderingstyle_e_id])
REFERENCES [dbo].[renderingstyle] ([idcol])
GO

ALTER TABLE [dbo].[style] CHECK CONSTRAINT [FK68B1DB1F1E869A]
GO

Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #871953 is a reply to message #871912] Tue, 15 May 2012 07:47 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Erdal,
It seems that the parent object, the stylecontainer is not being saved/inserted before the style, can you check that?

gr. Martin

On 05/15/2012 08:08 AM, Erdal Karaca wrote:
> This sql is executed...
>
>
> Hibernate: insert into [style] ([color_background_e_id], [color_foreground_e_id], [linewidth], [linestyle], [filled],
> [linevisible], [renderingstyle_renderingstyle_e_id], [transparency], [id], [description], [font_font_e_id],
> [horizontalalignment], [verticalalignment], [angle], [stretchh], [stretchv], [proportional],
> [style_stylecontainer_e_id], [stylecontainer_e_id]) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
>
>
> Error message:
>
>
> java.sql.SQLException: Die INSERT-Anweisung steht in Konflikt mit der FOREIGN KEY-Einschränkung 'FK68B1DB139541E86'. Der
> Konflikt trat in der '_TEST'-Datenbank, Tabelle 'dbo.stylecontainer', column 'idcol' auf.
> at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
> at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
> at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)
> at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:632)
>
>
> I am not sure, but I think when the row is inserted the db checks whether the row already exists as it has a foreign key
> check to itself...
>
> This is the table that is generated for the Style EClass...
>
>
> CREATE TABLE [dbo].[style](
> [stylecontainer_e_id] [numeric](19, 0) NOT NULL,
> [color_background_e_id] [numeric](19, 0) NULL,
> [color_foreground_e_id] [numeric](19, 0) NULL,
> [linewidth] [int] NULL,
> [linestyle] [varchar](255) NULL,
> [filled] [tinyint] NULL,
> [linevisible] [tinyint] NULL,
> [renderingstyle_renderingstyle_e_id] [numeric](19, 0) NULL,
> [transparency] [float] NULL,
> [id] [varchar](255) NOT NULL,
> [description] [varchar](255) NULL,
> [font_font_e_id] [numeric](19, 0) NULL,
> [horizontalalignment] [varchar](255) NULL,
> [verticalalignment] [varchar](255) NULL,
> [angle] [int] NULL,
> [stretchh] [tinyint] NULL,
> [stretchv] [tinyint] NULL,
> [proportional] [tinyint] NULL,
> [style_stylecontainer_e_id] [numeric](19, 0) NULL,
> PRIMARY KEY CLUSTERED (
> [stylecontainer_e_id] ASC
> )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
> ON [PRIMARY]
> ) ON [PRIMARY]
>
> GO
>
> SET ANSI_PADDING OFF
> GO
>
> ALTER TABLE [dbo].[style] WITH CHECK ADD CONSTRAINT [FK68B1DB139541E86] FOREIGN KEY([style_stylecontainer_e_id])
> REFERENCES [dbo].[stylecontainer] ([idcol])
> GO
>
> ALTER TABLE [dbo].[style] CHECK CONSTRAINT [FK68B1DB139541E86]
> GO
>
> ALTER TABLE [dbo].[style] WITH CHECK ADD CONSTRAINT [FK68B1DB1405D6A0D] FOREIGN KEY([color_background_e_id])
> REFERENCES [dbo].[color] ([idcol])
> GO
>
> ALTER TABLE [dbo].[style] CHECK CONSTRAINT [FK68B1DB1405D6A0D]
> GO
>
> ALTER TABLE [dbo].[style] WITH CHECK ADD CONSTRAINT [FK68B1DB17AB711A4] FOREIGN KEY([font_font_e_id])
> REFERENCES [dbo].[font] ([idcol])
> GO
>
> ALTER TABLE [dbo].[style] CHECK CONSTRAINT [FK68B1DB17AB711A4]
> GO
>
> ALTER TABLE [dbo].[style] WITH CHECK ADD CONSTRAINT [FK68B1DB17D893549] FOREIGN KEY([style_stylecontainer_e_id])
> REFERENCES [dbo].[diagram] ([containershape_e_id])
> GO
>
> ALTER TABLE [dbo].[style] CHECK CONSTRAINT [FK68B1DB17D893549]
> GO
>
> ALTER TABLE [dbo].[style] WITH CHECK ADD CONSTRAINT [FK68B1DB1CD6F9B18] FOREIGN KEY([color_foreground_e_id])
> REFERENCES [dbo].[color] ([idcol])
> GO
>
> ALTER TABLE [dbo].[style] CHECK CONSTRAINT [FK68B1DB1CD6F9B18]
> GO
>
> ALTER TABLE [dbo].[style] WITH CHECK ADD CONSTRAINT [FK68B1DB1E7A93614] FOREIGN KEY([stylecontainer_e_id])
> REFERENCES [dbo].[stylecontainer] ([idcol])
> GO
>
> ALTER TABLE [dbo].[style] CHECK CONSTRAINT [FK68B1DB1E7A93614]
> GO
>
> ALTER TABLE [dbo].[style] WITH CHECK ADD CONSTRAINT [FK68B1DB1F1E869A] FOREIGN KEY([renderingstyle_renderingstyle_e_id])
> REFERENCES [dbo].[renderingstyle] ([idcol])
> GO
>
> ALTER TABLE [dbo].[style] CHECK CONSTRAINT [FK68B1DB1F1E869A]
> GO
>
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #871956 is a reply to message #871953] Tue, 15 May 2012 08:02 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Ahh... that is a good hint... is it possible to influence the order of inserts? I.e. let StyleContainer be inserted before Style?
Note: Style is a sub-class of StyleContainer

If I remove all FK constraints of Style, the inserts/transaction will commit successfully...
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #871969 is a reply to message #871956] Tue, 15 May 2012 08:26 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
This is the ouput of the log on server side:

Hibernate: insert into [stylecontainer] (resource_id, container_id, e_version, commit_TimeStamp) values (?, ?, ?, ?)
2012-05-15 10:22:04.512 DEBUG [Thread-7 ] (IdentifierGeneratorHelper.java:87)  - Natively generated identity: 1
2012-05-15 10:22:04.512 DEBUG [Thread-7 ] (AbstractBatcher.java:418)  - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2012-05-15 10:22:04.512 DEBUG [Thread-7 ] (AbstractBatcher.java:410)  - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2012-05-15 10:22:04.512 DEBUG [Thread-7 ] (SQLStatementLogger.java:111)  - insert into [style] ([color_background_e_id], [color_foreground_e_id], [linewidth], [linestyle], [filled], [linevisible], [renderingstyle_renderingstyle_e_id], [transparency], [id], [description], [font_font_e_id], [horizontalalignment], [verticalalignment], [angle], [stretchh], [stretchv], [proportional], [style_stylecontainer_e_id], [stylecontainer_e_id]) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into [style] ([color_background_e_id], [color_foreground_e_id], [linewidth], [linestyle], [filled], [linevisible], [renderingstyle_renderingstyle_e_id], [transparency], [id], [description], [font_font_e_id], [horizontalalignment], [verticalalignment], [angle], [stretchh], [stretchv], [proportional], [style_stylecontainer_e_id], [stylecontainer_e_id]) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2012-05-15 10:22:04.543 DEBUG [Thread-7 ] (AbstractBatcher.java:418)  - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2012-05-15 10:22:04.559 DEBUG [Thread-7 ] (JDBCExceptionReporter.java:225)  - could not insert: [Style] [insert into [style] ([color_background_e_id], [color_foreground_e_id], [linewidth], [linestyle], [filled], [linevisible], [renderingstyle_renderingstyle_e_id], [transparency], [id], [description], [font_font_e_id], [horizontalalignment], [verticalalignment], [angle], [stretchh], [stretchv], [proportional], [style_stylecontainer_e_id], [stylecontainer_e_id]) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]
java.sql.SQLException: Die INSERT-Anweisung steht in Konflikt mit der FOREIGN KEY-Einschränkung 'FK68B1DB139541E86'. Der Konflikt trat in der '_TEST'-Datenbank, Tabelle 'dbo.stylecontainer', column 'idcol' auf.
	at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
	at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
	at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)


And, this is after removal of all fk constraints of Style...

2012-05-15 10:14:43.065 DEBUG [Thread-7 ] (AbstractBatcher.java:410)  - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2012-05-15 10:14:43.065 DEBUG [Thread-7 ] (SQLStatementLogger.java:111)  - insert into [stylecontainer] (resource_id, container_id, e_version, commit_TimeStamp) values (?, ?, ?, ?)
Hibernate: insert into [stylecontainer] (resource_id, container_id, e_version, commit_TimeStamp) values (?, ?, ?, ?)
2012-05-15 10:14:43.080 DEBUG [Thread-7 ] (IdentifierGeneratorHelper.java:87)  - Natively generated identity: 1
2012-05-15 10:14:43.080 DEBUG [Thread-7 ] (AbstractBatcher.java:418)  - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2012-05-15 10:14:43.080 DEBUG [Thread-7 ] (AbstractBatcher.java:410)  - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2012-05-15 10:14:43.080 DEBUG [Thread-7 ] (SQLStatementLogger.java:111)  - insert into [style] ([color_background_e_id], [color_foreground_e_id], [linewidth], [linestyle], [filled], [linevisible], [renderingstyle_renderingstyle_e_id], [transparency], [id], [description], [font_font_e_id], [horizontalalignment], [verticalalignment], [angle], [stretchh], [stretchv], [proportional], [style_stylecontainer_e_id], [stylecontainer_e_id]) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into [style] ([color_background_e_id], [color_foreground_e_id], [linewidth], [linestyle], [filled], [linevisible], [renderingstyle_renderingstyle_e_id], [transparency], [id], [description], [font_font_e_id], [horizontalalignment], [verticalalignment], [angle], [stretchh], [stretchv], [proportional], [style_stylecontainer_e_id], [stylecontainer_e_id]) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2012-05-15 10:14:43.080 DEBUG [Thread-7 ] (AbstractBatcher.java:418)  - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2012-05-15 10:14:43.080 DEBUG [Thread-7 ] (AbstractSaveEventListener.java:319)  - executing identity-insert immediately


Does that mean that Style must be inserted before StyleContainer?
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #872021 is a reply to message #871969] Tue, 15 May 2012 10:16 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Erdal,
For the FK constraint mentioned in the error (FK68B1DB139541E86 note id may change in re-installs..) can you check/post
what the source and target columns are?

gr. Martin

On 05/15/2012 10:26 AM, Erdal Karaca wrote:
> This is the ouput of the log on server side:
>
>
> Hibernate: insert into [stylecontainer] (resource_id, container_id, e_version, commit_TimeStamp) values (?, ?, ?, ?)
> 2012-05-15 10:22:04.512 DEBUG [Thread-7 ] (IdentifierGeneratorHelper.java:87) - Natively generated identity: 1
> 2012-05-15 10:22:04.512 DEBUG [Thread-7 ] (AbstractBatcher.java:418) - about to close PreparedStatement (open
> PreparedStatements: 1, globally: 1)
> 2012-05-15 10:22:04.512 DEBUG [Thread-7 ] (AbstractBatcher.java:410) - about to open PreparedStatement (open
> PreparedStatements: 0, globally: 0)
> 2012-05-15 10:22:04.512 DEBUG [Thread-7 ] (SQLStatementLogger.java:111) - insert into [style] ([color_background_e_id],
> [color_foreground_e_id], [linewidth], [linestyle], [filled], [linevisible], [renderingstyle_renderingstyle_e_id],
> [transparency], [id], [description], [font_font_e_id], [horizontalalignment], [verticalalignment], [angle], [stretchh],
> [stretchv], [proportional], [style_stylecontainer_e_id], [stylecontainer_e_id]) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
> ?, ?, ?, ?, ?, ?, ?, ?)
> Hibernate: insert into [style] ([color_background_e_id], [color_foreground_e_id], [linewidth], [linestyle], [filled],
> [linevisible], [renderingstyle_renderingstyle_e_id], [transparency], [id], [description], [font_font_e_id],
> [horizontalalignment], [verticalalignment], [angle], [stretchh], [stretchv], [proportional],
> [style_stylecontainer_e_id], [stylecontainer_e_id]) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
> 2012-05-15 10:22:04.543 DEBUG [Thread-7 ] (AbstractBatcher.java:418) - about to close PreparedStatement (open
> PreparedStatements: 1, globally: 1)
> 2012-05-15 10:22:04.559 DEBUG [Thread-7 ] (JDBCExceptionReporter.java:225) - could not insert: [Style] [insert into
> [style] ([color_background_e_id], [color_foreground_e_id], [linewidth], [linestyle], [filled], [linevisible],
> [renderingstyle_renderingstyle_e_id], [transparency], [id], [description], [font_font_e_id], [horizontalalignment],
> [verticalalignment], [angle], [stretchh], [stretchv], [proportional], [style_stylecontainer_e_id],
> [stylecontainer_e_id]) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]
> java.sql.SQLException: Die INSERT-Anweisung steht in Konflikt mit der FOREIGN KEY-Einschränkung 'FK68B1DB139541E86'. Der
> Konflikt trat in der '_TEST'-Datenbank, Tabelle 'dbo.stylecontainer', column 'idcol' auf.
> at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
> at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
> at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)
>
>
> And, this is after removal of all fk constraints of Style...
>
>
> 2012-05-15 10:14:43.065 DEBUG [Thread-7 ] (AbstractBatcher.java:410) - about to open PreparedStatement (open
> PreparedStatements: 0, globally: 0)
> 2012-05-15 10:14:43.065 DEBUG [Thread-7 ] (SQLStatementLogger.java:111) - insert into [stylecontainer] (resource_id,
> container_id, e_version, commit_TimeStamp) values (?, ?, ?, ?)
> Hibernate: insert into [stylecontainer] (resource_id, container_id, e_version, commit_TimeStamp) values (?, ?, ?, ?)
> 2012-05-15 10:14:43.080 DEBUG [Thread-7 ] (IdentifierGeneratorHelper.java:87) - Natively generated identity: 1
> 2012-05-15 10:14:43.080 DEBUG [Thread-7 ] (AbstractBatcher.java:418) - about to close PreparedStatement (open
> PreparedStatements: 1, globally: 1)
> 2012-05-15 10:14:43.080 DEBUG [Thread-7 ] (AbstractBatcher.java:410) - about to open PreparedStatement (open
> PreparedStatements: 0, globally: 0)
> 2012-05-15 10:14:43.080 DEBUG [Thread-7 ] (SQLStatementLogger.java:111) - insert into [style] ([color_background_e_id],
> [color_foreground_e_id], [linewidth], [linestyle], [filled], [linevisible], [renderingstyle_renderingstyle_e_id],
> [transparency], [id], [description], [font_font_e_id], [horizontalalignment], [verticalalignment], [angle], [stretchh],
> [stretchv], [proportional], [style_stylecontainer_e_id], [stylecontainer_e_id]) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
> ?, ?, ?, ?, ?, ?, ?, ?)
> Hibernate: insert into [style] ([color_background_e_id], [color_foreground_e_id], [linewidth], [linestyle], [filled],
> [linevisible], [renderingstyle_renderingstyle_e_id], [transparency], [id], [description], [font_font_e_id],
> [horizontalalignment], [verticalalignment], [angle], [stretchh], [stretchv], [proportional],
> [style_stylecontainer_e_id], [stylecontainer_e_id]) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
> 2012-05-15 10:14:43.080 DEBUG [Thread-7 ] (AbstractBatcher.java:418) - about to close PreparedStatement (open
> PreparedStatements: 1, globally: 1)
> 2012-05-15 10:14:43.080 DEBUG [Thread-7 ] (AbstractSaveEventListener.java:319) - executing identity-insert immediately
>
>
> Does that mean that Style must be inserted before StyleContainer?


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #872059 is a reply to message #872021] Tue, 15 May 2012 11:51 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Martin,
Here is the sql that generates that FK:

ALTER TABLE [dbo].[style]  WITH CHECK ADD  CONSTRAINT [FK68B1DB139541E86] FOREIGN KEY([style_stylecontainer_e_id])
REFERENCES [dbo].[stylecontainer] ([idcol])
GO

ALTER TABLE [dbo].[style] CHECK CONSTRAINT [FK68B1DB139541E86]
GO


BTW. the FK name seems to never change, even if I re-install the DB...
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #872064 is a reply to message #872059] Tue, 15 May 2012 12:00 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
I.e. column style.style_stylecontainer_e_id (source column) references stylecontainer.idcol (target column) Smile
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #872089 is a reply to message #872064] Tue, 15 May 2012 12:37 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Is the referenced style container persisted in the same commit? (what I am looking at is if the persist order is somehow
wrong). If you want to debug you can go into HibernateStoreAccessor.write method, there is a for-loop there which
persists the new objects, I think the order seems to matter...

Although Hibernate would normally throw another error if the persist order results in objects being stored before their
referenced objects.

gr. Martin

On 05/15/2012 02:00 PM, Erdal Karaca wrote:
> I.e. column style.style_stylecontainer_e_id (source column) references stylecontainer.idcol (target column) :)


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #874585 is a reply to message #872089] Mon, 21 May 2012 07:36 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
This ist the location I debugged:

org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.doWrite(InternalCommitContext, OMMonitor)


      final List<InternalCDORevision> repairContainerIDs = new ArrayList<InternalCDORevision>();
      final List<InternalCDORevision> repairResourceIDs = new ArrayList<InternalCDORevision>();
      for (InternalCDORevision revision : context.getNewObjects())
      {
        // keep track for which cdoRevisions the container id needs to be repaired afterwards
        final CDOID containerID = (CDOID)revision.getContainerID();
        if (containerID instanceof CDOIDTemp && !containerID.isNull())
        {
          repairContainerIDs.add(revision);
        }

        final CDOID resourceID = revision.getResourceID();
        if (resourceID instanceof CDOIDTemp && !resourceID.isNull())
        {
          repairResourceIDs.add(revision);
        }

        final String entityName = getStore().getEntityName(revision.getEClass());
        session.saveOrUpdate(entityName, revision);
      }


The second iteration of the for-loop will saveOrUpdate an entity with the name "ContainerShape" and fails in the flow of that call.
(First call is a regular business object not specific to graphiti and succeeds.)

It fails when trying to execute this:

Hibernate: insert into [style] ([color_background_e_id], [color_foreground_e_id], [linewidth], [linestyle], [filled], [linevisible], [renderingstyle_renderingstyle_e_id], [transparency], [id], [description], [font_font_e_id], [horizontalalignment], [verticalalignment], [angle], [stretchh], [stretchv], [proportional], [style_stylecontainer_e_id], [stylecontainer_e_id]) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)


The hibernate mapping contains this (using JOINED inheritance mode):

	<joined-subclass entity-name="ContainerShape" abstract="false" lazy="true" extends="Shape" table="`containershape`">
		<meta attribute="eclassName">ContainerShape</meta>
		<meta attribute="epackage">http://eclipse.org/graphiti/mm/pictograms</meta>
		<tuplizer entity-mode="pojo" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<tuplizer entity-mode="dynamic-map" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<key>
			<column name="`shape_e_id`"/>
		</key>
		<bag name="children" lazy="true" cascade="all,delete-orphan">
			<key update="true">
				<column name="`shape_container_e_id`" not-null="false" unique="false"/>
			</key>
			<one-to-many entity-name="Shape"/>
		</bag>
	</joined-subclass>


	<joined-subclass entity-name="Shape" abstract="false" lazy="true" extends="AnchorContainer" table="`shape`">
		<meta attribute="eclassName">Shape</meta>
		<meta attribute="epackage">http://eclipse.org/graphiti/mm/pictograms</meta>
		<tuplizer entity-mode="pojo" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<tuplizer entity-mode="dynamic-map" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<key>
			<column name="`anchorcontainer_e_id`"/>
		</key>
		<many-to-one name="container" entity-name="ContainerShape" lazy="false" cascade="merge,persist,save-update,lock,refresh" insert="true" update="true" not-null="false">
			<column not-null="false" unique="false" name="`shape_container_e_id`"/>
		</many-to-one>
	</joined-subclass>

	<joined-subclass entity-name="AnchorContainer" abstract="true" lazy="true" extends="PictogramElement" table="`anchorcontainer`">
		<meta attribute="eclassName">AnchorContainer</meta>
		<meta attribute="epackage">http://eclipse.org/graphiti/mm/pictograms</meta>
		<tuplizer entity-mode="pojo" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<tuplizer entity-mode="dynamic-map" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<key>
			<column name="`pictogramelement_e_id`"/>
		</key>
		<bag name="anchors" lazy="true" cascade="all,delete-orphan">
			<key update="true">
				<column name="`anchor_parent_e_id`" not-null="false" unique="false"/>
			</key>
			<one-to-many entity-name="Anchor"/>
		</bag>
	</joined-subclass>

	<joined-subclass entity-name="PictogramElement" abstract="true" lazy="true" extends="GraphicsAlgorithmContainer" table="`pictogramelement`">
		<meta attribute="eclassName">PictogramElement</meta>
		<meta attribute="epackage">http://eclipse.org/graphiti/mm/pictograms</meta>
		<tuplizer entity-mode="pojo" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<tuplizer entity-mode="dynamic-map" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<key>
			<column name="`graphicsalgorithmcontainer_e_id`"/>
		</key>
		<property name="visible" lazy="false" insert="true" update="true" not-null="true" unique="false" type="boolean">
			<column not-null="true" unique="false" name="`visible`"/>
		</property>
		<many-to-one name="graphicsAlgorithm" entity-name="GraphicsAlgorithm" cascade="all" not-null="false" lazy="false" insert="true" update="true"/>
		<property name="active" lazy="false" insert="true" update="true" not-null="true" unique="false" type="boolean">
			<column not-null="true" unique="false" name="`active`"/>
		</property>
		<many-to-one name="link" entity-name="PictogramLink" cascade="all" not-null="false" lazy="false" insert="true" update="true"/>
	</joined-subclass>

	<joined-subclass entity-name="GraphicsAlgorithmContainer" abstract="true" lazy="true" extends="PropertyContainer" table="`graphicsalgorithmcontainer`">
		<meta attribute="eclassName">GraphicsAlgorithmContainer</meta>
		<meta attribute="epackage">http://eclipse.org/graphiti/mm</meta>
		<tuplizer entity-mode="pojo" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<tuplizer entity-mode="dynamic-map" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<key>
			<column name="`propertycontainer_e_id`"/>
		</key>
	</joined-subclass>

	<class entity-name="PropertyContainer" abstract="true" lazy="true" table="`propertycontainer`">
		<meta attribute="eclassName">PropertyContainer</meta>
		<meta attribute="epackage">http://eclipse.org/graphiti/mm</meta>
		<tuplizer entity-mode="pojo" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<tuplizer entity-mode="dynamic-map" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/>
		<id type="long" name="idcol" column="idcol" access="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOSyntheticIdPropertyHandler">
			<meta attribute="syntheticId">true</meta>
			<generator class="native"/>
		</id>
		<property name="resourceID" type="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDUserType">
			<column name="resource_id"/>
		</property>
		<property name="containerID" type="string">
			<column name="container_id"/>
		</property>
		<property name="cdo_teneo_e_version" type="java.lang.Integer">
			<meta attribute="version">true</meta>
			<column name="e_version"/>
		</property>
		<property name="commit_TimeStamp" type="java.lang.Long"/>
		<bag name="properties" lazy="true" cascade="all,delete-orphan">
			<key update="true">
				<column name="`propertycontainer_properties_e_id`" not-null="false" unique="false"/>
			</key>
			<one-to-many entity-name="Property"/>
		</bag>
	</class>


I have attached an image of the type hierarchy of the Diagram EClass of graphiti...
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #881382 is a reply to message #874585] Mon, 04 June 2012 12:49 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
How do I tell teneo to prevent specific FK constraints to be generated.
The generated FK constraints can be safely deactivated or prevented from being generated at all...

I am using an external annotations file to override the persistence/hibernate mapping.
I could not find out just by inspecting persistence-mapping-hibernate.xsd
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #881387 is a reply to message #881382] Mon, 04 June 2012 12:52 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Erdal,
Preventing only the FK Constraints from being generated is not possible. Or do you mean to completely ignore the
association so that it is not mapped/managed by Hibernate?

gr. Martin

On 06/04/2012 02:49 PM, Erdal Karaca wrote:
> How do I tell teneo to prevent specific FK constraints to be generated.
> The generated FK constraints can be safely deactivated or prevented from being generated at all...
>
> I am using an external annotations file to override the persistence/hibernate mapping.
> I could not find out just by inspecting persistence-mapping-hibernate.xsd


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #881389 is a reply to message #881387] Mon, 04 June 2012 13:00 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
If the former is not possible, how would ignoring associations look like in the annotations file?

Martin taal wrote on Mon, 04 June 2012 08:52
Hi Erdal,
Preventing only the FK Constraints from being generated is not possible. Or do you mean to completely ignore the
association so that it is not mapped/managed by Hibernate?

gr. Martin


Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #881404 is a reply to message #881389] Mon, 04 June 2012 13:34 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
You can annotated EClasses and efeatures with the @Transient annotation, if an EClass has this annotation then all
associations pointing to this eclass will be transient (not mapped).

gr. Martin

On 06/04/2012 03:00 PM, Erdal Karaca wrote:
> If the former is not possible, how would ignoring associations look like in the annotations file?
>
> Martin taal wrote on Mon, 04 June 2012 08:52
>> Hi Erdal,
>> Preventing only the FK Constraints from being generated is not possible. Or do you mean to completely ignore the
>> association so that it is not mapped/managed by Hibernate?
>>
>> gr. Martin
>
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #881416 is a reply to message #881404] Mon, 04 June 2012 14:05 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Unfortunately, that leads to 'gaps' in the inheritance hierarchy... So, I have to debug it again and find out what is wrong with the insert statements order...
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #881736 is a reply to message #881416] Tue, 05 June 2012 07:14 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Martin,

I have saved the graphiti Diagram to a XMI file, see attachments.
I started the server (which is downloadable from the CDO downloads page) and the CDO explorer (cdo downloads page).

Then, I registered the graphiti ecore file from file system (for your convenience, see attachments) and imported the xmi file resource and saved...
Everything worked without errors.
Note: the downloaded CDO server uses a h2 store.

If you use hibernate to store the XMI file, I assume you will be getting the errors.
If you have a properly set up hibernate server, you could test to import the xmi file...

Thanks!
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #881740 is a reply to message #881736] Tue, 05 June 2012 07:18 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Erdal,
Hopefully sometime today I will have time to look at it.

gr. Martin

On 06/05/2012 09:14 AM, Erdal Karaca wrote:
> Martin,
>
> I have saved the graphiti Diagram to a XMI file, see attachments.
> I started the server (which is downloadable from the CDO downloads page) and the CDO explorer (cdo downloads page).
>
> Then, I registered the graphiti ecore file from file system (for your convenience, see attachments) and imported the xmi file resource and saved...
> Everything worked without errors.
> Note: the downloaded CDO server uses a h2 store.
>
> If you use hibernate to store the XMI file, I assume you will be getting the errors.
> If you have a properly set up hibernate server, you could test to import the xmi file...
>
> Thanks!


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #899504 is a reply to message #881740] Wed, 01 August 2012 08:23 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Martin,
Same problems with the latest release... Any news or hints to check for?
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #909318 is a reply to message #899504] Thu, 06 September 2012 23:55 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Erdal,
I tested this and with me the joined subclass inheritance strategy I get an error on the mapping of the Container class.
You didn't have that?

I tried your test file but it fails because it misses mandatory values for the attributes/properties of the color and
font type. I corrected those manually.

Then your file saved correctly, I tested on mysql and hsqldb.

I am on teneo 2.0 and cdo 4.2 (which is almost the same as 4.1).

gr. Martin

On 08/01/2012 10:23 AM, Erdal Karaca wrote:
> Martin,
> Same problems with the latest release... Any news or hints to check for?


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #910673 is a reply to message #909318] Mon, 10 September 2012 07:41 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Martin,
Just tested on mysql and cdo 4.1 and I am getting this error (no modifications to the attached files test.graphiti and graphiti.ecore):

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`repo1`.`style`, CONSTRAINT `style_stylecontainer` FOREIGN KEY (`style_stylecontainer_e_id`) REFERENCES `stylecontainer` (`idcol`))
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
	at com.mysql.jdbc.Util.getInstance(Util.java:381)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1038)
...


Maybe, my settings are wrong?

			<property name="teneo.mapping.inheritance" value="JOINED"/>
		
			<property name="teneo.mapping.always_map_list_as_bag" value="true"/>
			<property name="teneo.mapping.join_table_for_non_contained_associations" value="false"/>
			<property name="teneo.mapping.cascade_policy_on_non_containment" value="MERGE,PERSIST,REFRESH"/>
			<property name="hibernate.hbm2ddl.auto" value="update"/>
			<property name="hibernate.show_sql" value="true"/>
			<property name="hibernate.connection.pool_size" value="10"/>
			<property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
			<property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JDBCTransactionFactory"/>

			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
			<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
			<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/repo1"/>
			<property name="hibernate.connection.username" value="root"/>
			<property name="hibernate.connection.password" value="root"/>
			<property name="teneo.mapping.cascade_policy_on_containment" value="merge,persist,save-update,lock,refresh" />
			<property name="teneo.naming.version_column" value="e_version"/>
		<store type="hibernate">
			<mappingProvider type="teneo">
			</mappingProvider>
		</store>
Re: [CDO/Hibernate/SQLServer] SQL Error: 547, SQLState: 23000 [message #910700 is a reply to message #910673] Mon, 10 September 2012 08:33 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Erdal,
Your settings are not wrong, but they are different than what I tested. I will try with your settings.

> <property name="teneo.mapping.inheritance" value="JOINED"/>
>
> <property name="teneo.mapping.always_map_list_as_bag" value="true"/>
> <property name="teneo.mapping.join_table_for_non_contained_associations" value="false"/>
> <property name="teneo.mapping.cascade_policy_on_non_containment" value="MERGE,PERSIST,REFRESH"/>

gr. Martin


On 09/10/2012 09:41 AM, Erdal Karaca wrote:
> Martin,
> Just tested on mysql and cdo 4.1 and I am getting this error (no modifications to the attached files test.graphiti and
> graphiti.ecore):
>
>
> Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row:
> a foreign key constraint fails (`repo1`.`style`, CONSTRAINT `style_stylecontainer` FOREIGN KEY
> (`style_stylecontainer_e_id`) REFERENCES `stylecontainer` (`idcol`))
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
> at java.lang.reflect.Constructor.newInstance(Unknown Source)
> at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
> at com.mysql.jdbc.Util.getInstance(Util.java:381)
> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1038)
> ...
>
>
> Maybe, my settings are wrong?
>
>
> <property name="teneo.mapping.inheritance" value="JOINED"/>
>
> <property name="teneo.mapping.always_map_list_as_bag" value="true"/>
> <property name="teneo.mapping.join_table_for_non_contained_associations" value="false"/>
> <property name="teneo.mapping.cascade_policy_on_non_containment" value="MERGE,PERSIST,REFRESH"/>
> <property name="hibernate.hbm2ddl.auto" value="update"/>
> <property name="hibernate.show_sql" value="true"/>
> <property name="hibernate.connection.pool_size" value="10"/>
> <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
> <property name="hibernate.transaction.factory_class"
> value="org.hibernate.transaction.JDBCTransactionFactory"/>
>
> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
> <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/repo1"/>
> <property name="hibernate.connection.username" value="root"/>
> <property name="hibernate.connection.password" value="root"/>
> <property name="teneo.mapping.cascade_policy_on_containment" value="merge,persist,save-update,lock,refresh" />
> <property name="teneo.naming.version_column" value="e_version"/>
> <store type="hibernate">
> <mappingProvider type="teneo">
> </mappingProvider>
> </store>
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Previous Topic:Find instances of an EClass
Next Topic:[CDO] : have fix fragment URI on commit
Goto Forum:
  


Current Time: Fri Apr 26 12:10:07 GMT 2024

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

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

Back to the top