小编Art*_*oly的帖子

如何在org.springframework.dao.DataIntegrityViolationException中获取约束名称?

在我的应用程序中,当提出违规密钥时,我想获得约束名称,但我找不到任何获取此信息的方法."getMessage()"返回的消息非常概括,我需要有关错误的更多信息,以便向最终用户发出可自定义的错误消息.

堆栈跟踪:

84732 [http-8080-1] WARN  org.hibernate.util.JDBCExceptionReporter  - SQL Error: 0, SQLState: 23505
84732 [http-8080-1] ERROR org.hibernate.util.JDBCExceptionReporter  - ERROR: duplicate key value violates unique constraint "ix_tb_oferta_vaga"
  Detalhe: Key (cd_pj, cd_curso)=(680, 29) already exists.
187405 [http-8080-1] WARN  org.hibernate.util.JDBCExceptionReporter  - SQL Error: 0, SQLState: 23505
187405 [http-8080-1] ERROR org.hibernate.util.JDBCExceptionReporter  - ERROR: duplicate key value violates unique constraint "ix_tb_oferta_vaga"
  Detalhe: Key (cd_pj, cd_curso)=(680, 29) already exists.
Run Code Online (Sandbox Code Playgroud)

getMessage():

could not insert: [br.gov.ce.seduc.estagio.model.bean.OfertaVaga]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [br.gov.ce.seduc.estagio.model.bean.OfertaVaga]
Run Code Online (Sandbox Code Playgroud)

谢谢.

亚瑟

java spring hibernate

7
推荐指数
2
解决办法
4274
查看次数

如何使用Spotlight传递参数来运行shell脚本?

有人提到,我们可以使用聚光灯将其改名为形容为"myscript.command"执行shell脚本这里.但是从Spotlight调用它时是否可以将参数传递给脚本?

例如:

脚本myscript.command:

#!/bin/bash
echo "Parameter: " $1
Run Code Online (Sandbox Code Playgroud)

在Spotlight上:

myscript.command test
Run Code Online (Sandbox Code Playgroud)

输出:

(...)
Parameter: test
(...)
[Process completed]
Run Code Online (Sandbox Code Playgroud)

macos shell spotlight

6
推荐指数
1
解决办法
849
查看次数

标签 统计

hibernate ×1

java ×1

macos ×1

shell ×1

spotlight ×1

spring ×1