Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > BOOK: Professional Java for Web Applications
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 12th, 2016, 06:36 AM
Registered User
Points: 11, Level: 1
Points: 11, Level: 1 Points: 11, Level: 1 Points: 11, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #2 (permalink)  
Old January 12th, 2016, 07:22 AM
Registered User
Points: 11, Level: 1
Points: 11, Level: 1 Points: 11, Level: 1 Points: 11, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
  #3 (permalink)  
Old January 12th, 2016, 10:21 AM
Wrox Author
Points: 36, Level: 1
Points: 36, Level: 1 Points: 36, Level: 1 Points: 36, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #4 (permalink)  
Old January 13th, 2016, 08:31 AM
Registered User
Points: 11, Level: 1
Points: 11, Level: 1 Points: 11, Level: 1 Points: 11, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:20 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.