使用CriteriaBuilder构建Java查询

时间:2017-01-23 12:33:56

标签: java criteria query-builder

我需要使用java Criteria builder创建查询,如下所示 AND (column1 != value OR column2 != value)我只设法创建notEqual builder.notEqual(root.get(column), value));,其中AND column1 != value转换为AND (column1 != value OR column2 != value)我需要添加的其他内容_keystore.Load(null); _keyGen.Init(new KeyGenParameterSpec.Builder(_keyId, KeyStorePurpose.Encrypt | KeyStorePurpose.Decrypt) .SetBlockModes(KeyProperties.BlockModeCbc) // Require the user to authenticate with a fingerprint to authorize every use // of the key .SetUserAuthenticationRequired(true) .SetEncryptionPaddings(KeyProperties.EncryptionPaddingPkcs7) .Build()); _keyGen.GenerateKey(); Cipher _cipher = Cipher.GetInstance(KeyProperties.KeyAlgorithmAes + "/" + KeyProperties.BlockModeCbc + "/" + KeyProperties.EncryptionPaddingPkcs7); KeyStore _keystore = KeyStore.GetInstance("AndroidKeyStore"); FingerprintManager _fingerprintManager = (FingerprintManager) Context.GetSystemService(Context.FingerprintService); _keystore.Load(null); var key = _keystore.GetKey(_keyId, null); _cipher.Init(CipherMode.EncryptMode, key); _cryptoObject = new FingerprintManager.CryptoObject(_cipher); _fingerprintManager.Authenticate(_cryptoObject, _cancellationSignal, 0 /* flags */, this, null); //OnAuthSucceeded: var mySecret = _cipher.DoFinal(System.Text.Encoding.UTF8.GetBytes(textToEncrypt));

1 个答案:

答案 0 :(得分:0)

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

您可能还想查看CriteriaBuilder javadoc以了解其他表达方式。