Electrotek

From programming to day dreaming

Operator Precedence and concatenation

Today a colleague of mine was having a problem with running a JPQL query which for some reason failed with a rather cryptic exception.

The code looked something like:

String query = "select s from SomeEntity e "
        + "join e.something s "
        + "where something "
        + variable == null ? "and something" : "and other";
System.out.println(query); // What is the output?

Even experienced developers were puzzled by this and we had a good laugh after the mystery was unsolved :)

Operator Precedence

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.