hibernate

How do I use a custom select statement in Hibernate using the HibernateDaoSupport class

I am trying to write a custom select statement in Hibernate using the getHibernateTemplate() method. I am having problems with the resulting mapping. Example Code: List<User> users = getHibernateTemplate().find("Select user, sysdate as latestPost from User as user"); for (User user : users) { assertNotNull(users.name); } The goal of...

oracle hibernate + maven dependenciesm dbcp.basicdatasource exception

I'm trying to create a web application using maven, tomcat and hibernate. Now I'm getting a cannot find class for org.appache.commons.dbcp.basicdatasource for bean with name datasource... exception. Without the hibernate aspects it works fine, but if I add <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <pro...

How to write native SQL queries in Hibernate without hardcoding table names and fields?

Sometimes you have to write some of your queries in native SQL rather than hibernate HQL. Is there a nice way to avoid hardcoding table names and fields and get this data from existing mapping? For example instead of: String sql = "select user_name from tbl_user where user_id = :id"; something like: String sql = "select " + Hiberna...

Hibernate vs. Apache Torque

Can anybody provide detailed advantages and disadvantages of each ORM? First of all I'm interested in things that Hibernate provides, and Torquay not. ...

HIbernate query

Hi I want to execute a query using hibernate where the requirment is like select * from user where regionname='' that is select all the users from user where region name is some data How to write this in hibernate The below code is giving result appropraitely Criteria crit= HibernateUtil.getSession().createCriteria(User.class); ...

OS Reboot, Shutdown, Hibernate, Sleep, Wakeup (Windows Python)

Hi, I'm looking for an automatize way of doing Windows Power Management functions: - Reboot - Shutdown - Hibernate - Sleep - Wakeup Is there a Python module to cover this functionality? Of course any other solutions are also appreciated... ...

ORM in the realworld

I am begining a new project that i think will last for some years. Am in the point of deciding the ORM framework to use (or whether to use one at all). Can anyone with experience tell me whether orm frameworks are used in realworld applications. The problem i have in mind is this: The orm tool will generate for me tables and columns etc ...

easy object persistence strategy - hibernate?

Hi! I'm doing a Java software-project at my university that mainly is about storing data-sets (management of software tests). The first thing I thought of was a simple SQL DB, however the necessary DB scheme is not available for now (let's say the project is stupid but there's no choice). Is a persistency framework like Hibernate able...

Hibernate: Dirty Checking and Only Update of Dirty Attributes?

Hello Experts, in "good old JDBC days" I wrote a lot of SQL Queries that did very targeted updates of only the "attributes/members" that were actually changed: For Example having an object with the following members: public String name; public String address; public Date date; If only date was changed in some Business Method I woul...

Fetching multiple bags efficiently

Hi! I'm developing a multilingual application. For this reason many objects have in their name and description fields collections of something I call LocalizedStrings instead of plain strings. Every LocalizedString is basically a pair of a locale and a string localized to that locale. Let's take an example an entity, let's say a book -...

how to save an array value using hibernate

Hi All, i have a bean with type string[] which has two or more values .I want to save the array user.setItem(item[i]); session.beginTransaction(); session.save(user); session.getTransaction().commit(); but i am getting only one data saved not the entire array ...

Are there some newer books to read beside these?

I've come accross these websites who recommend certain books but they are pretty much old : http://www.joelonsoftware.com/navLinks/fog0000000262.html http://www.codinghorror.com/blog/2004/02/recommended-reading-for-developers.html http://sites.google.com/site/steveyegge2/ten-great-books Are there books in recent years which every dev...

Does Hibernate always need a setter when there is a getter?

We have some Hibernate getter methods annotated with both @Column and @Basic. We get an exception if we don't have the corresponding setter. Why is this? In our case we are deriving the value returned from the getter (to get stored in the DB) and the setter has no functional purpose. So we just have an empty method to get around the...

Is it possibele to write this SQL statement using HQL?

There is sql statement select distinct create_date from articles Is it possibele to write this statement using HQL? Cheers! ...

Changing location of c3p0.properties and hibernate.properties.

I have a problem regarding the use of hibernate.properties and c3p0.properties. I am dependent upon an API. The API uses Hibernate. As such the API has it's own hibernate.properties and c3p0.properties file included within its delivery jar. I need to ensure I ignore these properties completely when instantiating my Hibernate SessionF...

Hibernate HQL m:n join problem

I am very unfamiliar with SQL/HQL , and am currently stuck with this 'maybe' simple problem : I have two many-to-many Entities , with a relation table : Car , CarProblem , and Problem . One Car may have many Problems , One Problem may appear in many Cars, CarProblem is the association table with other properties . Now , I want to ...

Is this possible: JPA/Hibernate query with list property in result ?

In hibernate I want to run this JPQL / HQL query: select new org.test.userDTO( u.id, u.name, u.securityRoles) FROM User u WHERE u.name = :name userDTO class: public class UserDTO { private Integer id; private String name; private List<SecurityRole> securityRoles; public UserDTO(Integer id, String name, List<SecurityRole>...

Adding JBoss repository to m2eclipse, no latest Hibernate version

I'm trying to add JBoss repository to m2eclipse, mainly for Hibernate. It seems to work, but it can't find the latest version of Hibernate (3.5.1), only 3.5.0beta. I looked at some other packages, and they all seem a couple of months behind. What could be causing this? I'm running latest m2eclipse, and i guess latest Eclipse (it just say...

Generation of Create_Date and Update_Date columns using Hibernate

I'm using straight Hibernate 3.0 without annotations. When saving or updating domain objects, I would like to have Hibernate automatically generate the CREATE_DT and UPDATE_DT fields, as opposed to using database triggers. What are the best practices for accomplishing this? The background is that I have an object graph being passed ...

How to properly test for constraint violation in hibernate?

I'm trying to test Hibernate mappings, specifically a unique constraint. My POJO is mapped as follows: <property name="name" type="string" unique="true" not-null="true" /> What I want to do is to test that I can't persist two entities with the same name: public class ExpertiseAreaDAOTest{ private ExpertiseAreaDAO ead; static ...