hibernate

Spring, Hibernate, Java EE in the 3 Tier architecture

Hello! I need to get a start as to where I put those technologies in the 3 Tier architecture: This is what I have... presentation layer: HTML, JSP app. layer: Java EE, Spring data access layer: Hibernate, PostgreSQL database ...

Hibernate criteria difficult query

I am trying to assemble a query using hibernate criteria. In my db, there is a [Game] table, a [Tag] table, and a many-to-many relationship modelled using a join table called [GameTag], which contains a game_id field and a tag_id field. My input is a list of tags (or tag_ids), and I would like to retrieve all games having all of these ...

How to fill entity's field with separate queue in Hibernate?

Hi there! I have an entity, say @Entity public class Category { private String name; private int usersInCategory; } I want to fill usersInCategory field with some aggregating SQL query (select count(*) ... group by ...). How can I do this in Hibernate? ...

hibernate SQLquery extract variable

How can I extract variables total, min, max from hibernate SQL queries and assign them to java variables? (select count(*) as total, min(price) as min, max(price) as max from product).addScalar("total", Hibernate.INTEGER).addScalar("min", Hibernate.INTEGER).addScalar("max", Hibernate.INTEGER); ...

JPA and DTO's, best way to create DTO's?

We're to use DTO's to send data to and from the presentation layer. I have a method on a service object called PostAd which posts an advertisement entered by a user. The Ad has an association to another object called AdValues, which contain values for the Ad (title, price, description etc) @Entity public class Ad { @OneToMany Se...

JSF with Hibernate sample web application

Are there any ready-to-use sample web applications using JSF, RichFaces and Hibernate? ...

Map a NativeQuery into an entity

Hello everyone, I'm having trouble trying to map a native SQL query using JPA, and Hibernate as a provider. This is the code for the entity that I'm using for this purpose: package com.prueba.entities; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EntityResult; import javax.persistence.Field...

Hibernate: Value generated by SQL query

Hi, I want Hibernate 3.3.0 to generate a value by performing a SELECT query before INSERT (persist()). Which would work like this: @Generated(GenerationTime.INSERT) @GenerateSQL("SELECT RANDOM() * 2") private int number; I've had a look at @Generated(), that's good for TRIGGERs. I don't want to introduce a trigger. I also looked at ...

JPA, MySQL, Hibernate & Maven Skeleton

Hello, I've been trying to get a simple skeleton app to run (and commit to the DB) using JPA, MySQL, Hibernate & Maven, however I'm having problems. Listed below are my 2 trivial classes, my pom.xml, and my META-INF/persistence.xml I can build the project without any problem (mvn clean install), however running it (mvn exec:java -Dexe...

Any drawbacks of using Hibernate EntityManager (vs. Hibernate Core)?

The Hibernate EntityManager documentation states, that: You may use a combination of all three together, annotations without JPA programming interfaces and lifecycle, or even pure native Hibernate Core, depending on the business and technical needs of your project. You can at all times fall back to Hibernate native APIs, ...

Help me to understand SEAM and Hibernate?

Hi, I want to use SEAM Framework with Hibernate but do not want to use EJB. I cannot use EJB. First question is, can I use EntityManager? or is EntityManager a part of EJB? How can I get access to use Hibernate in my SEAM component? Thanks, Philip ...

Using load-collection for an element with a composite key

Hi, I have two mappings, one with 2 named queries. Everything maps fine to the objects when I execute 2 separate repository calls - one for each object. The mappings for this are below: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Company.Application.Models" assembly="Company.Application.Models"> <class name="Pro...

Is it possible to customize the hibernate-plugin autogenerated CRUD methods on my grails app?

My project's copy contains the following snippet in HibernateGrailsPlugin.groovy : def doWithDynamicMethods = { def dynamicMethods = HibernatePluginSupport.doWithDynamicMethods dynamicMethods.delegate = delegate dynamicMethods.call(it) // aids in generating appropriate documentation in plugin.xml since ...

Need to solve a query cache problem

I'm developing an double-entry accounting system and I need to insert posting records without any gaps in the sequential id. Since all database access will happen through a web application, I'm taking care of id generation using a syncronized static variable: import org.hibernate.*; public class JournalService { private static ...

Need help for one to many relationship design

I have an application form and a library of questions, one application form may contain one or more questions. When user selects a question from the library and adds the question to the application form, he can add some new attributes to the question or override existing attributes of the question if he wants to. When the user finishes q...

OSIV pattern - pro's and con's ? general question about OSIV and views

I'm in the planning stages of a web site project and deciding on whether to go for OSIV and not use dao(eao)/dto (used dao/dto for an existing project) im wondering if, with OSIV, the entities should be accessible in the view (for example, with struts2, i could push the entities on to the valuestack and use OGNL in the view templates) ...

Error while trying to run JAR of project having Hibernate from command prompt

Hi, I am novice in Hibernate technology. I have a Java project which uses Hibernate. When I run the project from Netbeans IDE the project runs fine without any issues. However when I run the JAR file of the project from command prompt I get an exception "org.hibernate.hql.ast.QuerySyntaxException:" XXXX is not mapped. I have i...

Hibernate: Does a thread block while waiting for the database to insert a batch?

I'm trying to find the optimal batch size for some operations we perform in bulk (persisting collections). If insert is going to block a thread, I think I'm going to want to make the batch size ~ the average size of the collection we are going to persist. If that isn't the case, it might make more sense to find a smaller batch size to ...

Multiple Hibernate configs

Good Morning everyone! I'm currently working on building a library to modularize some of my code and I'm running into a problem with Hibernate. In my main application I have a hibernate config to get information it needs to run but then I also have a need for hibernate in my library since some of the objects I want could be used in oth...

EJB3 RMI client

Hello Everybody! I'm currently working with on a fat client application using a self written RMI server (10 years ago). The server sends EJB1.1/2.0 beans to the client who has full access to these remote objects. After commiting a transaction, all dirty beans are persisted by the server. The plan is to replace the server by a JBoss5 & ...