问题描述
我试图在一个非常简单的映射中使用序列生成器。
我试图在Hibernate的ID序列生成中研究生成器类。
<?xml version =1.0encoding =UTF-8?>
<!DOCTYPE hibernate-mapping PUBLIC
- // Hibernate / Hibernate映射DTD 3.0 // EN
http://hibernate.sourceforge.net/hibernate-mapping-3.0 .dtd>
< hibernate-mapping package =com.test>
< class name =Customertable =Customer>
< id name =idcolumn =IDtype =long>
< generator class =sequence>
< param name =sequence> CUSTOMER_SEQUENCE< / param>
< / generator>
< / id>
< property name =nametype =stringcolumn =CUSTOMER_NAME/>
< / class>
< / hibernate-mapping>
我使用的是Apache Derby,客户表中的ID列只是一个简单的长数据类型。 p>
但是当我尝试执行一个简单的保存时,我遇到了下面的错误。
引起:java.sql .SQLSyntaxErrorException:SEQUENCE'CUSTOMER_SEQUENCE'不存在。
这是否意味着Apache Derby不支持序列生成?谢谢
似乎Derby不支持序列生成。从官方中引用:
I am trying to investigate the generator class in the ID sequence generation of Hibernate.
I tried to use the sequence generator on a very simple mapping
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.test">
<class name="Customer" table="Customer">
<id name="id" column="ID" type="long">
<generator class="sequence">
<param name="sequence">CUSTOMER_SEQUENCE</param>
</generator>
</id>
<property name="name" type="string" column="CUSTOMER_NAME" />
</class>
</hibernate-mapping>
I am using apache derby, the ID column in the customer table is justa simple long datatype.
But when I try to execute a simple save, I am encountering below error.
Caused by: java.sql.SQLSyntaxErrorException: SEQUENCE 'CUSTOMER_SEQUENCE' does not exist.Does this mean that Apache Derby does not support Sequence Generation? Thanks
It seems that Derby doesn't support sequence generation. Quote from official Derby FAQ:
这篇关于休眠Apache Derby自定义序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!