48094

QueryDSL: How to SELECT literals as part of a SQLSubQuery?

How do I implement https://stackoverflow.com/a/16392399/14731 using QueryDSL SQL?

I understand that

new SQLSubQuery().from(customer).where(customer.email.eq("foo@example.com"))

models

select customer where customer.email = 'foo@example.com'

but I don't understand how to <strong>select [literal]</strong> such as:

select 1 from customer or select 'foo@example.com', 0

as required by the aforementioned link.

Answer1:

If it is ok to use parameters then using constants should work

new SQLSubQuery().from(customer) .where(customer.email.eq("foo@example.com")) .list(Expressions.constant("foo@example.com"), Expressions.constant(0))

Expressions.constant is documented here http://www.querydsl.com/static/querydsl/3.2.3/apidocs/com/mysema/query/support/Expressions.html#constant%28T%29

Recommend

  • how to check type of value in postgres
  • Varchar to int typecasting in JPA 1.9
  • Parser Error Message: The file '/Site.master' does not exist
  • How can I default to the numeric keypad on focus of an EditText view?
  • Using Reactive Extension for certain KeyPress sequences?
  • Aggregating By Date in Mongodb
  • Advantage of 'one dimensional' hash over array in Perl
  • What's the benefit of the trailing apostrophe in character literals
  • SQL Server Nvarchar and Java prepared statement
  • Sort by a column in a union query in SqlAlchemy SQLite
  • Can you build a truly RESTful service that takes many parameters?
  • What does a hyphen at end of a term mean
  • Encrypting credit card details using AngularJS in Braintree
  • smarty nested if condition is not working properly?
  • How to access recipient on sent messages page with mailboxer
  • Dynamically set LESS variables from user settings
  • testing a POST using phpunit in laravel 4
  • Django model for a Postgres view
  • How to retrieve information from antrun back to maven?
  • 550 Access denied - Invalid HELO name
  • SAXReader not re-ecape characters
  • Combining two different ActiveRecord collections into one
  • Login not working in Firefox in Meteor
  • Does Mobilefirst provide a provision to access web services directly?
  • How do I access an unhandled exception in an MVC Error view?
  • Email verification using google app script and google forms
  • Meteor helpers not available in Angular template
  • Email format validation in mvc3 view
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder on below Lollipop versions
  • sending/ receiving email in Java
  • Build own AppleScript numerical error handling
  • ORA-29908: missing primary invocation for ancillary operator
  • How to get next/previous record number?
  • KeystoneJS: Relationships in Admin UI not updating
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • How do you join a server to an Active Directory (domain)?
  • How does Linux kernel interrupt the application?
  • Does armcc optimizes non-volatile variables with -O0?
  • java string with new operator and a literal