every time i want to query some like, 
i have to specify the query in the object 

like this

@NamedQueries({
    @NamedQuery(name = "Room.detailSearch", query = "from Room r where
r.price >= ?1 and r.maxPeople >= ?2")
})
public class Room implements Serializable {
.....
}

if in the Dao, 
public class Dao{
@SuppressWarnings({"unchecked"})
    public List<T> getList(String className, Object... params) {
        return (List<T>) createNamedQuery(className,
params).getResultList();
    }

    private Query createNamedQuery(String query, Object... params) {
        Query q = getEntityManager().createNamedQuery(query);
        for (int i = 1; i <= params.length; i++) {
            q.setParameter(i, params[i - 1]);
        }
        return q;
    }
}

i do things like this

getList("select r from Room r  where r.price >= ?1 and r.maxPeople >= ?2"",
maxNumberOfadult, maxNumberOfChild);

it always complain can not find the query!!!!

why?, is it that the only to do the query is to specify the query in the
domain object????
this is quite shit.....
-- 
View this message in context: 
http://n2.nabble.com/it-is-weird-i-can-not-create-query-tp1110234p1110234.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to