hibernate

Hibernate/Spring application - export to CSV

I'm writing a web application using Spring/Hibernate that displays a report to a user, I would like to allow the user to export the results to a CSV file. Can anyone suggest an efficient way to output Hibernate query results to a CSV file? Thanks! ...

Hibernate flush doesn't update database

I'm using hibernate to store a set of objects from a web service. As the object are received each I am saving them using hibernate. Receiving the objects is wrapped in a transaction and all the objects appear in the database after the final object is received. I am now trying have each object appear in the database when saved. I've ...

Spring and hibernate.cfg.xml

How do I get Spring to load Hibernate's properties from hibernate.cfg.xml? We're using Spring and JPA (with Hibernate as the implementation). Spring's applicationContext.xml specifies the JPA dialect and Hibernate properties: <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"> <propert...

Hibernate second level cache with Spring

I'm using Spring + JPA + Hibernate. I'm trying to enable Hibernate's second level cache. In my Spring's applicationContext.xml I have: <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop> <prop key="hibernate.cache.provider_configuration_file_resource_path">/ehcache.xml</prop> When I run ...

Multimap in Hibernate

I need a collection that stores entries as key-value pairs (so I can look up values by a key), but I need one that allows multiple values to share the same key using hibernate ...

Which are the required C3P0 settings for hibernate in order to avoid Deadlocks

I use Hibernate together with MySQL 5.1.30. I have the next libraries: c3p0-0.0.1.2.jar mysql-connector-java-5.0.3-bin.jar hibernate3.jar I use a hibernate.cfg.xml for configuration: <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-c...

What are the benefits of session-per-conversation?

Currently I'm using a session-per-request approach to manage Hibernate sessions in a Java web application. I heard the term session-per-conversation thrown around and was wondering what situations it suits and what benefits it can bring over session-per-request? ...

NHibernate Query Help

Hi, I have the following code which works fine. However, I only want to return rows where eventID = 5; Where can I add criteria to this query? tx = session.BeginTransaction(); List<Catergory> Catergories; using (tx) { Catergories = (List<Catergory>)session.CreateCriteria(typeof(Catergory)).AddOrder...

How do I create a NHibernate Mapping file for a multi-value component that is a Unique set of columns?

I'm using Nhibernate and fluent nhibernate to create a mapping file for a domain object (though I don't care if an answer uses fluent nhibernate or xml hbm syntax). And I'm having trouble with figuring out how I specify that a set of columns representing a component within the domain object is unique. Here's the domain object: public ...

how to add fields dynamically when using hibernate

The problem Dynamically add and remove fields to entities on the fly using Hibernate. I m sure this is a common scenario, most enterprise applications will require some level of customization. so what is the best way to do it? also ideally it should not require a recompile and smoothly create/remove the field in the schema and allow ...

JUnit Exception Catching

I am writing a few test cases that depend on the database being available, so on the @Before and @After I open and close the session (Hibernate), as well as start and finish the transaction. Now in the process of development sometimes I get exceptions in the test cases, so the @After is never called and I can't clean up (or rollback the...

Hibernate: Transitive persistance of set of objects in an @ManyToMany relationship

I am trying to map the following: public class Person{ ... @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }) @JoinTable(name = "person_categories", joinColumns = @JoinColumn(name = "personId"), inverseJoinColumns = @JoinColumn(name = "categoryId")) private Set<Category> categories ... } public class Category ...

Hibernate Performance Tweaks

In your experience what are some good Hibernate performance tweaks? I mean this in terms of Inserts/Updates and Querying. ...

How to handle stale connections?

Hi Friends, Ours is a J2EE app, using Struts-EJB-Hibernate on Websphere 6.1 over Mainframe/DB2 backend, that was recently moved to production. We are getting stale connection exception when the user login to the application first time or some times this exception occurs intermittently. on the second try the user able to log in to th...

How to pass an array as parameter from Hibernate to PL/SQL?

I need to pass an array of integers from Hibernate to PL/SQL function. The current solution is the covert the array to a comma separated string and surround it with parenthesis to use it as parameter. This is solution is outlined here. But, this approach doesn't look like a good solution when an array of 200k elements need to be passed ...

HQL Query using group by

I have the following class structure FlowerDAO with the fields (mapped using Hibernate): id unitPrice name color How can i create an hql query to obtain the flower(s) for each color that has(ve) the minimum unit price on that color? I have tried this, but it doesn't work from FlowerDAO as f where f.unitPrice<= (select min(f2.unitPr...

GORM in Grails and StaleObjectStateException

I'm writing a small Grails app, and I keep on getting StaleObjectStateException:s for about 1/10:th of the calls to "createfoo" when running the following rather simple code. Most probably I'm missing out on the best way to use GORM. This is the code: def viewfoo = { session.user.refresh() // ... } def createfoo = { session.user...

HQL - row identifier for pagination

Does anyone know if HQL has a keyword to identify rows such as ROWID or ROWNUM? I would like to implement pagination with HQL but I am not able to use .setMaxResult() or .setFirstResult() because I don't work with the session object directly and therefore don't use the Query object but simply create my query as a string and use the .fin...

Is there a recommend way to get Spring 2.5+ to autowire Hibernate domain objects

Is there a recommend way to get Spring 2.5+ to autowire Hibernate (3.0+) domain objects. I realize that there is a way to do this using AspectJ (@Configurable), but I would like to avoid pulling in AspectJ. Some Googling found this DependencyInjectionInterceptorFactoryBean class but it seems to just live in the sandbox (and just in 2.0....

What's the difference between Pretest existing pooled connections and prestest new connections in websphere 6.1

What's the difference between Pretest existing pooled connections and prestest new connections in websphere 6.1..and which option is best one? can we enable both options? ...