hibernate

Hibernate and parent/child relations

Hi to all, I'm using Hibernate in a Java application, and i feel that something could be done better for the management of parent/child relationships. I've a complex set of entities, that have some kind of relationships between them (one-to-many, many-to-many, one-to-one, both unidirectional and bidirectional). Every time an entity is...

Does overloading Grails static 'mapping' property to bolt on database objects violate DRY?

Does Grails static 'mapping' property in Domain classes violate DRY? Let's take a look at the canonical domain class: class Book {      Long id      String title      String isbn      Date published      Author author      static mapping = {             id generator:'hilo', params:[table:'hi_value',column:'n...

Hibernate querycount query, dont know how to do

I want to make an hibernate querycount on a table. I have to values, one string and one boolean HibernateUtil.queryCount(VoteOnPublication.class, new String[] {VOTED_PUBLICATION_ID_FIELD, FOR_OR_AGAINST_FIELD}, **********); my voted_publication_id_field is a string, and my for or against field is a boolean. What should i put in my s...

How to break a Hibernate session?

In the Hibernate reference, it is stated several times that All exceptions thrown by Hibernate are fatal. This means you have to roll back the database transaction and close the current Session. You aren’t allowed to continue working with a Session that threw an exception. One of our legacy apps uses a single session to update/...

DAO and Service layer in Spring: session management

Am I right in understanding the principles of DAO & Service layer interconnection? DAO performs extractions of base objects, say by id from a db. Service layer USES a DAO object and may invoke MORE THAN ONE METHOD of DAO in one function. So, Service layer has to: instantiate a DAO implementation object invoke as many methods of the DA...

Looking for detailed explanation of Hibernate UserType methods for mutable objects

I am creating a custom UserType class in Hibernate. The specific case is for an HL7v3 clinical document (I work in health IT). It is a mutable object and most of the documentation around the Hibernate UserType interface seems to center around immutable types. I want a better understanding of how and when the interface methods are used, s...

Mapping enum types with Hibernate Annotations

Hi there, I have an enum type on my Java model which I'd like to map to a table on the database. I'm working with Hibernate Annotations and I don't know how to do that. Since the answers I search were rather old, I wonder which way is the best? Thanks in advance ...

hibernate or eclipselink?

It seems like EclipseLink has been chosen by sun as the reference implementation of JPA 2.0, nevertheless I see lots of people continue to use hibernate... I have no experience with any of them, so I wonder which one should I choose for a new project... I'd like to know the pros / cons of each one... thanks a lot ps: btw, and this is...

LazyInitializationException when adding to a list that is held within a entity class using hibernate and gilead for gwt

Right so i am working with hibernate gilead and gwt to persist my data on users and files of a website. my users have a list of file locations. i am using annotations to map my classes to the database. I am getting a org.hibernate.LazyInitializationException when i try to add file locations to the list that is held in the user class. th...

hibernate proxy ..

load() just returns a proxy by default and database won’t be hit until the proxy is first invoked. what does it mean by proxy exactly here ? ...

Testing Hibernate with JUnit: "session is closed" exception

Hi, sometimes when testing some CRUD operations in my DAO classes using JUnit 4.5, Hibernate throws an exception: org.hibernate.SessionException: Session is closed! The session is not closed explicitly, so what happens? Thanks ...

What is detached persistance and transient object in hibernate ?

What is detached persistance and transient object in hibernate ? please clearify me with example.. Thankx in advance.. ...

what does synchronization mean in hibernate..

i read that upon session.flush() The data will be synchronized (but not committed) when session.flush() is called what is synchronized with what.. whether it is DB state that will come to memory by querying or memory state will be copied to Db ? clarify this plz.. ...

Hibernate session method to update object

I need this roadmap of a Hibernate managed object instance. First, I create an instance with initial properties and persist this object in a db. Then session associated with this object is closed. But still, I serialize my object and on the next step deserialize it, invoke some setters, and again, I need to update what changed in a data...

Hibernate ScrollableResults Do Not Return The Whole Set of Results

Some of the queries we run have 100'000+ results and it takes forever to load them and then send them to the client. So I'm using ScrollableResults to have a paged results feature. But we're topping at roughly 50k results (never exactly the same amount of results). I'm on an Oracle9i database, using the Oracle 10 drivers and Hibernate i...

Hibernate won't save into database

I mapped some classes to some tables with hibernate in Java, i set Hibernate to show SQL, it opens the session, it shows that it does the SQL, it closes the session but there are no modifications to the database. Entity public class Profesor implements Comparable<Profesor> { private int id; private String nume; private String prenume; ...

Client Server Communication and Persistence Frameworks

Hi, When using Persistence frameworks like Hibernate, JPA etc. on the server side, what are the general practices of passing on the data between client and server ? Are there any existing design patterns for the same ? Thanks. ...

How to generate hibernate POJO classes programmatically?

Hi I am aware of the Hibernate Eclipse plugin that helps us (through a series of screens and button clicks) to generate the POJO and DAO classes for the underlying tables. But I would like to mimic this in a runtime environment, i.e. I would like to be able to do the exact same steps programmatically , where I should be able to supply th...

Hibernate many-to-one - bad usage?

Just trying out Hibernate (with Annotations) and I'm having problems with my mappings. I have two entity classes, AudioCD and Artist. @Entity public class AudioCD implements CatalogItem { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; private String title; @ManyToOne(cascade = { CascadeType.ALL...

What is the best way to handle validity dates in applications ?

Hello, How do we model these objects ? Scenario 1: Price changes in a time period EffectiveDate ExpiryDate Price 2009-01-01 2009-01-31 800$ 2009-02-01 Null 900$ So, if the price changes to 910$ on 2009-02-15, then the system should automatically update the expiry date on the previous effective price to 2009-0...