报的错误是建表语句错误。可建表语句是hibernate自己创建的。。
我之后又单纯用hibernate生成表,又可以生成。。再结合spring。。还报错
这是他们各自的建表语句。
--hibernate:
    create table PersonModel (
        id integer not null auto_increment,
        name varchar(255),
        primary key (id)
    )
--spring+hibernate:
    create table PersonModel (
        id integer generated by default as identity (start with 1),
        name varchar(255),
        primary key (id)
    )
下边的建表语句直接放在数据库中也是报错:
check the manual that corresponds to your MySQL server version for the right syntax to use near 'generated by default as identity (start with 1), name varchar(255), primary key ' at line 1咋办啊 现在我还只是凑合着用hibernate生成表、然后再操作呢
代码:
spring bean
<!-- 定义使用C3P0连接池的数据源 -->
<bean id="myDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"  destroy-method="close">
<property name="driverClass"><value>com.mysql.jdbc.Driver</value></property>
<property name="jdbcUrl"><value>jdbc:mysql://localhost:3306/dbTest?useUnicode=true&amp;characterEncoding=UTF-8</value></property>
<property name="user"><value>root</value></property>
<property name="password"><value>123</value></property>
<property name="maxPoolSize"><value>20</value></property>
<property name="minPoolSize"><value>2</value></property>
<property name="initialPoolSize"><value>2</value></property>
<property name="maxIdleTime"><value>20</value></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="myDataSource"></property>
    <property name="annotatedClasses">
      <list>
        <value>another.test.PersonModel</value>
      </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.hbm2ddl.auto">create</prop>
    <prop key="hibernate.format_sql">true</prop>
    </props>
    </property>
</bean>PersonModel
@Entity
public class PersonModel {
private int id;
private String name;

public PersonModel(){
System.out.println("Model");
}

@Id
@GeneratedValue
public int getId() {
return id;
}
       //.......略...........
输出log INFO ClassPathXmlApplicationContext:411 - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@55e55f: display name [org.springframework.context.support.ClassPathXmlApplicationContext@55e55f]; startup date [Sat Jan 22 15:09:28 CST 2011]; root of context hierarchy
 INFO XmlBeanDefinitionReader:323 - Loading XML bean definitions from class path resource [bean_another.xml]
 INFO ClassPathXmlApplicationContext:426 - Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@55e55f]: org.springframework.beans.factory.support.DefaultListableBeanFactory@ebcdbb
 INFO DefaultListableBeanFactory:414 - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@ebcdbb: defining beans [org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.aop.config.internalAutoProxyCreator,personDaoPoint,myDataSource,sessionFactory,person,personDao]; root of factory hierarchy
 INFO MLog:80 - MLog clients using log4j logging.
 INFO C3P0Registry:204 - Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
 INFO AnnotationSessionFactoryBean:730 - Building new Hibernate SessionFactory
 INFO AbstractPoolBackedDataSource:462 - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1bqowtl8d1bvm7uu1tc49qg|1381960, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1bqowtl8d1bvm7uu1tc49qg|1381960, idleConnectionTestPeriod -> 0, initialPoolSize -> 2, jdbcUrl -> jdbc:mysql://localhost:3306/dbTest?useUnicode=true&characterEncoding=UTF-8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 20, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 20, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 2, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]
Model
 INFO SchemaExport:226 - Running hbm2ddl schema export
DEBUG SchemaExport:242 - import file not found: /import.sql
 INFO SchemaExport:251 - exporting generated schema to database
DEBUG SchemaExport:377 - 
    drop table PersonModel if exists
DEBUG SchemaExport:362 - Unsuccessful: drop table PersonModel if exists
DEBUG SchemaExport:363 - 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 'if exists' at line 1
DEBUG SchemaExport:377 - 
    create table PersonModel (
        id integer generated by default as identity (start with 1),
        name varchar(255),
        primary key (id)
    )
ERROR SchemaExport:348 - Unsuccessful: create table PersonModel (id integer generated by default as identity (start with 1), name varchar(255), primary key (id))
ERROR SchemaExport:349 - 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 'generated by default as identity (start with 1), name varchar(255), primary key ' at line 1
 INFO SchemaExport:268 - schema export complete
Model
Model
Impl
 INFO PersonDaoPoint:36 - execution(getPerson) start: 1
 INFO PersonDaoPoint:40 - execution(getPerson) over: 1
PersonModel [id=1, name=testName]
Model
 INFO PersonDaoPoint:45 - ---------权限控制----------
 INFO PersonDaoPoint:46 - another.test.PersonDaoImpl@11b50a1
Model
 INFO PersonDaoPoint:36 - execution(getsave) start: 1
DEBUG SQL:111 - 
    insert 
    into
        PersonModel
        (id, name) 
    values
        (null, ?)
Hibernate: 
    insert 
    into
        PersonModel
        (id, name) 
    values
        (null, ?)
saved
 INFO PersonDaoPoint:40 - execution(getsave) over: 1求解
另外,整合spring和hibernate的时候有两种方式
1,是把hibernate的配置写到spring,
2. 是hibernate自己有个hibernate.cfg.xml,由spring来读取这个哪个比较好呢????