Hibernate连接设计

发布于 2025-01-08 03:46:42 字数 267 浏览 0 评论 0原文

我有以下实体,每个实体映射到数据库中的一个表

: 商业 客户

活动实体拥有该活动所针对的业务。 客户实体拥有其所属的业务。我通过搜索与活动具有相同business_id 的所有客户来获取活动的客户(猜测此设计可以改进)。

我需要找到自上次运行活动以来进入系统的所有活动客户,并将活动发送给他们。对此最好的设计是什么?

我认为我需要创建一个名为 CampaignClient (特定活动的客户端)的新实体,但我不知道如何使用 Hibernate 来实现它。

I have the following entities, each mapped to a table in the DB:

Campaign
Business
Client

Campaign entity holds the business that the campaign was opened for.
Client entity holds the business it belongs to. I get the campaign's clients by searching for all the clients who have the same business_id as the campaign (guess this design could be improved).

I need to find all campaign clients that were entered into the system since the last time the campaign was run and send the campaign to them as well. What would be the best design for this?

I think I need to create a new entity called CampaignClient (client of a specific campaign) but I don't know how to implement this with Hibernate.

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

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

发布评论

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

评论(1

随风而去 2025-01-15 03:46:42
select client from campaign campaign
inner join campaign.business business
inner join business.clients client
where client.creationDate > campaign.lastRunDate

或者,如果您没有企业与客户之间的关联(但您应该有一个):

select client from campaign campaign
inner join campaign.business business
where client.business.id = business.id 
and client.creationDate > campaign.lastRunDate
select client from campaign campaign
inner join campaign.business business
inner join business.clients client
where client.creationDate > campaign.lastRunDate

Or, if you don't have an association from business to clients (but you should have one):

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