• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to perform query on multiple tables dynamically? tables that has no mapped entity

 
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Thank you for reading my post
My question is mostly technical and i want to know whether EJB 3.0 can do this or not.
we have an application which we are going to port it to EJB 3.0 from plain JDBC.

in our application, we have tables which are created after we complete the code, those tables contains some data which we do not know about its fields and.... in our application design time.

what we have in runtime is a set of metadata that describe those tables, for example thier fields and .....


now we want to be able to query those table with EJBQL , meanwhile we have no entity mapped for those table because they are created after we designed the application,

What i want to know is:
-how we can query them,
-what will be the query result? it is a collection? if it is a collection, then what are collection elements?

Thanks
[ December 16, 2006: Message edited by: raminaa niilian ]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, there are two different options, if you do not map them, then it will be a two dimenstional Object array, Object[][].

Mark

so there is only one option. I was going to suggest mapping them programatically.
 
raminaa niilian
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for reply.
-can you please explain about mapping them programatically?
-How much effort it will need to map them programatically if we have access to mapping files for those table in runtime?
-one more important thing, what will happen when we need to excute a query which include two type of objects?

Thanks
 
raminaa niilian
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any extra comment ?
thanks
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the Configuration and SessionFactory object can be modified programatically, there is an API.

"one more important thing, what will happen when we need to excute a query which include two type of objects?"

Can you query on two types of tables and union those queries together? It is kind of the same question. Do they have fields that relate to each other, same structure. If not, you will need two seperate queries. There is too many questions about what youa re doing to be able to completely ansewr your questions.

Mark
 
raminaa niilian
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the hint about Session Factory and configuration,
another question is :
how we can generate Java classes on the fly to map them with tables and add them to configuration object?


thanks
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"how we can generate Java classes on the fly"

Exactly, unless you can through Reflection, or the Class object, which I don't recall that you can do this, but I haven't really looked or wanted to try this.

Mark
 
raminaa niilian
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you sheriff,
I searched about reflection and byte code engineering and i find some libraries that make using reflection easier.

Also i thought that hibernate can generate entity from database, maybe i can use this functionality of hibernate to generate those classes from Tables on the fly.

is it a good suggestion?

thanks
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, something interesting that I saw today in the code of Hibernate, is that they have classes that utilize Javaassist to instrument byte code where you can add attributes and methods. Kind of cool.

I still doubt that you will find a solution for your problem of mapping to objects that are defined at runtime.

Mark
 
moose poop looks like football shaped elk poop. About the size of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic