-->
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: Problem with Mysql 5.5.10 on MAC OSX
PostPosted: Sat Apr 02, 2011 1:16 pm 
Newbie

Joined: Sat Apr 02, 2011 1:06 pm
Posts: 11
Hi there,

I have a piece of code that used to work great up until today. My computer crashed so I had to reinstall it, and as a result installed the latest MYSQL from Oracle - 5.5.10. After running the application again it fails with this exception:
Code:
Caused by: java.sql.BatchUpdateException: Cannot add or update a child row: a foreign key constraint fails (`komodjo`.`merchant`, CONSTRAINT `FK1087B9C8EF0491A8` FOREIGN KEY (`WIZ_TEMPLATE_ID`) REFERENCES `TEMPLATE` (`ID`))
   at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2007)
   at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1443)
   at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
   ... 117 more
ERROR KomodjoExceptionResolver - Could not execute JDBC batch update; SQL [update MERCHANT set AUTHORITY=?, CURRENCY=?, DESCRIPTION=?, ENABLED=?, INSURANCE=?, MERCHANT_IP_ADDRESSES=?, LANGUAGE=?, TYPE=?, NAME=?, PASSWORD=?, RESET_URL=?, SERVICE_COST=?, URL=?, USERNAME=?, WIZ_TEMPLATE_ID=? where ID=?]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; SQL [update MERCHANT set AUTHORITY=?, CURRENCY=?, DESCRIPTION=?, ENABLED=?, INSURANCE=?, MERCHANT_IP_ADDRESSES=?, LANGUAGE=?, TYPE=?, NAME=?, PASSWORD=?, RESET_URL=?, SERVICE_COST=?, URL=?, USERNAME=?, WIZ_TEMPLATE_ID=? where ID=?]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
   at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:637)
   at org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:793)
   at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:664)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
   at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy50.saveMerchant(Unknown Source)
   at com.komodjo.frontend.controller.merchant.MerchantProfileController.submitProfileForm(MerchantProfileController.java:168)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
   at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
   at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
   at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:59)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)
   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:99)
   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:60)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:119)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:57)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)
   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
   at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
   at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
   at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
   at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:195)
   at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:159)
   at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
   at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
   at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:417)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
   at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)
   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:119)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
   at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)
   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
   at java.lang.Thread.run(Thread.java:680)
Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:262)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:179)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
   at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:656)
   ... 109 more
Caused by: java.sql.BatchUpdateException: Cannot add or update a child row: a foreign key constraint fails (`komodjo`.`merchant`, CONSTRAINT `FK1087B9C8EF0491A8` FOREIGN KEY (`WIZ_TEMPLATE_ID`) REFERENCES `TEMPLATE` (`ID`))
   at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2007)
   at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1443)
   at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
   ... 117 more


Now I think that is really weird, so I tried to upgrade Hibernate from 3.5.6-Final to 3.6.2.Final but the problem is still there.
Here are the troublesome classes:

Code:
@Entity
@Table(name = "MERCHANT", uniqueConstraints = {@UniqueConstraint(columnNames = { "id", "username" }) })
public class Merchant implements Serializable {
...

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "WIZ_TEMPLATE_ID", nullable = true)
    private Template wizardTemplate;
...
}

Code:
@Entity
@Table(name = "TEMPLATE", uniqueConstraints = { @UniqueConstraint(columnNames = { "id" }) })
public class Template implements Serializable {
...

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "OWNER_ID", nullable = false)
    private Merchant owner;

....
}


Once again this all works in my SVN, and on the acceptance server with Mysql 5.1 and CentOS. It only fails locally with Mysql 5.5.10 and MAC OS.

Also, as a matter of fact I saw the exact same error with Hibernate and MYSQL some more times on the MySQL mailing lists:

http://forums.mysql.com/search.php?99,s ... h_threads=

however no one seems to know anything on the subject. Please if you know what's causing the problem, or if you need some more info let me know.

Sincerely, Petar.


Top
 Profile  
 
 Post subject: Re: Problem with Mysql 5.5.10 on MAC OSX
PostPosted: Sun Apr 03, 2011 7:25 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
MySQL on OSX might have some trouble with table name case. Could you check from a SQL command line that the references are fine?
I don't use OSX myself so I don't know the details, but there are configuration options to have mysql behave differently relating to case. As it worked before a reinstall, this must be a configuration mistake, and I doubt it could have anything to do with Hibernate.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Problem with Mysql 5.5.10 on MAC OSX
PostPosted: Sun Apr 03, 2011 8:24 am 
Newbie

Joined: Sat Apr 02, 2011 1:06 pm
Posts: 11
Hi there, and thanks for your response.

I also thought that the problem is in MYSQL, but from the link to the MYSQL forums that I pasted, you can see that all the people that are having the same problem re having it with Hibernate + MYSQL 5.5.10. Honestly I believe that the problem comes from the way Hibernate generates the tables in MYSQL.

I checked the tables and this is the result:

Code:
mysql> describe MERCHANT;
+-----------------------+--------------+------+-----+---------+----------------+
| Field                 | Type         | Null | Key | Default | Extra          |
+-----------------------+--------------+------+-----+---------+----------------+
| ID                    | bigint(20)   | NO   | PRI | NULL    | auto_increment |
......
| WIZ_TEMPLATE_ID       | bigint(20)   | YES  | MUL | NULL    |                |
+-----------------------+--------------+------+-----+---------+----------------+

mysql> describe template;
+----------+-------------+------+-----+---------+----------------+
| Field    | Type        | Null | Key | Default | Extra          |
+----------+-------------+------+-----+---------+----------------+
| ID       | bigint(20)  | NO   | PRI | NULL    | auto_increment |
...
| OWNER_ID | bigint(20)  | NO   | MUL | NULL    |                |
+----------+-------------+------+-----+---------+----------------+


Honestly, they look fine to me. I can work with lowercase and uppercase in mysql console with no problem. And weird enough if I change my current mapping to:

Code:
    @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE }, targetEntity = Merchant.class)
    @JoinTable(name = "MERCHANT_2_TEMPLATE",
               joinColumns = @JoinColumn(name = "TEMPLATE_ID", nullable = true),
               inverseJoinColumns = @JoinColumn(name = "MERCHANT_ID"))
    private Merchant owner;


it all seems to work. So with
Code:
@JoinColumn
seems to be broken, but with
Code:
@JoinTable
is working. The problem here is that Im creating another table just to store the relation, and also I'm having lots of db-mapping files, which I have to change manually :( .

Can you please tell me what else can I grab and paste here so that we can resolve it faster?


Top
 Profile  
 
 Post subject: Re: Problem with Mysql 5.5.10 on MAC OSX
PostPosted: Sun Apr 03, 2011 3:43 pm 
Newbie

Joined: Sat Apr 02, 2011 1:06 pm
Posts: 11
OK nevermind my fault :),

I went to the linux server where I still have MYSQL 5.1 and the project is working there, and checked and saw that the default engine is MyISAM. With the new distribution of MySQL however the default engine is set to InnoDB, and I had my dialect changed because I wanted to try something. Now I specified the default engine to be MyISAM, rollbacked the dialect and it all works now as it used to :) ..

Thanks, Petar.


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.