找到[nvarchar2(Types#OTHER)],但期望[varchar2(255 char)(Types#VARCHAR)]

时间:2018-03-24 13:23:38

标签: java oracle hibernate oracle12c

我正在使用Oracle数据库12c,Hibernate 5。 DDL

package com.donhuvy.model;

import org.hibernate.annotations.Type;    
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * Role entity.
 *
 */
@Entity
@Table(name = "AUTHORITIES")
public class Authorities {    
    @Id
    @Column(name = "AUTHORITY")
    private String authority;    
    @ManyToOne
    @JoinColumn(name = "USERNAME")
    private User user;

    public String getAuthority() {
        return authority;
    }    
    public void setAuthority(String authority) {
        this.authority = authority;
    }    
    public User getUser() {
        return user;
    }    
    public void setUser(User user) {
        this.user = user;
    }    
}

我有实体

Caused by: org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'getSessionFactory' defined in com.donhuvy.config.AppConfig:
Invocation of init method failed; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: 
Schema-validation: 
wrong column type encountered in column [AUTHORITY] in table [AUTHORITIES]; found [nvarchar2 (Types#OTHER)], but expecting [varchar2(255 char) (Types#VARCHAR)]

错误:

{{1}}

如何解决?

1 个答案:

答案 0 :(得分:0)

我知道这个问题有点老了,但我遇到了同样的问题并解决了。 像这样扩展注释:

(...)
@Column(name = "AUTHORITY", columnDefinition = "varchar2")
private String authority; 
(...)