Wednesday, 15 September 2010

hibernate - Get data from 3 tables using dynamic query -



hibernate - Get data from 3 tables using dynamic query -

i have 3 tables user_, usertracker, usertrackerpath

user_ has userid pk. fk in usertracker usertracker has usertrackerid pk fk in usertrackerpath , usertrackerpath has usertrackerpathid pk.

user_ tables has fields firstname, lastname, loginip, lastloginip usertracker has fields remoteaddr, remotehost usertrackerpath has fields path_, pathdate

all these fileds want.

i have written sql query , runs me, want result using dynamic query .

here sql query.

select concat(u.firstname," ",u.lastname) fullname,u.loginip,u.lastloginip,ut.remoteaddr,substring(ut.modifieddate,1,10) date,utp.path_ demo.user_ u, demo.usertracker ut, demo.usertrackerpath utp ((u.userid=ut.userid) , (ut.usertrackerid=utp.usertrackerid));

i wrote dynamic query projections confused how joining them.

//dynamic query user class dynamicquery dynamicquery_user = dynamicqueryfactoryutil.forclass(user.class,portalclassloaderutil.getclassloader()) .setprojection(projectionfactoryutil.property("userid")) .setprojection(projectionfactoryutil.property("firstname")) .setprojection(projectionfactoryutil.property("lastname")) .setprojection(projectionfactoryutil.property("loginip")) .setprojection(projectionfactoryutil.property("lastloginip")); //dynamic query user , usertracker class dynamicquery dynamicquery_usertracker = dynamicqueryfactoryutil.forclass(usertracker.class,portalclassloaderutil.getclassloader()) .setprojection(projectionfactoryutil.property("modifieddate")) .setprojection(projectionfactoryutil.property("remoteaddr")); //dynamic query usertracker , usertrackerpath dynamicquery dynamicquery_usertrackerpath = dynamicqueryfactoryutil.forclass(usertrackerpath.class,portalclassloaderutil.getclassloader()) .setprojection(projectionfactoryutil.property("path_")) .setprojection(projectionfactoryutil.property("pathdate"));

also tried..

dynamicquery_usertracker.add(propertyfactoryutil.forname("userid").in(dynamicquery_user)); dynamicquery_usertrackerpath.add(propertyfactoryutil.forname("usertrackerid").in(dynamicquery_usertracker));

i knows method incorrect. views or suggestions.

thanks.

jay think cannot joins dynamicquery api. can subqueries in , notin methods.

hibernate liferay liferay-6 dynamicquery

No comments:

Post a Comment