Giter Club home page Giter Club logo

Comments (15)

zozoh avatar zozoh commented on August 19, 2024

这个需求是不是说的是 http://code.google.com/p/nutz/issues/detail?id=285 ?

from nutz.

gevinhjy avatar gevinhjy commented on August 19, 2024

不是同一个需求,我的需求是这样的:
有这些数据:
DepartmentInfo表:
departmentInfoId departmentName
1 IT部
2 人力资源
3 财务部
4 市场部

UserInfo表:
userInfoId trueName departmentInfoId
1 Gevin 1
2 Wendal 1
3 小宝 2
4 灰太狼 3
5 E-Hunter 3
6 k-wait 4

我目前是用这个查询出下面列表,只能用departmentInfoId排序:
List uiList = this.userInfoService.query(Cnd.orderBy().asc("departmentInfoId"), null);
序号 部门 姓名
1 IT部 Gevin
2 IT部 Wendal
3 人力资源 小宝
4 财务部 灰太狼
5 财务部 E-Hunter
6 市场部 k-wait

而我想用departmentInfo.departmentName来排序,则无法实现。即用部门名称拼音排序。
List uiList = this.userInfoService.query(Cnd.orderBy().asc("departmentInfo.departmentName"), null);

from nutz.

gevinhjy avatar gevinhjy commented on August 19, 2024

之所以有这个需求,是我经常会碰到这种客户需求,部门是有固定的排序的,列出来的人员也是要求按部门的顺序显示。
比如DepartmentInfo表中加多一个字段departmentIndex,要求按departmentInfo.departmentIndex来排序。

from nutz.

zozoh avatar zozoh commented on August 19, 2024

你可以这么定义你的 UserInfo 对象

@Table("t_userinfo")
@View("(SELECT * FROM t_userinfo, t_dep WHERE t_userinfo.departmentInfoId = t_dept.id)")
public class UserInfo {

     @Column("departmentName")
     @Readonly
     private String departmentName;

    ...

from nutz.

gevinhjy avatar gevinhjy commented on August 19, 2024

嗯,我知道用视图是可以解决我那个需求,我之前也是那样子实现。

只是想了解有没有打算以后支持这种用法,因为假如出现三四个表进行关联的话,用视图维护起来比较麻烦。
如在基本表里面增加一个字段,那涉及到的视图都得同时更新,若使用对象关联,则只需要在基本表的Model类新增该属性,不需要更改到其它Model类。

from nutz.

zozoh avatar zozoh commented on August 19, 2024

是不是要实现这个功能,取决于这个功能被呼吁的有多强烈
就像这次 Dao 的重构(1.b.38), 因为 batchInsert 被不止一个人不止一次的提及,所以我们不得不重构
这个 Issue 将先观察一段时间,看看有没有更多的 comments

from nutz.

gevinhjy avatar gevinhjy commented on August 19, 2024

嗯,好的!

from nutz.

gevinhjy avatar gevinhjy commented on August 19, 2024

继续观察一下有没有人也有类似的需求。

from nutz.

zozoh avatar zozoh commented on August 19, 2024

围观,呵呵

from nutz.

hujun82589167 avatar hujun82589167 commented on August 19, 2024

强烈需要fetchLinks支持能指定条件和Pager

from nutz.

zozoh avatar zozoh commented on August 19, 2024

这个 Issue 与 #56 差不多

from nutz.

liuyxit avatar liuyxit commented on August 19, 2024

现在才开始在项目中大量使用视图,未知情况如何,如果可以关联查询并排序,我想也是好事吧。

from nutz.

enzozhong avatar enzozhong commented on August 19, 2024

如果不是关联查询,那么单对一个表进行查询有没有方法根据指定的字段进行排序呢?

from nutz.

wendal avatar wendal commented on August 19, 2024

Cnd.where(...).asc(XXX)

from nutz.

wendal avatar wendal commented on August 19, 2024

fix in 50c636d

from nutz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.