P. 1
seam reference

seam reference

5.0

|Views: 6,931|Likes:
Published by zzztimbo
seam reference seam 2.0.0 CR2
seam reference seam 2.0.0 CR2

More info:

Published by: zzztimbo on Oct 14, 2007
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

02/05/2014

pdf

text

original

Seam proxies the EntityManager or Session object whenever you use a Seam-managed persistence context or
inject a container managed persistence context using @PersistenceContext. This lets you use EL expressions
in your query strings, safely and efficiently. For example, this:

User user = em.createQuery("from User where username=#{user.username}")
.getSingleResult();

is equivalent to:

User user = em.createQuery("from User where username=:username")
.setParameter("username", user.getUsername())
.getSingleResult();

Of course, you should never, ever write it like this:

User user = em.createQuery("from User where username=" + user.getUsername()) //BAD!
.getSingleResult();

(It is inefficient and vulnerable to SQL injection attacks.)

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->