hibernate

how long can spring hibernatetemplate createSQLQuery where in(..) can be?

is there any limit of statement i can use where in(1,2,3,4,5,6....) in createSQLQuery in spring hibernatetemplate() ? ...

HQL : Getting the primary key of an object.

Hi , I am using HQL to save an object in the DB. It is something like this Query query = sessionFactory.getCurrentSession().createQuery(ASK_FOR_HELP_SAVE_QUERY); query.setInteger("status", askForHelp.getStatus()); query.setString("requestId", askForHelp.getRequestId()); query.setString("toAccountId", askForHelp...

How can I use Spring HibernateOperations for simple operations with a implicit transaction?

Hi all, I currently make heavy use of HibernateOperations in Spring for working with Hibernate. Some of the time I use a TransactionTemplate to demark a transaction explicitly. However sometimes I just want to save/update a single object. If I just call hibernateOperations.save() with no explicit transaction active then it sort of wo...

Hibernate and dry-running HQL queries statically

I'd like to "dry-run" Hibernate HQL queries. That is I'd like to know what actual SQL queries Hibernate will execute from given HQL query without actually executing the HQL query against real database. I have access to hibernate mapping for tables, the HQL query string, the dialect for my database. I have also access to database if that...

Hibernate. big Results and Pagination

Hi there, atm I'm fetchin a small amount of data (round a bout 100 records) as list and let displaytag render a table for this data. Now I'm facing a problem: I'm in need to show more results at once. If the query results in a size of > 5000 objects everything slows extremly down. I was wondering if there are any best-practices to reci...

Mapping multi-Level inheritance in Hibernate with Annotations

Take the situation listed in this question: http://stackoverflow.com/questions/261407/mapping-multi-level-inheritance-in-hibernate/1883829 How would this mapping be done with Annotations rather than an hbm file? ...

Grails dynamic database connections?

Where I'm working, we have multiple database we need to be able to query. Some of them are predefined and we're using Datasources to access. Others are named after the customer id #. For instance _2. We have hundreds of customers and some customers can pose as other customers and depending on which customer is using the interface at t...

HibernateTemplate Composite Key fetching value null

Hello All... I have one table that has composite key 'rid' and 'sid'. For that i have made following beans to map with hibernate annotations : WBList.java ============ @Entity @IdClass(WBListPK.class) public class WBList { private int rid; private int sid; private String wb; @Id @JoinColumn(name="rid") public ...

Update one value from a list of dependent objects

Given an entity with a list of components: class Entity{ Long id; String name; List<Component> components = new ArrayList<Component>(); } class Component{ Object value; } Configuration: <hibernate-mapping> <class name="Entity" table="entity"> <id name="id" access="field" column="id"/> <property name="...

cancel hibernate query

If user press the "search" button and then they desided to do "something else", we have to cancel already running query. We use Hibernate (and Oracle) as persistence solution. Hibernates Session interface provides cancelQuery() method. After some trys, it seams that cancelQuery() has no effect. Does somebody have some experience this t...

Connection hangs after time of inactivity

In my application, Spring manages connection pool for database access. Hibernate uses these connections for its queries. At first glance, I have no problems with the pool: it works correctly with concurrent clients and a pool with only one connection. I can execute a lot of queries, so I think that I (or Spring) don't leave open connecti...

Hibernate : Java Application must be restarted for data to be realoaded.

I am programming a JSP/JSF Web application and currently using Hibernate (and MySQL) libraries. When I update data using my running application everything is working fine. Example : I modify a customer information Although if I change data manually or add an entry in MySQL manually, the change will not be effective on my application si...

Getting Hibernate Exception : org.hibernate.QueryException: could not resolve property

Hello All... I have one table with composite key attribute.. For that i have made 2 beans for hibernate annotations mappings.. Now, it works fine for save, update and delete.. But when I am fetching using some criteria, it's giving me "could not resolve property" exception. My Beans are as follows : WBList.java @Entity public clas...

Breaking up a large Hibernate class

Dear all, I have a Hibernate class which is essentially just a wrapper around loads of collections. So the class is (massively simplified/pseudo) something like: @Entity public class MyClass { @OneToMany Map1 @OneToMany Map2 @OneToMany Map3 AddToMap1(); AddToMap2(); AddToMap3(); RemoveFromMap1()...

In-MemoryDB: create schema in 'setUp()' of Unit Testing: Netbeans (6.5.1) Hibernate (3) Junit(3), HSQL (1.8)

What are the steps needed to setup an in-memory DB, build the schema automatically with Hibernate's 'hbm2ddl' tool within a Junit (3) 'setUp()' using Netbeans 6.5.1 ? I'm not using Hibernate annotations - just a mapping file. For the actual code, I want to use an on-disk database of course. [that is the Junits live a separate 'test' pac...

Io exception: There is no process to read data written to a pipe.

I'm using Hibernate3.2+Websphere6.0+struts1.3.. After deploying ,application works fine. After some idle time ,i will get this type of error repeatedly,am not able to login at all. Im not using any connection pooling. i feel after idle time its not able to connect to the database again..if i restart the server everything works fine for ...

Adding an enum as a class property in HBM.

I am trying to create a class in HBM file which contains an Enum as a field. The HBM is similar to this: <class name="a.b.c.myObject" table="OBJECT" > <property name="myEnum" column="EXAMPLE" type="a.b.c.myEnum" /> </class> and let's say that this is the Enum: public enum myEnum{ a, b, c; } The problem is that in the DB...

In Grails how do I access the hibernate session inside of a domain class static method?

I've read various articles on the web, but they seem rather scattered on this point. Exactly what do I need to do in my configuration and in my method to get the hibernate session. I'm trying to make some direct sql calls for stored procedures. I have a large code base that I am porting from Ruby with lots of static methods and stored...

How to use JUnit and Hibernate usefully?

I want to use JUnit to test Hibernate code such as insert, update, delete,.. method and transaction management. But I don't know how to apply unit test for Hibernate usefully and what should I test with Hibernate. How can I test DAO methods? Hope that you could give me some guides! ...

Use Tomcat 6.0 as server for java web application cause javax.persistence annotations to be messed up

Normally, I use Glass Fish as my testing server for NetBeans. Recently, I tried to switch to Tomcat 6.0. As soon as I changed the server, compiler no longer understand javax.persistence.Entity. When I checked out the library structure of Tomcat 6.0, there was a file named annotation-api.jar, in which another javax.persistence package res...