I have a question very similar to this question. I am selecting all data from table1 for all matching unique combinations of field3 and field4 from table2. Here is my stripped down SQL: select * from table1 as t1 where (t1.field1, t1.field2) in (select distinct field3, field4 from table2 as t2 where t2.id=12345); I need to tr
我有一个和这个问题非常相似的问题。 我从table1中选择所有来自table2的field3和field4的唯一组合的唯一组合。 这是我精简的SQL: select * from table1 as t1 where (t1.field1, t1.field2) in (select distinct field3, field4 from table2 as t2 where t2.id=12345); 我需要将我的SQL转换为Hibernate Criteria。 我有我的实体对象正确映射到表并将
I have already finished writing a lot of queries in hibernate for my project. Now my requirement has changed and a new column name ACTIVE is added in all the tables I have in MySql. I have no permission to deny the addition of ACTIVE column. The ACTIVE field can hold values true or false and I have to add that to the criteria too. So, I have been thinking is there a way I could add a criteria
我已经完成了在我的项目中为hibernate写了大量的查询。 现在我的需求发生了变化,并且在MySql中的所有表中添加了新的列名ACTIVE。 我无权拒绝添加ACTIVE列。 ACTIVE字段可以保持值为true或false,我也必须将其添加到条件中。 所以,我一直在想,是否有一种方法可以在Hibernate中添加一个标准限制,这对我所做的所有查询都很常见,而不是将每个查询的标准都放在这个标准中? 编辑:我想,小小的误解,对不起,我打字时很着
I would be glad for any help with using projections on nested child mapped collections. The code shows everything I want to achieve especially TestWrapper contains list of some entities. Let's assume that TestWrapper is my DTO object accumulating other. I want to get from test3 for example name and store it as list of test3 objects containg only that field set. At beginning let's l
我会很高兴在嵌套子映射集合上使用投影的任何帮助。 代码显示了我想要实现的一切,特别是TestWrapper包含一些实体列表。 假设TestWrapper是我的DTO对象,正在积累其他对象。 我想从test3中获取名称并将其存储为仅包含该字段集的test3对象的列表。 开始让我们看看实体类,包装器和hibernate投影代码: @Entity public class Test { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) private Long id; private St
Is there any way to project multiple values for an root entity object using Criteria? Assume we have these classes (With the proper mappings): class Boss { private String name; private List<Employee> employees; // setters and getters and more stuff } class Employee { private String name; // setters and getters and more stuff } Then
有没有办法使用Criteria为根实体对象投影多个值? 假设我们有这些类(使用适当的映射): class Boss { private String name; private List<Employee> employees; // setters and getters and more stuff } class Employee { private String name; // setters and getters and more stuff } 然后我试图做到这一点: public void test() { Criteri
I cannot find a solution to a problem that seems to be easy. Say there are 2 entity classes: class A { Set<B> bs; } class B { String text; } How to create a criteria query that returns all A's that contains at least one B entity which fulfills a given condition (like b.text = 'condition')? I think this link can be useful: http://mikedesjardins.net/2008/09/22/hibernat
我无法找到解决问题的方法,这似乎很容易。 假设有2个实体类: class A { Set<B> bs; } class B { String text; } 如何创建一个返回所有包含至少一个满足给定条件的B实体(如b.text ='condition')的A的条件查询? 我认为这个链接可能很有用:http://mikedesjardins.net/2008/09/22/hibernate-criteria-subqueries-exists/ 它包含以下关于如何创建n存在条件的示例: “你真正想要做的是获得所有比
I have to following entity object @Entity public class Foobar { ... private List<String> uuids; ... } Now I'd like to make a criteria query which would fetch all Foobar pojos whose uuids list contains the string "abc123", I'm just not sure how to make the appropriate criterion. I assume you are using a version of Hibernate that implements JPA 2.0. Here&
我不得不遵循实体对象 @Entity public class Foobar { ... private List<String> uuids; ... } 现在我想做一个标准查询来获取所有Foobar pojos的uuids列表包含字符串“abc123”,我只是不确定如何制定适当的标准。 我假设你正在使用实现JPA 2.0的Hibernate版本。 这是一个JPA 2.0解决方案,可以与任何兼容的实现协同工作。 请使用JPA的@ElementCollection注释来注释uuids 。 不要像其他一些答案评论
I want to perform search action on entered string. whatever user enter it should search on first name and last name column. //pseudo hql query Select E.someproperty .... from Entity E where upper(E.firstName || '' || E.lastName) like upper(+userEntered+'%') // In above code I combined two column and did search on it. I want similar functionality using hibernate criteria.
我想对输入的字符串执行搜索操作。 无论用户输入什么内容,都应该在名字和姓氏列上进行搜索。 //pseudo hql query Select E.someproperty .... from Entity E where upper(E.firstName || '' || E.lastName) like upper(+userEntered+'%') // 在上面的代码中,我组合了两列,并对其进行搜索。 我想要使用休眠条件的类似功能。 我试过下面的查询,但它没有工作 empCriteria.add(Restrictions.disjun
I am trying to use Hibernate Criteria api to fetch only the topics based on the USER_ID but have no idea how to do it using the criteria. My Tables are "topic_users" (below) and "topics" table (below) I know how to do it using SQL, this would be something like: SELECT TOPICNAME FROM topic_users INNER JOIN topics on topic_users.TOPICS_TOPICS_ID = topics.TOPICS_ID WHERE
我正在尝试使用Hibernate Criteria api仅提取基于USER_ID的主题,但不知道如何使用条件来执行此操作。 我的表是“topic_users”(下面) 和“主题”表(下方) 我知道如何使用SQL来做到这一点,如下所示: SELECT TOPICNAME FROM topic_users INNER JOIN topics on topic_users.TOPICS_TOPICS_ID = topics.TOPICS_ID WHERE topic_users.USER_ID = 1 这将返回USER_ID 1的所有TOPICNAME ,这正是我想要的,但我如何使用Hiber
I have an Archive database where there are 2 tables with the same structure, EvntSumaryT which is active and ArchiveEvntSumaryT which is the archived. I want to change my current criteria api code which only queries EvntSumary so that it will fetch data from both tables based on the user selected dates and return the results into a list. My problem is that their is no Union feature in hibernate
我有一个存档数据库,其中有两个具有相同结构的表,即活动的EvntSumaryT和存档的ArchiveEvntSumaryT。 我想更改当前的标准api代码,它只查询EvntSumary,以便根据用户选择的日期从两个表中提取数据并将结果返回到列表中。 我的问题是,它们在hibernate-criteria中没有联合功能,所以我如何能够一次查询两个表并将结果合并到一个列表中? 以下是我的jpa实体类的代码。 我已经将活动表的实体设置为父类,并将子项设置为Archiv
Using hibernate 3.6.10 with hibernate jpa 2.0. My problem boils down to needing to set some criteria on a column of a child object during a somewhat complex joining query. I have a set of objects similar to: @Entity @Inheritance(strategy = InheritanceType.JOINED) public class Ball { private String name; //...getter and setter crud... } @Entity public class BeachBall extend ball
使用hibernate 3.6.10和hibernate jpa 2.0。 我的问题归结为需要在有点复杂的加入查询期间在子对象的列上设置一些条件。 我有一组对象类似于: @Entity @Inheritance(strategy = InheritanceType.JOINED) public class Ball { private String name; //...getter and setter crud... } @Entity public class BeachBall extend ball { private boolean atTheBeach; //...getter and setter crud... }