-->
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.  [ 3 posts ] 
Author Message
 Post subject: mysql issues with hibernate
PostPosted: Tue May 04, 2010 4:47 am 
Newbie

Joined: Tue May 04, 2010 4:38 am
Posts: 4
I have used ide's to generate my entities from mysql and I cant seem to get my test data into the database. I get a wrapped mysql exeption as follows in tomcat 6:
Code:
cmd /c C:\DEV\apache-tomcat-6.0.26\apache-tomcat-6.0.26\bin\catalina.bat run
Using CATALINA_BASE:   "C:\Users\owner\.IntelliJIdea90\system\tomcat\Unnamed_the-jar-bar9bf2a73c6"
Using CATALINA_HOME:   "C:\DEV\apache-tomcat-6.0.26\apache-tomcat-6.0.26"
Using CATALINA_TMPDIR: "C:\DEV\apache-tomcat-6.0.26\apache-tomcat-6.0.26\temp"
Using JRE_HOME:        "C:\Program Files (x86)\Java\jdk1.6.0_17"
Using CLASSPATH:       "C:\DEV\apache-tomcat-6.0.26\apache-tomcat-6.0.26\bin\bootstrap.jar"
04.mai.2010 10:23:57 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files (x86)\Java\jdk1.6.0_17\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\DEV\apache-maven-2.2.1-bin\apache-maven-2.2.1\bin;C:\Program Files (x86)\Java\jdk1.6.0_17\bin;c:\program files (x86)\jetbrains\intellij idea 9.0.2\jre\jre\bin
04.mai.2010 10:23:57 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
04.mai.2010 10:23:57 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 374 ms
04.mai.2010 10:23:57 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
04.mai.2010 10:23:57 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.26
04.mai.2010 10:23:57 org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor ROOT.xml
04.mai.2010 10:23:58 org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\DEV\apache-tomcat-6.0.26\apache-tomcat-6.0.26\webapps\ROOT\WEB-INF\lib\javaee.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
04.mai.2010 10:23:58 com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra (1.2_14-b01-FCS) for context ''
04.mai.2010 10:23:58 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
04.mai.2010 10:23:58 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
04.mai.2010 10:23:59 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory host-manager
04.mai.2010 10:23:59 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory manager
04.mai.2010 10:23:59 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
04.mai.2010 10:23:59 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
04.mai.2010 10:23:59 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/22  config=null
04.mai.2010 10:23:59 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1819 ms
Connected to server
04.mai.2010 10:24:01 com.sun.faces.lifecycle.Phase doPhase
SEVERE: JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /pages/welcome.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@1a76eff]
04.mai.2010 10:24:01 com.sun.faces.lifecycle.Phase doPhase
SEVERE: JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /pages/welcome.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@1a76eff]
04.mai.2010 10:24:10 org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.2.1.GA
04.mai.2010 10:24:10 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.6
04.mai.2010 10:24:10 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
04.mai.2010 10:24:10 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
04.mai.2010 10:24:10 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
04.mai.2010 10:24:10 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
04.mai.2010 10:24:10 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
04.mai.2010 10:24:10 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : org/bar/jar/model/SiteVisitorEntity.hbm.xml
04.mai.2010 10:24:10 org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
04.mai.2010 10:24:10 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: org.bar.jar.model.SiteVisitorEntity -> site_visitor
04.mai.2010 10:24:10 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
04.mai.2010 10:24:10 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
04.mai.2010 10:24:10 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
04.mai.2010 10:24:10 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/jar-bar
04.mai.2010 10:24:10 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=Yucca, password=****}
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.1.45-community
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.12 ( Revision: ${bzr.revision-id} )
04.mai.2010 10:24:11 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
04.mai.2010 10:24:11 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
04.mai.2010 10:24:11 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
04.mai.2010 10:24:11 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
04.mai.2010 10:24:11 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
04.mai.2010 10:24:11 org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
04.mai.2010 10:24:11 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
got began
Hibernate: insert into jar-bar.site_visitor (first_name, last_name, email_adr, pass, ip-adr, User_ID) values (?, ?, ?, ?, ?, ?)
04.mai.2010 10:24:11 org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 1064, SQLState: 42000
04.mai.2010 10:24:11 org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-bar.site_visitor (first_name, last_name, email_adr, pass, ip-adr, User_ID) valu' at line 1
04.mai.2010 10:24:11 org.hibernate.event.def.AbstractFlushingEventListener performExecutions
SEVERE: Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
   at org.bar.jar.model.UserManagedBean.create(UserManagedBean.java:65)
   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.apache.el.parser.AstValue.invoke(AstValue.java:191)
   at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
   at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68)
   at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
   at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
   at javax.faces.component.UICommand.broadcast(UICommand.java:387)
   at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
   at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
   at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
   at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   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:852)
   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:619)
Caused by: java.sql.BatchUpdateException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-bar.site_visitor (first_name, last_name, email_adr, pass, ip-adr, User_ID) valu' at line 1
   at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2018)
   at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1454)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
   ... 36 more
04.mai.2010 10:24:11 com.sun.faces.application.ActionListenerImpl processAction
SEVERE: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
javax.faces.el.EvaluationException: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
   at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
   at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
   at javax.faces.component.UICommand.broadcast(UICommand.java:387)
   at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
   at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
   at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
   at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   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:852)
   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:619)
Caused by: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
   at org.bar.jar.model.UserManagedBean.create(UserManagedBean.java:65)
   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.apache.el.parser.AstValue.invoke(AstValue.java:191)
   at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
   at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68)
   at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
   ... 20 more
Caused by: java.sql.BatchUpdateException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-bar.site_visitor (first_name, last_name, email_adr, pass, ip-adr, User_ID) valu' at line 1
   at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2018)
   at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1454)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
   ... 36 more
