Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

with temp in hql?

 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I use temporary tables in HQL?

Something like (SQL):



So you see, I need a temporary table that values are available in another table in the same Query.

Any suggestions?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't. HQL can be used with mapped tables only; you can't use it to create tables on the fly. Use native SQL if you need to do this.
 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

We can do something like this:



where the constructor do not have to be a Entity.

Maybe I can use subselects instead of temporary tables..
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but the implications are different. A temporary table exists in the database and is written to disk. Creating a new object in your HQL the data lives in memory and is not written to disk (unless you are using a second level cache that has a persistant cache implementation).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic