加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Oracle 同一SID下不同用户同名表名问题

发布时间:2020-12-12 15:48:13 所属栏目:百科 来源:网络整理
导读:From:http://xmkevinchen.iteye.com/blog/196372 一般来说hibernate配置数据库连接只需要下面几行配置 ##Oracle 9i/10g hibernate.dialect org.hibernate.dialect.Oracle9Dialect hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver hibern

From:http://xmkevinchen.iteye.com/blog/196372


一般来说hibernate配置数据库连接只需要下面几行配置

##Oracle 9i/10g  
hibernate.dialect org.hibernate.dialect.Oracle9Dialect  
hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver  
hibernate.connection.username xxxx  
hibernate.connection.password xxxx  
hibernate.connection.url jdbc:oracle:thin:@127.0.0.1:1521:SID  
Oracle是允许不同用户在同一个SID中创建同名的表的,但是如果按照上面的配置
Hibernate的SchemaUpdate操作是不会认帐的
SchemaUpdate指的hibernate配置成

hibernate.hbm2ddl.auto update
例如:
假设,有模型Entity,已用A用户运行过配置有hibernate的系统或者程序,则,此时数据库中有A.Entity表存在了。将hibernate配置用户改为B,然后运行系统或者程序。将会发现hibernate不会为我们创建B.Entity表。
如果Entity模型在以A用户运行过后经过修改,同时会发现hibernate既不会创建B.Entity表,也不会更改A.Entity表的结构

如果想让hibernate执行上述描述的特殊操作方式需要在hibernate的配置上指明用户的Schema名,即在hibernate配置添加上

hibernate.default_schema xxxx  
做个说明,Oracle中表的完整定位为username.tablename,而添加这个hibernate.default_schema的配置就是使hibernate在查找表的时候加上这个username的前缀

oracle中Schema含义解释参考:Oracle中User与Schema的简单理解

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读