将架构名称添加到Spring数据中的实体? [英] Adding Schema name to entity in Spring data?
本文介绍了将架构名称添加到Spring数据中的实体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Oracle DB
和Spring Data
时出现错误.错误是:
I am getting an error when using an Oracle DB
and Spring Data
. The error is:
ORA-00942: table or view does not exist
此错误的原因是与我连接的用户没有有权访问我要连接的架构中的表.
The cause of this error is that the user I am connecting with does not have access to the tables in the schemas I wish to connect to.
我了解到有2种解决方案,分别是在数据库中创建synonyms
或指定每个实体/表所属的schema
.
I read that 2 fixes to this are to create synonyms
in my database or to specify the schema
that each entity/table belongs to.
我将首先尝试使用Schema方法.我该怎么办?
I am going to try the Schema approach first. How do I do so?
下面的我的示例实体,在兽医模式中的狗:
My example entity below, a Dog in the Vet Schema:
@Entity
@Table(name = "Dog")
public class Dog
{
@Id
private String id;
@Column(name = "NAME")
private String name;
@Column(name = "Owner")
private String owner;
//getters and setters etc...
推荐答案
@Table
注释提供了schema
属性:
@Table(name = "Dog", schema = "Vet")
这篇关于将架构名称添加到Spring数据中的实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文