i working on javaee application, , there 1000+ tables in database, have query records parametes client.
generally create 1 entity each table, , create dao,service query.
however meet 2 problems:
1 number of tables
as said, 1000+ table 40+ columns each, nightmare create entity 1 one.
2 scheme update
even can create entity program, schema of data may change sometime out of control.
and in application, read operations related these kinds of data,no update,delete,create required.
so wonder if following solution possible:
1 use map instead of pojos
do not create pojos @ all, use native map wrap columns , values.
2 row mapping
when querying using hibernate or spring jdbctemplate or else, use mapper map each row entry in map.
if yes, use resultmetadata detect column name,type,value:
resultmetadata rmd=rs.getmetadata(); for(int i=0;i<rmd.getcolumncount();i++){ type t=rmd.gettype(i) if(t==....){ ... }else if(t=...){ ... } } looks part of jpa's job, library can used here?
if not, other alternatives?
Comments
Post a Comment