ORMLite:如何在没有外键的情况下连接两个表 [英] ORMLite: How to join two tables without foreign key

查看:182
本文介绍了ORMLite:如何在没有外键的情况下连接两个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在 sqlite 中加入两个独立的表.它们没有任何外键关系.

I have to join two independent tables in sqlite. They don't have any foreign key relationship.

示例:

  • 表A有一个字段name
  • 表 B 有一个字段 primaryName

我想做类似的事情

select A.* from A inner join B on A.name = B.primaryName
    where A.id = 10 and B.address is null

ORMLite 强制外键,有没有办法在 ORMLite 中做到这一点?

ORMLite enforces foreign key, is there a way to do this in ORMLite?

推荐答案

不幸的是,简短的回答是目前没有".您当然可以使用原始查询功能来支持这一点:

Unfortunately the short answer is "not at this time". You can certainly use the raw query functionality to support this:

http://ormlite.com/docs/raw-queries

这已经 [finally] 添加了 ORMLite.它已被签入主干并将在 4.49 版中.这是github上的签到:

This has [finally] been added ORMLite. It has been checked into trunk and will be in version 4.49. Here's the check-in on github:

https://github.com/j256/ormlite-core/commit/b3710bc70d473be1cf1b6de19b847f5"/a>

https://github.com/j256/ormlite-core/commit/b37914d76fbbbbbc70d473be1cf1b6de19b847f5

这篇关于ORMLite:如何在没有外键的情况下连接两个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