return « Field « JPA Q&A





1. Entities returned with only the ID field populated    forum.hibernate.org

Newbie Joined: Thu Jan 07, 2010 4:10 pm Posts: 1 When I get a JobPosting entity returned, the user, province, country and employmentType fields, fields that are mapped with @OneToOne and are unidirectional, are populated with their id field but no other fields are populated, respectively. For example, the employmentType field is of type EmploymentType and has two fields; an id ...

2. query order by an empty field doesn't return every rows    forum.hibernate.org

Hi, I have a query like this select t from Orders t order by t.merchanType.varMercTypeDescription desc The problem I have is if the field merchanType is empty, the query doesn't return that row. I have a grid where I want to let the user order by field. The other fields are always filled so it works great with them but when ...

3. How to return current date on query of date field.    forum.hibernate.org

I am using Hibernate 3 with a MySQL database and the current version of Java. I am currently implementing a search for dates and date ranges. My current table is very simple and contains a startDate and an endDate field. I am using a value of null in end date to signify the "present" or current date. Using HQL or the ...

4. Criteria does not return Boolean field    forum.hibernate.org

public List listDestacks() { return session.createCriteria(House.class) .add(Restrictions.isNotNull("destack")) .setProjection(Projections.projectionList() .add(Projections.property("codHouse").as("codHouse")) .add(Projections.property("destack").as("destack"))) .addOrder(Order.desc("dateInclusion")).setMaxResults(10).list(); }

5. Transient field returns "could not resolve property" error    forum.hibernate.org

public class Me { private Long id; private String username; private Car mycar = new Car(); public String getUsername() ...

6. String concatenation of returned fields in HSQL    forum.hibernate.org

Hibernate version 2.1.7 How do I do the equivalent of SELECT FIELD A || FIELDB FROM TABLE in HQL ? When I try this List list = getHibernateTemplate().find("select b.description2 || b.description3 from StandingDataRow a, StandingDataRow b" + " where b.description1 = ? and decimal(b.linkedTableKey1) = a.comp_id.genid " + "and b.comp_id.tabkey = ? and a.comp_id.tabkey = ? " + "and a.comp_id.genid > ...

7. Get after save returns MySQL TIMESTAMP field, otherwise not    forum.hibernate.org

I am using Hibernate 2.1.8 on JBoss 4.0.1 I am trying to avoid a round trip through Hibernate by returning the POJO ref after a save instead of just the id with a save and then the POJO ref with a get. This was a pattern I had developed while working with DTOs for the transfer to/from the session facade. So ...

8. returning selected fields from table    forum.hibernate.org

String queryString = "select distinct v.name, v.title from Vendor as v" Query query = session.createQuery(queryString); List list = query.list(); Iterator resultsIterator = list.iterator(); while (resultsIterator.hasNext()) { Object [] objects = (Object[]) resultsIterator.next(); //assuming that v.name and v.title are of type java.lang.String String name = (String) objects[0]; String title = (String) objects[1]; } //end of while

9. My HQL return all date fields with more 3 hours added    forum.hibernate.org

Hi, I am with a date problem with Hibernate. There are no exceptions and the code works fine! The problem is: 1. If I have the following date stored in the database: 2007-10-10 08:10:22. 2. When I run a HQL query, this date is added 3 hours. The date will be 2007-10-10 11:10:22. I already have tested with MySQL and Firefox ...





10. Possible to make criteria return field values?    forum.hibernate.org

Hello, I like criteria queries in hibernate quite a bit and would like to use them for a specific query problem. I need the query to return only the values of individual fields in a table (e.g. the primary keys) and not the entire row mapped to some Java object. Reading various books and docs I found no way to do ...