openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Scala <rsc...@buyersedgepurchasing.com>
Subject Re: JPA criteria
Date Fri, 21 Jul 2017 17:32:56 GMT
Matthew,

I haven't done this yet, but the documentation states that join returns 
a Join<X,Y> object, not a Root<X>.  I think in your case, it returns a 
Join<EntityZ,Detail>.

Where does the documentation need to be updated?

Rob


On 07/21/2017 12:50 PM, Matthew Broadhead wrote:
> Thanks Rob, this works:
> criteriaQuery.where(criteriaBuilder.equal(entity.get(EntityZ_.id), 
> entityId));
>   maybe the documentation needs updating?
>
>
>
> On 21/07/2017 12:49, Rob Scala wrote:
>>
>> Matthew,
>>
>> On your second point, expression methods (equal, gt, etc) belong to 
>> the CriteriaBuilder, not to the expressions.
>>
>> cb.equal(exp1, exp2)
>>
>> http://docs.oracle.com/javaee/7/api/javax/persistence/criteria/CriteriaBuilder.html

>>
>>
>> Rob
>>
>>
>> On 07/21/2017 05:03 AM, Matthew Broadhead wrote:
>>> Following the example on page 
>>> https://openjpa.apache.org/builds/2.4.2/apache-openjpa/docs/jpa_overview_criteria.html
>>>
>>> CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
>>> CriteriaQuery<EntityZ> criteriaQuery = 
>>> criteriaBuilder.createQuery(EntityZ.class);
>>> Root<EntityZ> entity = criteriaQuery.from(EntityZ.class);
>>> Root<Detail> detail = entity.join(entity.get(EntityZ_.details));
>>>
>>> results in
>>>
>>> Type mismatch: cannot convert from Expression<List<Detail>> to 
>>> SingularAttribute<? super EntityZ,Y>
>>>
>>> also is there a typo?
>>>
>>> qdef.where(customer.get(Customer_.name).equal("John 
>>> Doe").and(order.get(Order_.status).equal(OrderStatus.DELIVERED).not())); 
>>>
>>>
>>> there is no such function as equal?  should it be equals? also in my 
>>> case:
>>>
>>> criteriaQuery.where(entity.get(EntityZ_.id).equals(entityId));
>>>
>>> results in:
>>>
>>> The method where(Expression<Boolean>) in the type 
>>> CriteriaQuery<EntityZ> is not applicable for the arguments (boolean)
>>
>> -- 
>> *Rob Scala*
>> Director of Information Technology
>> Buyers Edge, Inc
>> 351 N. Frontage Road, Suite A210
>> New London, CT 06320
>> Phone - 860-865-2127
>> Fax - 860-701-0576
>

-- 
*Rob Scala*
Director of Information Technology
Buyers Edge, Inc
351 N. Frontage Road, Suite A210
New London, CT 06320
Phone - 860-865-2127
Fax - 860-701-0576

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message