[英]Using Spring boot JPA getting data from existing oracle db
Hi I have an existing oracle db, which contains tables.嗨,我有一个现有的 oracle 数据库,其中包含表。 Need to get data from multiple tables using jpa from spring boot api below are my questions需要从下面的spring boot api使用jpa从多个表中获取数据是我的问题
I presume you are trying to expose the query results as a spring boot rest API.我假设您正在尝试将查询结果公开为 Spring Boot Rest API。 You need to have some object definition to hold the query results into memory.您需要有一些对象定义来将查询结果保存到内存中。 It is always a good idea to have a model to represent your query results for better manageability and maintainability of code.使用模型来表示查询结果以提高代码的可管理性和可维护性始终是一个好主意。 Certainly, you can achieve it without creating any models by storing all the results into a Map.当然,您可以通过将所有结果存储到 Map 来实现它,而无需创建任何模型。
If you don't use models then you will be missing key features of ORM tools.如果您不使用模型,那么您将缺少 ORM 工具的关键功能。
Just to answer your questions -只为回答你的问题——
Do I need model classes of those multiple tables or I don't need model classes to get the required column data?我需要那些多个表的模型类还是不需要模型类来获取所需的列数据?
Answer: Not required but recommended to use model classes.答:不是必需的,但建议使用模型类。
Can I write a custom query joining multiple tables and get the list of values from my db using jpa?我可以编写一个加入多个表的自定义查询并使用 jpa 从我的数据库中获取值列表吗?
Answer: You can write the native SQL query by joining multiple tables.答:可以通过加入多个表来编写本机 SQL 查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.