property « Query « JPA Q&A





1. HQL: order by property of nullable property    stackoverflow.com

Assuming two tables, A[a_id, b_id] and B[b_id,c]. I need to execute the HQL query of form "From A a ORDER BY a.b.c", while b is nullable in class A. The query,however, returns only ...

2. How to add a Hibernate property that's really a query    stackoverflow.com

We're using Hibernate to load objects that meet certain criteria. If the user decides to view the details on one of the objects, I want to pull up some additional ...

3. Hibernate criteria query on different properties of different objects    stackoverflow.com

Suppose I have classes like:

class A {
 B getB();
 C getC();
}

class B {
 String getFoo();
}

class C {
 int getBar();
}
and I want to filter criteria on A, two filters on different subclass ...

4. Hibernate Criteria / Query on object properties    stackoverflow.com

I have a class AppUser;

class AppUser {
   private String firstName;
   private String lastName;
   //-- getters and setters
}
I also have another class Student;
class Student {
  ...

5. Order by nullable property simultaneously with ordering by not nullable property in HQL    stackoverflow.com

I have a table called Users in my database. Let's assume that User has only 3 properties int ID; string? Name; string Login; If user doesn't specify his name then Login is displayed. Otherwise Name ...

6. How to make query on a property from a joined table in Hibernate using Criteria    stackoverflow.com

I have the following mapping:

<hibernate-mapping package="server.modules.stats.data">
    <class name="User" table="user">
       <id name="id">
            ...

7. HQL specify an order by property order?    stackoverflow.com

How can I order by a specific property order in HQL? For MySQL I can use: SELECT * FROM question q ORDER BY q.status IN ("DONE", "NO_ACTION"), q.status IN ("NEW","SAVED"), q.created DESC but ...

8. Collection property and Projections of Criteria API (Hibernate)    stackoverflow.com

I have two entities that relate to each other as "many-to-one". So one type of the entity has a collection of child entities of another type. Is it possible to retrieve ...

9. How to sum two properties in a hibernate query    stackoverflow.com

How do you do this in hibernate criteria API, select schedule.* from schedule inner join route on route.routeId=schedule.routeId where schedule.scheduledFor >=1292198400 and (route.plannedArrivalTime + schedule.scheduledFor) <= (1292198400 + 86399); I could not understand ...





10. Hibernate projection on many-to-many property    stackoverflow.com

I'm using Hibernate 3.3.2. I have class A, which has a property b, which maps a many-to-many relation to B. Class A has the following mapping:

<set name="b" table="a_b" lazy="true">
   <key ...

11. How using a derived property in HQL where clause    stackoverflow.com

i have an entity like this:

public class Account{
    private String code;
    @ManyToOne
    private Account ledgerAccount;


    public String getCode(){
  ...

12. JPA2 (Hibernate) how to query 2 tables (joined) but only need certains properties from 2nd table    stackoverflow.com

I am using JPA2 with hibernate as provider in java ee6 environment. I have a one to many relationship and when getting all the rows for the one side to display ...

13. Criteria query and     forum.hibernate.org

Hi, maybe this is a known issue or I am doing something wrong, but I haven't been able to find an appropriate topic. I need two attributes as the target of a property-ref from another class, so I am grouping them with Code: ...

14. Selecting a Collection Property in HQL causes SQLException    forum.hibernate.org

Hello, I'm having trouble selecting a collection property in HQL. I wrote a special Object which should be created by hibernate and be filled with several properties of the queried entity. This does not work if any of the properties I select is a collection. In the resulting SQL-Query Hibernate will include a dot without any name before or after it ...

15. PostgreSQLDialect can't handle order property    forum.hibernate.org

16. HQL specify an order by property order?    forum.hibernate.org





17. Simply HQL query, could not resolve property    forum.hibernate.org

class ClassA{ @Id private long id; @ManyToOne(cascade = CascadeType.ALL) private ClassB classb; getters(); setters(); } class ClassB{ @Id private long id; private String name; ...

18. How to use HQL query as a property?    forum.hibernate.org

19. Order property causes table not to get created, but no error    forum.hibernate.org

I hope I'm posting to the right section. I did a quick search and didn't found mentions of the problem I'm reporting. If this is a known issues and/or has been resolved in a more recent version, please ignore this. I just found out that if an object has a property "order", the table does not get created when Hibernate generates ...

20. Projection on properties of one table only    forum.hibernate.org

Hello, Here is my Criteria based multi join query. It works fine, except that I would like it to return only the mail properties and not the admin ones. I guess I need some projections to do that... Code: public List findLikePattern(String pattern) { pattern = "%" + pattern + "%"; ...

21. How to order a collection property ?    forum.hibernate.org

Pro Joined: Mon Apr 16, 2007 8:10 am Posts: 213 I have a property that is a collection. I mapped it so as to order it by the listOrder index, like: Code: ...

22. Select properties query    forum.hibernate.org

Hi, I face an issue with my query with some of the properties been specified in the query. Eg: My query looks like, SELECT student.firstName, student.lastName, student.rollNo FROM Student AS student I assume, this query returns a list of Student with values been set to the properties specified in the query and all other properties to null reference. But the result ...

23. HQL queries with property names    forum.hibernate.org

24. query with "special" class property    forum.hibernate.org

25. Get property NAMES when using Query.Scroll    forum.hibernate.org

For the moment, I have the following code : sql = "SELECT i.companyCode, i.fundSponsor FROM abpro.beans.Funds2 i WHERE i.fundCode = 'B91A' AND i.classCode = 'A'"; // create an HQL statement and execute hql = session.createQuery(sql); results = hql.scroll(); results.beforeFirst(); while(results.next()) { System.out.println(results.get(0) + " - " + results.get(1)); } With this code, I get the VALUE of the properties. But how ...

26. Querying for one object using a owned object's properties    forum.hibernate.org

I have a user object with properties stored in the userex table (first, last, user names, id). I also have a join table to the jobs table (a many-to-many user to jobs). The jobs table contains employer and city fields along with an id. This is a basic many-to-many realtional database setup. I have mapped user to jobs successfully and queried ...

27. How to set a collection count without new property    forum.hibernate.org

Author Message adcworks Post subject: How to set a collection count without new property Posted: Tue Jul 13, 2004 10:25 am Senior Joined: Fri Jun 18, 2004 10:17 am Posts: 140 I have a situation where I load a list of Schedule objects and each Schedule contains a Set of ScheduleUpdate objects. On my list page I only ever ...

28. How to find column name from a property?    forum.hibernate.org

I want to know how to find column name from a property at runtime? for example: public interface A { public String getColumnName(Class bean,String propertyName); } public class B { public void main(String[] d) { A a = getA();//do not care how to get ...

29. I want to know how to find column name from a property?    forum.hibernate.org

I want to know how to find column name from a property at runtime? for example: ? public interface A { public String getColumnName(Class bean,String propertyName); } public class B { public void main(String[] d) { A a = getA();//do not care how to get ...

30. Selectively updating properties    forum.hibernate.org

Hibernate version: 2.1.6 Mapping documents: Code:

31. Can't find hibernate.properties in a JARed application    forum.hibernate.org

public static void main( String[] args ) { // extract hibernate.properties location from path if ( args.length < 1 ) { System.out.println( "Please specify the hibernate property file" ); return; ...

32. problem with derived property in criteria query    forum.hibernate.org

java.lang.NullPointerException at org.hibernate.persister.entity.AbstractPropertyMapping.toColumns(AbstractPropertyMapping.java:68) at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:33) at org.hibernate.persister.entity.BasicEntityPersister.toColumns(BasicEntityPersister.java:1104) at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:402) at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumnsUsingProjection(CriteriaQueryTranslator.java:368) at org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:42) at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:313) at org.hibernate.loader.criteria.CriteriaLoader.(CriteriaLoader.java:92) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1228) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:299) ...

33. Query is assuming a method as a property    forum.hibernate.org

Hibernate version: 2.17 I have 2 classes: Task and Group (TASK and GROUP tables respectively). There is one-to-many association from Task to Group. public class Task implements Serializable { private taskId Integer; ... public Integer getTaskId() { return taskId; } private void setTaskId(Integer taskId) { this.taskId = taskId; } ... } public class Group implements Serializable { private groupId Integer; private ...

34. Can't select byte[] property after migrating to Hibernate3    forum.hibernate.org

After migrating to Hibernate3, the following query can't be executed. select rightGroup.right from RightGroup rightGroup inner join rightGroup.userGroups userRightGroup where userRightGroup.userNo = ? and rightGroup.corpNo = ? and rightGroup.valid=1 The error message is: unexpected token: . near line 1, column 18 [select rightGroup.right from com.thunisoft.summer.right.data.RightGroup rightGroup inner join rightGroup.userGroups userRightGroup where userRightGroup.userNo = ? and rightGroup.corpNo ...

35. Subqueries.in VS Property.forname().in    forum.hibernate.org

Not sure if this is related, but I keep getting there classcastexceptions for just about anything now. Mapping: ID_SEQ ...

36. how to include all class properties in a report query    forum.hibernate.org

I want to create a report query, but I need to get properties defined for the class I am quering. Is there a method I can call that call create a select statement that would give me the select done for all class properties - e.g select A.prop1, A.prop2, A.prop3, A.pro4 from A ?

37. Order by sub property    forum.hibernate.org

public class Item { protected Integer itemId; protected State state; //getters and setters } public class State { protected Integer stateId; protected String name; protected String description; protected Integer naturalOrder; ...

38. How to use Criteria query on "class" property    forum.hibernate.org

How do I to use Criteria query on "class" property with custom discriminator-values? I've tried to find this from the docs, forums and google but found no clear answer. I tried various ways but none works: Code: s.createCriteria( Person.class ) .add( Restrictions.eq( "class", ...

39. HQL query with select new on class and also property    forum.hibernate.org

I am not sure whether this is possible to do. I have an HQL query this does "select distinct c from Class1 c, Class2 d where c.column1 = d.column2". That works fine, but now I have a property on Class1 that is not persisted in the database, however, when I do the same HQL query, I want to populate the value ...

40. Use properties instead of columns in collection order-by??    forum.hibernate.org

Thanks for your reply. I am aware of some of the options for sorting in Java. But doesn't that mean you have create a Comparator class for each collection you want to sort? Either way, it seems many people would want to do the ordering on the DB side. So why the SLQ-centric mapping for order-by? We've gone through the great ...

41. Accessing "virtual" properties in a select stateme    forum.hibernate.org

Hello. I have the following problem: in a SQL Statement "SELECT ..., 1 AS userCompanyID FROM Companies" i want to access the "virtual" Property userCompanyID and its value 1. "userCompanyID" doesnt exist as a column in my Companies-Table and should be readable from my Dataobject CompanyData (which is mapped to the Companies-Table) Hibernate argues that the column of my virtual property ...

42. Select ignoring any property    forum.hibernate.org

Author Message nicfournier Post subject: Select ignoring any property Posted: Thu Sep 01, 2005 4:01 pm Newbie Joined: Thu Jan 06, 2005 4:41 pm Posts: 8 Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: Hibernate 3.0.5 I just migrated to hibernate3 and one of my HQL query does not work anymore. To give some background ...

44. Removing properties from select    forum.hibernate.org

I have got an object which contains some complicated derived fields, based on values on other tables etc. I am worried about the performance implications of this since the derived queries always appear in the select clause of the sql if I use the criteria api. Is there a way of preventing this, ie only select a limited number of values ...

45. Excption with order by : could not resolve property    forum.hibernate.org

We select objects of type EvaluationFunction and up till now we only ordered these objects on columns proper to this table. Now a new requirement entered and the elements of the Evaluationfunction table must be ordered by a field of a foreign key field. Obviously this did not work too well. We added code bit in case if refers to a ...

47. How to access class properties in select w/ several classes    forum.hibernate.org

Hibernate version: 3.0 Hello everyone. I have a doubt. I have the following SQL: Code: Query select = session.createQuery("from OrdemItens oi," + ...

48. Wrapping selected object properties and ...    forum.hibernate.org

I need to point it out that the HQL in this thread only let Hibernate issue a single SQL statement and fetch data from the Book table only. A join statement is needed in order to fetch data from the Review table as well along with its parent object. This is an information from the reference documentation.

49. Can I use a property of a CompositeUserType in an ORDER BY?    forum.hibernate.org

Author Message kjohnston Post subject: Can I use a property of a CompositeUserType in an ORDER BY? Posted: Wed Dec 14, 2005 5:30 pm Newbie Joined: Wed Dec 14, 2005 4:20 pm Posts: 2 Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Can I use a property of a CompositeUserType in an ORDER BY? I am seeing ...

50. Problem with Projections.property and CompositeUserType    forum.hibernate.org

Hi Ivan, I solved the problem this way: Code: try { final Criteria criteria = HibernateUtil.getSession().createCriteria(IContract.class); ProjectionList projections = Projections.projectionList(); projections.add(Projections.property("value.value")); projections.add(Projections.property("value.currency")); ...

53. FK is PK: Unable to find properties    forum.hibernate.org

Unable to find properties (contractnr, producttypenr) in entity annotated with @IdClass:nl.reinders.bm.Producttype2Contract I assume this exception tries to tell me it can't find the properties in the Producttype2ContractPK class specified in nl.reinders.bm.Producttype2Contract. So I tried to resolved that, but now am stuck. There basically is a N-M relation between Producttype and Contract. However, the N-M relation "Producttype2Contract" itself contains some attributes, so ...

54. Using criteria query with collection properties    forum.hibernate.org

55. Querying for an object based on a property in a set...    forum.hibernate.org

class link { private Integer id; private Set uids = new HashSet(); // set of uidclass // ctor snipped // plain jane getter and setters snipped } class uidclass { private String uid; private boolean someprop1; private boolean someprop2; // ctor and plain jane ...

56. query referencing a property which is not explicitly joined    forum.hibernate.org

Hello, sorry if that is obvious to more experienced Hibernate users: i want to achieve ordering on the following query: select day.items from Day as day where (year(day.day) = ? and month(day.day) = ?) order by day.day asc, item.hour asc ---------------- the day.items is a Map Hibernate complains: org.hibernate.hql.ast.QuerySyntaxException: Invalid path: 'item.hour' how do I have to write the query correctly? ...

57. could not resolve property: in Criteria Query (joined Table)    forum.hibernate.org

Hello, i have a problem with searches in embedded(joined) Objects(tables). Following Query works in Hibernate Console: select abw.dbKey, abw.auftrag.kunde.kundenName from de.test.pps.VoAbweichung abw where abw.auftrag.kunde.kundenName like 'xyz%' If i make the same in a Criteria Query, i get the errormessage org.hibernate.QueryException: could not resolve property: auftrag.kunde.kundenName of: de.test.pps.VoAbweichung Hibernate version: hibernate 3.0.5 Mapping documents:

58. how can i find the cloumn of a property ?    forum.hibernate.org

hi , i need to develop a db configuration project . i need to find the physical table name of a property , this is easy if the property is belong to the entity's mapping table , but sometimes ,many to many , there will be a middle table ,so the property possiably come from this middle table , i can ...

59. Select just collection and a couple properties from object?    forum.hibernate.org

Newbie Joined: Fri Mar 24, 2006 2:07 pm Posts: 8 Details below, but basically I am trying to work out how to select a collection from an object in HQL without getting the whole object. I have an object A with a map of children (KEYOBJ, VALUEOBJ) and A contains various other properties. In this particular case I want to just ...

60. criteria order for joined table property?    forum.hibernate.org

This is undoubtedly something stupid on my part and I'm sure this must have been asked before but I can't find the answer... so here goes: I have two entities, Person and Country. There is a many to one relationship from Person to Country (i.e. a person has a country). I want to get a list of people sorted by the ...

62. Collection-valued property query    forum.hibernate.org

Hibernate version: 3.3.1.GA Mapping documents: I use annotations Code between sessionFactory.openSession() and session.close(): I use spring-orm, so i do not manage the sessions directly. Full stack trace of any exception that occurs: No exceptions at this time Name and version of the database you are using: hsqldb-1.8.0.10 The generated SQL (show_sql=true): Debug level Hibernate log excerpt: Hello, I would very much ...

63. Using properties in WHERE clause of a SQLQuery    forum.hibernate.org

64. Problem with order-by property    forum.hibernate.org

Newbie Joined: Fri Feb 27, 2009 7:57 pm Posts: 1 Hibernate version :- hibernate-3.2.1.ga. I am using a library example , the diagram is on this page at the top. http://www.eclipse.org/modeling/emf/docs/1.x/tutorials/glibmod/glibmod_emf1.1.html#top I have created the folowing already: Library:My Library Writer: JRR Tolkien Book: The Hobbit As a next step I am trying to add more books to an existing Writer. I ...

65. [Criteria] do not select all properties on join    forum.hibernate.org

66. HQL superclass's property not set on select    forum.hibernate.org