Я пытаюсь сгенерировать запрос с несколькими скобками в условиях «или» и «и», но внутренние скобки не генерируются.
Квадратные скобки для внешних предикатов генерируются правильно, но не для внутренних.
Код:
select
configurat0_.id as id1_1_,
configurat0_.createdAt as createdA2_1_,
configurat0_.updatedAt as updatedA3_1_,
configurat0_.configType as configTy4_1_,
configurat0_.customerId as customer7_1_,
configurat0_.keyType as keyType5_1_,
configurat0_.keyValue as keyValue6_1_
from
configuration_keys configurat0_
inner join
customers customer1_
on configurat0_.customerId=customer1_.id
where
customer1_.externalId=?
and configurat0_.configType=?
and (
configurat0_.keyType=?
and configurat0_.keyValue=?
or configurat0_.keyType=?
and configurat0_.keyValue=?
)
select
configurat0_.id as id1_1_,
configurat0_.createdAt as createdA2_1_,
configurat0_.updatedAt as updatedA3_1_,
configurat0_.configType as configTy4_1_,
configurat0_.customerId as customer7_1_,
configurat0_.keyType as keyType5_1_,
configurat0_.keyValue as keyValue6_1_
from
configuration_keys configurat0_
inner join
customers customer1_
on configurat0_.customerId=customer1_.id
where
customer1_.externalId=?
and configurat0_.configType=?
and (
(configurat0_.keyType=?
and configurat0_.keyValue=?)
or
(configurat0_.keyType=?
and configurat0_.keyValue=?)
)
Я пытаюсь сгенерировать запрос с несколькими скобками в условиях «или» и «и», но внутренние скобки не генерируются. Квадратные скобки для внешних предикатов генерируются правильно, но не для внутренних. Код:
final List predicates = new ArrayList(); predicates.add(criteriaBuilder.equal(configurationKeyCustomerJoin.get(Customer_.externalId), customerId)); predicates.add(criteriaBuilder.equal(configurationKeyRoot.get(ConfigurationKey_.configType), configType));
final List orPredicates = new ArrayList(); keys.forEach((x, y) -> { orPredicates.add( criteriaBuilder.and( criteriaBuilder.equal(configurationKeyRoot.get(ConfigurationKey_.keyType), x), criteriaBuilder.equal(configurationKeyRoot.get(ConfigurationKey_.keyValue), y) ) ); }
[code]select configurat0_.id as id1_1_, configurat0_.createdAt as createdA2_1_, configurat0_.updatedAt as updatedA3_1_, configurat0_.configType as configTy4_1_, configurat0_.customerId as customer7_1_, configurat0_.keyType as keyType5_1_, configurat0_.keyValue as keyValue6_1_ from configuration_keys configurat0_ inner join customers customer1_ on configurat0_.customerId=customer1_.id where customer1_.externalId=? and configurat0_.configType=? and ( configurat0_.keyType=? and configurat0_.keyValue=? or configurat0_.keyType=? and configurat0_.keyValue=? ) [/code]
Ожидаемый запрос:
[code]select configurat0_.id as id1_1_, configurat0_.createdAt as createdA2_1_, configurat0_.updatedAt as updatedA3_1_, configurat0_.configType as configTy4_1_, configurat0_.customerId as customer7_1_, configurat0_.keyType as keyType5_1_, configurat0_.keyValue as keyValue6_1_ from configuration_keys configurat0_ inner join customers customer1_ on configurat0_.customerId=customer1_.id where customer1_.externalId=? and configurat0_.configType=? and ( (configurat0_.keyType=? and configurat0_.keyValue=?) or (configurat0_.keyType=? and configurat0_.keyValue=?) ) [/code]
Я хочу добиться приведенного ниже результата с помощью ','
FROM table1 t1,
LATERAL jsonb_array_elements(secret_data->'rating'->'subRating') AS subRatings
WHERE
Я хочу добиться этого с помощью API критериев.
Я знаю, что мы можем создать...
Я хочу добиться приведенного ниже результата с помощью ','
FROM table1 t1,
LATERAL jsonb_array_elements(secret_data->'rating'->'subRating') AS subRatings
WHERE
Я хочу добиться этого с помощью Criteria API. Я знаю, что мы можем создать...
У меня есть таблица sql под названием school и еще одна таблица Student. У каждой школы есть идентификатор, и у каждого учащегося есть «идентификатор школы», который является идентификатором школы, к которой он принадлежит.
Теперь я хочу найти все...
Реализовано отношение «один ко многим» и выбран родительский и дочерний элементы. У меня есть отношение «один ко многим».
Используя построитель критериев, мне нужно получить родительский элемент и все связанные дочерние элементы, но выбрав только...
У меня есть таблица sql под названием school и еще одна таблица Student. У каждой школы есть идентификатор, и у каждого учащегося есть «идентификатор школы», который является идентификатором школы, к которой он принадлежит.
Теперь я хочу найти все...