473,396 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Foreign Key Constraints

------=_NextPart_000_0008_01C360DD.C2475700
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit

We are trying to load a set of data using Hibernate (O/R mapping tool).
Hibernate creates foreign key constraints when it is creating our DB
(mysql 4.0.14). The process for loading data requires us to break these
constraints at certain points, however they will all be satisfied at the
end of the transaction.

This is the perfect case for deferred FK constraints, however since
mysql does not support deferred FK. I read where we could use

Set foreign_key_checks=0

Do the data load

Set foreign_key_checks=1

However when we tried to run this we still got a FK error message.

Caused by: java.sql.SQLException: General error, message from server:
"Cannot delete or update a parent row: a foreign key constraint fails"

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:1628)

at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:88 6)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java :945)

at com.mysql.jdbc.Connection.execSQL(Connection.java: 1809)

at
com.mysql.jdbc.PreparedStatement.executeUpdate(Pre paredStatement.java:16
02)

at
com.mysql.jdbc.PreparedStatement.executeUpdate(Pre paredStatement.java:14
88)

at
org.jboss.resource.adapter.jdbc.WrappedPreparedSta tement.executeUpdate(W
rappedPreparedStatement.java:308)

at
net.sf.hibernate.persister.NormalizedEntityPersist er.delete(NormalizedEn
tityPersister.java:606)

at
net.sf.hibernate.impl.ScheduledDeletion.execute(Sc heduledDeletion.java:2
2)

at
net.sf.hibernate.impl.SessionImpl.executeAll(Sessi onImpl.java:2100)

at
net.sf.hibernate.impl.SessionImpl.execute(SessionI mpl.java:2066)

... 78 more

Anybody know why the Set foreign_key_checks=0 might not be working?

-John


------=_NextPart_000_0008_01C360DD.C2475700--

Jul 19 '05 #1
0 5279

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: D | last post by:
Database 1 is corrupted. Database 2 was created by dba but none of the primary or foreign key constraints were ported over. TOAD won't let me export. I will try ErWin next. What is the best way...
1
by: Jason Madison | last post by:
We sometimes get very large databases that we want to cut down to use for testing. The information is all related to a central accounts table. The way I thought of doing this is to grab all...
0
by: Scott Ribe | last post by:
I've got a problem which I think may be a bug in Postgres, but I wonder if I'm missing something. Two tables, A & B have foreign key relations to each other. A 3rd table C, inherits from A. A...
6
by: Brendan Jurd | last post by:
Hi all, I read on the manual page for Inheritance that: "A limitation of the inheritance feature is that indexes (including unique constraints) and foreign key constraints only apply to single...
13
by: Bob Stearns | last post by:
Why is the following constraint invalid? I want to make sure that every row in IS3.ANIMALS_PRIV_INDEXES matches one of those in IS3.table_var_defn with part of the primary key fixed. Since this is...
0
by: Rajesh Tiwari | last post by:
Hi Group, i have a foreign key in a table in sql server.i am using a dataset and populating it with the contents of this table.my problem is that i am not able to access the foreign key that i...
8
by: wespvp | last post by:
I am using PostgreSQL 7.4.1 on RedHat 7.2. The query I am executing is something like (I replaced all the return values with 'count'): db=> explain select count(*) from messages m join (select...
0
by: okonita | last post by:
DB2v8.2 LUW. Unable to drop Foreign Key constraints...although DROP constraints returns undefined name. Am I missing somrthing here? Hi all, I have a perplexing DB2 Drop command situation....
4
by: Bobby Edward | last post by:
I have an xsd dataset. I created a simple query called GetDataByUserId. I can preview the data fine! I created a very simple BLL function that calls it and returns a datatable. When I run...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.