Not able to access field through hibernate on oracle database on different userspace with only select privileges

随声附和 提交于 2020-01-06 08:44:09

问题


I am trying to get use Hibernate for access data from different userspace(where i just have select privileges).I have complete application running with tables in my userspace(so configurations are correct).When i try to get record from different userspace,i am able to see the size of list.However not able to access that collection.

Also when hibernate configuration start, i can see it trying to alter and update, which i would like to stop.Its oracle db .I would like to know where i am doing Wrong because of which i am just getting size but not actual data.

Jul 29, 2011 4:39:01 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata
INFO: table not found: INVENTORY.SWITCHDATA
SEVERE: Unsuccessful: create table INVENTORY.SWITCHDATA (SWITCH_ID number(19,0) not
 null, NAME varchar2(255), NPORTS number(10,0), NUSED number(10,0),     
VENDOR varchar2(255), STYPE varchar2(255), NET varchar2(255), primary key 
(SWITCH_ID))

Jul 29, 2011 4:39:01 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute

SEVERE: ORA-0: insufficient privileges

Jul 29, 2011 5:06:31 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute

INFO: schema update complete

Hibernate: select this_.SWITCHTYPE as y0_, this_.SWITCHTYPE as y1_ from 
INVENTORY.SWITCHDATA this_ group by this_.SType

100

do i have to inform about usersspace inventory in some other way then name my table with 'inventory.tablename' or i have to inform about privileges to hibernate somehow.


回答1:


The ORA-0: insufficient privileges error it's because when hibernate start he try to create and update the database table related to the mapping(hbm files). It's an oracle database error and you should ask DBA to grant the alter create, drop etc.. privileges to the user hibernate is using in the configuration file.

If you dont want hibernate to automatically update the database schema you can check that the properties Hibernate.hbm2ddl.auto is set to validate in the hibernate configuration file. The possible values for this property are: validate | update | create | create-drop. Maybe it is set to update in your config file. By disabling the autogeneration of the table schema it will be your responsability to create the table, index, constraint etc..

You can inform hibernate of the schema name to use in the hibernate configuration file with the property hibernate.default_schema and in the hbm.xml file in the <Hibernate-mapping ... element

Reference documentation

Hibernate.hbm2ddl.auto or Hibernate configuration
The hbm2ddl.auto option turns on automatic generation of database schemas directly into the database. This can also be turned off by removing the configuration option, or redirected to a file with the help of the SchemaExport Ant task.

hibernate.default_schema
Qualify unqualified table names with the given schema/tablespace in generated SQL. e.g.SCHEMA_NAME

5.1.2. Hibernate-mapping
This element has several optional attributes. The schema and catalog attributes specify that tables referred to in this mapping belong to the named schema and/or catalog. If they are specified, tablenames will be qualified by the given schema and catalog names. If they are missing, tablenames will be unqualified.



来源:https://stackoverflow.com/questions/6880215/not-able-to-access-field-through-hibernate-on-oracle-database-on-different-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!