-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: MYSQL and CaveatEmptor integration tests fail plz help
PostPosted: Wed Apr 04, 2007 7:29 pm 
Newbie

Joined: Wed Apr 04, 2007 11:58 am
Posts: 2
Location: United Kingdom
caveatemptor-native-061211

Hibernate version: hibernate3

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
[
<!ENTITY % globals SYSTEM "classpath://auction/persistence/globals.dtd">
%globals;

]>



Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
Test which is happening is
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="5" verbose="0" name="CaveatEmptor Integration" annotations="JDK">
<parameter name="webXmlResource" value="auction/test/web/hibernate-web.xml"/>
<test name="DBUnit" junit="false">
<groups>
<run>
<include name="integration-hibernate.*"/>
</run>
</groups>
<packages>
<package name="auction.test.basic">
</package>
</packages>
<classes>
<class name="auction.test.basic.AuditLogging"/>
<class name="auction.test.basic.Locking"/>
<class name="auction.test.basic.MapAndXMLRepresentation"/>
<class name="auction.test.basic.PersistentStateTransitions"/>
<class name="auction.test.basic.Queries$ItemPriceData"/>
<class name="auction.test.basic.Queries"/>
</classes>
</test>
<test name="WebFilters" junit="false">
<groups>
<run>
<include name="integration-hibernate.*"/>
</run>
</groups>
<packages>
<package name="auction.test.web">
</package>
</packages>
<classes>
<class name="auction.test.web.FilterTest"/>
<class name="auction.test.web.FilterTestServlet"/>
</classes>
</test>
</suite>

Exception:
DBUnit
auction.test.basic.AuditLogging:beforeTestMethod
Cannot add or update a child row: a foreign key constraint fails (`caveatemptor/users`, CONSTRAINT `FK_DEFAULT_BILLING_DETAILS_ID` FOREIGN KEY (`DEFAULT_BILLING_DETAILS_ID`) REFERENCES `billing_details` (`BILLING_DETAILS_ID`))


com.mysql.jdbc.SQLError.createSQLException(SQLError.java:931)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1160)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:685)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:790)
at org.dbunit.database.statement.SimplePreparedStatement.addBatch(SimplePreparedStatement.java:67)
at org.dbunit.database.statement.AutomaticPreparedBatchStatement.addBatch(AutomaticPreparedBatchStatement.java:57)
at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:187)
at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:67)
at auction.test.HibernateIntegrationTest.beforeTestMethod(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:632)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:360)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:140)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:407)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:683)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:115)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:101)
at org.testng.TestRunner.runWorkers(TestRunner.java:665)
at org.testng.TestRunner.privateRun(TestRunner.java:636)
at org.testng.TestRunner.run(TestRunner.java:513)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:279)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:264)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:244)
at org.testng.SuiteRunner.run(SuiteRunner.java:168)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:969)
at org.testng.TestNG.runSuitesLocally(TestNG.java:933)
at org.testng.TestNG.run(TestNG.java:701)
at org.testng.TestNG.privateMain(TestNG.java:1001)
at org.testng.TestNG.main(TestNG.java:979)
1 lines not shown
Click to show all stack frames
Name and version of the database you are using:
MYSQL 5.0
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: Found the Answer
PostPosted: Thu Apr 05, 2007 2:14 am 
Newbie

Joined: Wed Apr 04, 2007 11:58 am
Posts: 2
Location: United Kingdom
Class : HibernateIntegrationTest
Method:
protected IDatabaseConnection getConnection() throws Exception {
}

HSQL:
con.prepareStatement("set referential_integrity FALSE").execute();

MYSQL:
con.prepareStatement("set FOREIGN_KEY_CHECKS=0").execute();

It works


Top
 Profile  
 
 Post subject: Re: MYSQL and CaveatEmptor integration tests fail plz help
PostPosted: Wed Aug 12, 2009 10:58 am 
Newbie

Joined: Wed Aug 12, 2009 10:45 am
Posts: 16
Hi there;
I was never able to run the example with MySQL. I follow the instructions for HSQL and it works, but when I change the database to MySQL, it does not do anything. I try to export the schema, it shows a successful message, but never creates any table.

MySQL version is 5.0 and have the latest connector jar in the lib directory.

Any suggestion would be greatly appreciated.

Kamal


Top
 Profile  
 
 Post subject: Re: MYSQL and CaveatEmptor integration tests fail plz help
PostPosted: Fri Aug 14, 2009 4:05 pm 
Newbie

Joined: Wed Aug 12, 2009 10:45 am
Posts: 16
Got it to work. Thanks to me (GRIN).

I am using Eclipse IDE with the hibernate tools installed.

I put the mysql connector jar in the lib folder
I un-commented the part in hibernate.cfg.xml that says for MySQL database but modified it this way:

Code:
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://localhost/databasename</property>
        <property name="connection.username">username</property>
        <property name="connection.password">password</property>



Then I edited all the mapping files; did the following:
Removed the part that references the globals.dtd
Replaced the identifier reference by 'native'
and boom

I am able to export the schema to MySQL with the graphical tools.

Kamal


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.