【原创】MySQL+MyEclipse+对象映射文件,schema与category的关系

时间:2023-12-16 20:03:50

(一)

1.映射文件的类如下写法:
class name="com.sanqing.po.SysUser" table="sys_user"  catalog="javaprj_10" schema="Connection_1"

执行的Hibernate语句:
Hibernate:
select
sysuser0_.usr_id as usr1_7_,
sysuser0_.usr_role_id as usr2_7_,
sysuser0_.usr_name as usr3_7_,
sysuser0_.usr_password as usr4_7_,
sysuser0_.usr_flag as usr5_7_
from
javaprj_10.Connection_1.sys_user sysuser0_

2.将上面的映射文件修改如下:
class name="com.sanqing.po.SysUser" table="sys_user"  catalog="Connection_1" schema="javaprj_10"

执行的Hibernate语句:

Hibernate:
select
sysuser0_.usr_id as usr1_7_,
sysuser0_.usr_role_id as usr2_7_,
sysuser0_.usr_name as usr3_7_,
sysuser0_.usr_password as usr4_7_,
sysuser0_.usr_flag as usr5_7_
from
  Connection_1.javaprj_10.sys_user sysuser0_

3.若不写catalog="Connection_1" schema="javaprj_10",Hibernate查询语句:

【原创】MySQL+MyEclipse+对象映射文件,schema与category的关系

(二)数据库如图:

项目连接的名字就是Database Driver的Connection URL即javaprj_10,而非上面的MySQL或者是Connected to MySQL,

更应注意的是,对象映射文件此时就不要catalog="XXX" schema="XXX"了,直接按照上图去写,否则会出现SQLGrammerException。

【原创】MySQL+MyEclipse+对象映射文件,schema与category的关系