persistence@glassfish.java.net

RE: constructor in query

From: Gordon Yorke <gordon.yorke_at_oracle.com>
Date: Fri, 16 Feb 2007 11:34:16 -0500

The current Specification JPQL syntax does not allow for constant values to be passed to a constructor expression. Only Aggregate Functions and entity state can be passed in. A simple solution would be to update your class creating a constructor that accepts only 2 attributes and defaults the true value. Alternatively you could select the results and call the constructor in your own code.

Although this functionality would be against the specification it would be a helpful feature. Please file a glassfish enhancement request.
--Gordon
  -----Original Message-----
  From: sud [mailto:to_sud_at_yahoo.com]
  Sent: Friday, February 16, 2007 10:43 AM
  To: persistence_at_glassfish.dev.java.net
  Subject: constructor in query


  Is it possible to pass a primitive type as a constructor argument in a JPQL query. Here is an example of what I'm trying to do:

  SELECT DISTINCT new myPackage.MyClass(c.id, c.desc, true) FROM Entry c

  The boolean true argument is where my code barfs.

  Thanks
  -sud



------------------------------------------------------------------------------
  We won't tell. Get more on shows you hate to love
  (and love to hate): Yahoo! TV's Guilty Pleasures list.