criteria

JPA join criteria with datastore in google app engine

大城市里の小女人 提交于 2020-01-15 11:05:31
问题 Suppose I have 2 JPA classes which model 2 entities in datastore (Google app engine) like these: @Entity public class Clazz { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Key classKey; @Basic private String classId; @Basic private String className; @ManyToOne private Subject subject; } @Entity public class Subject { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Key subjectKey; @Basic private String subjectId; @Basic private String subjectName; @OneToMany

JPA join criteria with datastore in google app engine

笑着哭i 提交于 2020-01-15 11:04:12
问题 Suppose I have 2 JPA classes which model 2 entities in datastore (Google app engine) like these: @Entity public class Clazz { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Key classKey; @Basic private String classId; @Basic private String className; @ManyToOne private Subject subject; } @Entity public class Subject { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Key subjectKey; @Basic private String subjectId; @Basic private String subjectName; @OneToMany

criteria api--root.fectch() how to fetch a collection?

微笑、不失礼 提交于 2020-01-14 13:46:34
问题 The args' type of method fetch() can be SingularAttribute, PluralAttribute, why not can't be ListAttribute ? Then, how to fetch a collection with critria api ? Thank you. 回答1: Of course it can, as Rasmus Franke said. Just check from the javadocs for FetchParent or try this: @Entity public class SomeEntity { @Id int id; @OneToMany List<OtherEntity> others; } @Entity public class OtherEntity { @Id int id; } CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<SomeEntity> cq = cb

Yii condition <IS NULL>

帅比萌擦擦* 提交于 2020-01-13 11:15:54
问题 How to find row by column with null value? It doesn't work: $criteria->condition = '`seller_id` IS NULL'; 回答1: $criteria->addCondition('seller_id IS NULL'); $data= MODEL::model()->find($criteria); tried this? **seller_id** is the mapped column name in Yii , it may not be same as the actual column name in your database. 来源: https://stackoverflow.com/questions/5349788/yii-condition-is-null

Yii condition <IS NULL>

社会主义新天地 提交于 2020-01-13 11:14:48
问题 How to find row by column with null value? It doesn't work: $criteria->condition = '`seller_id` IS NULL'; 回答1: $criteria->addCondition('seller_id IS NULL'); $data= MODEL::model()->find($criteria); tried this? **seller_id** is the mapped column name in Yii , it may not be same as the actual column name in your database. 来源: https://stackoverflow.com/questions/5349788/yii-condition-is-null

Yii condition <IS NULL>

邮差的信 提交于 2020-01-13 11:13:18
问题 How to find row by column with null value? It doesn't work: $criteria->condition = '`seller_id` IS NULL'; 回答1: $criteria->addCondition('seller_id IS NULL'); $data= MODEL::model()->find($criteria); tried this? **seller_id** is the mapped column name in Yii , it may not be same as the actual column name in your database. 来源: https://stackoverflow.com/questions/5349788/yii-condition-is-null

How to set positional/named parameters dynamically to JPA criteria query?

荒凉一梦 提交于 2020-01-12 14:50:33
问题 Hibernate provider does not generate prepared statement for non-string type parameters unless they are set to entityManager.createQuery(criteriaQuery).setParameter(Parameter p, T t); as done by EclipseLink, by default. What is the way to set such parameters, if they are supplied dynamically at run time. For example, CriteriaBuilder criteriaBuilder=entityManager.getCriteriaBuilder(); CriteriaQuery<Long>criteriaQuery=criteriaBuilder.createQuery(Long.class); Metamodel metamodel=entityManager

How to set positional/named parameters dynamically to JPA criteria query?

梦想的初衷 提交于 2020-01-12 14:48:17
问题 Hibernate provider does not generate prepared statement for non-string type parameters unless they are set to entityManager.createQuery(criteriaQuery).setParameter(Parameter p, T t); as done by EclipseLink, by default. What is the way to set such parameters, if they are supplied dynamically at run time. For example, CriteriaBuilder criteriaBuilder=entityManager.getCriteriaBuilder(); CriteriaQuery<Long>criteriaQuery=criteriaBuilder.createQuery(Long.class); Metamodel metamodel=entityManager

How do I use a complex criteria inside a doctrine 2 entity's repository?

懵懂的女人 提交于 2020-01-09 08:55:47
问题 Lets say I have a table that holds information about festivals. Each festival has a start and end date. I want to select all the festivals that are live (that happen) on a given date. Meaning, I want to select all the festivals that their start date is before or on a given date, and that their end date is after or on a the same given date. So I went on to the repository class of the festival entity, and created a method to do just that. But the criteria argument "findBy" expects is an array,

Hibernate分页查询的知识

一世执手 提交于 2020-01-08 18:43:09
criteria.setProjection(null);目的是为了获得行数,并设置投影为空,为的是返回List出来,如果不设置setProjection(null)的话,criteria.list将返回的是行数 (int型),而不是所要查询的数据库信息。但是Criteria的ResultTransformer会变成 PassThroughResultTransformer,criteria.list的时候可能结果会跟理想的不一样,所以我们还要再 criteria.setResultTransformer(Criteria.ROOT_ENTITY);把结果以Entity的形式返回,而不是Object[]。 来源: https://www.cnblogs.com/jaynessvip/p/12167979.html