Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with HQL  RSS feed

 
Vivek Thirumalai
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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.
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hi all,

It worked fine once I gave the fully qualified class name...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!