Hi all,
I'm trying to execute a little demo of Spring + Hibernate using MySQL as database and I'm not able to run it (same code using H2 works perfect).
app-context.xml
hibernate.xmlCode:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xsi:schemaLocation=" http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <import resource="hibernate.xml" /> <tx:annotation-driven transaction-manager="transactionManager" /> <context:component-scan base-package="edu.elpasmo.spring" /> </beans>
Element.javaCode:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> <value>META-INF/spring/application.properties</value> </property> </bean> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="annotatedClasses"> <list> <value>edu.elpasmo.spring.hibernate.model.Element</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">create</prop> </props> </property> </bean> </beans>
The table is created right. The problem is in the first insert: Unknown table 'sequences' in information_schema.Code:@Entity public class Element { private Integer elementId; public Element() { } @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "ID") public Integer getElementId() { return elementId; } public void setElementId(Integer elementId) { this.elementId = elementId; } }
My system:
Ubuntu 11.04 64 bits
STS 2.8.0
mysql-connector-java 5.1.10 (I'd also tried with version 5.10.18).
MySQL Version 5.1.54
openjdk-6-jdk Version 6b22-1.10.2
I've tried with all the GenerationType for Element.id (SEQUENCE, IDENTITY, etc...).
I've tried switching to a H2 database and works perfectly.
I've tried also upgrading Hibernate from 3.6.0 to 3.6.7 with no joy.
I'll post the console output in the first reply due the post length limitation.


Reply With Quote
