hibernate

Hibernate not populate data from mapping table

I have User class and Country class with respective tables. Country table data is fixed. I make a mapping table User_Country(userid, countryid) and following mapping in User class @OneToMany(fetch=FetchType.EAGER) @JoinTable(name = "User_Country", joinColumns ={ @JoinColumn(name = "userid") }, inverseJoinColumns...

grails deleted object would be re-saved by cascade error

I have the project as set-up below. I am trying to delete a project, and I get the following: 2010-09-29 11:45:22,902 [http-8080-1] ERROR errors.GrailsExceptionResolver - deleted object would be re-saved by cascade (remove deleted object from associatio ns): [Project#204] org.hibernate.ObjectDeletedException: deleted object would be re...

Loading million rows in hibernate

If I want to fetch million rows in hibernate, how would it work? Will hibernate crash? How can I optimize that. ...

Inherited abstract class with JPA (+Hibernate)

How would you configure annotations in the following example code? I'd like to stick with JPA annotations only and avoid Hibernate specific dependencies. Is the code below correct? @Entity public class RefExample extends RefData { } (There will be multiple versions of these classes, RefSomeOtherExample, etc, and one db table per clas...

How to disable hibernate caching

I am trying to write a unit test class which will have to use same query to fetch the results from database two times in same test method. But as Hibernate cache is enabled second time it is not actually hitting the database and simply fetching the results from cache. Can someone please answer how to disable caching in persistence.xml. ...

How to use custom type in JPA column?

I have a class: public class Email { private String name; private String domain; public String toString() { return name + "@" + domain; } } I want to use it in JPA column: @Entity public class User { @Id private Integer id; private Email email; } This is what Hibernate says: org.hibernate.MappingException: Could ...

What's wrong with my custom type for JPA/Hibernate?

My custom type is (no default constructor!): package com.XXX.common; public class Email implements Serializable { private String e; public Email(String str) { e = str; } } My entity in Hibernate 3.5.6: package com.XXX.persistence; import com.XXX.common; @Entity @TypeDef( name = "email", defaultForType = Email.class, t...

spring mvc dao and service bean mapping

I am new to Spring and hibernate. I am trying to learn the best practices and design methodoligies in j2ee apps. I have a managed to create a basic spring mvc web app. now lookin for that - how should i map my service beans to dao beans or should just use dao beans only. - Is there any need to make DAO classes singleton - If i use s...

How to make hbm2ddl schemaExport to log schema to stdout?

A quote from persistence.xml: <persistence-unit name="test" transaction-type="RESOURCE_LOCAL"> <properties> <property name="hibernate.archive.autodetection" value="class" /> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.format_sql" value="true" /> <property name="hibern...

Null vs empty field in database

I have database in which data is imported from the other table. if data is empty there. so while importing to here it became null. When i query the columns like, name doesnot starts with 'a', it should return all records whose name doesn't start with 'a'. including NULL/empty column. its returning epty records but not null. But i need nu...

Using Hibernate/JPA Event Listener to update one entity when other entities are updated.

Hi, I have three entities in my system - one of which must be updated when fields on the other two are changed: @Entity public class Order { private String name; private Integer quantity; private String status; } @Entity public class OrderLocation { private String status; private String desc; } @Entity public cla...

How to use the CURRENT_DATE function in a hibernate criterion?

I want to translate the following HQL into Criteria notation: from Deal where CURRENT_DATE between startDate and endDate I tried using Restrictions.between but it doesn't recognize current_date Criteria c = session().createCriteria(Deal.class) .add(Restrictions.between("CURRENT_DATE", "startDate", "endDate"); ...

hibernate's objects eating up jboss's jvm heap

hi folks, am seeing consistent Out of Memory Exceptions due to Hibernate objects consuming over 50% of the heap. (over 500M) Am using EntityManager for persistence PersitanceBag and Collection Entry are some of them and there are some HashMaps as well contributed by Hibernate. Please advise if there is any procedure to get rid of them...

How to log in HibernateCriteriaBuilder

I try log some details in a namedQuery for a grails domain class but logging errors. static namedQueries = { firstThree { if (booleanValue) { log.trace "booleanValue = true" eq ('bar', foo) } maxResults(3) } } Error No such property: log for class: grails.orm.HibernateCriteriaBuilder How do I log in a ...

How to create reverse field mapping for an @Any Hibernate Annotation

When using the @Any annotation in hibernate how can you create the reverse mapping field, for use with orphan removal. My code looks like the example below, except that classes A and B each have their own inheritance hierarchies which is why I can not make Interface I an abstract class. public Interface I; @Entity public Class A impl...

How I can quote tables using hibernate3-maven-plugin hbm2ddl?

I have a project I'm building with maven and I need to generate a schema using the hbm2ddl tool from hibernate3-maven-plugin. I need to create database with a table called Order like the SQL keyword and I don't know how to make maven to quote this table when it's generating the script. I've done a search and I found there is a property...

what is the difference between Hibernate.initialize and eager fetching

Why I can't use EAGER fetching for the same purpose ...

Using rich datascroller With Hibernate Pagination on Server

I am having rich:datatable having 500(row) data and I am using rich:datascroller for pagination but the problem is all the data are fetched on 1st time, so if anybody having a way that click on page 2 hibernate fetches rows from table (11-20). I am using Spring+Hibernate. Please Give solution in detail. ...

update table using spring mvc web and hibernate

hi, I have simple spring mvc web application which can handle simple book store. I have a problem when the existing book is updating. I want to up date title of a book. My updateBook.jsp is somethig like this. <form method="post" action=""> Previous book title : <input type="text" name="previousTitle" /> <br> New book title :<i...

How do you set ANSI_NULLS off using JPA?

I'm trying to use one Named EntityQuery that will allow nulls in the Where clause using '=' Is there a way of setting ANSI_NULLS off or "set ANSI_NULLS off" in JPA the same way as in SQL? My JBOSS Data source file looks like the following: <?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>jdb...