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.
我读到有两个解决方法是在我的数据库中创建 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?
下面是我的示例实体,Vet架构中的狗:
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 数据中的实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将模式名称添加到 Spring 数据中的实体?
				
        
 
            
        基础教程推荐
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
 - 多个组件的复杂布局 2022-01-01
 - Java Swing计时器未清除 2022-01-01
 - 不推荐使用 Api 注释的描述 2022-01-01
 - 大摇大摆的枚举 2022-01-01
 - 从 python 访问 JVM 2022-01-01
 - Java 实例变量在两个语句中声明和初始化 2022-01-01
 - 验证是否调用了所有 getter 方法 2022-01-01
 - 在 Java 中创建日期的正确方法是什么? 2022-01-01
 - 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
 
    	
    	
    	
    	
    	
    	
    	
    	
						
						
						
						
						
				
				
				
				