hibernate

Which are the differences/similarities between hibernate and other frameworks or specifications?

I want to know the differences/similarities between Hibernate and simple persistence in Java EE 5? I'm not clear if Hibernate implements Java EE 5 persistence implementation or if it is a totally different approach to data representation over back-end systems. I'm confused about Hibernate and its relation with the concepts about java p...

Trouble using the Transactional annotation in groovy

Has anyone had any experience with Spring transactions (class-level, with proxy, annotation-driven) not getting started in a Groovy Class? I've been struggling with an unexplained LazyInitialization exception noticed that stacktrace does not include a call to start the transaction. Sounds crazy but I have to wonder whether Groovy picks u...

Hibernate criteria query using Max() projection on key field and group by foreign primary key

I'm having difficulty representing this query (which works on the database directly) as a criteria query in Hibernate (version 3.2.5): SELECT s.* FROM ftp_status s WHERE (s.datetime,s.connectionid) IN (SELECT MAX(f.datetime), f.connectionid FROM...

Why does every thread in my application use a different hibernate session?

Hi, I have a web-application which uses hibernate and for some reason every thread (httprequest or other threads related to queueing) uses a different session. I've implemented a HibernateSessionFactory class which looks like this: public class HibernateSessionFactory { private static final ThreadLocal<Session> threadLocal = new ThreadL...

Hibernate @OneToOne @NotNull

Is it valid to declare @OneToOne and @NotNull on both sides of a relationship, such as: class ChangeEntry { @OneToOne(cascade=CascadeType.ALL) @NotNull ChangeEntryDetails changeEntryDetails; public void addDetails(ChangeEntryDetails details) { this.changeEntryDetails = details; details.setChangeEntry(this)...

Spring Security DB Authentication w/Hibernate and hashed passwords?

I'm trying to set up spring security 3 to authenticate users against my hibernate 3 database. I'm storing only sha1 hashes of the passwords in the database (not plaintext). I've looked at this and this, which tell me to implement my own UserDetailsService. Unfortunately, the UserDetails that loadUserByUsername spits out seem to need the...

Do Hibernate table classes need to be Serializable?

I have inherited a Websphere Portal project that uses Hibernate 3.0 to connect to a SQL Server database. There are about 130 Hibernate table classes in this project. They all implement Serializable. None of them declare a serialVersionUID field, so the Eclipse IDE shows a warning for all of these classes. Is there any actual need for t...

Other use for a Hibernate Mapping file

I am trying to define db dependency for a web based application, and was thinking that perhaps the hibernate mappings used in the application might be importable into some sort of tool to produce a visual ERD diagram. Has anyone tried something like this? ...

Set primary key on hibernate generated sequence table

setup: hibernate 3.3, MySQL 5 I have an hibernate entity that have its PK generated using a sequence table. The annotation looks like this: @GenericGenerator(name = "SCENARIO_TABLE_GEN", strategy = "org.hibernate.id.enhanced.TableGenerator", parameters = { @Parameter(name = "initial_value", value = "5"), @Parameter(name...

Update the rank in a MySQL Table

I have the following table structure for a table Player Table Player { Long playerID; Long points; Long rank; } Assuming that the playerID and the points have valid values, can I update the rank for all the players based on the number of points in a single query? If two people have the same number of points, they should tie...

Changing hibernate batch size programatically

Hello, Is possible to change hibernate.jdbc.batch_size programmatically? I understand hibernate.jdbc.batch_size is a application level parameter, wanted to know if i can use it specifically for certain HQL inserts and not others. I would change the code only for those HQL inserts The big picture is that i need to introduce batch insert...

Spring & hibernate configuration (using maven): java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration

Hi, I am trying to include spring and hibernate in an application running on a Weblogic 10.3 server. When I run the application in the server, while accessing an TestServlet to check my configuration I get the following exception: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' ...

Hibernate query insert

could we realize an insert query with hibernate. I read that must be a jdbc connection to the database if we want to insert into a table. think you. ...

Hibernate: Safely reattach an object to the session

I'm maintaining a cache of objects across hibernate sessions by storing (possibly-detached) objects in a map. When the cache gets a hit, I test if the object is already part of the session with Session.contains(object). If not, I re-attach it with Session.lock(object, LockMode.NONE). The problem is, if the same object was loaded pre...

[Hibernate Mapping] relationship set between table and mapping table to use joins.

Hi guys, I have two table a "Module" table and a "StaffModule" I'm wanting to display a list of modules by which staff are present on the staffmodule mapping table. I've tried from Module join Staffmodule sm with ID = sm.MID with no luck, I get the following error Path Expected for join! however I thought I had the correct jo...

database design to speed up hibernate querying of large dataset

I currently have the below tables representing a bus network mapped in hibernate, accessed from a Spring MVC based bus route planner I'm trying to make my route planner application perform faster, I load all the above tables into Lists to perform the route planner logic. I would appreciate if anyone has any ideas of how to speed my per...

Hibernate + PostgreSQL : relation does not exist - SQL Error: 0, SQLState: 42P01

Hello, I am having some problems trying to work with PostgreSQL and Hibernate, more specifically, the issue mentioned in the title. I've been searching the net for a few hours now but none of the found solutions worked for me. I am using Eclipse Java EE IDE for Web Developers. Build id: 20090920-1017 with HibernateTools, Hibernate 3, ...

Hibernate: How do I link a subclass to its superclass?

Hey there! I'm having a little problem setting up my webshop project. Thing is, I have a User() superclass and two subclasses, PrivateUser and BusinessUser. Now, I'm not quite sure how to get my head around storing this relationship via hibernate. For the purpose of this question, the User() class contains only one field: String addre...

How to detect column conflicts with Hibernate?

So let's say I have an ArrayList full of Products that need to be committed to the database via Hibernate. There are already a large number of Products in the database. Each product has an ID. Note this is NOT the PK that is autogenerated by Hibernate. My questions is: what is the best way to detect conflicts with this ID? I am looking ...

hibernate3-maven-plugin dependencies for newer version of hibernate

I would like to use hibernate-3.5-1.Final along with this plugin, what should be my dependencies here. It seems to be picking up a older set of jars and failing right now. <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>hibernate3-maven-plugin</artifactId> <version>2....