Talk:Jakarta Persistence Query Language: Difference between revisions

Content deleted Content added
clean up using AWB
Line 1:
{{WikiProject Java|class=stub|importance=low}}
 
== Mistake in example? ==
 
This article currently has the following example:
 
<source lang="java">
import javax.persistence.EntityManager;
import javax.persistence.Query;
import org.apache.commons.lang.StringUtils;
 
...
 
@SuppressWarnings("unchecked")
public List<Author> getAuthorsByLastName(String lastName) {
String queryString = "SELECT a FROM Author a " +
"WHERE :lastName IS NULL OR LOWER(a.lastName) = :lastName";
Query query = getEntityManager().createQuery(queryString);
query.setParameter("lastName", StringUtils.lowerCase(lastName));
return query.getResultList();
}
</source>
(Keep in mind the Author class has a field <code>private String firstName</code>.)
 
The <code>WHERE :lastName IS NULL</code> part doesn't make sense to me. Shouldn't it be written <code>WHERE lastName IS NULL</code> (i.e., without the colon)? In case I'm wrong, can someone please explain the semantics of this query? --[[User:Abdull|Abdull]] ([[User talk:Abdull|talk]]) 15:20, 29 September 2012 (UTC)