我正在使用带有spring的JPA eclipse链接来查找基于字符串的数据库中的数据。我有一个方法
@Transactional
public String authorization(LL l){
Query query = m.createNativeQuery("SELECT a FROM user a WHERE a.name = ?");
query.setParameter(1, l.getName());
UserEntity tmp = (UserEntity) query.getSingleResult();
}
我的数据库很简单
id | name | password
然而,通过执行此我得到错误
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'a' in 'field list'
我已阅读文档,这应该是执行此类查询的正确方法。为什么抛出这个错误?我犯了错误还是忽略了什么?
感谢所有帮助。
答案 0 :(得分:1)
您似乎希望有一个实体作为结果,因此不是本机查询:
var text = "C123456 577 abcd 173944 C5678541883";
var regex = /\b([0-9]+)\b/g;
var match = regex.exec(text);
while(match !== null) {
console.log(match[1]);
match = regex.exec(text);
}
使用
<?php
// form 1 Will call the controller/model, prozess the data, and return to the view
echo form_open('test_controller/add_something');
echo form_input($input1);
echo form_textarea($txt_area1);
echo form_submit(array('id'=>'submit','value'=>'Save));
echo form_close();
// form 2 Will call the controller/model, process the data, and return to the same view ?>
<form name="uploadformular" enctype="multipart/form-data" action="dateiupload" method="post">
Datei: <input type="file" name="uploaddatei" size="60" maxlength="255">
<input type="Submit" name="submit" value="Datei hochladen">
</form>
<?php
// form 3 Will call the controller/model, process the data, and return to the same view
echo form_open('same_controller/add_detail_entry');
echo form_input($input2);
echo form_textarea($input3);
echo form_submit(array('id'=>'submit','value'=>'Save));
echo form_close();
?>
<强>更新强>
如果您需要使用本机查询,则应添加预期的结果类:
m.createNativeQuery