Criteria 2 « Criteria « JPA Q&A





1. Hibernate Criteria Problem    forum.hibernate.org

Guys, Have anyone used the Criteria Object of Hibernate? I have a Member object which has "careers" and "educations" as collections. For querying Members whose Career.A = x careerCriteria = criteria.createCriteria("careers"); careerCriteria.add(...); But I have to query Members just that, either Career.A is "X" or Education.B is "X". Is it possible to add a criteria like that? What do you suggest? ...

2. Criteria problem, please help    forum.hibernate.org

I have a class name employee which has a set of associated parameters. I am trying to get the employees with a specific parameters. When i ask for employes with only one parameters it is working fine, however when i ask for employees with more than 1 parameters, the result is none. Here is my Criteria request. List res = null; ...

3. Regarding Criteria ?    forum.hibernate.org

Hi Hibernate Experts, Thanks for Reading. I have one Question. I saw one Criterial Query Like String SQL_QUERY = "select sum(insurance.investementAmount),insurance.insuranceName " + "from Insurance insurance group by insurance.insuranceName"; Ok. In my point of view this Query is looking like Ordinary sql query. 1. My Question is , this Query is Ordinary Query or Hibernate Query? 2. If I change My ...

4. Assistance needed with criteria    forum.hibernate.org

Hi! This is my first post and I need some assistance. I could not find an answer searching or reading the documentation. (I am still "new" to hibernate, so please bear with me.) I am using criteria to return limited results. I have no problems with criteria using fields that are varchar2, integer, or an instance of another class. My problem ...

5. Using Criteria    forum.hibernate.org

Hello again, I am now trying to do the search using the Criteria class. What I would like to know is how can I search into other tables associated with the class I want to return. I understand that when I put this code: "Criteria searchCriteria = getSession().createCriteria(BaseStudent.class);" it means that when I call the .list() method it will return a ...

6. criteria question involving nulls    forum.hibernate.org

I have a table with a few bits of data and a varchar column called deleted that contains a single character 'Y' or 'N', or null, in the case where for some reason or other nothing has been inserted yet. I am using the Criteria object to create the query like so: Code: ...

7. Build Criteria Dinamically    forum.hibernate.org

Is it possible to build Criteria queries dinamically, like an SQL query? For example, i've this query SELECT name FROM table1 where 1=1 and name = Tom and program=JBOss and address = Lisbon, etc ..., and i want to build a criteria query, but i don't know how many conditions i would have in the Criteria. How i do this? Thanks, ...

8. What criteria to use when determining to use Hibernate.    forum.hibernate.org

Let me start by saying that if we need an ORM tool, Hibernate is my choice. That said, I am in discussion with some colleagues wherein I am taking the position that the needs of our project are not sophisticated enough to pull Hibernate into the mix of new technologies we are applying. I am basing this on the following: Most ...

9. simple criteria question    forum.hibernate.org

DetachedCriteria dc = DetachedCriteria.forClass( Project.class , "p" ) .createAlias( "departments", "depts" ) ...





10. something about the Criteria    forum.hibernate.org

Hi I met a problem when I use the class org.hibernate .Criteria my code were as follow: // User user=new User("good"); Example example=Example.create(user) .excludeZeroes() .excludeProperty("password") .ignoreCase() .enableLike(); List result=session.createCriteria(User.class) .add(example).list(); // the problem is when i use the primary key as a filter ,it will get all the rows in the database out,if I use other column else,it will work all ...

11. Criteria metadata    forum.hibernate.org

Hi, I'm writing a support library for the geotools projects so that hibernate mapped beans with geometric properties can be drawed onto geographical maps if needed. Now, the details are a bit long, so I won't explain everything, but in short the user will give me DetachedCriteria objects for each map layer he want to depict, and I have to turn ...

12. Criteria for many-to-one    forum.hibernate.org

13. How to use Criteria in Hibernate    forum.hibernate.org

