是否有任何 Scala ORM 实现从 SQL 生成代码 ->斯卡拉?
我使用 Squeryl 作为 MySQL 的 ORM。这是一个使用包含数百个表的现有模式的新项目。
据我所知,Squeryl 和任何可用的 Scala ORM 都无法从 R(mysql 表)生成 O(Scala 类)。我认为通过爬行信息模式来滚动我自己的工作不会太难,但如果其他人已经这样做了,我宁愿不重复这项工作。
我也很好奇是否有人能告诉我为什么 R->O 方向经常被忽视。根据我的经验,O->R 是例外,而不是规则。
我可能会开始推出自己的解决方案。如果在我听到另一个选项之前这已经接近完成,我将发布该代码的链接。
谢谢。
I am using Squeryl as an ORM with MySQL. This is a new project working with existing schemas that contain several hundred tables.
As far as I can tell, neither Squeryl nor any of the available Scala ORMs can generate the O (Scala classes) from the R (mysql tables). I suppose it wouldn't be too hard to roll my own by crawling the information schema, but I'd rather not duplicate that effort if someone else has already done so.
I'm also curious if anyone can tell me why the R->O direction is so often neglected. In my experience, O->R is the exception and not the rule.
I'll probably start down the path of rolling my own solution. If that's anywhere near complete before I hear of another option, I'll post a link to that code.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
QueryDSL 为您提供了一个实用程序,可以从现有表生成代码。然而,您需要接受它主要是一个 Java 库,而 Scala 仅被视为那里的扩展。
我想对RO的支持只是时间和用户反馈的问题。
QueryDSL provides you with a utility, that can generate code from existing tables. You would however need to accept, that it's primarily a Java lib, and Scala is treated only as an extension there.
I guess the support for R-O is just a matter of time and users' feedback.
有 Squealer 查询数据库表并生成 scala 代码。它使用 Squeryl 和其他库。
我设法通过最小的调整来使用它。
它的 gitub 位于这里
There is Squealer which does query database tables and generate scala code. It uses Squeryl and other libraries.
I managed to use it with minimal tweaking.
Its gitub is here
我很好奇您正在从事什么类型的项目,您发现 R->O 是规则。根据我的经验,我不仅包括我自己的项目,还包括其他 Squeryl 用户在邮件列表中提到的项目,大多数 Squeryl 项目主要是新应用程序,其中使用 SQL 数据库来保存应用程序特定的模型,而不是使用 SQL 数据库来保存应用程序特定的模型。为匹配现有模式而创建的模型。与大多数操作系统项目一样,开发人员往往首先关注他们自己需要的功能,然后关注社区最需要的功能,因此我鼓励您在 Squeryl Google 群组。
I'm curious what type of projects you are working on where you've found R->O to be the rule. My experience, and I'm including not just my own projects but those that other Squeryl users have mentioned on the mailing list, is that most Squeryl projects are predominantly new applications where an SQL database is being used to persist an application specific model rather than a model being created to match an existing schema. Like most OS projects the developers tend to focus first on features that they themselves need and second on features that are most requested by the community so I would encourage you to take this up at the Squeryl Google Group as well.