hibernate

What does hibernate.default_schema mean?

I was reading a blog-post of Ben Scheirman http://flux88.com/blog/blame-nhibernate-why-not/ about some NHibernate tweaks he made in order to increase the performance. In the end of article there is Lesson #7: Always make sure you’ve set hibernate.default_schema What does he mean by hibernate.default_schema? ...

Need help regarding cascading save,delete of non collection entity

I have an entity A who has entity B. Class Entity A { public EntityB; } Class Entity B { public Entity A; } Entity B has one to one relationship with A. I am trying to use cascade save,delete when entity A is saved so that I don't have to manually save entity B. It shpould be done automatically. my mapping for entity B looks...

How To Call A Named Query In Grails

Given the following example from Hibernate Make Easy, how can I call the named query, user.findByLoginName in Grails? package com.examscam.model; import javax.persistence.*; import org.hibernate.Session; import com.examscam.HibernateUtil; @Entity @Table(name = "user", schema = "examscam") @NamedQuery(name="user.findByLoginName", quer...

Unable to add custom logging data in REVINFO in envers

I am trying to use Envers for implementing Audit trails. Its creating the audit table Person_AUD and entering the audit data as well. But, when i am trying to add custom fields that is updated by to it, nothing happens. ...

Why is hibernate open session in view considered a bad practice?

And what kind of alternative strategies do you use for avoiding LazyLoadExceptions? I do understand that open session in view has issues with: Layered applications running in different jvm's Transactions are committed only at the end, and most probably you would like the results before. But, if you know that your application is runn...

Javax package and simple java application with spring hibernate

hello people! in my attempt to learn a bit faster the use of spring and hibernate i read few chapter on books and created a simple java project from netbeans 6.7. I've decided to use the hibernate annotations instead of mapping files.so in my pojo i import javax.persistence.*; and i have an error that javax doesn't exist.what sound surpr...

Hibernate bidirectional parent/child problem

I'm having a problem implementing a bi-directional parent/child relationship using hibernate 3. The parent, in this case is of the class ReportCriteria. The child is of class PkVisit. I've pasted my hibernate configuration files as well as the underlying java objects below. ReportCriteria configuration: <hibernate-mapping package="org....

adding auto-generated date/time stamp to a mapped collection of Strings (hibernate annotations)

Hello, I am using annotations to map a basic collection of Strings to an existing entity like this: Inside the parent entity class: @org.hibernate.annotations.CollectionOfElements @JoinTable (name="GoalToAchieve_entry", joinColumns=@JoinColumn(name="goalToAchieve_id")) @org.hibernate.annotations.Sort(type = org.hibernate.annotations.S...

Hibernate Save strange behaviour

I have a user object that has a one-to-many relationship with String types. I believe they are simple mappings. The types table hold the associated user_id and variable type names, with a primary key 'id' that is basically a counter. <class name="Users" table="users"> <id column="id" name="id" /> ... <set name="types" table=...

Why are my DBUnit tests consuming so much memory?

I've got a hibernate-based application which uses DBUnit for unit testing. We have an XML test database, which gets loaded up with dummy data in the setUp() of each test and deleted during the tearDown(). The problem is that I can no longer run the entire suite in an IDE (in this case, Intellij), because after about 300 tests, the heap...

Data access layer with Spring DAO and Hibernate.Problems

hi guys this is my first application in with spring and hibernate.So please bear with me with stupid questions :). i created a simple java application in netbeans 6.7. here are my daos interfaces UsersDAO package Dao; import Entities.Users; public interface UsersDAO { public Long GetIdByUsernameAndPasswor(String username, String ...

A @Embeddable that behaves like a @OneToOne (HIBERNATE)

Hi, I have a class named Parent as follows @Entity public class Parent { @Id @GeneratedValue private Integer id; @Embedded private Message message; } DBA (minimal OOP knowledge) has designed both Parent and Message properties in PARENT table. Message class behaves like a @OneToOne mapping because, at some cases...

hibernate insert into select

Hi, How can I generate insert statements like insert into table (sequence.nextval, 'b0) using hibernate? Hibernate currently selects the sequence.nextval value and only then it uses the value to insert the entry in the table. Note: I'm not very fond of custom id generators. ...

Hibernate composite key mapping issue

I'm trying to map entities of the same class (MyData) to each other through a mapping table. MyData has a composite primary key (id1 and id2). When I create the class (see below), it seems like Hibernate is reversing the order of the FK mappings (i.e. a_id1 is pointing to b_id2, etc...). This does not seem right. Does the inverseJoi...

JMockit Hibernate Emulation

I was wondering if anyone tried using JMockit Hibernate Emulation? Jmockit documentation says that when Hibernate Emulation tests are run, they won't use the O/R mapping information. So, this means it doesn't test O/R mappings, HQL query strings, Native queries, etc. Then what really are the benefits of Hibernate Emulation? One can jus...

How can hibernate access a private field ?

How can hibernate can access a private field/method of a java class , for example to set the @Id ? Thanks ...

Can javax.persistence.Query.getResultList() return null?

And if so, under what circumstances? Javadoc and JPA spec says nothing. ...

Drools Flow Persistence with MySQL (jpa, hibernate)

Needed steps for implementing Drools Flow Persistence with MySQL. I was following the Drools Flows Documentation on chapter 5.1.3.: Configuring Persistence.(https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/docs/drools-flow/html_single/index.html#d0e1157 ) Erroo-1: Caused by: bitronix.tm.utils.Propert...

Importing and normalising XML with Hibernate

When importing xml to a DB with Hibernate, is there a way to resolve an attribute consisting of comma-separated values to populate related table(s)? In this (somewhat obfuscated) example I have an xml file, each row of which represents a Person. The Person has a Hobbies property which contains a comma-separated list of values. The Perso...

Is it hard to convert a web app built with Jsp, Servlets & mySQL to one with Spring & Hibernate?

I'm currently working on building a java web app. I've been looking to use Spring and Hibernate so I get some proper exposure to them, but I'm just getting burned out reading and learning about them. If I go ahead and build it with JSP and Servlets on a MySQL back end, what kind of levels of code reuse would I be looking at? I imagine th...