Hi, I have a problem while using criteria in Hibernate. The problem I found is when I select max(last_modified_ts) of a particular val_status_id whose submission_id='' and val_def_mod_res_id=''. It is showing error. My table structure look like this: --------------------------- val_status : ------------------ val_status_id raw primary key val_session_id raw foreign key created_ts date last_modified_ts date val_def_mod_res_id raw val_session: --------------------------- val_session_id raw primary key ...

14. criteria trouble    forum.hibernate.org

Hi, I'm new to hibernate and I'm facing a trouble while I'm trying to get values with a criteria I've in my hbm the following line who define a relation between my object and an another table Code: I'm trying to get the ...

15. Learn Criteria...    forum.hibernate.org

16. Criteria+Set(Many-to-Many)    forum.hibernate.org

I had tried exactly the same things: fetch="subselect"/FetchMode.SELECT to no avail. I think FetchMode.SELECT is the new name for LAZY, i.e., it does additional selects later if needed. We close our Hib session quickly and must always get everything we will need before closing it to avoid a LazyInitEx. I found this forum topic: http://forums.hibernate.org/viewtopic.p ... af59ac91d9 And when I added ...





17. Help Needed with Criteria by Example    forum.hibernate.org

I have a Pojo called Product as follows: Public Class Product{ private ProductPK pk; private String stockNum; private Double price; public Product(){ } //getters and setters below } Note that the Product Pojo has a attribute of type ProductPK. ProductPK represents a composite key. It looks as follows: Public class ProductPK{ private String productCode; private Date operativeDate; public ProductPK(){ } //getters ...

18. Criteria problem    forum.hibernate.org

Newbie Joined: Thu Aug 31, 2006 7:56 am Posts: 14 ansi_c wrote: Hi please post your mapping files. thanks Apologies, I did not include the mapping files cos it was working using hql, here they are.. Code: Mapping files, Order, Rep & RepGroup ...

19. help write a criteria code    forum.hibernate.org

I have 3 classes. User, RoleRef, Role Code: public class User { public void setId(int id) { ... } public int getId() { return ...; } } Code: public ...

20. Criteria problem    forum.hibernate.org

Hi all, im newbie to hibernate, ive just initiate investigating the possibilities, theres a lot of. When im testing ive encoutered a problem (me), ive this mapping of 2 tables :

21. Multiple Criterias?    forum.hibernate.org

22. Problem in "detaching" a criteria    forum.hibernate.org

java.lang.NullPointerException at org.hibernate.loader.criteria.CriteriaQueryTranslator.getProjectedTypes(CriteriaQueryTranslator.java:317) at org.hibernate.criterion.SubqueryExpression.toSqlString(SubqueryExpression.java:56) at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:333) at org.hibernate.loader.criteria.CriteriaJoinWalker.(CriteriaJoinWalker.java:82) at org.hibernate.loader.criteria.CriteriaLoader.(CriteriaLoader.java:67) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1514) ...

23. Bitwise operation in Criteria    forum.hibernate.org

I'm using Hibernate 3.1 and I need to do bitwise operation. I've been using the bitwise workaround found on the forum to use bitwise operations on HQL queries. However, I want to use the criteria API instead of the HQL query. So far, I haven't found how to use any custom function in Criteria. What I'm trying to achieve is something ...

24. union of two hibernate criteria? Possible?    forum.hibernate.org

25. Little problem with a criteria    forum.hibernate.org

26. Problem with PropertyAccessor and Criteria    forum.hibernate.org

Hi, I have Objects with an ObjectId class as an identifier. This is mapped to a long in the DB. In the corresponding hibernate mapping I specified a PropertyAccesor in the tag which does the conversion long to/from ObjectId This works fine as long as I use Session.get() and load(). But when I create a Criteria, I get a ClassCastException ...

27. Criteria problem    forum.hibernate.org

