hibernate-4.x

How to create a generic entity model class that supports generic id including auto generated ids?

限于喜欢 提交于 2019-11-30 09:37:33
I have three kinds of primary keys for tables: INT auto generated primary key which use AUTO_INCREMENT capacity from database vendor (MySQL) CHAR(X) primary key to store a user readable value as key (where X is a number and 50 <= X <= 60) Complex primary keys, composed by 2 or 3 fields of the table. Also, there are some group of fields that may be present (or not): version, INT field. createdBy, VARCHAR(60) field, and lastUpdatedBy, VARCHAR(60) field (there are more fields but these covers a basic example). Some examples of above: Table1 id int primary key auto_increment version int value char

Hibernate event listeners for JPA callbacks

烈酒焚心 提交于 2019-11-29 14:12:35
How can I enable the Hibernate event listeners, that handle JPA callbacks? Currently I am using using Hibernate 4 with SessionFactory configuration, but JPA callbacks are not running properly, when I persist an object. Any suggestion are most welcome. Source code Temp Entity class: package com.esp.entity; import javax.persistence.Entity; import javax.persistence.EntityListeners; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.PostLoad; import javax.persistence.Table; import com.esp.aaa.TempVal; @Entity @EntityListeners(value=TempVal.class) @Table

Exception in GWT Dev Mode + Spring 3.1 + Hibernate 4.0.1

纵饮孤独 提交于 2019-11-28 08:38:16
I have a GWT+Hibernate+JPA+Spring configuration file which is OK with Spring 3.0.x + Hibernate 3.6.x. When I upgraded to Spring 3.1 and Hibernate 4.0, the following exception is thrown: Is there any known incompatibility withe Hibernate 4 and Spring 3.1? org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [META-INF/application-context.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: myPu] Unable to build EntityManagerFactory at org

Hibernate event listeners for JPA callbacks

十年热恋 提交于 2019-11-28 08:10:00
问题 How can I enable the Hibernate event listeners, that handle JPA callbacks? Currently I am using using Hibernate 4 with SessionFactory configuration, but JPA callbacks are not running properly, when I persist an object. Any suggestion are most welcome. Source code Temp Entity class: package com.esp.entity; import javax.persistence.Entity; import javax.persistence.EntityListeners; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.PostLoad; import

“Found: bit, expected: boolean” after Hibernate 4 upgrade

最后都变了- 提交于 2019-11-28 06:16:19
I'm trying to upgrade from Hibernate 3.6.5 to 4.0 (and from Spring 3.0.5 to 3.1 which is required for Hibernate 4 support). Now, with both MySQL and HSQL, I'm running into this problem with persistent boolean fields: Caused by: org.hibernate.HibernateException: Wrong column type in PUBLIC.PUBLIC.EVENT for column Checked. Found: bit, expected: boolean at org.hibernate.mapping.Table.validateColumns(Table.java:282) at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1268) at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155) at org.hibernate.internal

org.hibernate.HibernateException: No Session found for current thread

♀尐吖头ヾ 提交于 2019-11-27 18:21:51
I'm getting the above exception with Spring3 and Hibernte4 The following is my bean xml file <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0

No Session found for current thread (Spring 3.1.X and Hibernate 4)

血红的双手。 提交于 2019-11-27 12:49:18
I'm trying to set up my project using Spring 3.1 and Hibernate 4. I've been following some tutorials online. I'm getting a strange error that according to the spring forums should have been fixed with Spring 3.1. Spring Bug Tracker When my service calls getCurrentSession() , it throws the following exception: org.hibernate.HibernateException: **No Session found for current thread**] with root cause org.hibernate.HibernateException: No Session found for current thread at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:97) at org.hibernate

How to start spring-boot app without depending on Database?

被刻印的时光 ゝ 提交于 2019-11-27 02:53:08
I am using "Spring-boot + Hibernate4 + mysql" for my application. As part of which I have a requirement where my sprint-boot app should be able to start even when database is down. Currently it gives the below exception when I try to start my spring boot app without DB being up. I researched a lot and found out that this exception has to do with hibernate.temp.use_jdbc_metadata_defaults property. I tried setting this in "application.yml" of spring boot but this property's value is not being reflected at runtime. Exception Stack Trace: 2014-05-25 04:09:43.193 INFO 59755 --- [ main] o.hibernate

Exception in GWT Dev Mode + Spring 3.1 + Hibernate 4.0.1

本小妞迷上赌 提交于 2019-11-27 02:26:43
问题 I have a GWT+Hibernate+JPA+Spring configuration file which is OK with Spring 3.0.x + Hibernate 3.6.x. When I upgraded to Spring 3.1 and Hibernate 4.0, the following exception is thrown: Is there any known incompatibility withe Hibernate 4 and Spring 3.1? org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [META-INF/application-context.xml]: Invocation of init method failed; nested exception is javax

“Found: bit, expected: boolean” after Hibernate 4 upgrade

可紊 提交于 2019-11-27 01:15:45
问题 I'm trying to upgrade from Hibernate 3.6.5 to 4.0 (and from Spring 3.0.5 to 3.1 which is required for Hibernate 4 support). Now, with both MySQL and HSQL, I'm running into this problem with persistent boolean fields: Caused by: org.hibernate.HibernateException: Wrong column type in PUBLIC.PUBLIC.EVENT for column Checked. Found: bit, expected: boolean at org.hibernate.mapping.Table.validateColumns(Table.java:282) at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1268) at org