oracle 将架构名称添加到 Spring 数据中的实体?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36355358/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding Schema name to entity in Spring data?
提问by java123999
I am getting an error when using an Oracle DB
and Spring Data
. The error is:
使用Oracle DB
and时出现错误Spring Data
。错误是:
ORA-00942: table or view does not exist
The cause of this error is that the user I am connecting with does nothave access to the tables in the schemas I wish to connect to.
这个错误的原因是,我与连接用户没有访问中我希望连接到的模式的表。
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.
我读到 2 个修复是synonyms
在我的数据库中创建或指定schema
每个实体/表所属的。
I am going to try the Schema approach first. How do I do so?
我将首先尝试 Schema 方法。我该怎么做?
My example entitybelow, a Dogin the VetSchema:
下面是我的示例实体,VetSchema中的一只狗:
@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...
回答by Patrick
The @Table
annotation provides the schema
attribute:
该@Table
注释提供了schema
属性:
@Table(name = "Dog", schema = "Vet")
回答by J. Chomel
You must prefix your tables with the schema name and with a .
inbetween them:
您必须使用架构名称作为表的前缀,并在.
它们之间添加一个中间:
@Table(name = "VET.Dog")