Wrox Programmer Forums
|
BOOK: Professional Java for Web Applications
This is the forum to discuss the Wrox book Professional Java for Web Applications by Nicholas S. Williams; ISBN: 978-1-118-65646-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Java for Web Applications section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 12th, 2016, 06:36 AM
Registered User
 
Join Date: Jan 2016
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Criterion won't compile

Hi,
I'm trying to use the Criterion class from ch23 and the compiler is complaining about a few statements like this:
Code:
return b.lessThan(r.<Comparable> get(c.getPropertyName()), getComparable(c));
with the error:
"The method lessThan(Expression<? extends Y>, Expression<? extends Y>) in the type CriteriaBuilder is not applicable for the arguments (Path<Comparable>, Comparable<capture#4-of ?>)".

It looks like the getComparable(Criterion c) method is not valid with latest JPA API (I'm using 2.1:1.0.0.Final), but I'm not certain yet - still investigating.

Any ideas?


Thanks,
Tasos
 
Old January 12th, 2016, 07:22 AM
Registered User
 
Join Date: Jan 2016
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have managed to get rid of the compiler error by removing the
Code:
<?>
from this signature:
Code:
private static Comparable<?> getComparable(Criterion c)
Still not sure if this is a correct fix though - I'll test soon.
 
Old January 12th, 2016, 10:21 AM
Wrox Author
 
Join Date: Jun 2014
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That's not the correct fix, because it reduces type safety in the code. But I can't figure out why this isn't working for you.

This code was tested with org.eclipse.persistence:javax.persistence:2.1.0. That's the same version you are using, but it's possible you're using a different library. Are you using org.eclipse.persistence:javax.persistence or something else? What's your full Java version? Who supplied the compiler (Oracle, Eclipse, or some other company)?
__________________
-- Nick Williams
 
Old January 13th, 2016, 08:31 AM
Registered User
 
Join Date: Jan 2016
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, thanks for looking into this.
I am using java 1.8 (by Oracle on Mac with Eclipse Mars).
I'm also using Hibernate: 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final'.

Looking at the Oracle JPA api docs, the CriteriaBuilder.lessThan signature (and the other "comparing" ones) look to match the ones from the Hibernate library I'm using: http://docs.oracle.com/javaee/6/api/...iaBuilder.html

It also looks to match the EclipseLink API also... http://www.eclipse.org/eclipselink/a...iaBuilder.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
Criteria vs. Criterion arius BOOK: Professional ASP.NET Design Patterns 2 September 30th, 2014 02:19 PM
Maximum as a criterion in an Access Query rmccafferty Access 1 March 2nd, 2012 02:08 PM
Maximum as a criterion in an Access Query rmccafferty Excel VBA 1 March 2nd, 2012 12:26 PM
where clause/criterion sauloftarsus SQL Server 2005 0 November 23rd, 2011 04:15 AM
compile aspb ASP.NET 2.0 Basics 0 September 8th, 2006 10:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.