postgresql的ALTER常用操作
647 2023-04-02 01:39:44
SEVERE: Servlet.service() for servlet [calzoneServlet] in context with path [/calzone] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Name must not be null or empty!; nested exception is java.lang.IllegalArgumentException: Name must not be null or empty!] with root cause
java.lang.IllegalArgumentException: Name must not be null or empty!
在这个项目中,所有模型都使用hibernate和jpa映射到数据库.前端使用Twitter Bootstrap(带弹簧形式验证等)
错误发生在程序的不同部分,其中一个是激活用户帐户的控制器(下面的代码).对我来说,这看起来像某种验证错误,但它不是我曾经定义的错误.由于我无法确定错误的确切位置,因此我将仅提供下面的控制器.值得注意的是,activateUser方法中的任何调试消息(无论是通过记录器还是仅仅是一个普通的旧sysout)都不会显示.
所有依赖项(pom.xml)都可以在这里找到:http://pastebin.com/fs7SG0W2
Web.xml:http://pastebin.com/vAJh29Aw
整个堆栈跟踪可以在这里找到:http://codepad.org/p0Yt5hi2(在键盘上,因为它有水平滚动)
有没有人知道为什么会发生这种错误,或者有任何线索可以找出为什么会发生这种错误?
@Controllerpublic class ActivateAccountController { final Logger logger = LoggerFactory.getLogger(getClass()); @RequestMapping(value = "/activate/{keyString}", method = RequestMethod.GET) public String activateUser(@PathVariable String keyString) { ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); KeyService keyService = (KeyService) context.getBean("keyService"); UserService userService = (UserService) context.getBean("userService"); User user; try { logger.error("DID I GET HERE?"); user = keyService.findUserByKey(keyString); } catch (KeyNotFoundException ex) { return "ActivatedNotAccount"; } finally { // Close the application context in every case context.close(); } // Activate the in-memory user userService.activateUser(user); // Delete the key from the database keyService.deleteKey(keyString); // Finally, update the user in the database userService.updateUser(user); logger.info("Acticated user with ID "{}", First name: "{}", Last name: "{}" and username: "{}"", user.getId(), user.getPerson().getFirstName(), user.getPerson().getLastName(), user.getUsername()); return "ActivatedAccount"; }}您的KeyService使用方法findKeyByKeyString()方法调用一些Spring Data JPA存储库.该方法导致Spring Data JPA爆炸,因为缺少某些查询参数.
在org.springframework.data.jpa.repository.query.StringQuery.getBindingFor(StringQuery.java:104)上放置一个条件断点,匹配if!StringUtils.hasText(name)以查看正在发生的事情,或查看findKeyByKeyString()方法.