hibernate

Hibernate: Generate Statistics

So in my persistence.xml I turned on hibernate.generate_statistics. <property name="hibernate.generate_statistics">true</property> My question is.. how do I access them? Where do the statistics go? ...

"Cached Item Was Locked" causing Select Statement in Hibernate

I am having trouble with getting some caching to work with hibernate exactly the way I would like. I created some example code to replicate this problem I am having. I have one object that contains instances of itself. For instance, a Part that is made up of more Parts. I really need to minimize the select statements that Hibernat...

Does Hibernate EntityManager include Core?

I'm using Hibernate's implementation of JPA. My Maven pom.xml references hibernate-entitymanager. My question is, does Hibernate EntityManager (called "Standard Java Persistence API for Java SE and Java EE" on Hibernate's home page) depend on or use the Hibernate Core code? I've discovered a bug with Hibernate that is documented and fix...

Hibernate Core daily/weekly build Maven repository

I'm looking for a Maven repository that contains daily or weekly builds of Hibernate Core. More specifically I'm trying to get a hibernate-core build that contains a bug fix which was checked-in on December 9, 2008. Unfortunately the most recent hibernate-core is 3.3.1GA built during September, 2008. ...

Case insensitive search in grails

I am developing grails application which uses file searching.For that I wrote the following code. This code works and it is gives the results with case sensitive.But I want to search files without case sensitive. def criteria = FileDomain.createCriteria() def results = criteria { and { like('user', User.findById(session?.user...

What is your favourite Hibernate trick?

What is your favourite Hibernate trick? ...

Hibernate tutorials

Let's say that I'm new to Hibernate, is there a way to get my skills up to speed? Are there any good tutorials? ...

Can Hibernate be used in performance sensitive applications?

I'm seeing performance problems with retrieving multiple instances of objects that have many relationships with other objects. I'm using Spring and Hibernate's JPA implementation with MySQL. The issue is that when executing a JPA query, Hibernate does not automatically join to other tables. This results in n*r + 1 SQL queries, where n is...

Querying on collection of strings with NHibernate

Hi, I have an "Item" class, and this class has a collection "Tags". Item IList<string> Tags; my DB looks like this: Items Id Tags ItemId TagName I am trying to get all Items which have the tags "x" and "y". How can I do this with NHibernate (preferably with criteria API)? Is it even possible? Thanks. EDIT: can I do...

How to find a JNDI resource inside the hibernatetool Ant task

I want to generate my database schema with Ant. I am using hbm2ddl task. I am using Hibernate with JNDI. My hibernate.cfg.xml looks like: <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt; <hibernate-config...

Hibernate Detached Criteria

I have a DetachedCriteria which I am using to search a table based on a name field. I want to make the search case-insensitive, and am wondering if there is a way to do this without using HQL. Something like: private void searchByFullName(DetachedCriteria criteria, String searchCriteria) { criteria.add(Restrictions.like("fullName", "%"...

Hibernate <generator class="" > When is it best to use what?

I am relatively new with Hibernate. I used Persistence and Toplink prior to this but didn't help too much when learning Hib. When I define my entity classes, specifically the id attributes,I find myself not knowing which values to use. Obviously theres different situations that call for different values. What do some of these values mean...

Hibernate: Retrieve rows that are not joined

I have two tables joined together with entities like this (entities anonymized, and trimmed of irrelevant properties): Email - Email_ID - Title - Body (hibernate uses a Body_ID field here) Body - Body_ID - Body_Text I'd like to retrieve all Email entries that do not have an associated Body row (ie, Body_ID is null). What HQL wou...

How do you manage Hibernate's zillion JAR files

For my previous employer I've worked with Hibernate, and now that I'm in a small startup I would like to use it again. However, downloading both the Hibernate core and the Hibernate annotations distributions is rather painful, as it requires putting a lot of JAR files together. Because the JARs are split up into categories such as "requi...

Hibernate: Is it okay to not bind SessionFactory to a JNDI name?

There is a way to set the JNDI name of a SessionFactory in the hibernate.cfg.xml file. However, if I'm not explicitly using JNDI lookup to get my SessionFactory at all in my web app, is it okay to NOT give it a JNDI name? The reason I ask is that if I didn't set up my JNDI name, my JUnit tests will run fine. But if I do set it up by onl...

Saving a XML-Document in a Database (Combination of Hibernate and JAXB) in Java

I am looking for a solution to save a XML-File in a database using Hibernate. The problem is, that the structure of the XML-file is different to the Hibernate-beans. I'm trying to use JAXB to serialize the XML-content to the Hibernate beans. Please imagine the following scenario: There is this xml file: <root> <general> ...

OSGi + Hibernate

Instead of having database actions scattered in four (osgi) bundles, all doing there slightly different things. I want to create a (simple) OSGi bundle that is responsible for all persistance issues. I feel that this is not as simple as it sounds because of the "unique classloader per bundle" thing. So what I really would appreciate is ...

Oracle Deadlock when Hibernate application loading data for readonly use

We are experiencing an Oracle Deadlock (org.hibernate.util.JDBCExceptionReporter - ORA-00060: deadlock detected while waiting for resource) error. It has been suggested that the issue is with a process that is performing readonly operations using Hibernate while another process is performing an update on the same row. The readonly proc...

SQL IN clause slower than individual queries

I'm using Hibernate's JPA implementation with MySQL 5.0.67. MySQL is configured to use InnoDB. In performing a JPA query (which is translated to SQL), I've discovered that using the IN clause is slower than performing individual queries. Example: SELECT p FROM Person p WHERE p.name IN ('Joe', 'Jane', 'Bob', 'Alice') is slower than fo...

NHibernate Single Table Inheritance

I'm having trouble setting up a role based structure using inheritance and NHibernate. Basically I would like to have an abstract class called ObjectInRole. This class (and corresponding database table) contains a RoleId, an ObjectId, and an ObjectType (this would be the discriminator column). The discriminator column would be the obj...