public class Author implements java.io.Serializable { private int number; private String name; private Set books = new HashSet(0); ... } public class Book implements java.io.Serializable { private int number; private String title; private Short year; ...

28. Criteria.setReadOnly?    forum.hibernate.org

Hi all, A simple question: is it possible to make the results returned from Criteria read-only (i.e., with dirty-checking disabled)? I'm using Hibernate 3.2 and my Criteria query returns a large number of results which won't be modified but only displayed to the user. I want to tell Hibernate not to create snapshots of all these results for dirty checking. There ...

29. Simple criteria question    forum.hibernate.org

Hi, Does anyone know how to do this HQL with a criteria in stead: String sql = SELECT cp FROM Company cp, Person ps, WHERE cp.person = ps.id AND ps.cpr = ? List list = getHibernateTemplate().find(sql, cpr); So what i actually want to do is to make a search by associating two entities that are not related in my hibernate mapping ...

30. getNamedQuery() with Criteria    forum.hibernate.org

is there a way to *marry* getNamedQuery() with Criteria queries in Hibernate3, so that one can apply additional constraints on an already defined query on the fly? I tried also to use filters, but as soon as they are gobal session-wide objects, I had to manually enable/disable each of them. That also could lead to some weird consequences if one would ...

31. Criteria: Many-to-many    forum.hibernate.org

Hi I've looked for this in the forum (and google, ..), but I have not found something that solves my problem. Maybe I cannot find the right thing, because I do not know what to look for. I have following Problem (simplified): Class A { Set bs; //set of Bs .. } And I am searching for all As with several ...

32. How to do rand() in Criteria?    forum.hibernate.org

Firstly, hi. I'm new at using hibernate and criteria(and all the stuff), and I have came across this little problem, I need to get one single record of my DB and it need to be a random one. I would know how to do it in SQL but I have no idea using Criteria. Any help? Thank you in advance.

33. Multi-criteria problem    forum.hibernate.org

34. about Criteria using ...    forum.hibernate.org

36. How to use Criteria    forum.hibernate.org

You can use either Criteria or HQL (Named Queries) HQL is powerfull with advanced features and usefull for more difficult problems. Criteria allows you to built a query at runtime. But criteria are often less readable then HQL but are validated at compile time. A Criteria is a tree of Criterion instances. (Restrictions return criterion instances). For example: Criteria criteria = ...

37. Help With My Criterias    forum.hibernate.org

38. Need help with Hibernate Criteria    forum.hibernate.org

Hi All, I need a little help with Hibernate Critieria. I have the following classes: public class Bottle{ private Long id; ... ... } public class BigContainer{ private Collection allBottles; ... ... } public class RedContainer{ private Collection redBottles; ... ... } I need a Hibernate Crieria to find all the bottles from BigContainer.allBottles that do NOT contain RedContainer.redBottles. I am ...

39. Criteria parsing    forum.hibernate.org

Hi, how can i parse a Criteria object which contains some levels of Subcriterias in it? I can get all the Subcriterias of a Criteria, but how to get all the Subcriterias from a Subcriteria? And eventually hot to get all the restrictions which are applied on a certain Subcriteria? Please advice.

40. Many-to-Many criteria problem    forum.hibernate.org

Hello, the last weeks I tried to build a Criteria that queries many-to-many associations, without success. I have USERs, ROLEs and USER_ROLEs where USER_ROLE is the jointable. I want to build a Criteria that gets me all USERs containing a number of ROLEs at the same time (for example 2 or more). The following attempt does not work properly, because it ...

41. Criteria question    forum.hibernate.org

42. Criteria question    forum.hibernate.org

Criteria criteria = session.createCriteria(Username .class); criteria.add(Expression.eq("username", userName)); List result = criteria.list(); for (Iterator iter = result.iterator(); iter.hasNext();) { ...

43. Criteria and type boxing    forum.hibernate.org

Hi all I'm building a framework using Struts and Hibernate. I am trying to automate a search form. Basicly, in my form, the field name is a column name of my persistant object, whereas the value is the criteria value. Once I submit the form, I build a map, the key is the column name and the value is the value ...

44. what's wrong with my Criteria..?    forum.hibernate.org

45. Criteria error    forum.hibernate.org

46. hibernate criteria    forum.hibernate.org

Hi, I am using Hibernate criteria for search purposes. I have an option to search the objects using its id.(primary key). This id search should be like search and not exact search. i.e If i give 1, then all objects having key start with 1 should be displayed. In my pojo this id is Long. (if i concat % to this ...

47. Criteria    forum.hibernate.org

48. criteria interface    forum.hibernate.org

49. OR with multiple Criteria trouble    forum.hibernate.org

50. Criteria question    forum.hibernate.org

Apologies for the cross post, but this one's relevant to all hibernate users as well as nhibernate so thought you might be able to help ... Can anyone suggest any simplification for the following query? I'm looking for people who have an address in paris and an address in london. Query is currently so complex to avoid searching for 'person with ...

52. how to add one criteria to another criteria    forum.hibernate.org

HI All, i am using two criteria's. i want to combine these two criteria's to one criteria. please let me know how to do. actually what i did? Criteria schdlInstanceCriteria = session.createCriteria(ReportScheduleInstance.class,"scheduleInstance") .createCriteria("scheduleInstance.report", "report") .createCriteria("scheduleInstance.clientCompany", "clientCompany") .setProjection(Projections.projectionList() .add(Projections.property("scheduleInstance.reptSchdlInstanceId")) .add(Projections.property("scheduleInstance.isScheduled")) .add(Projections.property("scheduleInstance.reptScheduleDesc")) .add(Projections.property("clientCompany.clientCompId"))) .add(Restrictions.eq("scheduleInstance.isScheduled", new Integer(reportSearchVO.getGeneratedMethod()))) .add(Restrictions.eq("report.reprotDefId", new Long(reportSearchVO.getReportId()))); if(reportSearchVO.getCompanyNumber()!= 0 ){ Criteria accountCriteria = session.createCriteria(ClientAccount.class,"clientAccount") .createCriteria("clientAccount.clientCompany", "clientCompany") .add(Restrictions.eq("clientCompany.companyNumber", new Long(reportSearchVO.getCompanyNumber()))); if(reportSearchVO.getAccountNumber()!=0){ accountCriteria.add(Restrictions.eq("clientAccount.clientAcctNum", ...

53. help w/ Criteria    forum.hibernate.org

54. Adding criteria to many-to-many    forum.hibernate.org

Hello, I have searched the internet and this forum, but haven't been able to find some hints to get things done. So, here it goes: I have this situation. - Table 'Articles' - Table 'Categories' - Jointable 'Article_categories' The relation between articles and categories is a many-to-many. Easy to map this. The class Category has a method getArticles that returns a ...

55. Criteria question    forum.hibernate.org

Hi All, I am relatively new to hibernate and having a few problems with implementing criteria. I want a query smiliar to: FROM T1 WHERE (x=1 and x2=1) OR (y=1 and y2=1). Code: List test = session.createCriteria(T1.class) ...

56. Deepcopy of Criteria    forum.hibernate.org

Hi, I am working with HibernateCritera API on a quite simple problem: "Find the sum of all positive values and find the sum of all negative values in a table" ... i get the Criteria from the framework to determine the intersection of the table. the simple approach: Code: Criteria c1 = criteria.getExecutableCriteria(s); ...

57. multiple criteria's    forum.hibernate.org

HI, I am new to hibernate. I have a scenario where i would like to use multiple criteria's. I have a map where i will be popping up the elements and try to AND them / OR them. So, is their a better way than using criteria because when we use criteria we need to give it a session. But, i ...

58. hibernate criteria for ipaddress subnet    forum.hibernate.org

hi everyone, I have a situation where i have to search in database for an IP_ADDRESS column, which contains 1000's of ipaddress. An example of ip address is 157.198.156.45 in this ip address the third octet is called C subnet. So, the condition here is that i have to write a hibernate criteria so, that we have to count the no.of ...

59. Criteria "or"ing in a loop    forum.hibernate.org

public String searchPatient(String patient){ String sql = "select * from PATIENT where "; String names[] = patient.split(" "); for(int i = 0;i < names.length ;i++){ sql += "upper(PATIENT_NAME) like '%" + names[i].toUpperCase() + "%' OR upper(PATIENT_SURNAME) like '%" + names[i].toUpperCase() + "%'"; if(i+1 !=names.length) sql += ...

60. Hibernate - Creating Criteria    forum.hibernate.org

61. Universal quantifier (forall) using criteria    forum.hibernate.org

Hi, is there any way to simulate universal quantifier (for all) using criteria? E.g. I have object Employee and Task in OneToMany association. Employee 1 ----- * Task Task has status attribute. I would like to select all Employees, which have all their tasks in status DONE. Easiest way to do this is rewrite FORALL Condition to NOT EXISTS (NOT Condition) ...

62. is that possible with criteria ?    forum.hibernate.org

Hi I need to know if it's possible within criteria queries to create a query that meet the following needs I've an entity affaire that have a communes relations and these commune have a relation to district how to access to affaire.communes.district.libelleFr like '%Toto%' I've tryed to first create a criteria within the affaire object then create a criteriera for the ...

63. criteria and set    forum.hibernate.org

64. Criteria question    forum.hibernate.org

Hi, I'm using hibernate through grails, and aksed this question on the grails mailing list, but no answers. Maybe somebody here can help me. I'm trying to do the following sql query using gorm/hibernate criteria: select k.* from kandidaat as k where exists ( select 1 from reactie where reactie_tekst = 'gereageerd' and kandidaat_id = k.id ); I'm using the isNotEmpty ...

67. Criteria question    forum.hibernate.org

68. How can I express this in Criteria    forum.hibernate.org

Thanks for your answer alexandrubarbat, these are my mappings. (I have the mappings you said.)

69. Criteria reverse reference    forum.hibernate.org

Hi, I have two classes class Product { Integer id; } class Characteristic { Integer id; @ManyToOne Product product; String type; } I want to select products which have characteristic.type="foo" SELECT product.* INNER JOIN characteristic on ( characteristic.product_id = product.id ) WHERE characteristic.type="foo"; Can i do this via Criteria API? The method riteria.createCriteria("...") won't work.

70. Hibernate Criterias    forum.hibernate.org

crit.add(Restrictions.like("prodName", "%" + s + "%")); crit.add(Restrictions.like("prodCode", "%" + s + "%")); crit.add(Restrictions.like("prodDescription", ...

71. Criteria Help    forum.hibernate.org

72. Issue with parenthesis in criterias    forum.hibernate.org

public List findByInstitutionName(String institutionName) { DetachedCriteria searchCriterias = DetachedCriteria.forClass(Institution.class); if (StringUtils.isNotBlank(institutionName)) searchCriterias.add(Restrictions.eq("institutionName", institutionName).ignoreCase()); searchCriterias.addOrder(Order.desc("id")); return getHibernateTemplate().findByCriteria(searchCriterias); } ...

73. Set containment: how to use Criteria    forum.hibernate.org

public class Merchant { public enum Service { A, B, C, D, E, F, } @CollectionOfElements(fetch=FetchType.LAZY) @JoinTable(name = "Merchant_Service", joinColumns = {@JoinColumn(name = "mId")}) @Column(name="service", nullable=false, columnDefinition="smallint(2)") @Enumerated(value=EnumType.ORDINAL) public Set getServices() { return services; } } Every merchant provides a set of Service, such as {A, B, D}, {A, D, F}, etc. Using Criteria API: Query: return all Merchants that provide ...

74. criteria's strange behavior    forum.hibernate.org

75. Hibernate criteria question    forum.hibernate.org

Hi guys I have an object say Basket that has a collection of Fruit which is a super class of Apple and Orange. What I'm trying to do is fetching a Basket with all of its Fruit objects initialized so I don't get class cast exception with polymorphism and proxy obj when doing something like (Apple)(basket.getBasketFruits().getIterator().next()) ; And consider the following ...

76. Hibernate Criteria    forums.oracle.com

77. calculate an addition with hibernate criteria    forums.oracle.com

78. Regarding Hibernate Criteria    forums.oracle.com