1. How do I do a custom projection with the Criteria API in NHibernate? stackoverflow.comWith HQL I can use dynamic instantiation like this:
Now I need to create my queries dynamically with the Criteria ... | ||
2. How to make Divide(column1/column2) in hibernate criteria projections stackoverflow.comI am new to Hibernate. I need to perform
| ||
3. How do you put raw-sql projections in an object using Hibernate? stackoverflow.comLet's say I have a query that begins with the following projections:
This is raw sql, and I am using createSqlQuery on the Hibernate session object. ... | ||
4. Hibernate Many-to-Many Criteria Projection stackoverflow.comEDIT> i am at a dead end... so i can continue looking for the main reason .. Please tell me how to make a simple criteria for many to many relationships ... | ||
5. hibernate where clause with projection stackoverflow.comThere's a table name STUDENTS with column studentName and studentID I want to run a query like select studentName from STUDENTS where studentId ='1'; ... | ||
6. Hibernate Criteria projections stackoverflow.comIs there a way to specify a group by in a criteria and get the ROOT_ENTITY? i mean this:
this returns only ... | ||
7. Criteria and Projections stackoverflow.comI have an entity: Order Detail. It look like as follows:
| ||
8. Criteria Projections Query stackoverflow.comI need make a query in the table called EmployeebyProject {EmployeeId, ProjectId, date,...}. I need to know the employees that have one project, and the projects that have an employee. So try with ... | ||
9. Help on a HQL projection query with collections stackoverflow.comI'm using Potgres 8.4 with Spring/Hibernate 3.6.5. | ||
10. When to use hibernate projections? stackoverflow.comi am more confused of hibernate projections and criteria. when to use projections and when to use criteria. please help me. Thanks! | ||
11. Changing the projection of a criteria object. forum.hibernate.orgHi I have a User entity which has a many-to-many relation to the Group entity. After constructing the criteria and adding all the restriction I have a check whether or not to count all the records in the database ...if yes I change the projection. And after that I need to change back to the original projection, because if a set ... | ||
12. Projections.rowCount() behaviour forum.hibernate.org | ||
13. how to reference multi tables in Projections.sqlProjection forum.hibernate.orgIf I have two tables: A(A1,A2) B(B1,B2) I need write Projections like : Code: DetachedCriteria ACriteria=DetachedCriteria.forClass(A.class) .createAlias("B","b") .setProjection(Projections .sqlProjection("(sum(A.A1) / B.B1) as test" ... | ||
14. Restricting Projections in Criteria forum.hibernate.orgI'm trying to find a way to do a restriction on a nested aggregation query For example: I want a report of CA & NV total students when the average class size is above 30. SQL would be: Code: select schoolId, avgClassSize, totalStudents from ( select schoolId, avg(classSize) as avgClassSize, sum(classSize) as totalStudents ... | ||
15. Hibernate Many to Many Criteria Projection forum.hibernate.orgHi all, I am new here so if this topic is not in the right subforum, please move it where it should be. I have posted my problem on couple forums but no answer till now. So here it goes. EDIT> i am at a dead end... so i can continue looking for the main reason .. Please tell me how ... | ||
16. Using Restricitons and Projections forum.hibernate.orgHi all, I have 2 classes - Distributor{ Date signUpDate; } and Transactions { int sponsorId; Date orderDate; //which has an instance of member class } This is wat i have written to compare orderDate >= signUpDate and orderDate <= signUpDate+31 Criteria crit = session.createCriteria(Transactions.class,"ord"); crit.add(Restrictions.eq("ord.sponsorId", sponsorId)); crit.add(Restrictions.ge("ord.orderDate", "ord.distributor.signupDate")); crit.add(Restrictions.le("ord.orderDate", "ord.distributor.signupDate"+31)); I know this is wrong since i ma getting classcastException, ... | ||
17. Projection and subquery forum.hibernate.org | ||
18. How do you do a criteria API projection on a superclass? forum.hibernate.org | ||
19. Projections - Help please forum.hibernate.org | ||
20. How to use Projections in JPA forum.hibernate.orgHi, Hibernate gives the feature of selecting (filtering) the no of feilds/or columns needed with Projections Concept. My Doubt here is how can utilize the same kind of stuff to improve the Performance in JPA. please suggest me if there is any approach. Code: import java.util.Date; public class Employee { private int empId; private String ... | ||
21. criteria API: apply projections in outer query and subquery? forum.hibernate.orgI am using Hibernate 3.3.2.GA with a PostgreSQL database. I have a user_scores table which looks like (irrelevant portions omitted): Code: user_scores ( user_id int, type varchar, score int ) I would like to count the number of users of each type with positive, negative, and zero total score. With SQL I ... | ||
22. Static text in hibernate projection forum.hibernate.org | ||
23. using projection and not getting object of class expected forum.hibernate.orgI'm using projection to avoid getting clobs when populating a GUI table but I'm getting back a list of object arrays with 3 objects in each instead of instances of the type I expect. I'm using HQL : select document.docId, document.sourceTx, document.typeCd from com.potomacfusion.vid.dao.Document as document Is there a way to specify this query to get back Document objects? | ||
24. projection and collection forum.hibernate.org | ||
25. projection and "no persister" error forum.hibernate.orgBeginner Joined: Thu Jan 01, 2004 11:36 am Posts: 23 Location: Belgium Hello, Hibernate version: 2.1 java 1.4 Name and version of the database you are using: Oracle 9i I am trying to use a query which could populate a DTO object (one object per row); this object is not mapped as it does not correspond with any persistent entity (it ... | ||
26. Will the following be possible with Projections? forum.hibernate.orgVampBoy wrote: Wow, blast from the past. I can't remember what I wanted this for, must not have been that important :D Haha, yeah - didn't notice the date on this post - 2004! I was searching the forum for my problem and found a number of posts about it, so i replied to each one with that post. I've hit ... | ||
27. Mutli-level Criteria Projection forum.hibernate.orgUsing Hibernate 3.0.2, I am trying to execute criteria queries using property projections that traverse the object graph something like this: Code: Criteria criteria = session.createCriteria(Root.class); criteria.setProjection(Projections.property("propA.propB.propC")); criteria.list(); where propA is a property of Root, propB is a property of propA, and propC is a property of propB. It appears that Hibernate can handle projections out through "propA" without an alias, ... | ||
28. Criteria Projection produces unnecessary from clause forum.hibernate.orgselect this_.pk as y0_ from orders.orders this_ left outer join product.products product2_ on this_.product_fk=product2_.pk left outer join scoring.first_steps firststep3_ on product2_.first_step_fk=firststep3_.pk left outer join questionnaire.questionsets questionse4_ on firststep3_.question_set_fk=questionse4_.pk left outer join questionnaire.questionset_versions questionse5_ on questionse4_.questionset_version_fk=questionse5_.pk left outer join questionnaire.questionsets questionse6_ on questionse5_.questionset_fk=questionse6_.pk left outer join company.companies company7_ on questionse6_.company_fk=company7_.pk left outer join billing.billing_configurations billingcon8_ on company7_.billing_configuration_fk=billingcon8_.pk left outer join company.companies company9_ ... | ||
29. Using projection API to get a count from a criteria forum.hibernate.orgHibernate version: 3.0.5 I've written a generic method to perform a count on a Criteria object using the Projections API. However, although it does return the correct count, when using the criteria again to perform the actual query to get the data, it causes the wrong entity to be returned. Please can any one advise on how to perform a count ... | ||
30. projection query (select a,b,c instead of all columns) forum.hibernate.orgPals, I am replacing an existing hql query like (simplified version), "from Person pers" with, "select new MyPersonRow(pers.lastName, pers.firstName, pers.otherDataObj) from Person pers" where lastName, firstName are string properties in Person and otherDataObj is a user defined Type OtherData. Person maps to table PERSON and otherDataObj maps to table OTHERDATA which is a many-to-one association inside person.hbm.xml. I notice that if ... | ||
31. How do I create a projection based on a "dependent obje forum.hibernate.org[b]Hibernate version: 3.0[/b] I have a situation where I have certain fields that appear in multiple tables. I started off by having these fields as member variables of Java Bean. Then I saw the section (9.1) on 'Dependent Objects' and figure I would extract these fields into one class (i.e. Name.class) and reuse that class in other classes (i.e. Person.class). I ... | ||
32. GroupBy in Hibernate Projections??? forum.hibernate.orgNeed help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 3.1 Mapping documents: CertCertificatesTrns.hbm.xml | ||
33. nvl Support in Hibernate Projections??? forum.hibernate.orgNeed help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 3.0 Mapping documents: CertPalletsTrns.hbm.xml | ||
34. Projections.sqlProjection() in Criteria??? forum.hibernate.orgCode between sessionFactory.openSession() and session.close(): I am using HQL with nvl(). Since nvl() is not supported in hibernate projections.I planned to write the SQL directly using Projections.sqlProjection(). This is my query :- private static final String SEARCH_BOOKS_DESC_DATE="from CertBooksTrnsDTO certBooksTrns WHERE certBooksTrns.certBooks.cbBookNo=? ORDER BY nvl(certBooksTrns.cbtUpdateDt,'01-jan-2006') DESC "; How to use it with Projections.sqlProjection() with Criteria??? I will be waiting for ur reply... ... | ||
35. Help with Criteria to get projection prop from collection forum.hibernate.orgHi, We are using Hibernate 3.1.x. I am trying to get a list of properties instead of a collection using Criteria. When I run the form I have, no sql gets executed and there are no errors. can someone help me figure out the criteria or let me know whether it is possible or not. DetachedCriteria criteria; long parentId = 5; ... | ||
36. Projections class is final forum.hibernate.orgNeed help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 3.1 The following is comming from projections class header /** * The criterion package may be used by applications as a framework for building * new kinds of Projection. However, it is intended that most applications will * simply use the built-in projection types via the static factory methods ... | ||
37. Working with Projections forum.hibernate.orgHibernate version: 3.2 Hi! I'm trying to query out some root object, using restrictions based on a subquery. I want to get some items (PAH), which have a 1-N relationship with some other items (PA) that have a date associated with them. I want to get the latest PA's, then their parent PAHs. The SQL query looks like this: select distinct ... | ||
38. How to set the object class name in a projection? forum.hibernate.orgcriteria = session.createCriteria(BaseClass .class); criteria.setProjection(Projections.projectionList() .add(Projections.property("oid"), "oid") .add(Projections.property("year"), "articleYear") ... | ||
39. How to set the object class name in a projection? forum.hibernate.orgcriteria = session.createCriteria(BaseClass .class); criteria.setProjection(Projections.projectionList() .add(Projections.property("oid"), "oid") .add(Projections.property("year"), "articleYear") ... | ||
40. Object Projections, GroupBY with RowCount Problem? forum.hibernate.orgHi everyone, Well, I have two classes. One with the following code: Code: ... public class City implements Serializable, Comparable | ||
41. Criteria projections order by forum.hibernate.orghello all iam trying to generate a SQL using a hib criteria...the desired sql is select A.COL1 from Atable A group by COL1 order by count(A.ID) desc with the criteria i can get both the column A and count but not just the column A. The reason i want only the column A is because i want to use that in ... | ||
42. Arithmetic operations in Criteria Projections forum.hibernate.orgCould please provide me a solution, how to use Arithmetic operations in Projections, current code: --------------------- .add( Projections.sum("broker.total"), "total" ) Expecting -------------------- .add( Projections.sum("broker.total") * 100/2, "total" ) the other way is, we can use : .add( Projections.sqlProjection( "((sum({alias}.percentage)*100)/" + bgTotalPercentage + ") as percentage ", new String[] { "percentage"},new Type[] { Hibernate.BIG_DECIMAL} )) I dont want to give databse column ... | ||
43. Join with Projections forum.hibernate.orgI'm trying to use Projections to bring only what i need... But now i just need to bring the Id, Description and the Parent Description... From a table like this example: Table TpDoc: int PkTpDoc int FkTpDoc varchar(50) DescTpDoc manymanyotherfieldshere... (This FkTpDoc points to PkTpDoc) How can i do it without using HQL and creating a constructor in the class TpDoc?? ... | ||
44. NEWBIE trasform Projection returnResult from scalar2entity forum.hibernate.orgHi *, I need a way to obtain a valid entity from a criteria with projection. Hi had sucess with a SQLQuery: Code: SQLQuery tds = _hsession .createSQLQuery( "select ADDRESS_PROVINCE_NATION_CODE NATION_CODE, ADDRESS_PROVINCE_CODE CODE, COUNT(*) NUM_DRIVERS" ... | ||
45. Remove (unset) projection from Criteria? forum.hibernate.orgCriteria c = session.CreateCriteria(); /* some code that set expressions, orders, etc */ Integer eventsCount = (Integer) c.setProjection(Projections.rowCount()).uniqueResult(); if (eventCount < MAX) { result = c.list(); /* But at this point c has projection set, is it possible to remove it in order not to create second Criteria and repeat all code? */ } | ||
46. Important Criteria And Projection Queries For U All:-Part 1 forum.hibernate.org | ||
47. Imortant Criteria Projection Queries For U all:- Part 1 forum.hibernate.org | ||
48. Joining and Projections forum.hibernate.orgHi there! I have a Many-To-One Relation between the entities AdLog and Page. In the AdLog entity there should be inserted an entry each time a Page gets displayed. And a Page should only be displayed when its adMaxTime is not overstepped. So, I came to the conclusion that I have to join the entities, sum up AdLog.duration and compare the ... | ||
49. How to use Projections with net.sf.hibernate.* forum.hibernate.orgHi, I am very new to Hibernate, and stuck with some issue. 1) I have net.sf.hibernate.* package APIs in my project , Where as when i see Hibernate examples in the Hibernate book they have examples using org.hibernate.* . So my first question is "what is the difference between two?" 2) I want to able to execute the following query select ... | ||
50. how to get Collections from Projections forum.hibernate.orgHi All, i am using POJO's with in Pojo's. this is like class A{ private int a1; private B b; } class B { private int b1; private set c; } Class C{ int c1; } how can i access Set of values from calss A. i am using Criteria and Projections in the Criteria. i write like this List list ... | ||
51. how to get Collections from Projections forum.hibernate.orgHi All, i am using POJO's with in Pojo's. this is like class A{ private int a1; private B b; } class B { private int b1; private set c; } Class C{ int c1; } how can i access Set of values from calss A. i am using Criteria and Projections in the Criteria. i write like this List list ... | ||
52. How to specify typesafe 'projection' using the Criteria API? forum.hibernate.orgHow does one use the Criteria API to specify something like: select new java.lang.Long(distinct t.taskId) from Tasks t where ... I can easily figure how how to do this using the Criteria API: select distinct t.taskId from Tasks t where ... but the API for wrapping the result objects into typesafe objects, i.e. specifying the 'new ...(...)' part using the Criteria ... | ||
53. Using Multiple Projections and a ResultTransformer forum.hibernate.orgFrom what I've read you can never retrieve an Entity from projections or transform the results into an Entity. It seems you can only do this with non-Entities. I've noticed most of the examples I've seen use DTOs. So you if you had a Student Entity and only wanted a few properties (partially hydrated) that you end up creating a StudentDTO ... | ||
54. Handling Specific Columns using Projections. forum.hibernate.orgHow do I select lets say 2 columns from a select statement instead of all columns? When I specify the 2 columns in a Projection list, the iterator is giving me an object that is not Castable to the Entity class (Trade), and therefore, I am unable to invoke a getXXX for these columns. Code: ... | ||
55. subquery with modified projection forum.hibernate.orgHi! I have a subquery: DetachedCriteria subquery = DetachedCriteria.forClass(SemopsTransaction.class, "T"); subquery .add(Restrictions.eq("paymentStatus",status) ....... Criteria criteriaCount = subquery.getExecutableCriteria(sessionFactory.getCurrentSession()); criteriaCount.setProjection(Projections.countDistinct("idTransaction")); int count = (Integer)criteriaCount.uniqueResult(); Affter count is queried I want to use the same subquery (with some modification) to get entries from the table (without any projection): Criteria criteria = subquery.getExecutableCriteria(sessionFactory.getCurrentSession()); criteria .add(Property.forName("E.timestamp").in(subqueryGroup)) .setFetchMode("E", FetchMode.JOIN); List | ||
56. Projection for select clause forum.hibernate.org | ||
57. Criteria Projections.rowCount() causes update of objects forum.hibernate.orgWhen testing a DAO while having Hibernate (3) output its SQL, I noticed some unexpected updates. The test involved a criteria query to fetch a few objects with MaxResults set to 15, then a second criteria query (with the same search criteria) using Projects.rowCount() to get the count of all matching records. The test simply logs a few of the properties ... | ||
58. Subquery in Projection and Order By forum.hibernate.orgAuthor Message skanjo Post subject: Subquery in Projection and Order By Posted: Fri Mar 07, 2008 12:43 pm Newbie Joined: Fri Jun 09, 2006 4:27 pm Posts: 10 Subquery in Projection and Order By I have a situation in which I can not create a Criteria or Query to represent the SQL that I need without resorting to a ... | ||
59. Projections.rowCount forum.hibernate.orgHello, hello I have a function that returns the row count of a Criteria. It basically adds a Projections.rowCount to the criterias projectionList. It works great for me, except when the criteria already has a project. Normally it produces the following sql: select count(*) from cats where cats.color = ? //great! but when I have a projections already it does the ... | ||
60. How to use Projection with two tables forum.hibernate.orgSuppose there are two tables. 1. Person table(columns are personId[pk], personName); 2. Address table( addressId[pk], personId[fk], address1, address2 ) now suppode Person table has one record[11, bikash] and Address table contains two records [1(addressId),11(parentId as fk), kolkata, delhi] [2(addressId),11(parentId as fk), b'lore, mumbai] now i nedd only personName and latest address1 and address2 for each person record. I am able to ... | ||
61. Projections.sqlGroupProjection sql is provider dependent? forum.hibernate.org | ||
62. Using a subquery as a projection in a criteria forum.hibernate.org | ||
63. Hibernate Projections and collections forum.hibernate.org | ||
64. Projection over Projection - How can I do? forum.hibernate.orgreturn (Collection | ||
65. AliasToBeanResultTransformer and Projection.count Problem forum.hibernate.orgNewbie Joined: Tue May 22, 2007 2:12 am Posts: 9 Hi, I am firing a query in which i want to extract the "calling number","called number" and count of "called number" from database. I've written the following query --- Code: public List getCallDetsForReport(Map objectArgs) { logger.info("start of call details records"); ... | ||
66. help with query and Projection forum.hibernate.orgNeed help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp [b]Hibernate version:3.1[/b] Hi to all, I have this java code with hibernate: Session s = HibernateUtil.currentSession(); s.clear(); ArrayList | ||
67. Projections forum.hibernate.orgHey guys, I'm new to posting in Hibernate forums, so let me know if I leave out any pertinent info. Anyways, I'm simply trying to find the highest id in a given table - basically, "Select MAX( Hi! I have three entities: User { School school; } School { City city; } City { Integer id; } I want to get count of users with the city id of 1. My criteria: Criteria crit = session.createCriteria(User.class, "u"); crit.createAlias("school.city", "cty", Criteria.INNER_JOIN); crit.add(Restrictions.eq("cty.id", cityId)); crit.setProjection(Projections.count("id")); Problem: Hibernate: select count(this_.id) as y0_ from users this_ where this_.type=? and cty1_.id=? and this_.active=? ... |