我正在使用Hibernate SessionFactory
和auto-table-creation选项,但是当我想启动Tomcat时,数据库没有启动,并且控制台中出现以下错误消息:
2015-10-14 23:07:26 DEBUG SQL:104 - 创建表TEACHER(ID bigint not null,firstName varchar(255),lastName varchar(255), 主键(ID),唯一(ID))
2015-10-14 23:07:26错误SchemaExport:426 - HHH000389:不成功:创建表教师(ID bigint not null,firstName varchar(255),lastName varchar(255),主键(ID),唯一(ID))2015-10-14 23:07:26错误SchemaExport:427 - ORA-00902:数据类型无效
这是我的配置:
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:component-scan base-package="com.sante.gestion" />
<context:annotation-config />
<context:spring-configured />
<!-- DataSource -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@localhost:1521:XE" />
<property name="username" value="gestion" />
<property name="password" value="gestion" />
</bean>
<!-- Session Factory Declaration -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<value>com.sante.gestion.model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>
<!-- Transaction Manager is defined -->
<bean id="txManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- Enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="txManager" />
</beans>
这是我的对象模型:
@Entity(name = "COURSE")
public class Course implements Serializable {
private static final long serialVersionUID = 8736444902161357518L;
@Id
@Basic(optional = false)
@Column(name = "ID", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "COURSE_SEQ")
@SequenceGenerator(name = "COURSE_SEQ",
sequenceName = "COURSE_SEQ",
initialValue = 1,
allocationSize = 999999999)
@Type(type = "java.lang.Long")
private Long id;
@Column
private String name;