English 中文(简体)
在藏匿地,可以找到一份由多对一关系物体的财产所订购的实体清单。
原标题:In hibernate is there a way to retrieve a list of entities ordered by a property of a many-to-one relationship object

我的关系如下:

    <hibernate-mapping default-lazy="false" package="com.my.sample.data">
  <class name="Person" table="person_table">
<!-- other stuff -->
 <many-to-one class="Company" column="p_id" fetch="join" insert="false" name="company" update="false" not-found="ignore" not-null="false" />

公司向公司地图,拥有一家房地产公司。 是否有办法挑选公司下令的个人名单。 因此,我问

  items = (List<A>) getSession().createCriteria(Person.class)                        
                        .add(Restrictions.in("person_id", pIds)
                        ).list();

So I end up with a list of Person ordered by company_id. The only addOrder syntax I found took a property name like

addOrder(Order.asc("person_id").` 

我无法找到如何提及外国物体与类似于外国物体的财产名称。

addOrder.Order.asc("company.company_id")

感谢。

问题回答

引证。 我认为这将有助于这项工作。 标准理论基础。 标准不能暗中加入。 因此,我们明确表示了这一点。

例:

items = (List<A>) getSession().createCriteria(Person.class)                        
                        .add(Restrictions.in("person_id", pIds)
                        .createCriteria("company")
                        .addOrder("company_id");
                        ).list();

希望这对你有益。





相关问题
Multiple Hibernate instances using C3P0

I am facing a weird problem and it seems to be c3p0 related. I am starting two instances of an app in the same java vm which interact with each other. After some operations "APPARENT DEADLOCK" ...

Hibernate vs Ibatis caching

We can speed up a hibernate app easyly with 2nd level cache using infinispan or ehcache/terracotta,... but ibatis only have a simple interface to implement for caching. And hibernate knows more ...

Using annotations to implement a static join in hibernate

I m relatively new to hibernate and was wondering if someone could help me out. While I have no issues implementing a normal join on multiple columns in hibernate using the @JoinColumns tag, I m ...

Hibernate query with fetch question

I have a 2 entities in a One-To-Many relationship: OfficeView.java: public class OfficeView implements java.io.Serializable { private Integer officeId; private String addr1; private ...

hibernate interceptors : afterTransactionCompletion

I wrote a Hibernate interceptor : public class MyInterceptor extends EmptyInterceptor { private boolean isCanal=false; public boolean onSave(Object entity, Serializable arg1, Object[] arg2, String[]...

How to prevent JPA from rolling back transaction?

Methods invoked: 1. Struts Action 2. Service class method (annotated by @Transactional) 3. Xfire webservice call Everything including struts (DelegatingActionProxy) and transactions is configured ...

Hibernate/GORM: collection was not processed by flush()

I have an integration test in my Grails application that fails when I try to save an entity of type Member invitingMember.save(flush: true) This raises the following exception org.hibernate....

Hibernate Criteria API equivalent for "elements()"

Is it possible to implement the following query using Criteria API? select order from ORDER as order,ITEM as item where item.itemID like ITM_01 and item in elements(order.items)

热门标签