我是Hibernate的新手.
我正在尝试获取所有管理员的名字和姓氏列表.
我的以下代码中有两个警告.我已经尝试在线搜索了很多.
1)查询是原始类型.应该参数化对泛型类型Query的引用.
2)不推荐使用Query类型的方法list().
public List<Object> loadAllAdmins() {
List<Object> allAdmins = new ArrayList<Object>();
try {
HibernateUtil.beginTransaction();
Query q = currentSession.createQuery("SELECT admin.firstName, admin.lastName from AdminBean admin");
allAdmins= q.list();
HibernateUtil.commitTransaction();
} catch (HibernateException ex) {
System.out.println("List<AdminBean> loadAllPersons: HibernateException");
}
return allAdmins;
}
Run Code Online (Sandbox Code Playgroud)
但我在整个网络上都看到了这样的示例代码.我该如何解决这两个问题?
更新
我只是尝试按照建议使用Criteria.它还说,对于Criteria,list()方法是弃用的......看起来很多方法都被弃用了Query和Criteria,包括uniqueResult()和其他...任何建议我应该如何替换它们?
当我添加"{upsert:true}"行时,我收到此错误:
TypeError:callback.apply不是函数
// on routes that end in /users/competitorAnalysisTextData
// ----------------------------------------------------
router.route('/users/competitorAnalysisTextData/:userName')
// update the user info (accessed at PUT http://localhost:8080/api/users/competitorAnalysisTextData)
.post(function(req, res) {
// use our user model to find the user we want
User.findOne({ userName: req.params.userName}, function(err, user) {
if (err)
res.send(err);
console.log('user.competitorAnalysis.firstObservation: %@', user.competitorAnalysis.firstObservation);
// Got the user name
var userName = user.userName;
// update the text data
console.log('Baobao is here!');
user.update(
{
userName: userName
},
{ $set: { "competitorAnalysis.firstObservation" : req.body.firstObservation,
"competitorAnalysis.secondObservation" : req.body.secondObservation,
"competitorAnalysis.thirdObservation" : …Run Code Online (Sandbox Code Playgroud) 我已经在线检查了许多解决方案,但在解析“hh:mm a”时仍然出现异常。
在 JSP 中:
$('#t2').timepicker({
timeFormat : 'hh:mm a',
interval : 30,
maxTime : '11:00 pm',
startTime : '08:00 am',
dynamic : false,
dropdown : true,
scrollbar : true
});
...
<div class="form-group">
<label
class="col-md-3 control-label">Start
Time</label>
<div class="col-md-7">
<input type="text"
class="timepicker"
id="t1"
name="startTime"
readonly="readonly">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
在 Java 中:
String startTime = request.getParameter("startTime");
DateTimeFormatter formatterTime1 = DateTimeFormatter.ofPattern("hh:mm a", Locale.US);
LocalDateTime localStartTime = LocalDateTime.parse(startTime, formatterTime1);
Run Code Online (Sandbox Code Playgroud)
例外:
java.time.format.DateTimeParseException: Text '08:00 am' could not be parsed at index 6
Run Code Online (Sandbox Code Playgroud)
即使我尝试硬编码:
String …Run Code Online (Sandbox Code Playgroud) 我使用的 jQuery Timepicker: http: //timepicker.co/
我想要实现的目标:
$('#t1').timepicker({
timeFormat : 'hh:mm a',
interval : 30,
minTime : '8',
maxTime : '11:00 PM',
startTime : '08:00 AM',
dynamic : false,
dropdown : true,
scrollbar : true
});
$('#t1')
.timepicker('option', 'change', function(time) {
$('#t2').timepicker('option', 'minTime', time);
$('#t2').timepicker('setTime', time);
});
$('#t2').timepicker({
timeFormat : 'hh:mm a',
interval : 30,
maxTime : '11:00 PM',
startTime : '08:00 AM',
dynamic : false,
dropdown : true,
scrollbar : true
});
Run Code Online (Sandbox Code Playgroud)
现在一切都很顺利,除了增加 …
尝试使用链接中第一个答案中的代码(由 Kampai 提供): How to use UIAlertController to replace UIActionSheet?
但是,在我的代码中甚至没有调用完成处理程序。
按下两个按钮后可以解除警报操作表,但完成处理程序内部没有任何工作。知道可能是什么问题吗?我是使用完成处理程序的新手,并试图在网上找到答案,但很少有人遇到与我相同的问题。
- (IBAction)takePhotoButtonPressed:(UIButton *)sender {
pressedButtonTagNumber = sender.tag;
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
// Cancel button tappped
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Take a Photo" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSLog(@"!");
// Take a Photo button tapped
[self dismissViewControllerAnimated:YES completion:^{
NSLog(@"0"); // NOT CALLED
// Initialize UIImagePickerController
UIImagePickerController *takePhotoImagePickerController = [[UIImagePickerController alloc] init]; takePhotoImagePickerController.delegate = self;
takePhotoImagePickerController.allowsEditing = YES; …Run Code Online (Sandbox Code Playgroud) objective-c uiviewcontroller ios completionhandler ios-camera
java ×2
javascript ×2
callback ×1
dao ×1
datetime ×1
hibernate ×1
hql ×1
ios ×1
ios-camera ×1
java-8 ×1
jquery ×1
mongodb ×1
mongoose ×1
node.js ×1
objective-c ×1
sql ×1
time ×1
timepicker ×1