• Post Reply Bookmark Topic Watch Topic
  • New Topic

,expected in select

 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i am trying to select two columns in the entity i am getting below error like

, expected in SELECT [select itc.interestTypeKey as interestTypeKey from com.org.state.dsl.btlds.admin.entities.InterestTypeCodeEntity itc ]

This is my java code , i am not able to figure out where iam doing mistake, Please help me in understanding the problem.





if i change the select query like as below it is working fine


String sql=" select new InterestTypeCodeEntity( itc.interestTypeKey , itc.interestTypeName) from InterestTypeCodeEntity itc where itc.endDate is null

i dont like to create any constructors in my class


Thanks
Amir



 
Dave Tolls
Ranch Hand
Posts: 2378
25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just select itc.
You want the whole entity, so select it:

 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dave,

Thanks for the reply.

i just want to select only the two columns not the whole entity.

Thanks
Amir
 
Dave Tolls
Ranch Hand
Posts: 2378
25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But you're assigning it to the entity:

which is where the problem is.

If you only want those two columns (as in your original query) then the returned List is a List<Object[]>.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!