MyBatis可以创建数据库模式吗? [英] Can MyBatis create the database schema?

查看:517
本文介绍了MyBatis可以创建数据库模式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MyBatis有什么特性允许像Hibernate一样从类模型中创建SQL模式吗?



我在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屋!

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