Java Hibernate/Oracle序列不工作

Java Hibernate/Oracle序列不工作,java,oracle,hibernate,Java,Oracle,Hibernate,我正在使用hibernate和oracle DB尝试使用序列将自动ID插入表中。该序列显然存在于数据库中,但hibernate似乎无法找到它 以下是所有相关信息: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.htm

我正在使用hibernate和oracle DB尝试使用序列将自动ID插入表中。该序列显然存在于数据库中,但hibernate似乎无法找到它

以下是所有相关信息:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. org.hibernate.exception.SQLGrammarException: could not get next sequence value at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) .... Caused by: java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist .... ... 12 more 顺序:

create sequence property_seq start with 1 increment by 1 nomaxvalue; 
映射xml:

<class name="com.rental.model.property.Property" table="PROPERTY">
    <meta attribute="class-description"> This class contains the property detail. </meta>
    <id name="id" type="integer" column="id">
        <generator class="sequence"/>
    </id>
    <property name="address" column="ADDRESS" type="string" />
    <property name="town" column="TOWN" type="string" />
    <property name="postCode" column="POSTCODE" type="string" />
    <property name="purchasePrice" column="PURCHASEPRICE" type="integer" />
</class>

为什么要同时使用xml和
@Annotation
?也许xml定义战胜了注释,Hibernate正在检索默认序列,而不是您的
属性

尝试删除xml映射并检查其是否有效。

序列对象是否与登录到hibernate会话的用户在相同的架构中创建?如果没有,您是否创建了同义词并授予对序列的访问权限?也许可以尝试在属性“”上添加公共同义词Hibernate使用的用户与创建序列的用户相同。我完全删除了xml并添加了所有其他注释,然后将我的工厂更改为:factory=newannotationconfiguration().configure().addannotationdclass(Property.class)。buildSessionFactory();
<class name="com.rental.model.property.Property" table="PROPERTY">
    <meta attribute="class-description"> This class contains the property detail. </meta>
    <id name="id" type="integer" column="id">
        <generator class="sequence"/>
    </id>
    <property name="address" column="ADDRESS" type="string" />
    <property name="town" column="TOWN" type="string" />
    <property name="postCode" column="POSTCODE" type="string" />
    <property name="purchasePrice" column="PURCHASEPRICE" type="integer" />
</class>
@Id
@SequenceGenerator(name="property_seq", sequenceName="property_seq", allocationSize=1, initialValue=1) 
@GeneratedValue (strategy = GenerationType.SEQUENCE, generator="property_seq")
public int getId() {
    return id;
}