Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate query

 
Rafael Andrade
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I�m having a problem makin an HQL. I need to instantiate a Value Object getting the value from another. I have VO1 and VO2. VO1 has a var Long VO2, wich is its Id. So I make a constructor on VO1:
public VO1(Long id, String vo2Name){
setId(id);
setVo2Name(vo2Name);
}
I want to get the name from VO2 and Id from VO1. So I tried:
select new VO1(v1.id,v2.name) from VO1 as v1, VO2 as v2

but it didn�t work. How can I make it?

thanks!
 
kapil patel
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Few things you might need to consider. If you have not, please check it out:

1> You need default constructor in all VO.

Moreover, can you submit your full code if possible. Use INstant UBB Code opation so it can be readable.

thanks,
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!