hibernate

Query in Lucene

The structure of the table "testtable" is id int primary key productid int attributeid int value varchar(250) where productid is the unique id of a product, attributeid is the unique id of attribute of a product e.g. size, quality,height, color and 'value' is the value for the attribute i have to filter a result. I achieve the re...

hibernate cascade deletion

i have one class called course and one class called tutorials in class i hav set of tutorials .Wnen i delete course i want all tutorials associaed with that course to be deleted . But presently the tutorials are not geting deleted when i delete the owner course only the foreign key courseid in tutorials tables becomes null; i am using ...

hibernate cascade deletion example

can any one provide me full 2 mapping file which implements cascade delete. measn if A contasis a set of B then when A is deleted B shold automatically be deleted. ...

OneToOne relationship with shared primary key generates n+1 selects; any workaround?

Imagine 2 tables in a relational database, e.g. Person and Billing. There is a (non-mandatory) OneToOne association defined between these entities, and they share the Person primary key (i.e. PERSON_ID is defined in both Person and Billing, and it is a foreign key in the latter). When doing a select on Person via a named query such as: ...

Hibernate Criteria query with restricted associations

The use case here is to find some restricted set of Boys who have Kites with lengths in a certain range, and then optionally retrieve all of the Kites in that range belonging to those boys. Do not assume that I know much about SQL or Hibernate. I would like to form a Hibernate Criteria query where an associated collection has been res...

How to maintain null for numeric values when using BeanUtils.copyProperties?

I have a numeric database field (numeric(3) in SQL Server 2000) that allows nulls, and null is my preferred "no value" value. That field is mapped to the non-primitive java Long class in Hibernate: <property column="my_column" name="my_column" type="java.lang.Long" not-null="false" /> The field is set as java.lang.Long in both my stru...

Using Different Hibernate User Types in Different Situations

I am using Hibernate + JPA as my ORM solution. I am using HSQL for unit testing and PostgreSQL as the real database. I want to be able to use Postgres's native UUID type with Hibernate, and use the UUID in its String representation with HSQL for unit testing (since HSQL does not have a UUID type). I am using a persistence XML with dif...

JPA/Hibernate Query Returns Stale Results

I am using an EXTENDED Persistent Context because it will allow me to Lazily Load a one-many relationship on an object and it also won't require a SELECT before I "merge" an object with the persistent context. I have an DummyObject with: A "Last Updated" Date Field A One-Many Relationship This Object is being updated every 5 seconds...

Cascading updates with business key equality: Hibernate best practices?

I'm new to Hibernate, and while there are literally tons of examples to look at, there seems to be so much flexibility here that it's sometimes very hard to narrow all the options down the best way of doing things. I've been working on a project for a little while now, and despite reading through a lot of books, articles, and forums, I'...

Hibernate Example OneToMany with compositeKey

Can you give me an example of a Hibernate mapping for the following situation: Parent table(foo) with a simple primary key (foo_id) child table(bar) with a composite key consisting of a> Foreign key to parent table (foo_id) b> key(item) of type string There is one parent to many child The Parent class will have a list of Child objects...

Getting Hibernate to do simple updates, instead of enormous select then updates...

Lets setup the question first. What I have is >4 tables: Customer, Address, Order, OrderItems. Each are mapped using Hibernate Annotations and accessed through a Spring DAO/Services layer. What I am trying to do is merge duplicate customers together. So all that really needs to happen is all orders and addresses associated with custom...

What's the default value of the Hibernate property hibernate.jdbc.factory_class?

I want to provide a custom Batcher for Hibernate to use (for this reason: http://stackoverflow.com/questions/83093/hibernate-insert-batch-with-postgresql), but I want to create a modification of whatever it's already using (BatchingBatcher or NonBatchingBatcher). What's the default value of hibernate.jdbc.factory_class, or how can I fig...

What's wrong with this HQL? "No data type for node"

session.createQuery("Select attribute from GoodsSection tgs " + "join gs.ascendants ags join ags.attributes attribute " + "where attribute.outerId = :outerId and tgs = :section ") .setString("outerId", pOuterId) .setEntity("section", section) .setMaxResults(1) .uniqueResult(); Looks fine to me, but the result is java.lang.Ille...

Hibernate Unidirectional Parent/Child relationship - delete() performs update on child table instead of delete

If I delete a record from the Parent table I want the corresponding records in the child table to be deleted. How can I make Hibernate delete from the Child table rather than attempt to update with a null? I'm using Hibernate 3 but cannot use annotations at this time. I've attached copies of HBM, DAO etc below. -- Thank you in Advance...

Bypassing DELETE_ORPHANS in a transaction when moving objects from one parent to another, hibernate.

I am using a combination of Spring 2.5.6 and Hibernate Annotations. I have three objects(tables or w/e) under consideration: Customer, Address, Order. Customer has the Cascade DELETE_ORPHANS property set for addresses. What i am doing is a customer merge, i'm moving all addresses and orders from one customer to another, then setting a d...

Java: Using which database technology could I persist objects? (Something that does NOT require me to take care of mapping objects to tables and back)?

Hello! I need to use an object oriented data repository for a project. It's going to be something between a wiki and a CMS. I'm not an expert in the field of persistence yet. I suppose Hibernate and Jackrabbit are the frameworks to go, right? As far as I'm informed correctly, Jackrabbit does not support annotations or other convenienc...

Hibernate findByCriteria strange behaviour

I have a simple method that just does two lines and tries to return all objects in an oracle database table: DetachedCriteria criteria = DetachedCriteria.forClass(Object.class); return (Collection)getHibernateTemplate().findByCriteria(criteria); However, I got an "ORA-01031: insufficient privileges" error. When I checked the logs for ...

Hibernate Query Hints for JPA

I have been trying to find a definitive resource for all of the hints that can be set through the Query.setHint(String,Object) method call in JPA, but I am coming up empty. Anyone know if a good reference? ...

Hibernate findById isn't finding records that it previously found

We have a very simple method that uses "findById". public Cart getCart(long cartId) { Cart cart = null; try { dbSession.beginTransaction(); cart = (Cart)dbSession.findById(Cart.class, cartId); dbSession.commitTransaction(); if (logger.isDebugEnabled()) { logger.debug("The getCart call committed successfully"); } } f...

Query for restricting associated entities

I would like to form a query where an associated collection has been restricted, ideally with Hibernate Criteria or HQL, but I'd be interested in how to do this in SQL. For example, say I have a Boy class with a bidirectional one-to-many association to the Kites class. I want to get a List of the Boys whose kites' lengths are in a range...