多对一选择语句?

发布于 2024-10-01 07:53:54 字数 241 浏览 0 评论 0原文

如何在JPA中

以多对一的方式选择多对一的关系如何做select语句示例

学生-班级
学生是多对一班级
班级是班级中的一对多学生

,我可以选择

select c from Class c where c.studentid = :studentid

学生中是否有班级实例?

我如何对 Student 执行相同的选择语句?

How to select with relationship is many to one in JPA

in Many to One How to do select statement example

Student - Class
student is many to one class
class is one to many student

in class i can select

select c from Class c where c.studentid = :studentid

if if in student it have instance of Class?

how i do the same select statement about with Student ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

物价感观 2024-10-08 07:53:54

不知道你在问什么,但是怎么样?

Select s from Student s where s.class.id = :classId

Not sure what you are asking, but how about?

Select s from Student s where s.class.id = :classId
忆悲凉 2024-10-08 07:53:54

从您编写示例查询的方式来看,班级对于学生来说是多对一的。

假设您提到的关系,查询将为

班级学生(根据限制放置在哪里)

  select c.students from class c

The way you have written the sample query, it looks that class is many to one to student.

Assuming the relationship that you have mentioned, the queries will be

For students of the class (where to be put at per the restriction)

  select c.students from class c
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文