result 1 « Query « JPA Q&A





1. hibernate result ordering    stackoverflow.com

how do i sort the result( list ) returned byhibernate dynamically.Means i dont want to put the order by clause in hbm file. This is because i want to sort then ...

2. Hibernate - Same result after update/select    stackoverflow.com


hibernateSession.createQuery("select foo where id = 1");
// This command return the Item with id 1.

// [BREAK POINT STOP] ==> I go in MySQL and I delete this item ...

3. Projections.count() and Projections.countDistinct() both result in the same query    stackoverflow.com

EDIT: I've edited this post completely, so that the new description of my problem includes all the details and not only what I previously considered relevant. Maybe this new description will ...

4. JPA + Hibernate + Named Query + how to JOIN a subquery result    stackoverflow.com

Can anybody help me in converting the following native query into a Named Query? Native Query:

SELECT 
      usr1.user_id, urr1.role_id, usr2.user_id, urr2.role_id, usr1.school_id, 
     ...

5. Hibernate find by criteria get single result    stackoverflow.com

i am experimenting using Hibernate. I am trying to get a User by id this is what i do

public User get(DetachedCriteria dc){
    List<User> users = getHibernateTemplate().findByCriteria(dc);
    ...

6. Problem with getting query result from database    stackoverflow.com

I made a class called SpecializationBean which has two private fields:

private ArrayList<SelectItem> specializationItems= new ArrayList<SelectItem>();
private String specializationName;
I have ofcourse a getter and setter for those two. and a buildSpecializationList method which builds ...

7. How to get the results with count 0 too with Hibernate?    stackoverflow.com

I am using the Projections.rowCount() function on Hibernate, but it will only return the counts greater than 0. I need to get the list with the 0 count too. This is the ...

8. Hibernate query result    stackoverflow.com

I have the following query in my application:v

public List getLocation(String id) {
    List object = null;
    try {
        ...

9. Hibernate - Perform HQL query on Criteria Result    stackoverflow.com

I am concerned with a problem regarding criteria and hql. In first step a complex criteria construction limits a big amount of datasets. In second step a hql calculation should be performed on ...





10. getting result set into DTO with native SQL Query in Hibernate    stackoverflow.com

I have a query like below

select f.id, s.name, ss.name
from first f
left join second s on f.id = s.id
left join second ss on f.sId = ss.id
If I could use HQL, I would ...

11. JPA one-to-many query result problem    stackoverflow.com

Ok I have a 1-to-many mapping between a parent and child class. I can save the parent and it will automatically save the children objects, but problem is when doing a ...

12. JPA Query - how to get a specific result set?    stackoverflow.com

In an app based on JPA2/Hibernate/Oracle+Spring+Wicket, I use the following model:

public class Item {
 private String name;
 private Set<Application> apps;
 private ...
}

public class Application {
 private String applicant;
 private Item item;
 ...

13. Hibernate HQL query results problem    stackoverflow.com

In the web application I'm developing I use this query "from Messages".Although there are 13 records in messages table at my database,when I print the results I get this: 1) id:0 mesname:bla ...

14. HQL - get results from select with DOT seperator    stackoverflow.com


Is it possible to get HQL results with dot.
for example:

select Employee.name as 'Employee.name'
I know that mysql allows that, is there any support fir that in hibernate.
This ...

15. Tuple result Criteria API subquery    stackoverflow.com

I am trying to use subqueries in an application I am writing using JPA 2.0 type-safe criteria API, with Hibernate 3.6.1.Final as my provider. I have no problem selecting primitive types ...

16. hibernate query result to a predefined object?    stackoverflow.com

It is possible in hibernate to get a result of a query to a mapped db object. Is it possible to create a non-persistent object and get the query result into ...





17. Select top 1 result using JPA    stackoverflow.com

I need to bring from DB only one single result. How can I do that with JPA?

Select top 1 * from table
I tried
"select t from table t"
query.setMaxResults(1);

query.getSingleResult();
but didn't ...

18. Cache Results of Db queries and Keep them updated    stackoverflow.com

My usecase is

  1. I want to cache results of few database queries in memory so that when same query is repeated again, results can be returned from memory.
  2. Data can get modified ...

19. hibernate quering results format    stackoverflow.com

I have a web service that provides queries functionality using hibernate. A query can return multiple results - each results contains multiple parameters. The question is: How should I return the result: 1. Can serlize ...

20. Hibernate: How to get result from query with multiple classes    stackoverflow.com

If my query contain one class, like: query = session.createQuery("select u from User as u"); queryResult = query.list(); then I iterate it, where queryResult is an object of User class. So how to get ...

21. Inconsistent Hibernate query results    coderanch.com

I'm using Hibernate 2.1.8 and am having the following problem: I am getting different results for the same HQL query even though nothing has changed in the database. For example, object A has ten instances of object B. Often, my query gives me back the ten B objects, but just as often it returns an empty list. Nothing is being changed ...

22. Hibernate - Retriving Custom Query Result    coderanch.com

I have a bean named Offer. Which has been mapped on offer table. There are say 10 columns which are mapped on bean, accordingly. Now, I have a query which is to be run on Offer table select offer.COUNTRY_ID , sum(sortorder) from offer group by COUNTRY_ID This will return a resultset with 2 columns only, which are definitely not mapped on ...

23. Hibernate- why my query results are caching?    coderanch.com

I have not set any second level cache. I am just doing- Query query = currentSession.createQuery("from Employee v where v.empId=" + empid); List retList = query.list(); and what I was doing is updating one of the employee object. and when I execute the query sometimes it returns update employee in the collection and sometimes old employee in that collection. can some ...

24. hibernate create query method result in Stirng?    coderanch.com

public List fetchMsgIdentifierByMessageId(Integer strWhereClause){//added for CNR report to get messagecategory from messagemaster List lstCode = null; String strQuery = null; try { if(strWhereClause != null){ strQuery = "select messageCategory, messageNumber from MessageMaster where messageId= " +strWhereClause ; } lstCode = sessionFactory.getCurrentSession().createQuery(strQuery).list(); sessionFactory.getCurrentSession().flush(); return lstCode; } catch (RuntimeException re) { throw re; } } Hi I am using above method to get ...

25. Hibernate query with Hardcoded result    coderanch.com

27. Different results using similar HQL and Criteria queries    forum.hibernate.org

I think i found an explanation. First, the two queries are actually not the same, as the createAlias() method uses an INNER JOIN. If I change that I can reproduce the HQL behavior. However, it seems to me that the original programmer was using HQL in a wrong way to generate the desired result (i.e. only genres that are fulfilling the ...

28. HQL query results problem    forum.hibernate.org

Hi there, In the web application I'm developing I use this query "from Messages".Although there are 13 records in messages table at my database,when I print the results I get this: 1) id:0 mesname:bla message:bla,bla 2) id:0 mesname:bla1 message:bla1,bla1. In other words although all the fields of Messages Pojo are set correctly the id field is always 0 as if it ...

29. Different query parsing results, during migration from 3.3.2    forum.hibernate.org

Hi, during migration from Hibernate 3.3.2 to 3.6.2 I notice strange behaviourr of parsing hql queries. The old query was: Code: select distinct a2p.article from ArticleToProduct a2p where a2p.product = :product ...

30. count of "criteria with projections" results    forum.hibernate.org

31. Caching HQL query results    forum.hibernate.org

Hi all - First, kudos to hibernate. Its the best. My question - what would be a good (the best?) way to cache a set of objects defined by an HQL query? As I understand it, if I execute a find() or iterate(), a query will always run to generate object IDs, but the objects themselves may be returned from a ...

32. how to get the count of result    forum.hibernate.org

33. Strange Query Result    forum.hibernate.org

Beginner Joined: Wed Sep 10, 2003 5:32 pm Posts: 28 Hi everyone, I am experiencing something really strange with my query result and I would like to find out if I am doing something wrong. I am trying to run a HQL query under the following two mapping files: Here is the mapping of my customer class: Code:

34. Weird query results..    forum.hibernate.org

I have the following code being executed.. NumericCapability and StringCapability are subclasses of DeviceCapability. Code: public List findByDevice(Device device) { List result = (List) getHibernateTemplate().find( "select deviceCapType " + "from DeviceCapType as deviceCapType, NumericCapability as numericCapability, " + "StringCapability as stringCapability, Device as device " + ...

35. Query result    forum.hibernate.org

36. interate() results in multiple queries    forum.hibernate.org

Hi, I'm sorry about posting a question that has already been answered, but I can't find the relevant post . a call to session.iterate() results in multiple queries being generated: the first one that collects record ids, followed by a select for each title id (and we have bucketload of titles). What needs to be done to make hibernate generate a ...

37. Duplicate results in query    forum.hibernate.org

Here is the SQL SELECT Be careful : evenement is event and internaute is user Hibernate: select evenemen3_.identifiant as x0_0_ from internaute internau0_ lef t outer join evenement evenemen1_ on internau0_.identifiant=evenemen1_.internaut e_id, evenement evenemen2_, evenement evenemen3_ where internau0_.identifiant=ev enemen2_.internaute_id and evenemen2_.identifiant=evenemen3_.identifiant and ((i nternau0_.identifiant=? )and(evenemen1_.periode=? )) Hibernate: select evenemen0_.identifiant as identifi1_0_, evenemen0_.type as typ e0_, evenemen0_.periode as periode0_, evenemen0_.heure as heure0_, ...

38. Request: Scrollable results with criteria query    forum.hibernate.org

I have several queries which are used to display results in a web page. My original code used the criteria API to formulate these queries: Code: Criteria crit = session.createCriteria(Learner.class); if (learnerCriteria.getFirstNames() != null) { crit.add(Expression.ilike("firstNames", learnerCriteria.getFirstNames(), MatchMode.START)); } if (learnerCriteria.getSurname() != null) { crit.add(Expression.ilike("surname", learnerCriteria.getSurname(), MatchMode.START)); } if (learnerCriteria.getUserName() ...

39. retrieving results from query - error in Hibernate document?    forum.hibernate.org

After performing the query, i got the results of type List which I call rList. According to the top example in page 61 of the Hibernate2 Reference Documentation(pdf), I did the following Iterator it = rlist.iterator(); Object[] row = it.next(); ... but it.next() returns an object. The error from Eclipse shows: type mismatch:cannot convert object to object[] Any thoughts? Thank you ...

40. impossible result from hibernate query    forum.hibernate.org

The following hibernate query returns 1100 records(OK) : -FROM tournament.Match The following hibernate queries return about 10 records (OK): -FROM tournament.Match as match WHERE match.participation1.contender.id IN (23,43) -FROM tournament.Match as match WHERE match.participation2.contender.id IN (23,43) problem: The following hibernate query returns more than 3000 results which is impossible since there are only 1100 tournament.Match records(NOT OK): -FROM tournament.Match as match WHERE ...

41. Wrong results from Query object    forum.hibernate.org

String findAuctionInfo = "from Person as person where person.AUCTID = :auctionId"; Query query = sess.createQuery(findAuctionInfo); query.setString("auctionId", auctionId);// some id List list = query.list(); // I checked this line in debug mode. I have 500 people in database for this id with FNAME and LNAME. But my list has all 500 Person objects with "Dorothy", "Advins". This is the first record. FNAME ...

42. count query result    forum.hibernate.org

Hello, How can I count the number of results of a query without returning the result values? (It would be difficult to create another query for counting because the queries are not created by me.) SQL have the following: select count(*) from (some subquery) eg. select count(*) from (select * from countries) but HQL doesn't allow me to write: select count(*) ...

43. Business objects with query results.    forum.hibernate.org

hi, i'm wanting to have my business objects populated with results from queries on loading but am wondering if i'm even going about it in the right way. I have an account object that i want populated with it's balance which is a calcuation of transactions and orders. i thought i could mabye use an interceptor to execute the queries whenever ...

44. Identical queries resulting in different results    forum.hibernate.org

Newbie Joined: Tue Apr 06, 2004 8:44 am Posts: 9 I have one large table "transaction" and it is mapped to a BaseTransaction object. This base object has numerous subclasses that are mapped to the same transaction table. For some reason, query 1 (see running code section) below works (returns results) and query 2 does not (returns empty List). According to ...

45. Updating query results?    forum.hibernate.org

I'm trying to build a simple CRUD app that populates an editable table with multiple rows from a query using Hibernate 2.1, MySQL 4.0. I can edit and save existing data but removing or inserting rows doesn't work. My question: is it supposed to? The docs show examples of containers embedded in objects but not a list returned from a query. ...

46. Looping out result from select query    forum.hibernate.org

Hey, I got a select query but for some reason I can't print out the result. What am I missing? Code: Query q = session.createQuery("SELECT c.customerTPK.customerno " + "FROM net.sf.hibernate.CustomerT c " + "WHERE c.customerTPK.customerno='1397549'"); List ...

47. Does Hibernate cache based on objects (results) or queries?    forum.hibernate.org

To clear up what I'm asking... I have an object User that has a one-to-one relationship with another object UserType. I have a getter on the User that retrieves an instances of UserType. I have another method that is used that returns an entire list of all the UserTypes defined in the system. I'm wondering if Hibernate can notice that the ...

48. Query result inconsistency problem    forum.hibernate.org

Hi, I met a problem that when I try to use createQuery to retrieve the rows from DB, it will go for the temporary objects in the memory or maybe cache instead of retrieving data from the DB. I've changed the configuration to let the hibernate.cache.use_query_cache=false. But it continues to load the wrong objects. Does anyone has any clue to this ...

49. how to have the same results of a query without subselects    forum.hibernate.org

im basically trying to find out if user with id 1 has a role with id 1 in its user.roles set, im using a mysql db without subselect support i havent tested this only a db with subselects but I think it should work select r from Role as r where r.id = 1 and r in (select u, elements(u.roles) from ...

50. Unexpected Cached Query Results    forum.hibernate.org

I should also add that I verified that it is neither the database nor the driver that is caching by writing a straight JDBC test... I tested both reuising the prepared statement and connection as well as destroying and recreating them...and in both cases, the results always reflected the proper "fresh" data from the database...

51. Faq does not appead to complet ans. count of query results?    forum.hibernate.org

I don't want to be annoying. However, I have looked through the faq. I have found Code: ( (Integer) s.createFilter( collection, "select count(*)" ).iterate().next() ).intValue() However, how does this help for named queries? I am using the following code with "name" is supplied parameter of the named query we want to execute. Code: public ResultInfo getPagedResults(final String name, ...

52. query results    forum.hibernate.org

/** * Called just before an object is initialized. The interceptor may change the state, which will * be propagated to the persistent object. Note that when this method is called, entity will be * an empty uninitialized instance of the class. * * @return true if the user modified the state in any way. */ public boolean onLoad(Object entity, Serializable ...

53. same query different result ???    forum.hibernate.org

Hibernate 2.1.? What is the minor version number? Not that it will make that much of a difference, but everything helps. Can you confirm that it is using the same SQL? Within your configuration, set the show_sql property to true and compare the actual SQL that is generated with what you are using in SQL*PLUS.

54. same result running query    forum.hibernate.org

I'm running the following query and it is returning the same value althought I have diferent values in the database. I executed the SQL generated from hibernate in SQLStudio and It executed OK Hibernate version: 2.1.6 Mapping documents: ...

55. Order in which result set is read.    forum.hibernate.org

SQL Server 2000 seems to have an issue with the order columns are read from the result set if there are any blob/clob datatypes used. http://support.microsoft.com/default.aspx?kbid=824106 Does anyone know in which order hibernate does the read? Also, is there something configuration-wise that I need to do to tell it in what order to read? Is there a configuration work around, or ...

56. No duplicate in query results    forum.hibernate.org

Hello folks, Query q1 = session.createQuery("select cust from Customer cust " + "join cust.orders custorder " + "join custorder.orderlines orderline " + "where orderline.product.price > 100.00"); this query returns a list of Customer instances. But the list contains multiple references to the same customer instances. How is it possible to have unique instances (no duplicates) without re-wprking my result. Is there ...

57. No duplicate in query results    forum.hibernate.org

Hello folks, Query q1 = session.createQuery("select cust from Customer cust " + "join cust.orders custorder " + "join custorder.orderlines orderline " + "where orderline.product.price > 100.00"); this query returns a list of Customer instances. But the list contains multiple references to the same customer instances. How is it possible to have unique instances (no duplicates) without re-wprking my result. Is there ...

58. Invalid results from "wrong way" one-to-one query?    forum.hibernate.org

Author Message archie172 Post subject: Invalid results from "wrong way" one-to-one query? Posted: Thu Nov 18, 2004 5:10 pm Newbie Joined: Tue Nov 16, 2004 1:10 pm Posts: 5 Suppose you have a one-to-one "property-ref" mapping between two tables. It seems that Hibernate queries from the "pointed-to" end return invalid results. In this example, the query returns results that ...

59. using criteria result in a query    forum.hibernate.org

Hello, i create a dynamic query by using criteria. But query has some things criteria cannot provide (like count, group by etc). Question is, is it possible to use criteria result list in a normal hibernate Query? Something like this: List cats = sess.createCriteria(Cat.class) .add( Expression.like("name", "F%") .addOrder( Order.asc("name") ) .setMaxResults(50) .list(); Then using the results like this: Collection counts = ...

60. Help printing the result of a query    forum.hibernate.org

Hi for all... I'm trying to print (System.out) the result of a single query through the code that follows: ------------------------------------------------------------------------------- String sqlQuery = null; sqlQuery ="FROM AMIGO in class HIBERNA.Amigo where Amigo.nome = 'lara'"; List lista = dao.getList(sqlQuery); for(int indice = 0; indice < lista.size(); indice++) System.out.println(lista.get(indice)); ------------------------------------------------------------------------------ The DAO method is: public java.util.List getList(String sqlQuery) throws Exception { Session session ...

61. Scrollable Result Set in Hibernate?    forum.hibernate.org

62. problem with ordered results using criteria    forum.hibernate.org

First i'm not good at English so I hope you understood my mistake. I want to get some ordered results by hibernate Creteria. First native query that I want to ordered results is select * from foo order by regist_date; 1. table DDL is # Table: 'foo' # CREATE TABLE `foo` ( `sort_id` bigint(20) NOT NULL default '0', `regist_date` varchar(7) NOT ...

63. DBMS Query is fast, hibernate delivers the result slower    forum.hibernate.org

Hi !! thanks for answering !! No memory problems (memory stays constant, and the resultset is not that large... only 800 rows) No network problems... in fact i'm doing the query from the same development pc than it is used for the query analyzer. but, first level cache? what do you mean by that ? is there something I should do ...

64. Hibernate.initialize() on criteria query results    forum.hibernate.org

Is it possible to initialize via Hibernate.initialize(), lazy="true" associations for criteria based queries without iterating through the entire list? I keep getting lazyInitializationExceptions and don't know what else I can do to get around them. I got rid of them from my getters by initializing selected associations. Now I am at an impasse. Using Hibernate 3.0.3 and the session facade pattern ...

65. Counting HQL result    forum.hibernate.org

Hi. I have an HQL which returns too many rows to not to use pagination. The hql is a join between too classes and has a 'having' clause. The fact is that I need to count the total number of result objects (not only the ones I select on the current page) and It's something like this select sum(movs.amount),mae.cod from mae ...

67. cached query skipped --> no results shown    forum.hibernate.org

Hello, I have a problem with caching: Everytime I select a list of records from the database, these are cached by hibernate, as the following log excerpt underlines: Code: The query is already compiled, s kipping... 2005-08-02 11:18:38,506 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] flushing session 2005-08-02 11:18:38,506 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] processing flush-time cascades There is no exception thrown, but in fact, I don't get any ...

68. Criteria Query and Duplicate Results    forum.hibernate.org

Hi, I am using Hibernate 3.0 with Oracle 9i. I have four entities with the following configuration, Entities ****** 1. SchemeMember 2. SchemeMemberConfigurationGroup 3. ConfigurationGroup 4. ValidResponse Relationships *********** 1. SchemeMember -> SchemeMemberConfigurationGroup : one-to-many bidirectional. 2. SchemeMemberConfigurationGroup -> ConfigurationGroup : many-to-one bidirectional 3. ConfigurationGroup -> ValidResponse : one-to-many bidirectional Code ***** List findBySchemeMember(SchemeMember schemeMember) { Criteria criteria = getSession().createCriteria(SchemeMemberConfigurationGroup.class); criteria.add(Restrictions.eq("schemeMember", ...

69. Query result semantics    forum.hibernate.org

Hibernate version:3.0.5 Hi, I have a basic question about some query semantics of Hibernate. I have two classes, A and B, with a bidirectional one-to-many association between A and B. In the database, instance a1 is related to instances b1, b2, b3, b4. First, I execute the following query: from A as a left join fetch a.b as b where a.ID ...

70. Problem: Same object reference in query result    forum.hibernate.org

Hello to all of you! I have a problem with Hibernate 3.0.5 under Eclipse. Fot most of the tables in my DB (sqlserver), every query goes ok but for one of them, the queries (select * from...) ALWAYS return the exact number of reference to objects I would have expected (1 for each rows) except that almost every reference points to ...

71. Add a non java interface to send queries and receive results    forum.hibernate.org

Hello, This is my first post on this forum, because I've so far used hibernate without any blocking problem that'd require me to ask for help. But this time its different :) I've read the documentation very widely, without finding what I'm searching for. Here is the objective : I want my Java application that uses hibernate to generate the SQL ...

72. count criteria results wirhout initializing it    forum.hibernate.org

Q: How to count results with criteria without initializing whole collection. I have pageable page. When I do search, I return only 10 results per page, but I need total number of results to show on page. Code: Example ex = Example.create(user).ignoreCase().enableLike(MatchMode.ANYWHERE); Criteria c = session.createCriteria(User.class).add(ex); c.setFirstResult(10); c.setMaxResults(20); return c.list(); 1. Without c.setFirstResult and c.setMaxresults hibernate works 6 sec, so c.list().size() ...

73. HQL: strange select result    forum.hibernate.org

...

74. how can i get result through the query?????????    forum.hibernate.org

hi pksiv thank you for reply i use this method get the result String hql="Select count(id) From RegisterInfo Where status = " + sId; Integer itmp = (Integer)registerInfoMng.findMng(hql).iterator().next(); System.out.println(itmp); registerInfoMng has a find method the method body is List registerList = this.getHibernateTemplate().find(hql); return registerList; this is ok?? why not a output result???

75. Pb with result of select HQL command    forum.hibernate.org

Hello, i have a pb using a simple HQL select command. String q = "from XXX c where c.version.id = " + versionId; List result = getDao().executeQuery(q); this returns me always only 1 element in the result list, even if in my table i have multiples lines where the version id = the parameter !?... If i use the following syntax ...

76. Result from Projections on Criteria queries    forum.hibernate.org

Can someone explain me why with Projections added to a Criteria query, you get a Object[] as a result in de List result ? I was using the Projections this afternoon and the documentation on how to implement them are very complete, but they do not mention the processing of the result. After some debugging I found out that it returned ...

77. SQL Query result caching weirdness    forum.hibernate.org

I have a weird caching problem that I cannot seem to resolve through my standard google-search means, read the faq, etc. I think my problem is a hibernate caching thing but I could be wrong. I've got a chunk of code that runs and then sleeps for 30 seconds in a while ( FOREVER ) loop. Essentially it does this: Code: ...

79. Calculations on multiple subqueriy results in 1 HQL query    forum.hibernate.org

I am trying to use the results or two subqueries in a simple calculation. What I need to do is limit the results in the where clause to Code: where reclassify.numpieces - numCommitted - (I could find no way to alias the subqueries and have no problem repeating the subquery here ...

80. Strange Query result    forum.hibernate.org

class Party { int id; List taxPayers; ... ...

81. SOS: hibernate query, findId no result, but other well!    forum.hibernate.org

I use "STRUCT+SPRING+HIBERNATE" framework to connect ORACLE database all configuration is right, execute as follows: .... Session session=SessionFactoryUtils.getSession(usernameDAO.getSessionFactory(), false); Query q=session.createQuery("from Username user where user.username='AAA1'"); Iterator it=q.list().iterator(); Username name=new Username(); while(it.hasNext()){ name=(Username)it.next(); } System.out.println(name.getDepartment()); ..... here i can get the result from the console: test department but if i execute as follow: Username name=this.usernameDAO.findById("AAA1"); System.out.println(name.getDepartment()); i see the sql was executed ...

82. Hibernate SQLQuery scrollable results    forum.hibernate.org

83. HQL Query result    forum.hibernate.org

can anyone suggest me why this query gives duplicate results, despite of being only one in the database public List findAllBugs() { Session session = getHibernateTemplate().getSessionFactory() .getCurrentSession(); String SQL_QUERY = "from Bug as bug inner join fetch bug.users as users"; log.info(SQL_QUERY); Query query = session.createQuery(SQL_QUERY); return query.list(); } i have a 2 table named USERS and BUGS mapped as many to ...

84. Hibernate update commands results in just a query    forum.hibernate.org

I have the following code which just query an object from the database. But when I turn on hibernate sql output. it causes 2 sqls: 1. query 2. update . My question is why hibernate generate the 2nd update? I did not modify the cat object at all in my transaction? Code: private static Cat getCat(String name, Home home) { ...

85. Get SQL Query Result    forum.hibernate.org

86. Use of query cache and allow for stale query results?    forum.hibernate.org

I'm wondering if there's a way to use the query cache such that even if updates/inserts/deletes happen to the underlying tables of the query that it not invalidate the cached query results and instead allow them to still be fetched and not hit the DB. Instead it would depend on some kind of other cache entry expiration policy, such as a ...

87. query result to class object    forum.hibernate.org

Hi, I am using the HQL query select ct.id, ct.firstName from Contact ct I am querying only 2 fields where there are 4 fields in the table. So I cannot use the following code since number of elements in the class and query does not match Contact ct=(Contact)it.next(); System.out.println("ID: " + ct.getId()); System.out.println("First Name: " + ct.getFirstName()); where Contact is the ...

88. Limiting result count doesn't work with joined objects    forum.hibernate.org

Hi, We're having problems retrieving a limited number of objects using Criteria. We have persistent DataModification objects, each of which might have any number of DataModificationValues attached to it. We'd like 25 DataModifications to be returned using criteria.list(), so we're calling criteria.setMaxResults(25). Unfortunately this results in the following query (I've simplified it a bit - see complete query below): select top ...

90. cached results in find    forum.hibernate.org

91. How to check whether a query has results    forum.hibernate.org

Hello, I would like to check whether an SQL query has any results, but I don't need the returned entities/tuples. A simple solution would be: SQLQuery query = session.createSQLQuery("..."); boolean hasResults = !query.list().isEmpty(); But this is very inefficient since list() creates all the entities (or in this case tuples) if I'm not mistaken. Is there any way to check whether the ...

92. query results not found in cache (if executed after 2 min..)    forum.hibernate.org

Hello, Iam kind of new to Hibernate, so trying to see whats wrong with the configuration/code i have. If i execute the query in a loop the results are fine, Iam getting all the values from cache. But when i sleep for 2 min or so and execute its executing the sqls and not getting from the cache. Following are some ...

93. Querying two classes with the result of one    forum.hibernate.org

94. Query Result is removed from the Cache on table update    forum.hibernate.org

The second level cache is enabled on the application. The Query Cache is enabled on the application. There is a table TABLE_ACCOUNTS and queries Q1 Q2 and Q3 on the same table. The above queries will return a set of Data, these queries are frequently used in the application by many concurrent threaded. I was planning to use QueryCache to cache ...

96. How Can I count the query results using a HQL query???    forum.hibernate.org

Hi everybody: I want to know how Can I count the query results with HQL language. I retrieve a group of documents from the database using the hibernate's tricks for paging the results but I want to know how many documents satisfied that query, I can't do it with a sql query so I want to use a hql query to ...

97. Problem retrieving query results    forum.hibernate.org

I am using session.list() to retrieve data from DB table. Every item in the returned List is an Object[], so I need to use get[index] method to retrieve a value for the particular field. However I would prefer to use "getPropertyName" methods to obtain values for the particular fields. Is there any way to do that? here is my code : ...

98. Error retreiving Hibernate Query Result in View [Trinidad]    forum.hibernate.org

Hi All, I am doing my application with Hibernate, Spring and Trinidad. I am using org.hibernate.hql.classic.ClassicQueryTranslatorFactory property in my spring-context.xml file {Spring Configuration file} For Hibernate Query to work with Trinidad. The other factory class property org.hibernate.hql.ast.ASTQueryTranslatorFactory is not working with view Layer [Trinidad]. My question is.... When ever I am having a HQL with case when...else...end condition. The ...

99. Order the results of a projection    forum.hibernate.org

Hi, Consider there are 3 classes representing 3 database tables: Student, Course and StudentCourse(associative relationship). The source code bellow returns all students from the associative table that conform to some restrictions (ommited for clarity) Code: Criteria criteria= session.createCriteria(StudentCourse.class); criteria.createCriteria("student", "s"); criteria.createCriteria("course", c"); // add some restrictions on s and c criteria.setProjection(Projections.distinct(Projections.projectionList().add( ...