1

Can I use query results (Spring JDBC) from database without storing in Java POJO?

I have many queries to use in my project? I don't want to map those big query columns names to POJO varaiables Please suggest some way?

Vijaya Ram
  • 37
  • 9
  • 1
    Yo are not precise enough. How do you want store data ? And what are your data types you want to go up from your queries ? – davidxxx Jul 15 '16 at 13:49

2 Answers2

1

How about making queries to only those columns you are interested in ? The essence of having mapping is to do less. Or else you would need to use plain Java jdbc. [edit]

There is no connection between you objects and the database table(s). Either you explicitly mention the tables and columns if you are using plain jdbc. OR . you do a pre-mapping so that you don't need to write table and column names all the time, which is error prone.

To summarise

  • No mapping

    • Use plain jdbc [POJO]
  • Pre-Mapped

    • xml configuration
    • Annotation

When you use xml configuration, it may look POJO but it is not.

elha2en
  • 192
  • 8
1

RowSet

You can get a RowSet from your ResultSet obtained via JDBC.

The CachedRowSet extension of that RowSet interface is for storing the rows of data in memory within your JVM. You may continue to access the CachedRowSet even after closing your connection to the database.

Oracle provides an open-source free-of-cost (GPL 2 license) implementation of CachedRowSet. This may be bundled with your Java installation. If not, you can obtain the source-code separately. See this Question, Implementations of RowSet, CachedRowSet etc.

For more information, see the Oracle Tutorial.

Surprisingly, the RowSet interface and its implementations have garnered little attention. They seem like a good idea to me. I have personally used the Oracle-provided implementation of CachedRowSet successfully in a small project.

Community
  • 1
  • 1
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154