hibernate

Hibernate hql problem using case keyword

Hello! I really need help regarding this one. Here is the code snippet: hSql=" select case when min(start_day_plan) is not NULL then min(start_day_plan) else to_date((min(insertDate)) - cast('1 month' as interval),'yyyy-MM-dd' ) end from Project" getHibernateTemplate().find(hSql); But this generates the error below: java...

What does Hibernate/Toplink offer above JPA?

As far as I know, JPA itself offers all the shiny features like ORM, JPQL, entity relations mapping and so on. But I don't really understand, why do people use Hibernate or Toplink on top of JPA. What does Hibernate offer that JPA itself doesn't have? ...

Hibernate named query parameter

Hi, I am having problem with named query parameter. My query is as follow: <sql-query name="getCustomer"> <![CDATA[ select * from customer where customerId=:custId and billId in ( :billIdList ) ]]> </sql-query> I am setting all parameters, but having problem in :billIdList whenever I am setting this parameter I am getting a Empt...

Hibernate SQL to HQL

Im running into some problems when trying to convert a SQL query into HQL (or Criteria/Restriction). I have the following SQL query: Select count(n), CreatedDate from ( Select count(serverId) as n, Date(Created) as CreatedDate from mytable group by Date(Created), serverId ) as tbl group by CreatedDate; So what is the HQL (or ...

how to use composite-id class element ?

when should you use the class element of the composite-id ? for example, consider this snippet : <composite-id name="id" ***class="OrderLineId"***> <key-property name="lineId"/> <key-property name="orderId"/> <key-property name="customerId"/> </composite-id> <property name="name"/> <many-to-one name="order" class="Order...

How use hibernate criteria for a left outer join without direct link into the two tables

I'm trying to translate a SQL quest into Hibernate criteria. My quest is working in SQL : select * from objective left outer join conditionstate on objective.conditionid = conditionstate.conditionid and conditionstate.personid = XXXX where objective.toto_id = YYYYY The objective is not directly mapped t...

Need help with Hibernate Mapping

Hi, I am trying to create a dashboard for a homegrown solution that collects native performance related statistics of application servers. Here's the DDL for the data that's been gathered by various agents. I have skipped few columns and non-relevant tables for brevity. create table server ( id integer not null auto...

Hibernate: best collection type to use - bag, idbag, set, list, map

I am looking for what most people use as their collection type when making one-to-many associations in Hibernate. The legacy application I am maintaining uses bags exclusively, but keeps them as lists in code. The tables associated have an id field, so an idbag seems more appropriate, but documentation recommends a Set. EDIT: I mistake...

Hibernate/Ehcache: evicting collections from 2nd level cache not synchronized with other DB reads

I have an application using JPA, Hibernate and ehcache, as well as Spring's declarative transactions. The load on DB is rather high so everything is cached to speed things up, including collections. Now it is not a secret that collections are cached separately from the entities that own them so if I delete an entity that is an element of...

On String creation for queries in Hibernate and whether those queries would reduce object creation if they were final static

Given this Hibernate snippet @org.hibernate.annotations.NamedQueries({ @org.hibernate.annotations.NamedQuery( name = "ASSIGNED_CONTINGENCIES", query = "select ctg.id from Cont ctg join ctg.labels cl where cl.id = :label_id and ctg.datasetId = tscommon.rdsidtodsid(:datasetting_id)...." ) }) Does it mean that eve...

How to map dynamically created table in Hibernate?

I am working on a web application. We are using Hibernate as ORM in our project. Actually, our application creates some tables dynamically based on user selection. The user can select table name, column name and then s/he can import data from a csv file. So my question is: how to map this dynamically created table with Hibernate and Java...

Why doesn't the JPA spec (including 2.0) or Hibernate extension allow u to specify a generator e.g. Oracle sequence for the @Version annotation

I think the preamble of my use case cluttered my actual point, so I am restating more succinctly: Why can't @Version take a generator and allow me to assign a sequence to it like I can do for @Id; something like this @Entity @javax.persistence.SequenceGenerator( name="SEQ_STORE", sequenceName="my_sequence" ) public class Store i...

How to configure query timeout threshhold for c3p0/hibernate

I have an application that is using Hibernate 3, c3p0, and spring 2.5.6. We have a datasource that is configured to speak with a postgres database. Everything was working great until a firewall was introduced between the application server and the database. We intermittently are getting java.net.SocketTimeoutException: Read Timed Out err...

Reproduce com.mysql.jdbc.exceptions.jdbc4.CommunicationsException with a setup of Spring, hibernate and C3P0

I got this error from the production code: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was36940 seconds ago.The last packet sent successfully to the server was 36940 seconds ago, which is longer than the server configured value of 'wait_timeout'. You sho...

Why doesn't JPA offer a loadChildren() method for lazily loaded relations?

There are times when I want to define a relationship as being lazily loaded, since 90% of the time I don't want the child entities, yet also have the possibility of getting the whole hierarchy at once, under certain circumstances. I don't want to achieve this by using a named query, since the parent-child hierarchy is useful when I conve...

EJB3 Getting at original JDBC Errors

Hi all, I am using EJB3 on Glassfish using the default TopLink persistance manager. Within a Session Bean, when the persistence manager catches a DB exception, it marks the transaction to be rolled back, and throws an EJBException, in turn wrapping a RollbackException. Now I was expecting to be able to get the original jdbc exception ou...

Problem managing session with multiple data sources

I am working on a project where we each service refers four separate data-source. Until now, we have been using ProxyFactoryBean to refer to the Dao target and the Transaction Intereceptor - something like this.. <bean id="readOnlyUserProxy" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="target" ref="read...

using ehcache blocking decorator with hibernate

Hello I'm using ehcache with hibernate and I'd like to use the blocking or SelfPopulating cache to avoid the issues presented in http://ehcache.org/documentation/constructs-0_5.html#mozTocId722946 An expensive operation is required, say rendering a large web page, which takes 30 seconds. The page is not considered stale until it is ...

Java Web Start: unsigned cglib

I am using hibernate on the server side with a client application started via Java Web Start. I can't sign the jars (I'd like to but I can't). I get a permission exception when I get a POJO with lazy fields. Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission cglib.debugLocation read) at java...

Oracle legacy table without good PK: How to Hibernate?

I have legacy tables in an Oracle database which i'd like to access from a Java application with Hibernate. The problem is: the tables don't have good primary keys. For instance, a table would look like this: create table employee ( first_name varchar(64) not null, last_name varchar(64) not null, hired_at date, depar...