problem about criteria-Collection of common programming errors


  • JoeBrockhaus
    nhibernate conditional criteria
    I’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(“GroupID”, groupIDs)|| nhc.Restrictions.Eq(“UserIDScheduled”, userID));but what I need to do is check if the groupIDs & userID params actually have values before adding them here, because otherwise I’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’s

  • user3418584
    jpa hql criteria jpql builder
    I need help with this query is possible in JPA Criteria Builder? select * from (select * from…) this is specific query don’t work? select a.codeoffice,a,nameoffice, count(case when status=’I’ then a.codeCustomer else 0) as Incomplete, count(case when status=’E’ then a.codeCustomer else 0) as Evaluation count(case when status=’A’ then a.codeCustomer else 0) as appoved, count(distinct a.codeCustomer) as totalCustomer from ( select distinct codeCustomer,codeoffice,nameoffice,status from

  • ObjectDB
    jpa criteria jpql objectdb
    I 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 ‘EXISTS’Second problem is with Criteria Lang

  • instanceOfObject
    database hibernate criteria projection
    We 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 ‘0’ 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.

  • simon
    java oracle hibernate criteria
    I have the following codeCriteria criteria = this.getCriteriaForClass(DeviceListItem.class); Projection rowCountProjection = Projections.countDistinct(“color”); 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 “color”. The problem is that Projections.countDistinct(“color”);returns the same number of results as Projections.count(“color”

  • Muhnamana
    ms-access access-vba criteria ms-access-2010
    So the following VBA code I have will requery the form based on the Combo1 value equal to January. Eventually, I’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 = “2013” Then [Form_Main Form].RecordSource = “Main_Form_Query” [Form_Main Form].Requery

  • reach4thelasers
    criteria icriteria nhlambdaextensions
    My application creates a dynamically generated query at runtime based on user input by creating Criterion objects e.g:ICriterion criterion = Restrictions.Eq(“Name”, “John”); …… detachedCriteriaSomewhereElse.Add(criterion);How do I do this in NHLambdaExtensions?what I really need to do isICriterion criterion = Restrictions.Eq<Person>(p=> p.Name == “John”);but this isn’t valid. Is there any way to do this?

  • Pascal Thivent
    java hibernate orm criteria performance
    i 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(“case.estadoOperativo”, Caso.EstadoOperativo.COMPLETADO)).add(Restrictions.eq(“case.estadoAdministrativo”, Caso.EstadoAdministrativo.TARIFICADO));2nd way:criteria.add(Restrictions.eq(“case.estadoOperativo”, Caso.EstadoOperativo.COMPLETADO)); criteria.add(Restrictions.eq(“case.estadoAdministrativo”,Caso.EstadoAdministrativo.

  • user503413
    jpa persistence jpa-2.0 criteria criteria-api
    I 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:<?xml version=’1.0′ encoding=’UTF-8′ standalone=’yes’?> <Criteria xmlns=’criteria’ maxResults=’2′><Expression><CompareRestriction propertyType=’Date’ operator=’GREATER_THAN_OR_EQUALS’ propertyName=’deliveryDate’>2010-07-02</CompareRestriction><CompareRestriction propertyType=’Float’ operator=’GREATER_THAN_OR_EQUALS’ propertyNa

  • sikrip
    grails groovy gorm criteria
    In a gorm domain class, I can dodef q = {property1{eq(‘attr’, 0)} }MyDomainClass.list(q)How could I modify the closure ‘q’ (or create a new closure that would contain the restrictions that closure ‘q’ 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(‘pAttr’, 0)}} }class Child extends Parent{int cAttrstat

  • ssedano
    hibernate criteria
    This is my hierarchy:// Table a class A {}// Table(” 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(“a.class”, 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

  • Tsunaze
    android google-maps geolocation location criteria
    LocationManager 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

  • littlealien
    sql-order-by criteria propel case-insensitive
    I have been looking around for days and couldnt find anything helpfull.my problem is; I couldn’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(‘ORDER’ => ‘UPPER(name)’));But propel doesnt let me to use UPPER in setting criterias. So I have to set it like this;Criterias::setCriterias(Array(‘ORDER’ => ‘name’)

  • Adam
    ruby-on-rails-3 mongoid criteria
    I’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 => 1200, :in_state_tuition.lt => 12000) endThis generates the error:undefined method `all_of’ for College:ClassAm I supposed to use criteria in the College Model as opposed to the Controller? Thanks in advance!

  • tirengarfio
    symfony1 criteria propel
    i have retrieved a group of elements using a propel criteria. Now are at $Sedi18nsWhen i use this:$SediI18ns->prev()I get:( ! ) Fatal error: Call to undefinedmethodsfOutputEscaperArrayDecorator::prev()No problems when i use next().Any idea?RegardsJavi

  • tirengarfio
    sql mysql criteria propel
    $c = new Criteria(); $c->addSelectColumn(‘MAX(‘.Moto::matricula.’)’);But i get this error:Fatal error: Undefined class constant’matricula’ in /opt/lampp/htdocs/prueba/lib/model/MotoPeer.php on line25.Any idea?I’m using symfony 1.4 and propel 1.4. RegardsJavi

  • tirengarfio
    symfony1 criteria propel offset
    i 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->addSelectColumn(‘MAX(‘.MotoPeer::MATRICULA.’)’);$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

  • BalusC
    java jpa criteria
    I’m trying to do a search page that retrieves some data from my database using JPA 2.0 Criteria API. I’m getting the same exception error everytime I try to do the search.Here is my search method:public List<Matches> search(SearchCommercialsDTO searchCommercialsDTO) {CriteriaBuilder builder = em.getCriteriaBuilder();CriteriaQuery<Matches> criteria = builder.createQuery( Matches.class );Root<Matches> matchesRoot = criteria.from( Matches.class );criteria.select( matchesRoot );Lis

  • Eduardo Born
    java hibernate query syntax criteria
    I’m having a hard time constructing a criteria query to get the “permissions” attribute from the Role entity with id = 2. The permission attribute is of Set type, so I’m creating a join and selecting from it, but the query fails with invalid grammar exception reporting “Unknown column ‘2L’ in ‘where clause'”The criteria query that generates the error was built this way:EntityManager entityManager = getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); Criteria

  • Jonathan
    java hibernate criteria
    I need to convert the following HQL to CRITERIA:Query query = bd.getSession().createQuery(“from Booking as b ” + ” where ” + ” b.cadimp.cdCadimp = :cdCadimp AND “+ ” b.dtEntrada >= :dateParam AND ” + ” b.idCancelado <> ‘S’ AND ” + ” b.cdNavio <> 141 AND ” + ” 0 = (select count(*) from Item i2 where ” +” (” +” i2.pk.cdEmpresa = b.pedido.cdEmpresa ” +” AND i2.pk.nrPedido = b.pedido.nrPedido ” +” AND”

  • FinalArt2005
    java hibernate postgresql group-by criteria
    I’m having some trouble with an sql query. I’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

  • b_gunay
    java hibernate query criteria jpa-2.0
    I’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<T> criteriaRoot; @Pattern(regexp=”([a-zA-Z0-9_\\s]+?|^$)”, message=”invalid filter”) private String addressFilter;public void setAddressFilter(String addressFilter) { this.addressFilter = addressFilter; // apply this as a filter CriteriaBuilder cb = getCriteriaBuilde

  • j0k
    mysql symfony1 criteria propel
    I’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->add(LinktablePeer::TBL1_CODIGO,$parameter,Criteria::EQUAL);//Selecting the rows in Table2 that matched with the last query$c1->addJoin(LinktablePeer::TBL2_CODIGO,Table2Peer::TBL2_CODIGO);$list = LinktablePeer::doSelect($c1);

Web site is in building