MyBatis可以创建数据库模式吗? [英] Can MyBatis create the database schema?
问题描述
我在Google上寻找这个功能,我只找到了有关MyBatis Generator( http://mybatis.github.io/generator/ )。
这个工具似乎对于从SQL架构中生成Java模型很有用,这正好与我想要的相反。
MyBatis可以创建数据库模式吗?
恐怕不行。为了做到这一点,你需要一个ORM,MyBatis不是一个ORM。
使用ORM解决方案(例如Hibernate)将表映射到实体。实体是(关系)表的(对象)表示,并包含创建该表所需的所有元数据(getter / setter,注释等)。
MyBatis确实不是将实体映射到表,它将方法映射到SQL语句。无法从方法或SQL语句中确定数据库的结构应该是什么。当你使用MyBatis时,表格必须已经存在。
Has MyBatis any feature to allow create the SQL schema from de Class Model like Hibernate does?
I'm looking for that in Google and I only found information about MyBatis Generator (http://mybatis.github.io/generator/). This tool seems to be useful for generate the Java model from the SQL Schema, which is just the opposite I want.
Can MyBatis create the database schema?
I'm afraid not. In order to do that you need an ORM and MyBatis is not an ORM.
With an ORM solution (like Hibernate for example) you map tables to entities. The entity is the (object) representation of the (relational) table and contains all the metadata (getters/setters, annotations etc) necessary to create the table.
MyBatis does not map entities to tables, it maps methods to SQL statements. There is no way to determine from the methods or the SQL statements what the structure of the database should be. When you use MyBatis the tables must already exist.
这篇关于MyBatis可以创建数据库模式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!