|
From: Juraj B. <ju...@vo...> - 2006-05-23 11:39:59
|
Problem definition: javax.persistence.Query interface has not defined "typed" setPrarameter methods. There exists valid queries that can't be parametrized properly via methods in javax.persistence.Query. details: in java.sql.PreparedStatement exists only two method for setting null values, namely setNull(int parameterIndex, int sqlType) && setNull(int parameterIndex, int sqlType, String typeName). If we need pass valid null value into the query, these methods must be used. In hibernate Query interface (org.hibernate.Query) exists method Query setParameter(int position, Object val, Type type) that solve this problem. So, we need define more rich API in javax.persistence.Query interface to pass "types" into a Query. probably we need add methods : public Query setParameter(int position, Type value) public Query setParameter(String name, Type value), where Type is from Long, Boolean ...., in general NullableType see org.hibernate.type.NullableType. Problem is that fixes in EJB 3 specification are necessary. :-( remarks: org.hibernate.Query is not well object oriented. I mean that methods like setInteger, setBoolean ... should be "marked" obsolete and should be replaced with methods setParamater(int, int)/setParameter(String, int), setParameter(int, boolean)/setParameter(String boolean) ... in future releases. best regards JuBu p.s. sorry for my weak English ||| | ||| | |