How to use the condition “NULLS LAST” in an order by in a readAllQuery in TopLink

StackOverflow https://stackoverflow.com/questions/8050809

  •  24-02-2021
  •  | 
  •  

質問

Hi need to make a query in toplink that uses the NULLS LAST clause in an order by. Basically this is the query i'd like to do:

select * from VW_SEGNA_PRZZ_DEP_INFO where ente_cd = '7316' and refr_cd = '000070434' order by dp_dt_timestamp_modifica DESC NULLS LAST;

And this is my code:

        ReadAllQuery query = new ReadAllQuery();
        query.setReferenceClass(VwSegnaPrzzDepInfo.class);

        Expression exp = new ExpressionBuilder();

        exp = 
exp.and(new ExpressionBuilder().get("enteCd").equal(getEnteCd()));
        exp = 
exp.and(new ExpressionBuilder().get("refrCd").equal(spdf.getRefrCd()));

        query.setSelectionCriteria(exp);
        query.addDescendingOrdering("dpDtTimestampModifica");

I don't know how to insert the NULLS LAST clause. I'm using toplink 3.0 an Oracle 9i as a database.

役に立ちましたか?

解決

You can use,

query.addOrdering(Expression)

To create the Expression you will need to create your own ExpressionOperator that prints itself as "DESC NULLS LAST" (refer to the desc operator as an example).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top