首页 \ 问答 \ 学说查询不同的相关实体(Doctrine query distinct related entity)

学说查询不同的相关实体(Doctrine query distinct related entity)

我可能忽略了一些非常简单的东西,只是盯着它太多,但我无法让这个DQL查询工作。 我收到一个异常,指出:

Cannot select entity through identification variables without choosing at least one root entity alias.

这是我的查询。 用户与Group有多对一的关系。 请注意,这是一种单向关系! 这对你来说可能没有意义,但在我们的领域逻辑中它是有意义的。

SELECT DISTINCT g
FROM Entity\User u
LEFT JOIN u.group g
WHERE u.active = :active

你能告诉我我在这里错过了什么吗?


I'm probably overlooking something very simple and just been staring at it too much, but I can't get this DQL query to work. I get an exception stating:

Cannot select entity through identification variables without choosing at least one root entity alias.

Here's my query. User has a many-to-one relation to Group. Note that this is a unidirectional relation! That may make no sense to you, but it makes sense in our domain logic.

SELECT DISTINCT g
FROM Entity\User u
LEFT JOIN u.group g
WHERE u.active = :active

Can you tell me what I am missing here?


原文:https://stackoverflow.com/questions/10204700
更新时间:2024-01-11 12:01

最满意答案

在哪里实例化QPen并不重要。

QPen的默认宽度为0.这是一个特殊的值,这意味着化妆品是真实的,宽度实际上是1.所以,如果你不想让笔化妆,你必须将其设置为所需的宽度。 您可能还需要将化妆品设置为假。

这是一个简单的例子:

#include <QtGui>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QGraphicsView view;
    QGraphicsScene scene;

    QGraphicsRectItem *item1 = scene.addRect(20, 20, 20, 20);
    QGraphicsRectItem *item2 = scene.addRect(50, 20, 20, 20);

    QPen pen1, pen2;
    pen1.setWidth(5);
    pen2.setWidth(5);
    pen1.setCosmetic(true);
    pen2.setCosmetic(false);

    item1->setPen(pen1);
    item2->setPen(pen2);

    view.setScene(&scene);
    view.scale(4, 4); // both rects are the same size, but one a has wider pen
    view.show();

    return a.exec();
}

It doesn't really matter where you instantiate the QPen.

QPen has a default width of 0. This is a special value that means cosmetic is true and the width is actually 1. So if you don't want the pen to be cosmetic you have to set it to the desired width. You might also need to set cosmetic to false.

Here is a simple example:

#include <QtGui>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QGraphicsView view;
    QGraphicsScene scene;

    QGraphicsRectItem *item1 = scene.addRect(20, 20, 20, 20);
    QGraphicsRectItem *item2 = scene.addRect(50, 20, 20, 20);

    QPen pen1, pen2;
    pen1.setWidth(5);
    pen2.setWidth(5);
    pen1.setCosmetic(true);
    pen2.setCosmetic(false);

    item1->setPen(pen1);
    item2->setPen(pen2);

    view.setScene(&scene);
    view.scale(4, 4); // both rects are the same size, but one a has wider pen
    view.show();

    return a.exec();
}

相关问答

更多
  • 在哪里实例化QPen并不重要。 QPen的默认宽度为0.这是一个特殊的值,这意味着化妆品是真实的,宽度实际上是1.所以,如果你不想让笔化妆,你必须将其设置为所需的宽度。 您可能还需要将化妆品设置为假。 这是一个简单的例子: #include int main(int argc, char *argv[]) { QApplication a(argc, argv); QGraphicsView view; QGraphicsScene scene; QGr ...
  • 如果我正确理解您的问题,您需要的基本步骤是: 将Qt的原点概念转换为您想要缩放的位置,即左上角 然后应用比例 然后再翻译一下 If I understand your question correctly, the basic steps you'll need are: Translate Qt's idea of the origin to where you want to scale around, i.e. top-left Then apply the scale Then translate ...
  • 我用它做了 void mousePressEvent(QGraphicsSceneMouseEvent *event) { myPath = new QGraphicsPathItem(); previous = event->scenePos(); QPainterPath p; p.moveTo(previous); myPath->setPath(p); this->addItem(myPath); } void ::mouseMoveEvent(QGraphicsSceneMouseEvent ...
  • 你需要sceneRect不只是width和height 。 对于调整大小的缩放,您希望将插槽连接到sceneRectChanged以便在场景更改大小时调整图像大小。 或者你可以派生一个QGraphicsView并使用重写的updateSceneRect来更改图像大小,或者更好的是,只需重写drawBackground 。 You want sceneRect not just width and height. For the scaling on resize you want to connect a ...
  • if ( !m_click ) { QGraphicsView::mousePressEvent(e); } 只需调用父类的实现即可使用“正常”行为。 if ( !m_click ) { QGraphicsView::mousePressEvent(e); } Just call the parent class' implementation to use the 'normal' behaviour.
  • 我必须在zoomout函数之前实现全局变量的初始化,如果在进入mouseMoveEvent时初始化了这个变量,那么我将直接退出该函数。 I had to implement the initialization of a global variable before the zoomout function, and if this variable was initialized when entering the mouseMoveEvent, then I would directly exit th ...
  • 在showEvent中处理视图也适合: void TestApp::showEvent ( QShowEvent * event ) { view->fitInView(0, 0, scene->width(), scene->height()); QWidget::showEvent(event); } Handle the view fit also inside the showEvent: void TestApp::showEvent ( QShowEvent * event ) ...
  • 如果你看看QColor :: setNamedColor() ,它说: Sets the RGB value of this QColor to name, which may be in one of these formats: ... A name from the list of colors defined in the list of SVG color keyword names provided by the World Wide Web Consortium; for example, " ...
  • 根据文档 ,问题是因为你没有将sceneRect设置为QGraphicsScene : sceneRect:QRectF 此属性保存场景矩形; 场景的边界矩形 场景矩形定义场景的范围。 它主要由QGraphicsView用于确定视图的默认可滚动区域,以及由QGraphicsScene来管理项目索引。 如果未设置,或者设置为空QRectF,那么sceneRect()将返回场景创建后场景中所有项目的最大边界矩形(即,在项目添加到场景中或在场景中移动时增长的矩形,但永不畏缩)。 所以每次添加一条新线时,如果它大于 ...
  • 您可以创建继承自QGraphicsView的自定义类。 您应该在自定义QGraphicsView中重新实现resizeEvent(QResizeEvent * event),如: void MyView::resizeEvent(QResizeEvent *event) { fitInView(0, 0, 500, 500,Qt::KeepAspectRatio); QGraphicsView::resizeEvent(event); } 这样,视图将始终显示整个场景。 即,如果更改窗 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)