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?
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?
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
Pre-Mapped
When you use xml configuration, it may look POJO but it is not.
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.