gpt4 book ai didi

hibernate - 捕获 hibernate 异常 SqlExceptionHelper

转载 作者:行者123 更新时间:2023-12-02 23:37:55 26 4
gpt4 key购买 nike

当列与数据库列不匹配时,我们在日志中收到如下异常。但它并没有抛出异常。我什至保留了 try catch。我怎样才能捕获异常?

警告 2015-11-04 17:25:44,055 [http-apr-8080-exec-4][SqlExceptionHelper.java:144]:SQL 错误:904,SQLState:42000错误2015-11-04 17:25:44,055 [http-apr-8080-exec-4][SqlExceptionHelper.java:146]:ORA-00904:“SH_RATE_DESCRIPTIO”:无效的标识火气

 import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

import com.core.model.entity.ShippingTable;

@Repository("sTableDAO")
public class STableDao {


@PersistenceContext(unitName = "somaUnit")
private EntityManager entityManager;


public STable save(STable sTable) {
try{
sTable = entityManager.merge(sTable);
}catch(Exception e){
e.printStackTrace();
}
return sTable;
}
}

最佳答案

Level.FATAL 甚至吞下了错误日志消息。设置

org.apache.log4j.Logger.getLogger("org.hibernate.engine.jdbc.spi.SqlExceptionHelper")
.setLevel(Level.ALL);

在某个任意类的static初始化 block 中就可以实现这个目的!

关于hibernate - 捕获 hibernate 异常 SqlExceptionHelper,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33521595/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com