• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Help with HQL

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is my use case :

I need to create an object from two Hibernate mapped classes .
ex:

class1 : a,b - mapped to a table
class2 : c,d - mapped to a table
class3: a,c - no mappings

I did something like "select new class3(class1.a,class2.c) from class1,class2)"
but hibernate is throwing error saying no class like class3. I know this is because class3 is not mapped (not in the resource file). So I have 2 qns :

1) Can I create a hbm file for class3 but not mapping to any table
2) If not, is there any way to get around this apart from creating a new table for class3.

Thanks,
Vivek.
 
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
Try doing it as an SQLQuery instead of Query, you can actually do "select new Class3(a.fieldA, c.fieldB) from table1 a, table3 c"

Class3 does not have to be mapped.

Mark
 
Vivek Thirumalai
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

It worked fine once I gave the fully qualified class name...
 
To do a great right, do a little wrong - shakepeare. twisted little ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic