value « Query « JPA Q&A





1. Hibernate and order by using column values    stackoverflow.com

Is there a way I can pull off the below query (order by followed by a like) using hibernate criteria api?

select * from table where first_name like 'bar%' order by first_name ...

2. Hibernate - query caching/second level cache does not work by value object containing subitems    stackoverflow.com

I have been struggling with the following problem:
I have a value object containing different panels. Each panel has a list of fields. Mapping:

<class name="com.aviseurope.core.application.RACountryPanels" table="CTRY" schema="DBDEV1A" where="PEARL_CTRY='Y'" lazy="join">
<cache usage="read-only"/>
<id name="ctryCode">
<column name="CTRY_CD_ID" sql-type="VARCHAR2(2)" ...

3. Ordering results by computed value in Hibernate    stackoverflow.com

I have a table Player with columns id, name, wins, games_played. I mapped it to a class Player. I want to do the following query in Hibernate (preferably with Criteria, if not ...

4. Keeping only distinct values in tables using Hibernate    stackoverflow.com

I am storing a relatively complex immutable object in a database. There are many many-to-one associations - the object has properties that have properties and so on. I would like to ...

5. using hibernate criteria to select into value objects    stackoverflow.com

I'm trying to find out if it is possible to do the following HQL using the Hibernate Criteria API:

String hql = "select new InitialCount(substring(name, 1,1), count(id)) from Person group by substring(name, ...

6. how to select value from database using hibernate?    stackoverflow.com

I am newbie for hibernate,i am using mysql database,with two tables serviceTypeDetails,validateConfig.In serviceTypeDetails,it's having four types of services and another table validateconfig contain 31 row with respect to each servicetypeid,using hibernate ...

7. Hibernate: How to query to an object which it's collection proprty contains a specific value?    stackoverflow.com

I've got a Player Object in which there is a Collection<Stock>. I'm willing to write a hibernate query which returns the list of players who have a specific stock (for example ...

8. Using Hibernate and Criteria to Select the Most Common Value    stackoverflow.com

Given a table, say:

orderId | typeId
----------------
1       | 1
2       | 1
3       | 2
4  ...

9. How to find using JPQL if member value is in a collection of values    stackoverflow.com

I have an object in which a member is an enum, and I want to write a query returning all elements for which that member is in a list of values. ...





10. distinct clause not working properly in hibernate    stackoverflow.com

I am trying to get Distinct states of US from my SQL , but its distinct funtionality not working properly in hibernate , like Alaska is coming 6 times (its present ...

11. Hibernate :: Combine Column values    stackoverflow.com

how to combine column values on hibernate?
for example:

City
-------
texas
california
new york
newark 
Result:
City
-------
texas,clifornia,new york,newark

12. Select column value in Hibernate    coderanch.com

No. In your mapping you have an associated object called Product, which must have a property of id. As you have it the only way to get the value of that directly is to refer to it via the Product object. If you don't want to make reference to the product at all, you will need to add a read only ...

14. Change DB values for hibernate select    forum.hibernate.org

Hello everyone! The company I work for is using an old stupid ERP system, which treats the db column value of '8000000000000000' as null-> that's what it needs (dumb isn't it?). I somehow need to set up hibernate to treat this value as null. So, I wish hibernate to behave like this "If I see a column value of '8000000000000000' I ...

15. Show values of executed query    forum.hibernate.org

16. Including literal values in select clause of HQL    forum.hibernate.org

Is it possible to include a literal value in the select clause of an HQL query? For example, in an hbm file, Code: The reason that I want to do this is I have ...





17. Get property values when using Query.Scroll    forum.hibernate.org

I have the following .hbm.xml file ( part of it ): And I have this query to lookup in the database, and this code to check up the database for this object : ...

18. Need to count nulls with other values in one select    forum.hibernate.org

I am using hibernate 2.1 with Oracle 8.1.7. I want to count the various types of values in a column (called status), but one of the values is null. A simple "...count(status) group by status" will not work because the null are not compared and counted. If I run a the following query, I get the expected results: select count((nvl(status, 1)), ...

19. HQL query for selecting based on set of values in a collect    forum.hibernate.org

Hibernate version: 2.1.6 Name and version of the database you are using: MySQL 4.0.18 Hi: I am new to Hibernate and I went through most of the postings here and I am pretty sure this doesn't belong in the FAQ (I went through them also). My question is regarding the HQL query. It looked simple to me but I couldn't get ...

20. Criteria query linking one-to-many using a value not a class    forum.hibernate.org

Author Message aritchie Post subject: Criteria query linking one-to-many using a value not a class Posted: Tue Jul 19, 2005 10:56 am Newbie Joined: Tue Jul 19, 2005 10:33 am Posts: 3 Location: Omaha, Ne hibernate version 3.0 This is my mapping setup for a parent table sowtemplate and its children, goals, tasks and degrees. ...

21. Named queries with nullable columns/values    forum.hibernate.org

thanks for the reply - but I need matching values in this case (I only want null's if mycolval == null). I would use Criteria as follows: if(obj == null) criteria.add(Restrictions.isNull(mycol)); else criteria.add(Restrictions.eg(mycol, obj)); ??? however I can't figure out using this criteria with an aggregate select eg 'select max(t.num) from table t' --> + above Criteria

22. Querying against values in a collection of values    forum.hibernate.org

as far as I know, Criteria queries cannot be used with Collection objects. They can only be used with entities. Which is probably why you are getting the error. I am also looking for a solution to querying inside maps - I have been unable to do it till now. If someone knows the solution and could post it, it would ...

23. Criteria queries and value collections    forum.hibernate.org

...

24. Query for several collection values w/o huge no. of joins    forum.hibernate.org

Hi, I'm still trying to figure out how to query for an object that has several specified matches in it's collection object. So, say I have a Feature which has multiple Settings. I simply want to find the Features where the Settings are equals to "A", "B", "C" and "D". I can do this with multiple joins on Settings, but doesn't ...

26. Summing values in distinct objects    forum.hibernate.org

Hi! I'm new with Hibernate and HQL and I'm sure many of you can easily solve my problem, which seems quite challenging to me! I'm trying to get Hibernate to return a tuple with: 1) an Order object 2) the sum of Bill.value:s, where the Bills are related to the Order in question through one or more OrderItems 3) the sum ...

27. Query with constant value    forum.hibernate.org

28. Hibernate Projection Problem for Many-to-one Values    forum.hibernate.org

Hi, Hibernate version: 3.1 Mapping documents: CertCartons.hbm.xml Code between sessionFactory.openSession() and session.close(): List alReasons = hibSession.createCriteria(CertCartonsDTO.class,"carton") .createAlias("certPallets","cp") //association path with alias .setProjection(Projections.projectionList() .add(Projections.property("carton.ccCartonNo"),"ccCartonNo")// working well .add(Projections.property("cp.cpPalletNo"),"certPallets.cpPalletNo")) // Not working for many-to-one .add(Property.forName("carton.ccCartonNo").eq(new String("CA89374238"))) .setResultTransformer(new AliasToBeanResultTransformer(CertCartonsDTO.class)).list(); System.out.println("The list size is what???"+alReasons.size()); for(int i=0;i

29. Where clause to know if a collections contains some values    forum.hibernate.org

I'm new to Hibernate, and I can't find what i'm searching for. Here is what I want to do. I have a Adresse object which contains a array of long. I want to retrieve all Adresse objects that have at least one value (from a list a provide) in their long array. I'm searching for the HQL query to do this ...

30. Query with where clause on unflushed property values    forum.hibernate.org

HI! We are evaluating Hibernate (3.2.0CR1) for a large ERP app, that uses our own OR mapper at the moment. One of the biggest advantages of Hibernate over own OR mapper would be the automatic flush on commit, resulting in minimal lock time (updated, but not yet committed rows). So, I set FlushMode.COMMIT. Also, using EH 2nd level cache. Now, if ...

31. Finding distinct values from a set    forum.hibernate.org

@Entity public class Person { private Set _children = new HashSet(); private String name; @ManyToMany(targetEntity=Child.class, cascade=CascadeType.ALL) @JoinTable( name="CHILD_MAP", joinColumns={@JoinColumn(name="PERSONID")}, inverseJoinColumns={@JoinColumn(name="CHILDID")} ...

32. Value truncation while using decimals in select query    forum.hibernate.org

Hi, The mapping file for hibernate has the following for a db column. this is one of the primary key for my fetch. The value is set in Hibernate prepared statements is 1036479002, but the hibernate Query execution automatically runs the query for 36479002 against the DB. While I try the query with number 1136479002, ...

34. Select by scalar collection value    forum.hibernate.org

I have what seems to be a simple request, but I have found it very difficult to do. I have a scalar collection of strings for an object that represent (choose all that apply) answers. I want a query to find only the objects that contain a particular answer in their string collection. I tried an HQL query "from Member m ...

35. Select value object with native SQL    forum.hibernate.org

... ...

36. Querying against objects in a collection of values    forum.hibernate.org

Hi again, Having tried substituting the IDs as mentioned earlier I do get the query on the collection to work, however in doing this joins are created rather than a subquery. I am wanting to perform an 'OR' query and the join is not desirable. I understand that to perform a subquery I need to use DetachedCriteria in some way, however ...

37. ordering by calculated value    forum.hibernate.org

Dear Hibernate Experts, I need to order the results of a query by a calculated value. Specifically, I have a table with columns Latitude and Longitude and I need to order by Euclidean distance from 0, 0. In other words, i need "ORDER BY Latitude * Latitude + Longitude * Longitude" (Because sqrt is a strictly increasing function it can be ...

38. executing query and transient values    forum.hibernate.org

40. How to Select Distinct Values    forum.hibernate.org

Hi, How to select the distinct rows with the particular field like there is a particular field say "type" with that i have "TT" field value repeated twice where it should get only the distinct value with the row instead of fetching all the rows. How can this be acheived using the criteria queries or HQL. Pls Anyone help me in ...

41. Like Query with \ (backslash)as the value    forum.hibernate.org

hello, Why is it that my like query fails to return any values when I call it in the following way? criteria.add( Restrictions.like(attribute, values.toString(),MatchMode.ANYWHERE)); CASE 1 attribute - Headline values = "\" No values are returned eventhough the DB clearly shows values such as "hello\" CASE 2 attribute - Headline values = "\\" All values with \\ and \ are returned ...

42. Specifying Ordering from Enumerated Value    forum.hibernate.org

Hi, I have the following problem with enumerated values and ordering, and can not seem to find an answer. I am trying to use the JPA annotations and queries only. Hibernate entity manager 3.3.1.GA I have these two classes: @Entity @Table(name="SEVERITY") public class Severity implements Serializable, Comparable{ public enum ImfLevel{ INFO, WARN, SEVERE, CRITICAL; } private String severitytext; @Id private String ...

43. Querying against a collection of values    forum.hibernate.org

44. Select Collection of Value Objects    forum.hibernate.org

...

45. error while finding value from Db using Hibernate ....    forum.hibernate.org

hi i facing a Exception when i want to find the values from my DB using hibernate... in my Struts Action class i use that code ProductDAO ob=new ProductDAO(); List list=ob.findByTitle(my search value); request.setAttribute("products", list); but it create the Exception can some one Help me out what i m doing wrong and how to prevent or slove that Exception... Witing fr ...

46. Need Help with selecting a value from DB    forum.hibernate.org

Hi All, I tried to retrieve a value from DB using session.get(), but in session.get we can pass only the id of the table and we can retrieve according to table's id, but in my case i want to retrieve value by passing a string which is not the id, how can i do this without writing query. Thanks, vyrav.

47. injecting values into objects created by a query    forum.hibernate.org

Hi, I have two classes in a simple composition relationship: class A { private B child; } class B { private Policy policy; } At some point, I'm using Spring's Hibernate template to retrieve all entities of type A: hibernateTemplate.find("from A"); This query will return a list of instances of type A, each also having a lazy association to an object ...

48. selecting dfefault value from a one-to-many collection    forum.hibernate.org

I've been dealing with this for a few days now without success. I have a customer object with a collection of addresses. I'm mapped the usual one-to-many relationship successfully so that a customer has a set of addresses. I also have a requirement where I need to only get the default address (marked with a flag on the address field) from ...

49. HQL query sorted by a computed value    forum.hibernate.org