hibernate

Hibernate: How to generate Id from entity constructor parameters ?

How to generate id for entity using constructor parameters - is that possible ? I need that to make tree structure (category -> subcategories...) passing to constructor parent category id. Category category = new Category(parentId); CategoryDAO.add(category); ...

hbm files in hibernate

i am working on some updation in Hibernate application. in which Struts and Spring used. we do entries of .hbm file in configration file(.cfg file). but when using spring with hibernate app we do entries in application context.xml. but i can not find configration entries in entire application. Is there any other class where we configure...

Hibernate: how to fetch only not-logically deleted objects

Nearly every table in our database has a FK to the Auditing table which logs created, updated and deleted status (date and username). We mapped the auditing table to the Auditing class and use it like this: @MappedSuperclass public class BusinessObject extends DataObject { private static final long serialVersionUID = -114781101039594...

which version of Spring + Hibernate + JBoss work

Looking for guidance as to what version of Spring, Hibernate and JBoss work together. I am currently using: <dependencies> <dependency org="javax.servlet" name="jstl" rev="1.1.2" conf="runtime->default"/> <dependency org="org.springframework" name="spring" rev="2.5.6" conf="runtime->default"/> <dependency org="org.springfra...

PageListView and dataset loading

The dataset I display using PageableListView can get very big and keeping the whole dataset as a model would be very inefficient. Is it possible to load for example only the set of IDs first and then load only the objects that are to be displayed on the current page? I use Wicket+Spring+Hibernate/JPA. Or is there a better approach to pag...

How to perform locale based sorting while using hibernate as ORM

I use server based sorting(in the db) using orderby clause. But now that I want to support multiple locales, how should I pass the locale information to the DB via hibernate layer. I have pre-defined views to which I add criteria and order in the hibernate layer. ...

JPA with Hibernate 3 - ManyToMany-Stack overflow and Multiple bag errors

I am facing issues while retrieving data for entities having bi-directional many-to-many relationship. If I use List for storing entities, I get unable to fetch multiple bags simultaneously error. If i change my code to use Set, I get stackoverflow error. Details : Spring 3.0.3 Hibernate-core : 3.5.1-Final Hibernate-annotations : 3.5....

Hibernate: association refers to an unmapped class

Hi, I have three tables (DEVICES, DEVICE_DETAILS and LOCATIONS) which I want to map to two classes (Device and Location). To do this I use the following hibernate mappings: Device.hbm.xml: <hibernate-mapping> <class name="bo.Device" table="DEVICES"> <id name="deviceId" type="int"> <column name="NR"/> <generator cl...

Can Hibernate delete orphaned collections when updating a detached object?

I know that deleting orphaned child objects is a common question on SO and a common problem for people new to Hibernate, and that the fairly standard answer is to ensure that you have some variation of cascade=all,delete-orphan or cascade=all-delete-orphan on the child collection. I'd like to be able to have Hibernate detect that child ...

Using JFace databinding with Hibernate: is this possible?

Our project is an Eclipse RCP application using Hibernate as an ORM. I recently learned about JFace databinding, in which the GUI and data models can be synchronized automagically. I put together a short test implementation along the lines of Lars Vogel's excellent JFace Data Binding Tutorial and was fairly impressed with the framework...

Why does HQL suppress results if using properties on null in or-clause

I just discovered a strange problem when dealing with HQL queries on nested objects. My class looks like this: class MyClass { MyClass predecessor } So using predecessor, I can build a Hierarchy. Now let's say I have a "thin" tree like this: obj1.predecessor = null obj2.predecessor = obj1 obj3.predecessor = obj2 obj4.predecessor =...

JPA one-to-many query result problem

Ok I have a 1-to-many mapping between a parent and child class. I can save the parent and it will automatically save the children objects, but problem is when doing a SELECT on the parent class. It seems that I'm getting a Parent object for every Child object in database table. So if I save 1 parent object with 2 child objects, when I u...

Spring transactions & hibernate: lazy initialization

From what I've read so far I had the understanding that using transactions would be the solution to hibernate's lazy loading problems. The session would be available during the whole transaction in the service layer without further adue. So maybe I misconfigured my transaction management? I'm actually a newb when it comes to spring and ...

Relationships between Spring, Hibernate, JDBC..

Dear All, I just start reading Sun's JDBC tutorial. I installed MySQL Connector/J and was just skimming through its menu, then came across this statement: "Although JDBC is useful by itself, we would hope that if you are not familiar with JDBC that after reading the first few sections of this manual, that you would avoid using naked JD...

jdbc datatype API/Reference

I am getting an exception: org.hibernate.MappingException: No Dialect mapping for JDBC type: -9 I found a list of JDBC Data type here Apache DB Project . How do I find out "-9" maps to one of the data types listed? From googling, people seem to say -9 represents nvarchar, but is there an authoritative source? ...

Hibernate many-to-one relationship delete not working as expected

Hi I have 3 tables as following 1) User has userId 2) UserProductEntitlement has userId and productId and a boolean 3) Product has productId This is my class representation : @Table(name="User") class User { @OneToMany(fetch=FetchType.EAGER, targetEntity = ProductEntitlement.class, cascade=CascadeType.ALL) @JoinColumn(nam...

XStream aliasing problem - generating "javassit" and junk characters

I'm using XStream to convert my Hibernate entities to XML. All the entities were properly converted to XML until I changed the attributes to LAZY fetching. I see problems in aliasing. I see some javassit code. However, this is happening to only one node. As you can see, for the "id2" it has aliased properly. <foo> <domain id="domain...

Hibernate Exception

org.hibernate.hql.ast.QuerySyntaxException: cannot dereference scalar collection element: cspName st.append("SELECT customers.name,sum(csp.cspValue) as TotalMoney "); st.append("from Account as account "); st.append("left join account.CSPFields as csp with ((account.accountID=csp.id) and (csp.cspName = 'Target')...

How can use Struts 2.0, Spring and Hibernate in my framework

Is it possible put these three framework Spring, Struts 2.0 and Hibernate in single application and how without using JPA? ...

GORM Querying where filter is not a direct attribute of a class.

I am trying to figure out the most efficient / effective way of performing a certain type of query using Grails GORM. This is the scenario where I want to query all of the children / linked items in a many to one relationship. This is a one way relationship whereby the many side used the id of the thing it is linked to. One example in...