criteria

SQL syntax term for 'WHERE (col1, col2) < (val1, val2)'

浪子不回头ぞ 提交于 2019-12-17 09:52:42
问题 As my question states, I would like to know what we call types of queries with that type of condition in the WHERE clause, i.e.: SELECT * FROM mytable WHERE (col1, col2) < (1, 2); In other words: Give me all records where col1 is less than '1' or if it equals '1' then col2 must be less than '2' - and none of the values are NULL. I really like this type of syntax, but don't know what the naming convention is on how to refer to this type of condition. It looks like a tuple conditional but that

How do add NOLOCK with nHibernate?

夙愿已清 提交于 2019-12-17 06:36:43
问题 How do you add NOLOCK when using nhibernate? (criteria query) 回答1: SetLockMode(LockMode.None) or connection.isolation ReadUncomitted does NOT append a NOLOCK to your queries. Ayende goes into the correct answer on his blog: If you're using <sql-query> you can do the following: <sql-query name="PeopleByName"> <return alias="person" class="Person"/> SELECT {person.*} FROM People {person} WITH(nolock) WHERE {person}.Name LIKE :name </sql-query> Note the WTIH(nolock) appended to the FROM clause.

criteria api set predicate in where clause for MapJoin

谁说我不能喝 提交于 2019-12-13 21:13:00
问题 I'm having some trouble with setting the where clause of the following query: CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Configuration> cq = cb.createQuery(Configuration.class); Root<Configuration> conf = cq.from(Configuration.class); MapJoin<Configuration, String, Component> mapJoin = conf.join(Configuration_.components, JoinType.LEFT); cq.where(cb.and(cb.like(mapJoin.key(), "%abc%"), cb.like(mapJoin.value().get(Component_.displayName), "%def%"))); cq.select(pc); I am

Grails…Mocking criteria that returns PagedResultList

筅森魡賤 提交于 2019-12-13 16:45:08
问题 In my controller, i have an action which uses criteria to hit db and fetch results. params.max = Math.min(params.max ? params.int('max') : 20, 100) def c = DomainObj.createCriteria() def result =[] result = c.list(params) { 'eq'("employerid", id) } I have mocked this call in my testcase this way: def result=[DomainObj1] def mycriteria =[ list: {Object params=null,Closure cls -> result} ] DomainObj.metaClass.static.createCriteria = {mycriteria} Works fine so far. But in the controller, there

Error: column “this_.phitorsionangle” must appear in the GROUP BY clause or be used in an aggregate function

喜欢而已 提交于 2019-12-13 15:16:03
问题 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

Hibernate 中Criteria Query查询详解

两盒软妹~` 提交于 2019-12-13 13:12:52
当查询数据时,人们往往需要设置查询条件。在SQL或HQL语句中,查询条件常常放在where子句中。此外,Hibernate还支持Criteria查询(Criteria Query),这种查询方式把查询条件封装为一个Criteria对象。在实际应用中,使用Session的createCriteria()方法构建一个org.hibernate.Criteria实例,然后把具体的查询条件通过Criteria的add()方法加入到Criteria实例中。这样,程序员可以不使用SQL甚至HQL的情况下进行数据查询,如例程9-1所示。 例程9-1 Criteria应用实例 代码 Criteria cr = session.createCriteria(Student.class); //生成一个Criteria对象 cr.add(Restrictions.eq("name", "Bill"));//等价于where name=’Bill’ List list = cr.list(); Student stu = (Student)list.get(0); System.out.println(stu.getName()); 1.常用的查询限制方法 在例程9-1中,Restrictions.eq()方法表示equal,即等于的情况。Restrictions类提供了查询限制机制。它提供了许多方法

Challenging formula to calculate amount of hours based on several criteria

﹥>﹥吖頭↗ 提交于 2019-12-13 11:14:25
问题 I am working on a business travel template where I am trying to incorporate some of our policies as follows (additional hours criteria below): In cell N15, I need the total number of hours to be added based on the criteria listed on the image below the scenario. I just need to find a formula to work out the number of additional hours. (Means of transport selection is a drop down, all available options are listed in this example.) 回答1: I think the result you want might be achieved with: =3

Java criteria restrictions sum of columns lower than value

这一生的挚爱 提交于 2019-12-13 07:04:19
问题 Hi I've a question about converting a simple SQL statement into a java hibernate restriction. SQL: SELECT a + b FROM col WHERE a + b < 10 When I try to convert this to a criteria I get: Criteria criteria = createCriteria(); criteria.createAlias("col","col").add(Restrictions.lt("a+b",10)); But it seems like the string "a+b" is not accepted. How do I have to write my restriction? 回答1: It's likely because Hibernate is trying to resolve a+b as your entity's property, and you get org.hibernate

Select subset of the list contained in an entity

爷,独闯天下 提交于 2019-12-13 06:02:17
问题 Say I want to get all rows of the MyEntity that have an id lower than 10. This entity contains a list of Another entity. I would like this list to be fetched only by a subset of the listAnother . This subset containing only Another where the user contained in it is a specific one. Basically in SQL it would be like this : SELECT * FROM myentity m LEFT JOIN another a ON m.idTable=a.my_entity AND a.user = "test1" WHERE m.idTable < 10; I didn't manage however to translate this query to jpql. My

Alfresco filter people by creator name

别来无恙 提交于 2019-12-13 05:51:00
问题 I want to modify the webscript alfresco-remote-api-5.0.d.jar\alfresco\templates\webscripts\org\alfresco\repository\person\people.get.js . I need to display for the connected user only user he has created. I have modify the filter to include username in query. filter = filter + " AND cm:creator:admin"; people.getPeoplePaging(filter, paging, sortBy, sortAsc); This must display only users created by admin. But it's not working(no user is returned). How can i select only users created by a