hibernate

create a new hibernate session in multi-thread program

How to create a new hibernate session at a new thread ? The SessionFacatory was managed by Spring. ...

NoClassDef for JDBCExceptionHelper in JBoss 5, even if the class DOES exist in lib. Why??

I got this exception while calling a named HQL query in an EJB. I'm quite puzzled though because the app. functions fine with named queries and all. Only when it throws some exception, it can't find the JDBCExceptionHelper. javax.ejb.EJBTransactionRolledbackException: Unexpected Error java.lang.NoClassDefFoundError: org/hibernate/exce...

Is it possible to set aliases to a property within an Embedded as part of a Criteria ?

This is a general purpose question but from my experiences it does not appear to be possible to reference a property belonging to a embedded class within another. Directory Directory parent. Name // embedded String name; i cant seem to be able to create a Query that does find a directory where parent of parent's name is somet...

java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.MethodNode

greetings all, i got this exception in the following method and i don't know why: List<Date> temps = getCurrentSession() .createQuery( "select distinct date(uploadDate) from FileDomain where projectId=:projectId" + " and entityId not in(select fileId from FileVersio...

How to include Hibernate Javadoc in NetBeans?

In netbeans I was looking for a hibernate javadoc option (the code completion is working properly but I was looking for the description of the functions). I got one JAR file for Hibernate Javadoc : hibernate-3.2.2.ga-javadoc.jar but couldn't find a way to include this and make it work in NetBeans. I included the jar file in the Javadoc...

Newbie question on Hibernate... in context of Martin Fowler article.

Hi, In Domain Logic and SQL, Martin Fowler talks about 3 styles of interfacing with a database: Transaction Script Domain Model, and Logic in SQL What I'd like to know is: When employing Hibernate for persistence, which of the above 3 styles is typically used and/or encouraged? Is there any 4th style when using Hibernate? (In co...

java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails

Hi Could someone help me understand that why am I getting the following error when I am trying to persist ServiceProvider entity? java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails (`springmvc/businesslocation`, CONSTRAINT `FK5CB747B5A26ED80E` FOREIGN KEY (`state_id`) REFERENCES `state` (`id`)) at ...

insert statement is not working in hibernate...

I'm using netbeans 6.9 and Hibernate and I'm trying to insert some values in a database (postgres) but I get the following exception: INFO: Not binding factory to JNDI, no JNDI name configured Exception in thread "main" org.hibernate.MappingException: Unknown entity: SELECTPACK.beanClass at org.hibernate.impl.SessionFactoryImp...

Is it possible create column name with white spaces using hibernate?

Hi, I am building data base system for electronic components. Unfortunatly other programs, that will use some of my tables need to have white spaces in column names. Ive tried in my hbm.xml file something like this with property: ... property name="partGroup" column="part group" type="string" ... of course hibernate wont create table...

Hibernate: Query cache never used

Hi, During performing some performance tuning in my application I have noticed, that hibernate query cache is never used. I am quite sure I have it properly set up: hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider hibernate.cache.use_query_cache=true I use setCacheable(true) on queries I want to cache I have set u...

Hibernate and Inheritance (TABLE_PER_CLASS)

Hi, I use Hibernate to persist inherited objects but I got this message when I try to persist objects in database: org.springframework.dao.InvalidDataAccessResourceUsageException: Could not execute JDBC batch update; SQL [update Widget set CONTAINER_ID=? where WIDGET_ID=?]; nested exception is org.hibernate.exception.SQLGrammarExceptio...

JPA, Spring, Hibernate problem with loading entities ManyToMany Assotiation

I'm trying to get data from assotiation N:N, but I receive blank field. There are my Hibernate mapping class: @Entity @Table(name = "companies") public class Company extends NamedEntity { //some_code @ManyToMany( targetEntity = com.hqcargo.shippingstock.domain.CompanyProfile.class, cascade = {CascadeType.ALL, CascadeTy...

How can I force Maven to use Ehcache 2.2.0 with Hibernate 3.3.2GA?

Assuming that the two are compatible, how can I force Maven 2 to use Ehcache 2.2.0 instead of Ehcache 1.2.3 with Hibernate 3.3.2.GA? Essentially, I wish to replace the puzzling and practically cyclic dependency chain Hibernate Ehcache Integration 3.3.2.GA => Ehcache 1.2.3 => Hibernate 3.2.0.cr3 => Ehcache 1.2 with Hibernate Ehca...

Can domain classes be configured to insert a new record instead of updating when saved?

When I change a domain object, rather than updating the database record, I'd like to archive the old record record and create a new one. I'd like to force GORM to do this automatically. For example, if I had this domain class: class User { String username String email Boolean active } then I'd like user.email = email us...

JPA - create-if-not-exists entity?

I have several mapped objects in my JPA / Hibernate application. On the network I receive packets that represent updates to these objects, or may in fact represent new objects entirely. I'd like to write a method like <T> T getOrCreate(Class<T> klass, Object primaryKey) that returns an object of the provided class if one exists in ...

Testing with Spring - Avoiding false positives?

In the spring documentation regarding testing, it states: Avoid false positives when testing ORM code When you test code involving an ORM framework such as JPA or Hibernate, flush the underlying session within test methods which update the state of the session. Failing to flush the ORM framework's underlying sessi...

How to map a read only property backed by a query in Hibernate

I'm wondering how to best implement a property (here, LatestRequest) which is read-only, backed by a query. Here, I have an Export, which can be requested to happen multiple times. I'd like to have a property on the Export to get the latest ExportRequest. At the moment, I've got a many-to-one mapping with a formula, like this: <class ...

How to manage object revisions in Grails?

I need to implement a revision system for articles in my grails web app. After searching grails forum, stackoverflow, grails plugins and googling internet, I have ended up with 3 options: Option 1 - Using the grails Envers plugin (see http://code.google.com/p/grails-envers-plugin/). Has anyone used it successfully? Or using Envers with...

Refreshing entity instance after using merge in hibernate?

Hi there, am using hibernate merge method, to deal with detached instance from entity, and i thought that the return of this method will be a new fetched instance from database as hibernate saveOrUpdate method, but that wasn't the case, and i think it's logic as it's a detached instance, so is there a better way to return the new instan...

Help with HQL query (group by, order by)

I have problem writing HQL to display distinct applicationId with the latest application (newest createDate) for the following data in the table. +---------------+-------------+----------+---------------------+ | applicationId | firstName | lastName | createDate | +---------------+-------------+----------+--------------------...