hibernate

Hibernate Enum mapping using annotaions

I have an existing database that I am now connecting to using hibernate. I cannot change the data in it at the moment and have everything working apart from a single column. I have a status column that has the values: new mailed in out And the column is mapped as follows: @Column(name = "STATUS", nullable = false, length = 50) @En...

Problem arise while integrate hibernate with restful web service?

Hello Everybody, I am using hibernate for a while now without any (bigger) problems. Now I am trying to work out RESTful Webservices with project jersey. It seems that hibernate wich depends on ASM framework (asm.jar, asm-attrs.jar) and jersey which depends on ASM too (asm V3.1 as of asm-3.1.jar) are having problems with the asm impleme...

Hibernate Serialization Exception in GWT but Eclipselink not

Dear members, I am using eclipselink JPA implementation (Entity) with GWT 2.0 framework on presentation layer. Everything is working properly. But when i change my JPA implementation to Hibernate, I get Serialization/Deserialization Exception on GWT Layer when I pass entity beans but It is okay on eclipselink JPA. Whats really happens? H...

[Hibernate] How to group results by intervals?

Hello all, I have a table containing events with a "speed" property. In order to see the statistical distribution of this property, I'd like to group the results by intervals, let's say: [0-49.99km/h] 3 objects [50-100km/h] 13 objects [100-150km/h] 50 objects etc This would let me see that most objects are in a certain interval. Ob...

Hibernate HQL strange behavior with IS NULL

I have a problem with a HQL query. I want to get all PID that has an administrative sex set to 'M' or no administrative sex (in Java the value is set to null). PID.class @Entity @Table(name = "PatientIdentification") public class PID { @OneToOne(cascade = CascadeType.ALL) @JoinColumn(name = "administrativeSex", referencedC...

What happens to dereferenced hibernate (JPA) entities?

In a project i am working on, we have an EJB backend where various clients connect remotely (i.e. Web layer, web services layer, etc). The clients are on another machine and can be in another data center, so the front end and backend are never in the same app server. The backend is layered as follows: SLSB <-> Service Layer Objects <-...

HQL version of a SQL join with group by

I have two tables, Band and Votes. Band has a name and an id, and Votes has a total_votes column and a foreign key called band_id pointing to band.id. I have lots of votes, saved at various dates. What I want to do is find the maximum value of the total_votes column for each band. The following SQL query works: select b.name,max(v.t...

How to intercept the Hibernate generated SQL?

For a security system which works as a big brother (like a watched mandatory access control), we have to intercept and handle all select statements hibernate is generating. We store the user, the timestamp and the sql select in a database to enable some profiling with other tools. The informations allow to determine what a user tried to ...

Hibernate : dynamic-update dynamic-insert - Performance Effects

Hi, Using dynamic-update or dynamic-insert has positive, though generally slight only on performance, as also mentioned by http://www.mkyong.com/hibernate/hibernate-dynamic-update-attribute-example/ But the reference documentation mentions that this could have negative performance effects also as mentioned below in http://docs.jboss.or...

Multiple unique constraints in JPA

Is there a way to specify using JPA that there should be multiple unique constraints on different sets of columns? @Entity @Table(name="person", uniqueConstraints=@UniqueConstraint(columnNames={"code", "uid"})) public class Person { // Unique on code and uid public String code; public String uid; // Unique on us...

hibernate plugins

I am working in galileo, i am in need of hibernate feature in it. how can i get it? ...

Specifying an index (non unique key) using JPA

How do you define a field, ie email as having an index using JPA annotations. We need a non-unique key on email because there are literally millions of queries on this field per day, and its a bit slow without the key. @Entity @Table(name="person", uniqueConstraints=@UniqueConstraint(columnNames={"code", "uid"})) public class Pe...

Hibernate @GeneratedValue annotation setting existing value to new Object (violating primary key constraint)

Hi, I have an attribute set like: @GeneratedValue @Id private long id; Howerver, when I call the persist function, the id is set with a value that already exists in my Postgres database. I checked the my_seq field there and it is set correctly so I don't know where hibernate is getting that existing number from. Note that this was w...

Spring and Hibernate inside Axis2 inside Tomcat6

I'm try to create web service base on axis2 (without a ServletContext). I have code that work properly (Spring + Hebirnate) and try to put it into AAR as it describe in this article and this one . All work good except hibernate. I have: <bean id="dataSourceCommon" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="c...

Defining database independant JPA object uid

It turns out that the following example works when using mysql 5.x, however it doesnt when using an oracle 10g database. Is there a way to define a unique identifier field that is independant of the database technology? @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name="id") private long id; I have tested this in h...

Surrogate Key Generation Across Multiple Tables Using Hibernate

I want to get surrogate keys for my user table(s) in MySQL. I'm sure concatinating an incrementing value + a timestamp would get me unique keys across multiple tables but how do I get the incremental value for the class's persistence table before I persist it to the database. ...

hibernate to persist or just plain SQL query

Hi, I am using hibernate for the first time for one of my projects. One of the entity is Education(StudentObject, CollegeObject, MajorObject, degreeString). To insert Education object into database, i've to load student, college and major object from database and then instantiate it and persist. How is this better than just plain sql(ins...

Spring/Hibernate testing: Inserting test data after DDL creation

I have a Spring/Hibernate webapp that has some integration tests that run on an in-memory HSQL database. Hibernate takes this blank database and creates all of my test tables and constraints thanks to hbm2ddl=create. However, I have a new bean that checks for a particular config value from the database during its afterPropertiesSet() m...

Problem with Hibernate join query

Hi, I have a problem with writing a join query in Hibernate although I can write it in sql. It looks like this: Select * from z, y, t where z.id = y.id and t.id = z.id and z.id = 2 What would be the hibernate equivalent? I went through the documentation but the examples there were not very helpful in my situation or I was getting stra...

Updating large datasets in Hibernate

I have a standalone app developed in Spring and Hibernate. I need to update a pretty large dataset and right now the speed of the update makes it unusable. Looking for options to implement this more efficiently. And I realize Hibernate isnt the tool to handle large batch updating but I need to make it work for now. There are 3 tables...