hibernate-4.x

Org.hibernate.HibernateException: createQuery is not valid without active transaction

此生再无相见时 提交于 2019-12-06 09:29:42
Following this question , I am trying to add Hibernate 4.3.8.Final to Spring 4.1.5.RELEASE; but - The code throws an exception as following and at times throws - an exception that it cannot find entity class of hibernate (com.myproject.model.MyTable) although the class exists and is located in com.myproject.model package. StackTrace org.hibernate.HibernateException: createQuery is not valid without active transaction at org.hibernate.context.internal.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:352) at com.sun.proxy.$Proxy40.createQuery(Unknown

Spring4 + Hibernate4 + JTA Write Operations Fail

杀马特。学长 韩版系。学妹 提交于 2019-12-06 08:36:30
I am migrating a legacy Spring 3, Hibernate 3, JTA on JBoss 5 application to the latest versions (Spring 4.1.0.RELEASE, Hibernate 4.3.6.Final, JBoss Wildfly 8.1). It seems that Spring 4.1.0.RELEASE and Hibernate 4.3.6.Final do NOT work together in supporting transactions for write operations with the LocalSessionFactoryBean and the HibernateTransactionManager as configured below. Read-only get operations appear to be working ok. To migrate, org.springframework.orm. hibernate3 .support.HibernateDaoSupport has been updated to org.springframework.orm. hibernate4 .support.HibernateDaoSupport. The

Hibernate 4.3, when building SessionFactory why do we have to supply the properties twice?

允我心安 提交于 2019-12-06 04:26:33
Using the Hibernate 4.3.5 when you want to create a SessionFactory (e.g. unit testing) you will have to supply the properties twice: Once for configuration Second time, when applying settings to the service registry builder The example looks like: Properties properties = new Properties(); properties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); properties.put("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver"); properties.put("hibernate.connection.url", "jdbc:hsqldb:mem:test"); properties.put("hibernate.connection.username", "sa"); properties.put("hibernate

Hibernate 4 Annotation Configuration

风流意气都作罢 提交于 2019-12-06 00:26:51
问题 I'm trying to use Hibernate 4 with annotations only, and a hibernate.cfg.xml file. I've made my own annotation and am using reflection to add this to the configuration. I'm able to use Hibernate 4 in this manner fine, but my configuration is being built using a deprecated method. final Configuration configuration = new Configuration(); final Reflections reflections = new Reflections(Item.class.getPackage().getName()); final Set<Class<?>> classes = reflections.getTypesAnnotatedWith(Entity

Spring boot Hibernate error java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;

落爺英雄遲暮 提交于 2019-12-05 20:42:12
I am doing a prototype using Spring Boot on an existing project with many Hibernate dependencies. I am trying to define a custom LocalEntityManagerFactoryBean and it is here that I get this error: java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey; I have tried updating my hibernate versions (could not use all latest versions due to project backward compatibility causing many other compile errors) but with the following hibernate dependency graph could get it to compile but still get this runtime dependency error. When I searched for this error

JPA and Hibernate proxy behavior

筅森魡賤 提交于 2019-12-05 01:58:01
问题 i tried to observe JPA2 / Hibernate4 proxy behavior below, // Circular entity with lazy loading: @Entity public class Employee { @Id@Generated int id; String name; @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) Employee boss; public String toString() { return id + "|" + name + "|" + boss; } //getters and setters ... } // Persist entities: // Outer entity: Employee employee = new Employee(); employee.setName("engineer"); // Inner entity: Employee boss = new Employee(); boss

Null values are insering in data base using Struts2 and hibernate

拟墨画扇 提交于 2019-12-04 17:16:24
I am using struts2 and Hibernate integration application to insert values in database. But after inserting values from form filed only null value is saving in database; this is my form jsp file employee.jsp <%@ taglib uri ="/struts-tags" prefix="s"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <s:form action="employee" method="post"> <s:textfield name ="name" label="ENTER your name"/> <s:textfield name="address" label="Enter Address"/> <s:submit label="submit">submit</s:submit> </s:form> </body> </html>

Grails Hibernate4 upgrade errors on getGeneratedKeys()

余生颓废 提交于 2019-12-04 16:48:48
问题 I'm upgrading to the Hibernate4:4.3.5.3 plugin for Grails 2.3.9 . However, I'm getting an error: getGeneratedKeys() support is not enabled I haven't been able to find any configuration details on how to enable this. 回答1: I just found that you can configure it under DataSource.groovy in the hibernate{...} block hibernate{ jdbc.use_get_generated_keys = true } 来源: https://stackoverflow.com/questions/24050291/grails-hibernate4-upgrade-errors-on-getgeneratedkeys

What does HHH000387 Hibernate warning mean?

与世无争的帅哥 提交于 2019-12-04 09:57:55
问题 I have just updated to Hibernate 4.0 and am seeing the warning message : HHH000387: ResultSet's statement was not registered in my log files. What does this mean, and should I be worried? 回答1: I would not worry too much. In any case it looks like it is not in API's users hands to avoid this message. Logging is done in the org.hibernate.engine.jdbc.internal.JdbcResourceRegistryImpl. According documentation: The main function of a JdbcResourceRegistry is to make sure resources get cleaned up.

Migrate from Hibernate 4.3.6 to Hibernate 5

风格不统一 提交于 2019-12-04 06:38:58
I have old project where I use Date from Java API, and I want change this to new Java 8 Date API to LocalDateTime . I read that Hibernate version before 5 does not support the new Java 8 Date API, and I decided to migrate from Hibernate 4.3.6 to 5. In old project version everything works fine, but when I change the Hibernate version, I get error when I try start my application: wrz 21, 2015 7:14:23 PM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library