Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Teneo: constraint error using mssql
Teneo: constraint error using mssql [message #502711] Wed, 09 December 2009 14:13 Go to next message
Flavio Donze is currently offline Flavio DonzeFriend
Messages: 211
Registered: July 2009
Location: Switzerland
Senior Member
Hello Martin

I don't know if the following is a hibernate or teneo problem, if it's hibernate I'll bother them with it Smile.

Using postgresql everything works fine, we now test mssql 2005 & 2008 and getting the following error:

DEBUG: org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table [addressdata_types] add constraint FK2DA6FE981CA2C0FA foreign key ([addressdata_id]) references [addressdata]
DEBUG: org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table [addressdata_types] add constraint addressdata_types foreign key ([code_id]) references [code]
ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate - Unsuccessful: alter table [addressdata_types] add constraint addressdata_types foreign key ([code_id]) references [code]
ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate - In der Datenbank ist bereits ein Objekt mit dem Namen 'addressdata_types' vorhanden.
DEBUG: org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table [addressdata] add constraint person_addressdata foreign key ([person_addressdata_id]) references [person]
ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate - could not complete schema update
java.lang.NullPointerException
at org.tranql.connector.jdbc.ConnectionHandle.connectionError(C onnectionHandle.java:103)
at org.tranql.connector.jdbc.StatementHandle.executeUpdate(Stat ementHandle.java:168)
...

Seems link mssql does not like constraints that have the same name as the table.
Sometimes the constraint name is a UID (FK2DA6FE981CA2C0FA) and sometimes not (addressdata_types).
Who generates the constraint names Teneo or Hibernate? Why not always use a UID?

Here some maybe relevant properties:
<property name="hibernateProperties">
	<props>		 
		<prop key="hibernate.transaction.auto_close_session">true</prop>
		<prop key="hibernate.transaction.flush_before_completion">true</prop>
		<prop key="hibernate.dialect">${hibernate.dialect}</prop>
		<prop key="hibernate.hbm2ddl.auto">update</prop>
		<prop key="hibernate.jdbc.batch_size">2000</prop>
		<prop key="javax.persistence.transactionType">JTA</prop>
		<prop key="hibernate.transaction.manager_lookup_class">com.softmodeler.server.persistence.SoftmodelerTransactionManagerLookup</prop>								
	</props>
</property>


Here the postgresql log:
...
DEBUG: org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table "addressdata_types" add constraint FK2DA6FE981CA2C0FA foreign key ("addressdata_id") references "addressdata"
DEBUG: org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table "addressdata_types" add constraint addressdata_types foreign key ("code_id") references "code"
DEBUG: org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table "addressdata" add constraint person_addressdata foreign key ("person_addressdata_id") references "person"
DEBUG: org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table "addressdata" add constraint addressdata_state foreign key ("code_state_id") references "code"
DEBUG: org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table "addressdata" add constraint addressdata_country foreign key ("code_country_id") references "code"
...


greets
Flavio


Prozessmanagement und Qualitätsmanagement Software QMS/IMS
https://www.scodi.ch
Re: Teneo: constraint error using mssql [message #502745 is a reply to message #502711] Wed, 09 December 2009 15:07 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Flavio,
There is an option to control if Teneo generates readable foreign key constraint names. The default value of the option
is true:
PersistenceOptions.SET_FOREIGN_KEY_NAME

If you set it to false then hibernate will generate the foreign key constraint names. This will hopefully solve it.

gr. Martin

Flavio Donzé wrote:
> Hello Martin
>
> I don't know if the following is a hibernate or teneo problem, if it's
> hibernate I'll bother them with it :).
>
> Using postgresql everything works fine, we now test mssql 2005 & 2008
> and getting the following error:
>
> DEBUG: org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table
> [addressdata_types] add constraint FK2DA6FE981CA2C0FA foreign key
> ([addressdata_id]) references [addressdata] DEBUG:
> org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table
> [addressdata_types] add constraint addressdata_types foreign key
> ([code_id]) references [code]
> ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate - Unsuccessful: alter
> table [addressdata_types] add constraint addressdata_types foreign key
> ([code_id]) references [code]
> ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate - In der Datenbank ist
> bereits ein Objekt mit dem Namen 'addressdata_types' vorhanden.
> DEBUG: org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table
> [addressdata] add constraint person_addressdata foreign key
> ([person_addressdata_id]) references [person]
> ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate - could not complete
> schema update
> java.lang.NullPointerException
> at org.tranql.connector.jdbc.ConnectionHandle.connectionError(C
> onnectionHandle.java:103)
> at org.tranql.connector.jdbc.StatementHandle.executeUpdate(Stat
> ementHandle.java:168)
> ...
>
> Seems link mssql does not like constraints that have the same name as
> the table.
> Sometimes the constraint name is a UID (FK2DA6FE981CA2C0FA) and
> sometimes not (addressdata_types).
> Who generates the constraint names Teneo or Hibernate? Why not always
> use a UID?
>
> Here some maybe relevant properties:
>
> <property name="hibernateProperties">
> <props> <prop
> key="hibernate.transaction.auto_close_session">true</prop >
> <prop
> key="hibernate.transaction.flush_before_completion">true</prop >
> <prop key="hibernate.dialect">${hibernate.dialect}</prop>
> <prop key="hibernate.hbm2ddl.auto">update</prop>
> <prop key="hibernate.jdbc.batch_size">2000</prop>
> <prop key="javax.persistence.transactionType">JTA</prop>
> <prop
> key="hibernate.transaction.manager_lookup_class"> com.softmodeler.server.persistence.SoftmodelerTransactionMan agerLookup </prop>
>
> </props>
> </property>
>
>
> Here the postgresql log:
>
> ...
> DEBUG: org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table
> "addressdata_types" add constraint FK2DA6FE981CA2C0FA foreign key
> ("addressdata_id") references "addressdata"
> DEBUG: org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table
> "addressdata_types" add constraint addressdata_types foreign key
> ("code_id") references "code"
> DEBUG: org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table
> "addressdata" add constraint person_addressdata foreign key
> ("person_addressdata_id") references "person"
> DEBUG: org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table
> "addressdata" add constraint addressdata_state foreign key
> ("code_state_id") references "code"
> DEBUG: org.hibernate.tool.hbm2ddl.SchemaUpdate - alter table
> "addressdata" add constraint addressdata_country foreign key
> ("code_country_id") references "code"
> ...
>
>
> greets
> Flavio


--

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: constraint error using mssql [message #502893 is a reply to message #502745] Thu, 10 December 2009 08:36 Go to previous messageGo to next message
Flavio Donze is currently offline Flavio DonzeFriend
Messages: 211
Registered: July 2009
Location: Switzerland
Senior Member
Hey Martin

Once again you saved my day!

Hibernate uses generated foreign key names and hence no exception is thrown.

Found the following forum topic:
Backward compatibility: SET_FOREIGN_KEY_NAME to false
Why have you changed the default option? Maybe change it back to false since mssql makes trouble?

Thanks a lot!
Flavio



Prozessmanagement und Qualitätsmanagement Software QMS/IMS
https://www.scodi.ch
Re: Teneo: constraint error using mssql [message #502906 is a reply to message #502893] Thu, 10 December 2009 09:27 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Flavio,
I think it was a user request, and I had trouble myself once with hibernate generated foreign key constraints. But I
will make a note in the troubleshooting sections about it.

gr. Martin

Flavio Donzé wrote:
> Hey Martin
>
> Once again you saved my day!
>
> Hibernate uses generated foreign key names and hence no exception is
> thrown.
>
> Found the following forum topic:
> http://www.eclipse.org/forums/index.php?t=msg&goto=93239 &S=f3084f242ba309c82cf42030cf95bcf4
>
> Why have you changed the default option? Maybe change it back to false
> since mssql makes trouble?
>
> Thanks a lot!
> Flavio
>
>


--

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:Re: [CDO] TimeoutRuntimeException when trying to open session
Next Topic:[CDO] General Commit Operations
Goto Forum:
  


Current Time: Thu Apr 25 21:50:43 GMT 2024

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

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

Back to the top