Unable to select transient property in JPQL

Hi, I am unable to select a transient property in my JPQL query. Is this supported?


java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
Exception Description: Problem compiling [select e.net from test$Sale e]. 
The state field path 'e.net' cannot be resolved to a valid type.


select e.net from test$Sale e

I’ve tried a couple variations in my entity.

First Attempt:

@MetaProperty(related={"gross", "discount"})
public BigDecimal getNet() {
    return gross - discount;

Second attempt:

@MetaProperty(related={"gross", "discount"})
protected BigDecimal net;

public BigDecimal getNet() {
    return gross - net;


Transient properties do not exist on the database, and JPQL statements are translated to SQL for execution.

So what you are seeing is the result of an SQL statement trying to access a table column that doesn’t exist.

Why can’t you just

select (e.gross - e.discount) as net from test$Sale e

Yes, I can do that. I just like to avoid having duplicate logic in the system unless necessary. My hope was that since the entity has the “related” annotation, the query framework might be able to do that behind the scenes. Not a big deal. I was just looking for confirmation. Thanks.