{"id":3995,"date":"2014-03-30T07:03:45","date_gmt":"2014-03-30T07:03:45","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-criteria-collection-of-common-programming-errors\/"},"modified":"2014-03-30T07:03:45","modified_gmt":"2014-03-30T07:03:45","slug":"problem-about-criteria-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-criteria-collection-of-common-programming-errors\/","title":{"rendered":"problem about criteria-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c7072ccb19a86811e2acfe05d322ef5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJoeBrockhaus<br \/>\nnhibernate conditional criteria<br \/>\nI&#8217;ve got a working Criteria, but I want to make my method more flexible.one of the pieces of my criteria looks like this: .Add(nhc.Restrictions.In(&#8220;GroupID&#8221;, groupIDs)|| nhc.Restrictions.Eq(&#8220;UserIDScheduled&#8221;, userID));but what I need to do is check if the groupIDs &amp; userID params actually have values before adding them here, because otherwise I&#8217;ll get unexpected results\/query. for instance, If i want to get the entities where GroupID is in x,y,z, but not include the userid in the OR if it&#8217;s<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/graph.facebook.com\/1678430878\/picture?type=large\" \/><br \/>\nuser3418584<br \/>\njpa hql criteria jpql builder<br \/>\nI need help with this query is possible in JPA Criteria Builder? select * from (select * from&#8230;) this is specific query don&#8217;t work? select a.codeoffice,a,nameoffice, count(case when status=&#8217;I&#8217; then a.codeCustomer else 0) as Incomplete, count(case when status=&#8217;E&#8217; then a.codeCustomer else 0) as Evaluation count(case when status=&#8217;A&#8217; then a.codeCustomer else 0) as appoved, count(distinct a.codeCustomer) as totalCustomer from ( select distinct codeCustomer,codeoffice,nameoffice,status from<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6c883a84723be56d09c8cec2725b75ca?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nObjectDB<br \/>\njpa criteria jpql objectdb<br \/>\nI am trying to migrate my Spring project from Hibernate to ObjectDB. On ObjectDB page, they say that ObjectDB is 100% compatible with JPA. However, I have problem with this JPQL query:SELECT e FROM Employee e WHERE e.present = false AND NOT EXISTS (SELECT c FROM Computer c WHERE c.employeeEntity = e) ORDER BY e.namewith Hibernate, there was no problem with this query, but ObjectDB throws exception:com.objectdb.o.UserException: Unexpected query token &#8216;EXISTS&#8217;Second problem is with Criteria Lang<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8ccb0e3c6324092fc233919115da84b5?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ninstanceOfObject<br \/>\ndatabase hibernate criteria projection<br \/>\nWe are using hibernate 3.3 for our application and facing this weired problem in which Criteria criteria = getSession().createCriteria(table.class);criteria.setProjection(Projections.rowCount()); returns 4 rows, 3 having values &#8216;0&#8217; and 1 with correct value.Because of this issue criteria.uniqueResult(); throws an exception saying org.hibernate.NonUniqueResultException: query did not return a unique result: 4Any help would be highly appreciated.Thanks in advance.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c7fb64856eda5af7f46b4996ab8fd37b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsimon<br \/>\njava oracle hibernate criteria<br \/>\nI have the following codeCriteria criteria = this.getCriteriaForClass(DeviceListItem.class); Projection rowCountProjection = Projections.countDistinct(&#8220;color&#8221;); criteria.setProjection(rowCountProjection); int rowCount = ((Long) criteria.uniqueResult()).intValue(); return rowCount;, whose purpose is to find out the number of rows with different values for the field named &#8220;color&#8221;. The problem is that Projections.countDistinct(&#8220;color&#8221;);returns the same number of results as Projections.count(&#8220;color&#8221;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6ae137aeee34138c71423994f68ea01b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMuhnamana<br \/>\nms-access access-vba criteria ms-access-2010<br \/>\nSo the following VBA code I have will requery the form based on the Combo1 value equal to January. Eventually, I&#8217;ll have X number of years in the Combo value and only want to display all records based on each year.Is it possible to add additional VBA code to use the Criteria from the query instead of having X amount of queries and requery them based on the year.Private Sub Combo1_AfterUpdate()If Combo1.Value = &#8220;2013&#8221; Then [Form_Main Form].RecordSource = &#8220;Main_Form_Query&#8221; [Form_Main Form].Requery<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3849ae04cc1d65c892fcc6adc0f6b2fe?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nreach4thelasers<br \/>\ncriteria icriteria nhlambdaextensions<br \/>\nMy application creates a dynamically generated query at runtime based on user input by creating Criterion objects e.g:ICriterion criterion = Restrictions.Eq(&#8220;Name&#8221;, &#8220;John&#8221;); &#8230;&#8230; detachedCriteriaSomewhereElse.Add(criterion);How do I do this in NHLambdaExtensions?what I really need to do isICriterion criterion = Restrictions.Eq&lt;Person&gt;(p=&gt; p.Name == &#8220;John&#8221;);but this isn&#8217;t valid. Is there any way to do this?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/dc1a5b5fdba36ae9cdcf6e267f1a86ca?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPascal Thivent<br \/>\njava hibernate orm criteria performance<br \/>\ni have the following criteria specification and wanted to know if there is any difference in the performance or the memory usage of them. 1st way:criteria.add(Restrictions.eq(&#8220;case.estadoOperativo&#8221;, Caso.EstadoOperativo.COMPLETADO)).add(Restrictions.eq(&#8220;case.estadoAdministrativo&#8221;, Caso.EstadoAdministrativo.TARIFICADO));2nd way:criteria.add(Restrictions.eq(&#8220;case.estadoOperativo&#8221;, Caso.EstadoOperativo.COMPLETADO)); criteria.add(Restrictions.eq(&#8220;case.estadoAdministrativo&#8221;,Caso.EstadoAdministrativo.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/92e3be3b28d1a070a04077b087203522?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser503413<br \/>\njpa persistence jpa-2.0 criteria criteria-api<br \/>\nI am building a highly generic query mechanism on top of the JPA Criteria. I get as input an XML describing the query, something like this:&lt;?xml version=&#8217;1.0&#8242; encoding=&#8217;UTF-8&#8242; standalone=&#8217;yes&#8217;?&gt; &lt;Criteria xmlns=&#8217;criteria&#8217; maxResults=&#8217;2&#8242;&gt;&lt;Expression&gt;&lt;CompareRestriction propertyType=&#8217;Date&#8217; operator=&#8217;GREATER_THAN_OR_EQUALS&#8217; propertyName=&#8217;deliveryDate&#8217;&gt;2010-07-02&lt;\/CompareRestriction&gt;&lt;CompareRestriction propertyType=&#8217;Float&#8217; operator=&#8217;GREATER_THAN_OR_EQUALS&#8217; propertyNa<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8874149c58a50bffaeb6a9a249d3dc75?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsikrip<br \/>\ngrails groovy gorm criteria<br \/>\nIn a gorm domain class, I can dodef q = {property1{eq(&#8216;attr&#8217;, 0)} }MyDomainClass.list(q)How could I modify the closure &#8216;q&#8217; (or create a new closure that would contain the restrictions that closure &#8216;q&#8217; has) at runtime so for example I could add another property restriction?More detailsActually my problem is how to create combined criteria in a Domain Class Hierarchy.class Parent{int pAttrstatic def getCriteria(){def dummyParentCriteria = {eq(&#8216;pAttr&#8217;, 0)}} }class Child extends Parent{int cAttrstat<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/45f22121c1e4102e6bb1feb3f0fb95a5?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nssedano<br \/>\nhibernate criteria<br \/>\nThis is my hierarchy:\/\/ Table a class A {}\/\/ Table(&#8221; b class B extends A {}\/\/ Table my_class class MyClass {A a; }I want to retrieve all MyClass objects from database with a relation to B but not to A.B is a joined-subclass (extension of the table a by id).My idea was something :Criteria criteria = session.createCriteria(MyClass.class); criteria.add(Restrictions.eq(&#8220;a.class&#8221;, B.class);But it outputs an error:could not resolve property: a.class of a.b.MyClassThis is the simplest way I could put i<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e685f3213b5cbacc8c46a5268c09dd1f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTsunaze<br \/>\nandroid google-maps geolocation location criteria<br \/>\nLocationManager locationManager;String context = Context.LOCATION_SERVICE;locationManager = (LocationManager)getSystemService(context);Criteria criteria = new Criteria();criteria.setAccuracy(Criteria.ACCURACY_FINE);criteria.setAltitudeRequired(false);criteria.setBearingRequired(false);criteria.setCostAllowed(true);criteria.setPowerRequirement(Criteria.POWER_LOW);String provider = locationManager.getBestProvider(criteria, true);Location location = locationManager.getLastKnownLocation(provider);do<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/L1DR1.jpg?s=32&amp;g=1\" \/><br \/>\nlittlealien<br \/>\nsql-order-by criteria propel case-insensitive<br \/>\nI have been looking around for days and couldnt find anything helpfull.my problem is; I couldn&#8217;t set criteria case-insensitive ORDER (A a b B D d). Because when I try to fetch my records from DB, its not ordering properly since ascii problems (A B C a b c )I want to set my ORDER criteria like this;Criterias::setCriterias(Array(&#8216;ORDER&#8217; =&gt; &#8216;UPPER(name)&#8217;));But propel doesnt let me to use UPPER in setting criterias. So I have to set it like this;Criterias::setCriterias(Array(&#8216;ORDER&#8217; =&gt; &#8216;name&#8217;)<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e9b2f000a6ae6b518d1a0976980b3cbb?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAdam<br \/>\nruby-on-rails-3 mongoid criteria<br \/>\nI&#8217;d like to use the Mongoid criteria methods ( http:\/\/mongoid.org\/docs\/querying\/criteria.html ). I have a model named College. In the College controller:def index@colleges = College.all_of(:sat_rmw.gt =&gt; 1200, :in_state_tuition.lt =&gt; 12000) endThis generates the error:undefined method `all_of&#8217; for College:ClassAm I supposed to use criteria in the College Model as opposed to the Controller? Thanks in advance!<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8f6337c8c7a1cf04dab80ae3a8c40150?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ntirengarfio<br \/>\nsymfony1 criteria propel<br \/>\ni have retrieved a group of elements using a propel criteria. Now are at $Sedi18nsWhen i use this:$SediI18ns-&gt;prev()I get:( ! ) Fatal error: Call to undefinedmethodsfOutputEscaperArrayDecorator::prev()No problems when i use next().Any idea?RegardsJavi<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8f6337c8c7a1cf04dab80ae3a8c40150?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ntirengarfio<br \/>\nsql mysql criteria propel<br \/>\n$c = new Criteria(); $c-&gt;addSelectColumn(&#8216;MAX(&#8216;.Moto::matricula.&#8217;)&#8217;);But i get this error:Fatal error: Undefined class constant&#8217;matricula&#8217; in \/opt\/lampp\/htdocs\/prueba\/lib\/model\/MotoPeer.php on line25.Any idea?I&#8217;m using symfony 1.4 and propel 1.4. RegardsJavi<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8f6337c8c7a1cf04dab80ae3a8c40150?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ntirengarfio<br \/>\nsymfony1 criteria propel offset<br \/>\ni have this schema below, i have generated the classes using symfony and created a pair of objects using the form class generated.moto:marca: { type: varchar(255), required: true }matricula: { type: integer, required: true }Now i have this criteria:$c = new Criteria();$c-&gt;addSelectColumn(&#8216;MAX(&#8216;.MotoPeer::MATRICULA.&#8217;)&#8217;);$max_matricula = MotoPeer::doSelect($c);var_dump($max_matricula);return $max_matricula;When i call the criteria code It works ok, but these three notices below are showed.Any i<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/89927e2f4bde24991649b353a37678b9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBalusC<br \/>\njava jpa criteria<br \/>\nI&#8217;m trying to do a search page that retrieves some data from my database using JPA 2.0 Criteria API. I&#8217;m getting the same exception error everytime I try to do the search.Here is my search method:public List&lt;Matches&gt; search(SearchCommercialsDTO searchCommercialsDTO) {CriteriaBuilder builder = em.getCriteriaBuilder();CriteriaQuery&lt;Matches&gt; criteria = builder.createQuery( Matches.class );Root&lt;Matches&gt; matchesRoot = criteria.from( Matches.class );criteria.select( matchesRoot );Lis<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/feaeea6d2939022c49dc8b3a0510df43?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nEduardo Born<br \/>\njava hibernate query syntax criteria<br \/>\nI&#8217;m having a hard time constructing a criteria query to get the &#8220;permissions&#8221; attribute from the Role entity with id = 2. The permission attribute is of Set type, so I&#8217;m creating a join and selecting from it, but the query fails with invalid grammar exception reporting &#8220;Unknown column &#8216;2L&#8217; in &#8216;where clause'&#8221;The criteria query that generates the error was built this way:EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); Criteria<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6bd72e91ca6e57e553998a9e5e1be593?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJonathan<br \/>\njava hibernate criteria<br \/>\nI need to convert the following HQL to CRITERIA:Query query = bd.getSession().createQuery(&#8220;from Booking as b &#8221; + &#8221; where &#8221; + &#8221; b.cadimp.cdCadimp = :cdCadimp AND &#8220;+ &#8221; b.dtEntrada &gt;= :dateParam AND &#8221; + &#8221; b.idCancelado &lt;&gt; &#8216;S&#8217; AND &#8221; + &#8221; b.cdNavio &lt;&gt; 141 AND &#8221; + &#8221; 0 = (select count(*) from Item i2 where &#8221; +&#8221; (&#8221; +&#8221; i2.pk.cdEmpresa = b.pedido.cdEmpresa &#8221; +&#8221; AND i2.pk.nrPedido = b.pedido.nrPedido &#8221; +&#8221; AND&#8221;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/157611e1920cebabac9c1502efcc28ab?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nFinalArt2005<br \/>\njava hibernate postgresql group-by criteria<br \/>\nI&#8217;m having some trouble with an sql query. I&#8217;m using Hibernate Criteria to build the query. I create some bins from a database by rounding the values with certain intervals (the binSize) and then grouping them. This works great when I try it directly in SQL with the query:SELECT floor(phiTorsionAngle \/ 2) * 2 as phiTorsionAngleBin, floor(psiTorsionAngle \/ 2) * 2 as psiTorsionAngleBin, floor(phiTorsionAngle \/ 2) + 180 as phiTorsionAngleBinIndex, floor(psiTorsionAngle \/ 2) + 180 as psiTorsionAngle<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/19a55621e2d2441600c26df6d5a2d49c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nb_gunay<br \/>\njava hibernate query criteria jpa-2.0<br \/>\nI&#8217;ve a war application using hibernate-jpa 2.0, SiteListig is my entity, I want to make a criteria query, my code looks like:class Listing{ private Predicate criteria; @PersistenceContext private EntityManager em; private Root&lt;T&gt; criteriaRoot; @Pattern(regexp=&#8221;([a-zA-Z0-9_\\\\s]+?|^$)&#8221;, message=&#8221;invalid filter&#8221;) private String addressFilter;public void setAddressFilter(String addressFilter) { this.addressFilter = addressFilter; \/\/ apply this as a filter CriteriaBuilder cb = getCriteriaBuilde<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/aee3b44e5f0b4dfa0e2da672897b3751?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nj0k<br \/>\nmysql symfony1 criteria propel<br \/>\nI&#8217;m working on a symfony project and i need to query a many to many relationship, so i made this criteria based function to query the database:\/\/Create Criteria Object$c1 = new Criteria();\/\/Selecting the rows in the link table that matches the Table1 id (parameter)$c1-&gt;add(LinktablePeer::TBL1_CODIGO,$parameter,Criteria::EQUAL);\/\/Selecting the rows in Table2 that matched with the last query$c1-&gt;addJoin(LinktablePeer::TBL2_CODIGO,Table2Peer::TBL2_CODIGO);$list = LinktablePeer::doSelect($c1);<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JoeBrockhaus nhibernate conditional criteria I&#8217;ve got a working Criteria, but I want to make my method more flexible.one of the pieces of my criteria looks like this: .Add(nhc.Restrictions.In(&#8220;GroupID&#8221;, groupIDs)|| nhc.Restrictions.Eq(&#8220;UserIDScheduled&#8221;, userID));but what I need to do is check if the groupIDs &amp; userID params actually have values before adding them here, because otherwise I&#8217;ll get [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3995","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3995","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3995"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3995\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}