将模式名称添加到 Spring 数据中的实体?

编程入门 行业动态 更新时间:2024-10-24 10:19:43
本文介绍了将模式名称添加到 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 数据中的实体?

本文发布于:2023-10-29 03:31:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538599.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实体   名称   模式   数据   Spring

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!