hibernate-4.x

hiberate 4.3 - entity class instances not returned in list

Deadly 提交于 2019-12-12 03:25:12
问题 I am using Hibernate 4.3.8 without Spring. I am using Hibernate's session API. I have one entity class Category which I have annotated properly with @Entity , @Table , @Id , @Column and so on. I don't use .hbm.xml descriptor files, I just want to use the annotations in my domain/entity java source/class files. 1) OK, I create my hibernate SessionFactory in this way: Configuration configuration = new Configuration().configure(); // configuration.addClass(Category.class);

java.lang.NullPointerException in session factory building hibernate 4

余生颓废 提交于 2019-12-11 10:47:12
问题 I am simply trying to create a session factory object in hibernate 4. It throws null pointer exception while creating session factory object. Hibernate configuration file <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="connection.url">jdbc:oracle:thin:@SHKG9072DB:5030:TMSD10G2<

Grails 2.4.4 DataSource “create-drop” fails to drop all tables having FKs

半腔热情 提交于 2019-12-11 09:28:08
问题 Using Grails 2.4.4, and have ported my domain classes from 2.2.0. There's a problem I am facing w.r.t "create-drop" config of DataSource, using MySQL as the datasource. Whenever I issue a grails stop-app command, out of total 35 tables, 22 tables are left in the schema. After enabling debug mode for Hibernate classes, and at the end of the stop-app process, it was generating drop table if exists <tablename> for all 35 tables, but no error/confirmation was there in the logs whether the drop

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

☆樱花仙子☆ 提交于 2019-12-10 10:49:17
问题 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

Hibernate 4 ClassCastException on LAZY loading while EAGER works fine

别说谁变了你拦得住时间么 提交于 2019-12-09 16:24:17
问题 I have the following JOINED inheritance root entity for geographic areas (like continents, countries, states etc.): @Entity @Table(name = "GeoAreas") @Inheritance(strategy = InheritanceType.JOINED) public abstract class GeoArea implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column protected Integer id; @Column protected String name; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "parent_id", referencedColumnName = "id") protected GeoArea parent; ...

Hibernate 4 Error on sessionFactory creation

那年仲夏 提交于 2019-12-08 03:12:27
问题 During upgrading to Hibernate 4 from its 3.v, I run into this problem occurred at the TC starting up. ... Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/app-config.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506) at org.springframework.beans

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

江枫思渺然 提交于 2019-12-08 00:41:12
问题 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

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

我的未来我决定 提交于 2019-12-07 19:44:31
问题 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

Hibernate 4 Error on sessionFactory creation

大憨熊 提交于 2019-12-06 16:54:05
During upgrading to Hibernate 4 from its 3.v, I run into this problem occurred at the TC starting up. ... Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/app-config.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans

Null values are insering in data base using Struts2 and hibernate

此生再无相见时 提交于 2019-12-06 11:09:11
问题 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=