views:

37

answers:

3

I am trying to create an application in java which pulls out records from the database and maps it to objects. It does that without knowing what the schema of the database looks like. All i want to do is fetch all rows from all tables and store them somewhere. There could be a thousand tables with thousands of records each. The application doesn't know the name of any table or attribute. It should map "on the fly". I looked at hibernate but it doesnt give me what i want for this app. I don't want to create hard-coded xml files and classes for mapping. Any ideas how i can accomplish this ? Thanks

A: 

MyBatis provides a pretty simple way to map data results to objects and back, maybe check that out?

http://code.google.com/p/mybatis/

Anthony Bishopric
A: 

Not to be flip, but for this task, you might want to check out Ruby on Rails and its ActiveRecord approach

Alex Blakemore
not an option..it has to be done in java
Nanz
A: 

Oracle has a bunch of data dictionary views for metadata.

ALL_TABLES, ALL_TAB_COLUMNS would be first places to start. Then you'd build ad-hoc queries based on what you get out of there. Not sure whether you have to deal with all data types (dates, blobs, spatial, user-defined....).

Not sure what you mean by "store them somewhere". If you start thinking CSV or XML files, you'll need to escape various characters from VARCHAR2 columns.

If you are looking for some generic extract/unload routines, you should look at what is already available in the database or open-source/commercially.

Gary