Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to locate appropriate constructor on class...

 
Himanshu Rawat
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

this HQL is giving me error..
Caused by: Unable to locate appropriate constructor on class [Hibernate.CommonClasses.LibraryVO]

this is my query :- String query = "select new Hibernate.CommonClasses.LibraryVO(lib.libDocumentName,lib.libDocumentAddedDateTime,lib.libDocumentUploadedby,rat.libDocumentAdminRating,lib.libLocation,sta.libDocumentDownloadCount) from LibDocumentInfo as lib, LibDocumentStatus as sta, LibDocumentRating as rat where lib.libDocumentIndex=sta.libDocumentIndex and lib.libDocumentIndex=rat.libDocumentIndex and lib.libDocumentName like '" + val + "%'";
List temp= session.createQuery(query).list();

and this is my LibraryVO class construtor
public LibraryVO(String name,Date dat,String upload,String rating,String loc,int count) {
super();

libDocumentName=name;
libDocumentAddedDateTime=dat;
libDocumentUploadedby=upload;
libDocumentAdminRating=rating;
libLocation=loc;
libDocumentDownloadCount=count;

}

cam nybody tell me wats wrong in this???
 
Emanuel Kadziela
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you need to follow the JavaBean convention in your business objects if you want to use hibernate with them. You need a no-arg constructor as well as public getters and setters for all the fields you want persisted.
 
Himanshu Rawat
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i have public constructor with no arg and with arg also. Watever attributes i m declaring in class i have corresponding getter and setter too..moreover i have used same thing in other applications tooo there it works...bt its givin me error in this case....why sooo??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic