java - How to generate namedQuery by hibernate? -


i working in project java entity classes generated db scheme hibernate tool. have named queries in generated classes able find entities 1 of non primary-key field. have namedqueries this: finduserbyname or finduserbyheight. named queries optimal choice purpose besides entitymanger.find() , criteria api.

my question how configure hibernate tool / hbm2java / reverse engineering strategy generate namedqueries each column in db table. did not find corresponding information on internet. hope possible. using eclipse jpa 2.0 persistance manager in netbeans able generate named queries.

if using spring, should have @ hades. provides functionality create sql statements out of method names. thing need write interface (dao) - implmentation of "simulated" hades.

so can writing method declaration like:

public interface customerdao {   list<customer> findbyfirstname(string firstname); } 

if method name -- sql statment mapping not work complex queries hades provieds functionalty use statements defined in annotations.

@query("from deal x customer = :customer , (x.zombie = 'none' or x.zombie ='new')") deal findactivedealbycustomer(@param("customer") customer customer); 

@see http://redmine.synyx.org/projects/show/hades - project


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -