简体   繁体   中英

Java building query with CriteriaBuilder

I need to create query using java Criteria builder which would look like this AND (column1 != value OR column2 != value) i only managed to create notEqual which looks like this builder.notEqual(root.get(column), value)); which translates to AND column1 != value what else i need to add to make it AND (column1 != value OR column2 != value)

criteriaBuilder.or(criteriaBuilder.notEqual(root.get(column1), value),
                   criteriaBuilder.notEqual(root.get(column2), value))

You may also want to look into the CriteriaBuilder javadoc for additional expressions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM