简体   繁体   中英

Using Spring boot JPA getting data from existing oracle db

Hi I have an existing oracle db, which contains tables. Need to get data from multiple tables using jpa from spring boot api below are my questions

  1. Do I need model classes of those multiple tables or I don't need model classes to get the required column data? 2.Can I write a custom query joining multiple tables and get the list of values from my db using jpa?

I presume you are trying to expose the query results as a 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.

If you don't use models then you will be missing key features of ORM tools.

Just to answer your questions -

  1. 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.

  2. Can I write a custom query joining multiple tables and get the list of values from my db using jpa?

    Answer: You can write the native SQL query by joining multiple tables.

You can find more examples here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM