hibernate

hibernate and netbeans application

how i configuration hibernate and netbeans>??give simple tutorial with some example ...

Hibernate / MySQL Bulk insert problem

I'm having trouble getting Hibernate to perform a bulk insert on MySQL. I'm using Hibernate 3.3 and MySQL 5.1 At a high level, this is what's happening: @Transactional public Set<Long> doUpdate(Project project, IRepository externalSource) { List<IEntity> entities = externalSource.loadEntites(); buildEntities(entities, project)...

Taking advantage of Hibernate lazy loading?

I have a domain object that has an attribute which is a collection containing another domain object. This is accomplished using a hibernate mapping (which eventually performs a join on another table). Hibernate, by default, seems to lazily instantiate this collection. This turns out to be a great thing because, depending upon what I n...

Composite id in hibernate+postgres breaks due to returned column order

I have a parent object with composite-id (legacy db - can't modify this). I have a child object that is a bidirectional one-to-many (parent-to-children) relationship. The mapping is correct, as I can load an instance of either entity and correctly navigate across the relationship. My problem comes when I store the parent and it cascade...

Error in creating alias in formula tag

Hi all I have a sql query in formula tag inside property tag. In that query i am creating alias name but the hibernate appends table name and throwing me error. select sum(e.salary) as sal from employee e but hibernate changes to select sum(e.salary) as employee.sal from employee e how to avoid this .... it should recognise as sa...

Wicket: how to handle long running tasks

Hey all, I've setup a Wicket + Hibernate + Spring Web application that involves gathering some data (having some files generated and returned), storing this in a database, creating some images and displaying all this on a webpage. This all works fine for short runs, but sometimes gathering the data (which involves some remote number cr...

Ignore Hibernate @Where annotation

I have an Entity which has an association to another Entity annotated with @Where, like so public class EntityA { @OneToMany @Where(...) private List<EntityB> entityBList; } Recently the inevitable has happened, I need to load EntityB's that don't conform to the @Where clause. I could remove the @Where annotation, but it...

How do I connect to multiple databases using JPA?

I have an application using Java servlets/JSP's. There are multiple clients using my app, however each client has a separate database. All the databases have the same schema. I would like to determine which database connection to use at the time when a user logs into the system. For example client A logs in, I determine that client A b...

How to force NHibernate not to update all objects in collection

Hi guys. How to force NHibernate not to generate UPDATE for each element in collection if I change only one element of that collection. Here it is: internal class Master { private int _id; public string Name { get; set; } public ISet<Slave> Slaves { get; set; } public Master() { Slaves = new HashedSet<Slave...

Query syntax error when bulk-deleting in Hibernate.

I try to executer bulk delete using Hibernate HQL query, following reference manunal but I get a query syntax error. This line final Query qry = getSession(false).createQuery(" delete from NewCalendarDay"); causes exception: org.hibernate.QueryException: query must begin with SELECT or FROM: delete [ delete from pl.com.bms.avaro.s...

Problem in using indexes with SQL Server 2005 and Hibernate

I've a problem with a query generated by Hibernate that do not uses an index. Access to database is made from Java using JTDS and server version is SQL Server 2005, latest service pack. The field is nullable and is a foreign key that, in some specific scenarios, could be completely null, column is indexed via a not clustered index but t...

How does Jpa Query.setParameter work with MetaValue (polymorphic query)?

Hi, I've been trying to use polymorphic query with JPA (hibernate as provider) in the following domain scenario: PriceTable (1) <--->(n) ItemPrice (n) <----> (1) Item So for each PriceTable registered in my system I have a set of item prices which describe the price of a given item on that table. An item can be an Equipment or a Struc...

Grails: org.hibernate.TransientObjectException

Simple Groovy\Grails code: def start = { source.save() def result = getJson(hotelSite, eng + index, [:]) parse(JSONObject.fromObject( result.json.text() )) render "OK" } def parse = {JSONObject json -> def cities = json.get("filter").cities println cities def kievHotels...

ORA-22835 using JPA (Buffer too small)

I am trying to persist an Entity with a @Lob annotated String field. The content of that fiels if bigger than the 40k buffer size limit. The first problem I had was related to the setString method used internally by the JPA implementation (Hibernate in my case) and the Oracle JDBC Driver. This problem was solved adding <property n...

Stange column name appearing in nHibernate generated SQL

For some reason the following mapping seems to be creating me a very strange column name that I cant find anywhere. There error occures when trying to load the Events collection which is defined as a IList<Event> <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="JeanieMaster.Domain....

get the size of a list in a property

I have a class A which have a list of B elements. In my A class i would like to add: int size; which will be valued with the number of B elements. So when I would call myA.getSize() I will have it. Is it possible to map a count query with a single property in the hibernate mapping? I don't want to load the list that is why i woul...

JPA/Hibernate query with class name?

In this example com.test.Cat extends com.test.Animal and there is no field DB in CAT table of com.test.Cat explicitly defining its type (it wasn't me). When I query my animals from DB I get a collection of Animals. It is possible to sort them by class name: order by r.class but is there a way to use class name as a criteria? For exa...

NHibernate query problem

Hi all, these are my entities (simplified): public class IdentificationRequest { private int id; private ICollection<IdentificationRequestStateHistoryItem> stateHistoryItems; public virtual string Id { get { return id; } private set { id = value; } } ...

Hibernate default values during runtime - best practice

Hi stackoverflow coders, I have an app (since the iPhone its really chic to use this word :-)) persisting its data with Hibernate. The database scheme contains several date fields which can be NULL. I configured Hibernate then to fetch the field value also as NULL. The customer wants to configure these values in case these are NULL. So...

NoPrimaryKeyException from DBUnit when loading a dataset into a databse

I'm getting NoPrimaryKeyException when I try to run one of my unit tests which uses DBUnit. The datatable is created using Hibernate and is a join table between two classes mapping a many to many relationship. The annotations that define the relationship are as follows: @Override @ManyToMany @JoinTable(name="offset_file_offset_entries",...