简体   繁体   English

在 Java Play Framework (2.5.x) 中操作新创建的 MySQL DB 的正确方法是什么?

[英]What is the right way to operate on a newly created MySQL DB within Java Play Framework (2.5.x)?

I have already created the DB which has no tables so far & have successfully connected it with Play.我已经创建了迄今为止没有表的数据库并已成功将其与 Play 连接。 But what is the right way to create the tables from within Play?但是在 Play 中创建表格的正确方法是什么? I was going to proceed with Evolutions script but their documentation mentions that evolutions is to be used while updating the DB.我打算继续使用 Evolutions 脚本,但他们的文档提到在更新数据库时要使用进化。

In Django I have seen people defining their tables in a models file. 在 Django 中,我看到人们在模型文件中定义他们的表。 Is there any similar mechanism in Play. Play中有没有类似的机制。 If so, how? 如果是这样,如何?

Does JPA have anything to do with all this? JPA 与这一切有关系吗? Again, I have read their documentation on this. 同样,我已经阅读了他们关于此的文档。 It explains it in connection with Hibernate. 它解释了它与 Hibernate 的关联。 Is an ORM layer absolutely necessary? ORM 层是绝对必要的吗? Help me out here! 帮帮我!

So a user answered this question and then removed it.所以一个用户回答了这个问题,然后将其删除。 Nevertheless he suggested to use Ebean which manages the database through evolutions.尽管如此,他还是建议使用 Ebean,它通过进化来管理数据库。

The github link posted was: https://github.com/playframework/play-ebean-example 发布的 github 链接是: https : //github.com/playframework/play-ebean-example

It cleared up a few things and if someone faces the same problem, I hope this helps. 它解决了一些问题,如果有人遇到同样的问题,我希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM