hibernate

ORM solutions (JPA; Hibernate) vs. JDBC

I need to be able to insert/update objects at a consistent rate of at least 8000 objects every 5 seconds in an in-memory HSQL database. I have done some comparison performance testing between Spring/Hibernate/JPA and pure JDBC. I have found a significant difference in performance using HSQL.. With Spring/Hib/JPA, I can insert 3000-400...

Mapping multi-Level inheritance in Hibernate

Currently I have a structure like this: A | +--B | +--C It's mapped with one table per subclass using joined tables. For historic reasons I also use a discriminator, so the current situation is as described in Section 9.1.3 of the Hibernate manual. Question: How do I extend the mapping for a structure like this: A | +--B | | | D |...

Configuring Compass with Annotated Hibernate

I'm using Hibernate for a Java-based Web Application and want to add full-text search via Compass. Compass is supposed to support that, but fails to provide any useful Getting Started guide. I could figure out that I have to annotate my Entities with @Searchable and the various @SearchableXXX variations and accessing Compass in my servi...

What are "SQL-Hints"?

I am an advocate of ORM-solutions and from time to time I am giving a workshop about Hibernate. When talking about framework-generated SQL, people usually start talking about how they need to be able to use "hints", and this is supposedly not possible with ORM frameworks. Usually something like: "We tried Hibernate. It looked promising...

How do you create a Distinct query in HQL

Is there a way to create a Distinct query in HQL. Either by using the "distinct" keyword or some other method. I am not sure if distinct is a valid keywork for HQL, but I am looking for the HQL equivalent of the SQL keyword "distinct". ...

Querying ManyToMany relationship with Hibernate Criteria

I'm not sure how to describe this problem, so I think an example is the best way to ask my question: I have two tables with a manyToMany relationship: DriversLicence <-> LicenceClass LicenceClass is things like "Car", "Motorbike", and "Medium Rigid". Using Hibernate Criteria, how can I find all licences that have both "Car" and "Moto...

NHibernate architecture?

I'm planning to implement my next project (asp.net MVC) by using nhibernate as an ORM. Since I do not have experience with nhibernate, I wondering how I should organize dependencies between different projects. I've seen something like this as a recommended approach: UI depends on Model, Repositories and NHibernate Repositories depend o...

Spring configuration error

My spring-context file is shown below. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jms="http://www.springframework.org/schema/jms" xmln...

Converting SQL to HQL

I'm trying to convert the below SQL query to HQL and am having a few issues. A straight line by line conversion doesn't work, I am wondering if I should be using an Inner Join in the HQL? SELECT (UNIX_TIMESTAMP(cosc1.change_date) - UNIX_TIMESTAMP(cosc2.change_date)) FROM customer_order_state_change cosc1 LEFT ...

What's the best way to share business object instances between Java web apps using JBoss and Spring?

We currently have a web application loading a Spring application context which instantiates a stack of business objects, DAO objects and Hibernate. We would like to share this stack with another web application, to avoid having multiple instances of the same objects. We have looked into several approaches; exposing the objects using JMX...

Session management using Hibernate in a Swing application

How do you do your Hibernate session management in a Java Desktop Swing application? Do you use a single session? Multiple sessions? Here are a few references on the subject: http://www.hibernate.org/333.html http://blog.schauderhaft.de/2008/09/28/hibernate-sessions-in-two-tier-rich-client-applications/ http://in.relation.to/Bloggers...

Hibernate Transaction Manager Issue

I am new to Hibernate and attempting to run a java/spring example that retrieves data from a table in MS SqlServer. Everytime I try to run the program, the data source loads ok. But when spring tries to load the session facotry it gets the following error: Exception in thread "main" org.springframework.beans.factory.BeanCreationExcepti...

Hibernate/JPA Annotations -- Unknown Entity

An application that has been working well for months has stopped picking up the JPA @Entity annotations that have been a part of it for months. As my integration tests run I see dozens of "org.hibernate.MappingException: Unknown entity: com.whatever.OrderSystem" type errors. It isn't clear to me what's gone wrong here. I have no hiber...

Why does Hibernate/JDBC/MySQL drop connections after a day or so?

I have several server processes that once in a while respond to messages from the clients and perform read-only transactions. After about a few days that the servers are running, they stop working correctly and when I check it turns out that there's a whole bunch of messages about the connection being closed. When I checked it out, it ...

"No suitable driver" problem with Hibernate3, PostgreSQL 8.3 and Java 5

Hi. Does anybody know what's going on here: I run hibernate 3.2.6 against a PostgreSQL 8.3 (installed via fink) database on my Mac OS X. The setup works fine when I use Java 6 and the JDBC 4 driver (postgresql-8.3-603.jdbc4). However, I need this stuff to work with Java 5 and (hence) JDBC 3 (postgresql-8.3-603.jdbc3). When I change the...

With wicket where does hibernate.cfg.xml file go?

I'm new to Wicket and Hibernate and can't get past the "org.hibernate.HibernateException: /hibernate.cfg.xml not found" error. I've put that file in every location imagineable but I'm still stuck. Where exactly does that file go and/or am I missing a wicket file config setting somewhere? ...

Which book would you recommend for entering into the J2EE world?

I was wondering if there are any books you would recommend for learning J2EE. I have done a lot of OO programming in the past (mainly java, C# and C++), but I'm now entering the world of J2EE with my job:: "struts 2, hibernate, spring, etc.." so many different libraries, plugins and ways to configure eclipse or netbeans... I feel a bit o...

Hibernate JPA Sequence (non-Id)

Is it possible to use a DB sequence for some column that is not the identifier/is not part of a composite identifier? I'm using hibernate as jpa provider, and I have a table that has some columns that are generated values (using a sequence), although they are not part of the identifier. What I want is to use a sequence to create a new...

merge with hibernate causing error with dirty objects

I'm using Hibernate with Spring in my application. I have been consistently using detached objects and reattaching them whenever I need to make calls to the database. I'm using hibernate template to take care of managing the connections for me. My data structure is as follows: classA: <one-to-many name="classB" inverse="true" casca...

NHibernate: accessing configuration properties (Sql dialect) at runtime

Hello, I would like to retrieve at runtime the values for the "dialect" and "connection.driver_class" properties specified in the configuration file. Do you know how to do that? Many thanks, Nicola ...