所以我想在标准构建器中使用EclipseLink's REGEXP
function来将实体的 var storage = multer.diskStorage({
destination: function (req,file,cb) {
cb(null,'uploads/')
},filename: function (req,file.fieldname + '-' + Date.now())
}
})
var upload = multer({ storage: storage })
router.post('/',upload.single('myImage'),function(req,res){
if (req.body._id == '')
insertRecord(req,res);
else
updateRecord(req,res);
})
function insertRecord(req,res){
var img = fs.readFileSync(req.file.path);
var encode_image = img.toString('base64');
var finalImg = {
contentType: req.file.mimetype,image: new Buffer(encode_image,'base64')
};
const user=new User()
user.name=req.body.name
user.address=req.body.address
user.email=req.body.email
user.mobile=req.body.mobile
user.save(finalImg,(err,docs)=>{
if(!err){
res.redirect('/user/list')
}
else {
if (err.name == 'ValidationError') {
handleValidationError(err,req.body);
res.render("./users/addOrEdit",{
viewTitle: "Insert User",user: req.body
});
}
else
console.log('Error during record insertion : ' + err);
}
});
}
列与正则表达式匹配。
他们在上面链接中所记录的用途是
id_str
但是我似乎无法将其放入WHERE column_name REGEXP '<here be regex>'
中,所以我要放入
CriteriaBuilder
相反,假设infix运算符仍然这样做。
WHERE REGEXP (column,'<here be regex>')
但这似乎不起作用:
@Override
public Predicate visit(CriteriaBuilder cb,IdStringRegexSearchElement searchElement) {
Expression<String> identificationString = root.get("identificationString");
String regexPattern = searchElement.getRegex().getPattern();
return matchesRegex(cb,identificationString,regexPattern);
}
private Predicate matchesRegex(CriteriaBuilder cb,Expression<String> target,String regexPattern){
Expression<Boolean> idStrMatchesRegex = cb.function("REGEXP",Boolean.class,target,cb.literal(regexPattern));
return cb.isTrue(idStrMatchesRegex);
}
就我所希望的那样,呼叫对我而言似乎是正确的。
所以我假设我不能以这种方式调用infix函数。
正确的调用方式是什么?