• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

querying problem with Hibernate when we use multiple tables in query

 
raminaa niilian
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thank you for reading my post
I have an application that i want to migrate it to hibernate/EJB3, problem is that in my application i have some cases that columns that are included in the query are dynamically added to querry,
now when it return a collection of Objects what kind of objects it will return ?


thanks
 
Halcon Guatemala
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raminaa, are you saying these columns are added to projection or restrictions of your query? These columns are from the same table? Do you want to use Criteria API?

Thanks
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using projections then it returns a two dimensional Object array Object[][].

Or you can create a new class that has the attributes of the projection, then in your Query statement use

"select new MyObject(o.a, o.b, o.c)..."

But your MyObject must have a constructor that takes those exact arguments.

Mark
 
Jignesh Patel
Ranch Hand
Posts: 626
Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cases that columns that are included in the query are dynamically added to querry,
now when it return a collection of Objects what kind of objects it will return


They will return set object in hibernate. If you want to dig more you can think of List too.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic