Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: Re[eclipselink-users] strictions not changing...

Hello,

I haven't played with the criteriaBuilder as much as I should have, but it looks like you are getting a new Builder from the em rather than using the one from your query.  If so, you are adding the new restriction to an empty builder, while the one for your query remains exactly the same.  

How are you building and executing your query, and how are you adding the parameter?  Parameters should allow you to pass in new ones dynamically without making any changes to the query, such as:
cq.where(emp.get("address").<String>get("city").in(qb.parameter(String.class, "city")));  
Query query = em.createQuery(cq);  
qb.parameter(String.class, "city");
query.setParameter("city", "Ottawa");  
List<Employee> result = query.getResultList();  
query.setParameter("city", "Boston");
List<Employee> result2 = query.getResultList();  


Best Regards,
Chris

----- Original Message -----
From: diego.coronel@xxxxxxxxx
To: eclipselink-users@xxxxxxxxxxx
Sent: Tuesday, December 29, 2009 10:51:07 AM GMT -05:00 US/Canada Eastern
Subject: Re[eclipselink-users] strictions not changing...


Hi, im trying to make some queries with criteriaBuilder and when i did my
first query 

i did a query by login: 
FINE: SELECT ID, STATUS, LOGIN, NOME, PASSWORD FROM geral.USUARIO WHERE
(LOGIN = ?)
	bind => [a]

and when i change the parameter to 'diego' the same binding is showed
FINE: SELECT ID, STATUS, LOGIN, NOME, PASSWORD FROM geral.USUARIO WHERE
(LOGIN = ?)
	bind => [a]

i tried to make this:
entityManager =
entityManager.getEntityManagerFactory().createEntityManager()
			qb = entityManager.getCriteriaBuilder();

and this: 
getCriteriaBuilder().getRestriction().getExpressions().add(exp);

so.. i dont know how to change this bind..  its always locking in my first
try... i cant change the query anymore.

is there any way to add restrictions dinamically to criteriaQuery?

sry about english.. tks
-- 
View this message in context: http://old.nabble.com/Restrictions-not-changing...-tp26956138p26956138.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top