hibernate

Query the other way across a one-to-many with Criteria Builder

Lets say I have the following one-to-many relationship: Site has many Users User belongs to one Site I've setup the relationship like this class Site { static hasMany = [users:User] ... } and class User { static belongsTo = [site:Site] int number String username ... } Basically I want to update the userna...

org.hibernate.MappingException using annotations

I am using JPA annotations for these two classes: @Entity @RooJavaBean @RooToString @RooEntity @MappedSuperclass public abstract class BaseEntity { @Temporal(TemporalType.TIMESTAMP) @DateTimeFormat(style = "S-") private Calendar created; @Temporal(TemporalType.TIMESTAMP) @DateTimeFormat(style = "S-") private Calendar updat...

Hibernate Query with conditions in a complex db structure

I have a complex database that's looking like this: product *1 <-> n* inventory *n <-> 1* inventoryUser *1 <-> n* user Now I would like to query e.g. all products where user.firstname = 'peter' in hql. ...

Is it possible to mix orm.xml definitions with annotations when using JPA/hibernate ?

I'm working on an application whihc supports using several DB vendors, with the table definitions being different for each DB type. The trouble is that the column definitions are not what hibernate expects, and so my entities contain a lot of @Column(..columnDefintion="..."...) annotations. To further complicate the issue, there's no wa...

Hibernate (JPA) cascade - retrieve id from child

I have a parent class with the following field with cascading option: public class Parent { @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL) @Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN) private final Set<Child> children = new HashSet<Child>(); public addChild(Child child) { children.add(child); } } I...

Modelling a Two to Many Relationship in JPA/Hibernate

Hi folks, I have the following entity relationship problem. A "Game" must have two (and only two) "Team" objects. A "Team" can have many "Games" This, as far as I can see is a Two-to-Many relationship. However...I don't know how to model this in JPA. Eg, I was going to do something like this... @Entity public class Team extends BaseOb...

Deleted entity passed to persist exception

Hi, I have this kind of entities: Document | n .. to ..1 | DocumentType | 1 .. to .. n | PropertyType | 1 .. to .. n | DocumentProperty I simply try to remove a document like: entityManager.remove(document); but an error is firing: 16:45:51,499 ERROR [[Seam Resource Servlet...

Lazy loading in Hibernate

My Java Web application uses Hibernate to perform ORM. In some of my objects, I use lazy loading to avoid getting data until I absolutely need it. The problem is that I load the initial object in a session, and then that session is destroyed. When I later attempt to resolve the lazy-loaded collections in my object I get the following err...

STRUTS HIBERNATE

Hi Friends, Is it good to shift from struts to hibernate. ...

How to define index by several columns in hibernate entity?

Morning. I need to add indexing in hibernate entity. As I know it is possible to do using @Index annotation to specify index for separate column but I need an index for several fields of entity. I've googled and found jboss annotation @Table, that allows to do this (by specification). But (I don't know why) this functionality doesn't w...

spring hibernate.createSQLQuery return as custom entity

after did Query query =hibernate.createSQLQuery("select abc,def from table"); Is it possible to auto "parse" the result to "pojo" list? so that i can do below List<CustomPOJO> abc = query.list(); //CustomPOJO is pojo not entity , no @Entity tag ...

Can spring transactions unsynchronize a synchronized method?

My colleague and I have a web application that uses Spring 3.0.0 and JPA (hibernate 3.5.0-Beta2) on Tomcat inside MyEclipse. One of the data structures is a tree. Just for fun, we tried stress-testing the "insert node" operation with JMeter, and found a concurrency problem. Hibernate reports finding two entities with the same private key...

Criteria API returns a too small resultset

How is this possible, I have to following criteria Criteria criteria = getSession().createCriteria(c); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); criteria.add(Restrictions.eq("active",true)); List list = criteria.list(); The size of list is now 20. If I add a max results to the criteria, Criteria criteria = getSes...

Hibernate annotation for postgresql SERIAL type

I have a postgresql table in which I have declared a column 'inv_seq' which is declared as 'SERIAL'. I have a Hibernate bean class to map the table. All the other columns are read properly except this column. here is the declaration in the Hibernate bean class: .... .... @GeneratedValue(strategy=javax.persistence.Generati...

Completely evicting Maps from Hibernate PersistenceContext

When I create or load an object with a simple HashMap that uses persistable objects for both keys and values and pass that object to evict(), the evict is only cascaded to the values of the Map and not to the keys (this has been checked by dumping the context of the PersistenceContext at various points). This leads to various situations ...

Data does not persist using HIbernate with Spring's @Transactional Annotation

I have an application that I am currently writing that will use Spring and Hibernate. In my services layer I have injected a DAO that will do some very basic CRUD-ing actions. For grins, I have created a method annotated as follows: @Transactional(readOnly = false, propogation=Propogation.REQUIRES_NEW) public void doSomeWork(Dao dao, En...

Save more than object with the same identifier into a database in the same session?

Hey i have two entiies connected through a many to one realtionship. many[category]---------one[game] columns idgame----------------------gameid category------------------game name I need to have many occureneces of the game primaary key in the category part of the realtionship. I have tried to do this in a session but i get the e...

Hibernate Search with index in a different database

I have a database which is readonly (I only have the access to view), but I have to index this database for search. The DAO layer to this table is now using a generic DAO approach with Hibernate+JPA. Is it possible to add hibernate search to this view and store the index in a separate database? I am aware that I may lose the capability ...

Why does Hibernate query have compile error in IntelliJ?

I have this Hibernate code: Query q = session.createQuery("from MyTable where status = :status"); It compiles and works fine.. But in IntelliJ I get this error reported: Can't resolve expression, Can't resolve symbol 'MyTable' Why is IntelliJ complaining?? ...

Java type for date/time when using Oracle Date with Hibernate

We have a Oracle Date column. At first in our Java/Hibernate class we were using java.sql.Date. This worked but it didn't seem to store any time information in the database when we save so I changed the Java data type to Timestamp. Now we get this error: springframework.beans.factory.BeanCreationException: Error creating bean wi...