草庐IT

hibernate3

全部标签

java - c3p0 在 awaitAvailable 中挂起并 hibernate

我的控制台应用程序在执行期间挂起。这是我的配置:cfg.setProperty("hibernate.connection.driver_class","com.mysql.jdbc.Driver");cfg.setProperty("hibernate.connection.url","jdbc:mysql://localhost:3306/db?user=db&password=db");cfg.setProperty("hibernate.connection.username","db");cfg.setProperty("hibernate.connection.passwo

java - Hibernate 是否会在死锁时自动重启事务?

关于这个话题已经有很多文章了:RestartingtransactioninMySQLafterdeadlockDeadlockfoundwhentryingtogetlock;tryrestartingtransaction:@RetryTransactionMySQLJDBC:IsthereanoptionforautomaticretryafterInnoDBdeadlock?WorkingaroundMySQLerror"Deadlockfoundwhentryingtogetlock;tryrestartingtransaction"...更多我发现最后接受的答案特别有趣:I

java - MySQL 支持的基于 Hibernate 的 Java Servlet 应用程序中的 Hibernate 通信链路故障

让我描述一下我的问题-我有一个Java应用程序-Hibernate作为MySQL上的数据库接口(interface)层。我在我的应用程序中收到通信链接失败错误。此错误的发生是一个非常特殊的案例。我得到这个错误,当我让mysql服务器无人看管超过大约6小时(即,当超过大约6小时没有向MySQL发出查询时)。我在下面粘贴了一个顶级“异常”级别的描述,并添加了一个pastebin链接以获取详细的堆栈跟踪描述。javax.persistence.PersistenceException:org.hibernate.exception.JDBCConnectionException:Cannot

java - Springframework.dao.InvalidDataAccessResourceUsageException hibernate .SQLGrammarException MySQLSyntaxErrorException

我正在努力寻找这里出了什么问题。我正在处理一个模式:它有一个Story实体(表:故事),我正在尝试向这个stories.portofoliotype_id添加一列,这是一个外国PortfolioType(表:portofoliotypes)的键。我想我的注释是正确的,我什至记录了MySQL查询,它得到以下查询,这是正确的。我正在尝试创建一个新故事:插入故事(backlog_id,描述,iteration_id,名称,parent_id,portfoliotype_id,state,storyPoints,storyValue,treeRank)值(11,null,null,“调试故事”

java - 如何在Hibernate中使用ifnull(max(Id),0)等mysql语法

貌似Hibernate没有这个语法吧?publicintMaxIdenx(){intmax=0;Stringhql="selectifnull(max(empId),0)fromEmp";Queryquery=session.createQuery(hql);ListcurrentSeq=query.list();if(currentSeq==null){returnmax;}else{max=(Integer)currentSeq.get(0);returnmax+1;}} 最佳答案 这有一些问题......IFNULL在HQL(

java - [ hibernate ]错误 : entity class not found:

我厌倦了这个很长一段时间。我不知道是什么导致了这个错误。这是我的文件:Uzytkownik.hbm.xmlhibernate.cfg.xml:org.gjt.mm.mysql.Driverrootjdbc:mysql://localhost/sprawozdaniarootorg.hibernate.dialect.MySQL5Dialect我使用的是mysql5.5。我收到以下错误:Exceptioninthread"main"java.lang.ExceptionInInitializerErroratcom.vaannila.util.HibernateUtil.(Hiberna

java - Spring 配置的 Hibernate 方言问题

我使用由Spring配置的Hibernate(通过JPA),当我启动我的应用程序(war部署在Tomcat6上)时,我收到此错误:org.hibernate.HibernateException:Connectioncannotbenullwhen'hibernate.dialect'notset这看起来很奇怪,因为我将hibernate方言设置如下:p:databasePlatform="org.hibernate.dialect.MySQL5Dialect有关更多信息,请参阅我的完整applicationContext.xml:因此,我决定在META-INF/persistence

java - Hibernate OneToOne延迟加载和级联

这就是我想要做的。创建与child具有OneToOne关系的parentparent必须使用延迟加载来获取child如果parent被移除,child也被移除如果child被移除,parent应该不会受到影响级联更新和删除必须翻译成DDL父类@OneToOne(mappedBy="parent",cascade=CascadeType.ALL)publicChildgetChild()子类@OneToOne(fetch=FetchType.LAZY)@OnDelete(action=OnDeleteAction.CASCADE)@JoinColumn(name="parent_id")

mysql - 我可以对未映射到表的实体使用 hibernate 查询语言吗?

以下是我用来检索给定酒店的HolidayPackages的mySQL查询:SELECTpkg.idHolidayPackage,pkg.nameFROMholidaypackagepkgINNERJOINholidaypackagehotelhphONpkg.idHolidayPackage=hph.idHolidayPackageINNERJOINhotelroomhrONhr.idHotelRoom=hph.idHotelRoomWHEREhr.idHotel=1;我有POJO映射:假期套餐酒店酒店房间我没有HolidayPackageHotel的POJO。Isthereanywa

java - Hibernate、MySQL、Enum 和 NULL

我将MySQL数据库与Hibernate一起使用,并且某些枚举字段允许NULL或空值。一切都很好,直到进行查询并且Hibernate尝试将空值映射到定义的Enum上。我无法在Enum中定义一个可行的值,因为Enum确实允许空格。枚举类:privateenumObjType{itemA,itemB,NULL}它采用NULL作为成员,但这没有帮助。我是EEJava的新手,非常感谢任何帮助。谢谢 最佳答案 您可以向您的枚举添加一个unknown或default或invalid值,如果它是null,它将被映射或空格packagecom.te