04.mai.2010 10:24:11 com.sun.faces.lifecycle.InvokeApplicationPhase execute
WARNING: #{user.create}: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
javax.faces.FacesException: #{user.create}: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
   at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
   at javax.faces.component.UICommand.broadcast(UICommand.java:387)
   at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
   at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
   at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
   at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   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:852)
   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:619)
Caused by: javax.faces.el.EvaluationException: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
   at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
   at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
   ... 19 more
Caused by: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
   at org.bar.jar.model.UserManagedBean.create(UserManagedBean.java:65)
   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.apache.el.parser.AstValue.invoke(AstValue.java:191)
   at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
   at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68)
   at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
   ... 20 more
Caused by: java.sql.BatchUpdateException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-bar.site_visitor (first_name, last_name, email_adr, pass, ip-adr, User_ID) valu' at line 1
   at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2018)
   at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1454)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
   ... 36 more
04.mai.2010 10:24:11 com.sun.faces.lifecycle.Phase doPhase
SEVERE: JSF1054: (Phase ID: INVOKE_APPLICATION 5, View ID: /pages/user/CreateUser.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@1a76eff]


my DB schema is as follows:
Code:
CREATE TABLE  `jar-bar`.`site_visitor` (
  `first_name` varchar(30) NOT NULL,
  `last_name` varchar(30) NOT NULL,
  `email_adr` varchar(30) NOT NULL,
  `pass` varchar(20) NOT NULL,
  `ip-adr` varchar(45) NOT NULL,
  `User_ID` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`User_ID`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


and my generated entity is as follows:
Code:
package org.bar.jar.model;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.Id;

/**
* Created by IntelliJ IDEA.
* User: owner
* Date: 04.mai.2010
* Time: 10:22:59
* To change this template use File | Settings | File Templates.
*/
@javax.persistence.Table(name = "site_visitor", catalog = "jar-bar")
@Entity
public class SiteVisitorEntity {
    private String firstName;

    @javax.persistence.Column(name = "first_name", nullable = false, insertable = true, updatable = true, length = 30, precision = 0)
    @Basic
    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    private String lastName;

    @javax.persistence.Column(name = "last_name", nullable = false, insertable = true, updatable = true, length = 30, precision = 0)
    @Basic
    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    private String emailAdr;

    @javax.persistence.Column(name = "email_adr", nullable = false, insertable = true, updatable = true, length = 30, precision = 0)
    @Basic
    public String getEmailAdr() {
        return emailAdr;
    }

    public void setEmailAdr(String emailAdr) {
        this.emailAdr = emailAdr;
    }

    private String pass;

    @javax.persistence.Column(name = "pass", nullable = false, insertable = true, updatable = true, length = 20, precision = 0)
    @Basic
    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    private String ipAdr;

    @javax.persistence.Column(name = "ip-adr", nullable = false, insertable = true, updatable = true, length = 45, precision = 0)
    @Basic
    public String getIpAdr() {
        return ipAdr;
    }

    public void setIpAdr(String ipAdr) {
        this.ipAdr = ipAdr;
    }

    private int userId;

    @javax.persistence.Column(name = "User_ID", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Id
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SiteVisitorEntity that = (SiteVisitorEntity) o;

        if (userId != that.userId) return false;
        if (emailAdr != null ? !emailAdr.equals(that.emailAdr) : that.emailAdr != null) return false;
        if (firstName != null ? !firstName.equals(that.firstName) : that.firstName != null) return false;
        if (ipAdr != null ? !ipAdr.equals(that.ipAdr) : that.ipAdr != null) return false;
        if (lastName != null ? !lastName.equals(that.lastName) : that.lastName != null) return false;
        if (pass != null ? !pass.equals(that.pass) : that.pass != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = firstName != null ? firstName.hashCode() : 0;
        result = 31 * result + (lastName != null ? lastName.hashCode() : 0);
        result = 31 * result + (emailAdr != null ? emailAdr.hashCode() : 0);
        result = 31 * result + (pass != null ? pass.hashCode() : 0);
        result = 31 * result + (ipAdr != null ? ipAdr.hashCode() : 0);
        result = 31 * result + userId;
        return result;
    }
}



Anyone have any idea why I am getting mysql syntax error when trying to session.save(entity); with hibernate? Surely hibernate is supposed to have correct syntax

oh my xml is configue=red as follows:
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
  "-//Hibernate/Hibernate Configuration DTD//EN"
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="connection.url">jdbc:mysql://localhost:3306/jar-bar</property>
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="connection.username">Yucca</property>
    <property name="connection.password">pass</property>
      <property name="current_session_context_class">thread</property>
      <property name="hibernate.show_sql">true</property>
      <mapping class="org.bar.jar.model.SiteVisitorEntity"/>
      <mapping resource="org/bar/jar/model/SiteVisitorEntity.hbm.xml"/>

      <!-- DB schema will be updated if needed -->
    <!-- <property name="hbm2ddl.auto">update</property> -->
  </session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject: Re: mysql issues with hibernate
PostPosted: Tue May 04, 2010 5:13 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
The problem is that you have unquoted column/table/catalog names that have a '-' in their names. Such names must be quoted in the annotations with backticks (`). For example:

Code:
@javax.persistence.Table(name = "site_visitor", catalog = "`jar-bar`")


I don't know if your IDE can do this automatically or if you have to manually fix this. Another option is of course to rename things in the database.


Top
 Profile  
 
 Post subject: Re: mysql issues with hibernate
PostPosted: Tue May 04, 2010 5:21 am 
Newbie

Joined: Tue May 04, 2010 4:38 am
Posts: 4
Thank you soooooooo much wise one :)

I will fix and fix missing dialect property in xml before anyone else finds it :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.