views:

261

answers:

2
+1  A: 

I would suggest the former. To me its as simple as getting the list of entities, and add those in a single list, based on some filter.

Adeel Ansari
Thanks Vinegar for the reply. One more query. I have started reading about JDO/Hibernate and found that one needs to create a object class for the table and a mapping xml defining the data types and other details. In my case I have a result set instead of a database table. So I will have to create the object java class and xml file dynamically and enhance it using enhancer. I dont know if that is possible?
Saurabh
Yes, we call that 'Entity' class. Mapping in XML ain't necessary, you can do it using Java Annotations, introduced in Java 5. You need to forget about `ResultSet` in this case, you will be using your entity classes instead. Custom queries and results are still possible, using Hibernate at least. For that you should refer to the Hibernate documentation.
Adeel Ansari
What about dynamically creating the entity class from the result set obtained?
Saurabh
@Saurabh: We don't obtain ResultSet, we obtain entity object. Dynamically, creating entity class is possible, but wouldn't pay. It will make the things obscure for no reason.
Adeel Ansari
Vineger, may be I am not being clear. Let me explain my scenario again. I let my user to specify a complex query containing multiple tables, filter clauses, orders, join condition and a connection. All this information in store in my class. Now what I want is to let user join two or more instances of my classes containing complex query and the connection. Till here I do not any Entity class or anything related to JDO and only have two or more ResultSet. I want to combine these ResultSets using the condition specified by the user.
Saurabh
From where you got ResultSet/s, at that point? Sorry I am unable to see that. What you got is the information for the query and a connection object. By the way why you will keep the connection object like that?
Adeel Ansari
By connection I meant is a connection name. My user can create name connection which I pool at my application bootup. When the user executes the stored query, I execute the query on the connection and get a RessultSet
Saurabh
Exactly at this point, when you execute the query, you will be using Hibernate API to query the database. You will not create any `Statement` or `PreparedStatement` to fire the query to database. Now the that hibernate method will query the database using the query statement, and return you the list of entity objects.
Adeel Ansari
A: 

Oracle comes with a generic ODBC gateway that allows you to link the oracle database with another database, so you can join tables from both databases etc. with SQL, as if both tables were on Oracle. See this link for details. By doing that, you don't have to replicate database features in your java program.

ammoQ
Thanks ammoQ, but one od the result set may not always be on oracle. it can from varied source
Saurabh
Through that gateway, you can query the other database through Oracle; Oracle transparentely does access the other database through the network.
ammoQ
But for that I would need Oracle database atleast for the solution to work??
Saurabh
yes, one of the databases has to be oracle
ammoQ