hibernate

Comparing hibernate-mapped dates?

How can i map a date from a java object to a database with Hibernate? I try different approaches, but i am not happy with them. Why? Let me explain my issue. I have the following class [1] including the main method i invoke and with the following mapping [2]. The issue about this approach you can see, when you look at the console output....

When does Hibernate read from second-level cache and when from DB?

As far as I know Hibernate let's you configure entities and collections to be stored in a second-level cache. When does Hibernate try to read these cached entities from the second-level cache and when does it hit the DB? Does Hibernate only read from the second-level cache when loading entities by calling Sesssion.get() and when initia...

Do you always use a second-level cache in Hibernate?

Do you always use a second-level cache in Hibernate or do you first try it without and only use it when the performance goes down? ...

JBoss/EJB vs Symmetric DS

Hi all I'm working on a project which is just about to start, and since I was busy with another one my colleagues went ahead and started working on the specs to the new one. When I came in, they had just chosen to do persistence with plain SQL (promptly accepted my suggestion to add Hibernate, though) but insisted in that data replicati...

Blending RDF and ORM approaches

I'm working on a team investigating a technology stack for a green-field systems integration project. Part of our favored technology stack use Hibernate to persist its internal state and exposes hooks into the Hibernate transactions so that business entities stay synchronized with the state of this utility. Great, except we need to maint...

Difference btw org.hibernate.jmx.HibernateService and org.jboss.hibernate.jmx.Hibernate

Both of them are mbeans. Both are intended to setup Hibernate Session Factory and expose it through JNDI. Both are implemented in Red Hat. But at the same time each of them belongs to separate classes hierarchy. What is actually the difference between them? Thank you in advance. ...

NHibernate automatically rename the column name in C#

I couldn't figure out why NHibernate is doing this. Here's part of my table in MS SQL CREATE TABLE Person ( nameFamily text, nameGiven text ) Here's Person.hbm.xml <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="Infosci.Dpd.Model.Person,Infosci.Dpd.Model" table="Person" lazy="true"> <property type="stri...

Hibernate dynamic query performance issue solutions using result transformer!

This is a important addition especially to solve performance issues while being able to write efficient dynamic HQL queries. But, how do we modify the HQL transformer in case of loading a specific parent or another mapped entity property. session.createQuery( "select st.stNumber as stNumber, st.stDate as stDate " + " from SomeTable st "...

JPA Composite Key + Sequence

Hi, Is it possible in plain JPA or JPA+Hibernate extensions to declare a composite key, where an element of the composite key is a sequence? This is my composite class: @Embeddable public class IntegrationEJBPk implements Serializable { //... @ManyToOne(cascade = {}, fetch = FetchType.EAGER) @JoinColumn(name = "APPLICAT...

Setting FetchMode in native Hibernate

I need to set the fetch mode on my hibernate mappings to be eager in some cases, and lazy in others. I have my default (set through the hbm file) as lazy="true". How do I override this setting in code? MyClass has a set defined of type MyClass2 for which I want to set the FetchMode to EAGER. Currently, I have something like: Session s ...

What causes duplicate requests to occur using spring,tomcat and hibernate

I'm working on a project in Java using the spring framework, hibernate and tomcat. Background: I have a form page which takes data, validates, processes it and ultimately persists the data using hibernate. In processing the data I do some special command (model) manipulation prior to persisting using hibernate. Problem: For some reas...

Hibernate transaction problem

We are using Hibernate Spring MVC with OpenSessionInView filter. Here is a problem we are running into (pseudo code) transaction 1 load object foo transaction 1 end update foo's properties (not calling session.save or session.update but only foo's setters) validate foo (using hibernate validator) if validation fails ? go back to edi...

How JPA (Hibernate) deal with transaction when fetching Object from database

Hi all, I'm currently developping an application in java using Hibernate as a persistence manager and JPA as an abstraction of the persistence manage hibernate. I'd like to know the impact of wrapping a result query around a transaction. I know the entity manager must stay open for lazily fetched field bug what about transaction in al...

NHibernate: How can I combine fields from two classes?

Here is a simplified version of my database model. I have two tables: "Image", and "HostingProvider" which look like this: [Image] id filename hostingprovider_id [HostingProvider] id base_url Image HostingproviderId is a many-to-one foreign key relationship to the HostingProvider table. (Each image has one hosting provider). ...

Enabling ehcache statistics in jboss 4.2.1

I've set hibernate.generate_statistics=true and now need to register the mbeans so I can see the statistics in the jmx console. I can't seem to get anywhere and this doesn't seem like it should be such a difficult problem. Maybe I'm making things overcomplicated, but in any case so far I've tried: I copied EhCacheProvider and had it in...

Hibernate Criteria Question

I'm working on a Grails project using Hibernate (GORM). I have the following Domain Models ClientContact{ static hasMany = [owners: Person] static belongsTo = [Person] } Person{ static hasMany = [clientContacts:ClientContact] } When I try to retrieve all the ClientContacts with a specific owner (Person), I'm running into...

Hibernate CRUD à la Ruby on Rails' Scaffolding

Guys, Do you know of any tool that would do like Ruby on Rails' Scaffolding (create simple CRUD pages for any particular class to allow quickly populating a database with dummy data), only which used Java classes with Hibernate for database access, and JSP/JSF for the pages? It is a drag when you are programming one part of an applica...

JPA / Hibernate Select Column Subset on Join

In SQL it is easy to do a join and only return the columns you want from the joined table. What is the best way to map this in JPA / Hibernate? For example, there is a Folder entity mapped to the EMAIL_FOLDER and an Email entity mapped to the EMAIL table. There is a one-to-many relationship from Folder to Email. The Email entity is rath...

What are the disadvantages of auto generating the classes in Hibernate

I am working in a new part of an existing system. What are the disadvantages of auto-generating the classes for Hibernate for an existing database? I just think that whatever design failures we have at the moment (and there are plenty) we will port to this new part of the system. ...

Spring & Hibernate EJB Events

Is it possible to define a spring-managed EJB3 hibernate listener? I have this definition in my persistence.xml: <properties> <property name="hibernate.ejb.interceptor" value="my.class.HibernateAuditInterceptor" /> <property name="hibernate.ejb.event.post-update" value="my.class.HibernateAuditTrailEventListene...