hibernate

Problem with "not (a, b) in (select ...)" in JPA query using Hibernate EntityManager

Observation: This is a repost of a question I asked at the Hibernate forum but got no response. I have a simple graph structure like this (in MySQL): create table Node( id int not null auto_increment, name varchar(255), primary key(id) ) engine=InnoDB; create table Edge( source int not null, target int not null, cost...

How to get Hibernate session inside a Hibernate Interceptor?

How to get Hibernate session inside a Hibernate Interceptor? I'm trying to use Hibernate to enforce data access by organization id transparently. I have set a global Filter to filter all queries by organization id. Now, I need to use an Entity interceptor to set Organizational Id on all Entities before Save/Update. The organization id...

Spring and Hibernate, Lazy initiation problem

Hey I am developing an desktop application using Spring and Hibernate, and I have a problem with lazy initiation. I looked in the web and every solution is related to the open session in view pattern, but I can't use this pattern. I've also tried to get the sessionfactory from the HibernateTemplate, but it returns to me a disconnected se...

No Such Method Error when creating JUnit test

I've tried figuring out this problem for the last 2 days with no luck. I'm simply trying to create an annotation based JUnit test using the spring framework along with hibernate. My IDE is netbeans 6.5 and I'm using hibernate 3, spring 2.5.5 and JUnit 4.4. Here's the error I'm getting: Testcase: testFindContacts(com.mycontacts.data.d...

nHibrnate.Search with nHibernate v2

Hi I having trouble getting nHibernate.Search to create an Index. If I use 1.2.1.4 of nHibernate.dll & nHibernate.Search.dll then the index is created correctly and I can inspect it with Luke (a Lucene utility). A segments file is created as well as a Fragments file etc However, when I use v 2 of nHibernate.dll & nHibernate.Search.dll...

What adavantages does HQL have over SQL for Group By queries

I am concentrating this question on 'reporting-type' queries (count, avg etc. i.e. ones that don't return the domain model itself) and I was just wondering if there is any inherent performance benefit in using HQL, as it may be able to leverage the second level cache. Or perhaps even better - cache the entire query. The obvious implied ...

StaleObjectStateException ERROR - please help

Hi, Anyone can point me to the error please? Note: this is a simplified test case extracted from my real app. Thus the weird usage of 3 entity managers and em1.getTransaction().begin(); em1.clear(); em1.close(); at the end of each section. In real app it happens in different times. HibernateUtil is basically copied from the tutorial. ...

Grails, Inserting lots of data using withTransaction results in OutOfMemoryError

I'm using Grails 1.1 beta2. I need to import a large amount of data into my Grails application. If I repeatedly instantiate a grails domain class and then save it, the performance is unacceptably slow. Take for example importing people from a phone book: for (each person in legacy phone book) { // Construct new Grails domain class f...

How to do custom-query based collection mappings in Hibernate?

I have an object that is mapped to have a set of objects, very simple. However, what I really want to do is put some criteria on that mapping. Here's the current mapping: <set name="ops" inverse="true" cascade="all, delete-orphan"> <key column="cityblock_id" on-delete="cascade"/> <one-to-many class="com.tamedtornado....

Double-logging in Hibernate

I have been using Hibernate very successfully, but today I noticed a bizarre phenomenon to do with logging. If I turn on logging (at a "debug" level) for the classes underneath org.hibernate (for instance org.hibernate.SQL or org.hibernate.impl.SessionImpl), I get twice each log line corresponding to those classes. I never see that wit...

Self-referencing updates in HQL

I have the following query in HQL: update ProjectFile pf1 set pf1.validUntil.id =123 where pf1 = ( select pf from ProjectVersion pv, ProjectFile as pf where pf.validFrom.sequence <= pv.sequence and pf.validUntil.sequence >= pv.sequence and pf.state <> 12 and pf.projectVersion.project.id = 1 and pv.project.id = 1 and pv.id = 12 and pf...

Class inheritance with Hibernate and hbm2java

I am generating my domain objects from my hbm files with hbm2java and now I want them to all inherit a base class. This class will have some utility methods for dealing with listeners. It does not really need to be persisted and I am hoping that I would not have to do a hbm file for it since it will be abstract and only have methods. Is ...

How to use CurrentSessionContext/SpringSessionContext along with HibernateDaoSupport to intercept calls to getCurrentSession()

I'm using HibernateDaoSupport in Spring for Spring-Hibernate integration. I need to intercept all getCurrentSession calls and enable a filter and set a filter parameter value. Hibernate supports CurrentSessionContext impls to intercept getCurrentSession calls. Spring provides an implementation of this called SpringSessionContext. But wh...

Configuring Hibernate logging using Log4j XML config file?

I haven't been able to find any documentation on how to configure Hibernate's logging using the XML style configuration file for Log4j. Is this even possible or do I have use a properties style configuration file to control Hibernate's logging? If anyone has any information or links to documentation it would appreciated. EDIT: Just to...

Hibernate question hbm2ddl.auto possible values and what they do

I really want to know more about the update, export and the values that could be given to hbm2ddl.auto. I need to know when to use the update and when not? And what is the alternative? These are changes that could happen over DB: New tables new columns in old tables columns deleted data type of a column changed a type of a column chan...

LazyInitializationException even though openSessionInViewInterceptor

Hello! I have a problem with LazyInitializationException even though I'm using openSessionInViewInterceptor. I've read so many posts about that topic and I've tried three or four different approaches to it. First thing is that I don't want to set to false the lazzy attribute in the Hibernate configuration file. So, I want an actual solu...

com.ibm.websphere.jtaextensions.NotSupportedException thrown under load

Hi All, I have an application containing 4 MDB's each of which receives SOAP messages over JMS from MQ. Once the messages have been received we process the XML into an object model and process accordingly which always involves either loading or saving messages to an Oracle database via Hibernate. Additionally we have a quartz process w...

Hibernate generates invalid SQL query with MySQL

I have the following JPA entity classes (example case). A House belongs on a single Street. A Street has many Houses. @Entity public class House { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) public Integer id; public String name @ManyToOne public Street street; } @Entity public class Street { ...

How do I map a CHAR(1) to a boolean using Hibernate for Java?

How do I map a CHAR(1) to a boolean using Hibernate for Java? ...

Unicode String in Hibernate Queries

In SQL one can write a query that searches for a name of a person like this: SELECT * FROM Person P WHERE P.Name LIKE N'%ike%' This query would run with unicode characters (assuming that the Name column and database were setup to handle unicode support). I have a similar query in HQL that is run by Hibernate (NHibernate). The genera...