hibernate

How to handle large dataset with JPA (or at least with Hibernate)?

I need to make my web-app work with really huge datasets. At the moment I get either OutOfMemoryException or output which is being generated 1-2 minutes. Let's put it simple and suppose that we have 2 tables in DB: Worker and WorkLog with about 1000 rows in the first one and 10 000 000 rows in the second one. Latter table has several fi...

Efficiently retrieve objects with one to many references in Grails using GORM

I'm trying to determine how to find/retrieve/load objects efficiently in terms of a.) minimizing calls to database and b.) keeping the code as elegant/simple as possible (i.e. not writing hql etc.). Assume you have two objects: public class Foo { Bar bar String badge } public class Bar { String name } Each Foo has a bar...

how to configure cache in hibernate with jboss? ? And test as well in kumud console??

Does any one know, how to configure cache for hibernate with jboss ? My clear question is I am using JPA and Jboss. Every time I call JPA method its creating entity and binding query. My persistence properties are <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/> <property name="hibernate.cache.provid...

Usual hibernate performance pitfall

Hi, We have just finish to profile our application. ( she's begin to be slow ). the problem seems to be "in hibernate". It's a legacy mapping. Who work's, and do it's job. The relational shema behind is ok too. But some request are slow as hell. So, we would appreciate any input on common and usual mistake made with hibernate who ...

How do I implement Hibernate Pagination using a cursor (so the results stay consistent, despite new data being added to the table being paged)?

Hey all, Is there any way to maintain a database cursor using Hibernate between web requests? Basically, I'm trying to implement pagination, but the data that is being paged is consistently changing (i.e. new records are added into the database). We are trying to set it up such that when you do your initial search (returning a maximum of...

Wicket, Spring and Hibernate - Testing with Unitils - Error: Table not found in statement [select relname from pg_class]

Hi there. I've been following a tutorial and a sample application, namely 5 Days of Wicket - Writing the tests: http://www.mysticcoders.com/blog/2009/03/10/5-days-of-wicket-writing-the-tests/ I've set up my own little project with a simple shoutbox that saves messages to a database. I then wanted to set up a couple of tests that would ...

Spring & Hibernate SessionFactory - recovery from a down server

So pre spring, we used version of HibernateUtil that cached the SessionFactory instance if a successful raw JDBC connection was made, and threw SQLException otherwise. This allowed us to recover from initial setup of the SessionFactory being "bad" due to authentication or server connection issues. We moved to Spring and wired things in...

Is there a way to specify wildcarded region names when using ehcache with hibernate?

When using Ehcache with Hibernate, is there a way to specify region names with wildcards in the ehcache.xml file? For example, to allow for cache settings at the package level (with * as a wildcard indicator) where the given setting is applied to any region that matches the wildcarded name: <cache name="com.example.my.package1.*" ... ...

Wicket testing - AnnotApplicationContextMock - There is no application attached to current thread main

I've written a couple of tests for a small web app, but I get an error when I try to run the page specific tests that makes use of WicketTester. Google sends me to a mailing list for Apache Wicket, where a user experienced the same exception. He/she said the problem was that AnnotApplicationContextMock was initialized before the Wicket ...

Controlling when SQL UPDATE is executing on ehcache 'd classes

We are using Hibernate and ehcache as 2nd level cache. If I load an entity that is cached (e.g. cache-usage="read-write") and update it, it seems that this immediately results in an SQL UPDATE. (How) Can I influence when this SQL UPDATE happens? hibSession = HibernateUtil.getReadWriteSession(); tx = hibSession.beginTr...

Hibernate inserting into join table

I got several entities. Two of them got a many-to-many relation. When I do a bigger operation on these entities it fails with this exception: org.hibernate.exception.ConstraintViolationException: could not insert collection rows: I execute the operation i a @Transactional context. I don't do any explicit flushing i my daos. The flush ...

Hibernate fetches incorrectly using @ManyToOne EAGER

I have two entities, let's call them X and Y. They have many-to-many relation but I never needed to use that relation, i.e x.getYs(), so I did not set it up to keep things simple. I have a table that holds the relationship and has only rows that are keys to X and Y. In other words that x_y table's rows are only x_id and y_id What I need...

again about JPA/Hibernate bulk(batch) insert

Here is simple example I've created after reading several topics about jpa bulk inserts, I have 2 persistent objects User, and Site. One user could have many site, so we have one to many relations here. Suppose I want to create user and create/link several sites to user account. Here is how code looks like, considering my willing to use ...

Hibernate: same generated value in two properties

I want the first to be generated: @Id @Column(name = "PRODUCT_ID", unique = true, nullable = false, precision = 12, scale = 0) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PROD_GEN") @BusinessKey public Long getAId() { return this.aId; } I want the bId to be initially exactly as the aId. One approach i...

Spring transaction management breaks hibernate cascade

I'm having a problem where the addition of spring's transaction management to an application causes Hibernate to throw the following error: org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: org.fstrf.masterpk.domain.ReportCriteriaBean.treatmentArms org...

How can I restrict the key of a dictionary field in Hibernate?

We have a class "Foo" which requires some limited security. In particular, we have defined Authors, Editors, Owners, and Account Managers (aka RoleManager) for each 'foo'. The DB mapping table contains a FooID, a UserID, and an integer (binary representation of flags) which are used to determine which of those 4 roles you have on which...

Hibernate entities: columns without entity properties

Is there a way to "magically" persist a column which is not represented as a property in an entity? Concretely I want to add audit info to an entity without having the audit info on the entity. The audit values are not stored in the entity, but are retrieved from the environment at the time of persisting the entity. This happens in a Aud...

Dump Hibernate activity to sql script file

Hi, I'm trying to log hibernate activity (only dml operations) to an sql script file. My goal is to have a way to reconstruct the database from a given starting point to the current state by executing the generated script. I can get the sql queries from log4j logs but they have more information than the raw sql queries and i would need...

Grails deploy on Tomcat6

Hello, while trying to deploy a Grails application into tomcat6 I ran into some problems: I used the grails war command to build up a war, then copied it to var/lib/tomcat6/webapps and tried to restart the container. I had to change default Tomcat policy to skip security exceptions, since I couldn't access environment variable (like gra...

How can creating the SessionFactory become slow after updating Hibernate?

In my Java SE application I used Hibernate 3.3.2 and creating the SessionFactory took about 5 seconds. Today I updated to Hibernate 3.5.1 and suddenly it takes over a minute. What can be the cause of such a dramatic effect? I tried different things the better part of the day and I have no clue... Some data I collected According to...