These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Schema Export - Oracle Errors, with hibernate3, possible bug
PostPosted: Sun Feb 06, 2005 11:41 pm 
Beginner
Beginner

Joined: Thu Feb 03, 2005 7:23 pm
Posts: 23
Hello,

I am using hibernate3, eclipse 3.1M4 and hibernate tools, and oracle 10g.
After creating a persistent class, and the mapping document, I create a console configuration, and then create session factory.

I can see my class, and data members in the mapped entities.

At this point when I click run schema export I get the following errors:

First: java.sql.SQLException: ORA-00942: table or view does not exist
Second: java.sql.SQLException: ORA-02261: such unique or primary key already exists in the table

Well, if the table does not exist how can we get the second error?
Also, in my hibernate.cfg.xml I have
<property name="hibernate.show_sql">true</property>
Where is that we see the sql? (I am using eclipse)

Below are exception stack traces.

Greetings,

java.sql.SQLException: ORA-00942: table or view does not exist


at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)

at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)

at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:112)

at oracle.jdbc.driver.T4CStatement.execute_for_rows(T4CStatement.java:474)

at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1028)

at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1451)

at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:138)

at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:86)

at org.hibernate.eclipse.console.views.SchemaExportAction$1.execute(SchemaExportAction.java:59)

at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:76)

at org.hibernate.eclipse.console.views.SchemaExportAction.doRun(SchemaExportAction.java:48)

at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:47)

at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:167)

at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:555)

at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:505)

at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:419)

at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)

at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833)

at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2803)

at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2448)

at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1569)

at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1540)

at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:285)

at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144)

at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:102)

at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:220)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at org.eclipse.core.launcher.Main.basicRun(Main.java:185)

at org.eclipse.core.launcher.Main.run(Main.java:710)

at org.eclipse.core.launcher.Main.main(Main.java:694)


-----


java.sql.SQLException: ORA-02261: such unique or primary key already exists in the table


at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)

at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)

at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:112)

at oracle.jdbc.driver.T4CStatement.execute_for_rows(T4CStatement.java:474)

at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1028)

at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1451)

at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:156)

at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:86)

at org.hibernate.eclipse.console.views.SchemaExportAction$1.execute(SchemaExportAction.java:59)

at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:76)

at org.hibernate.eclipse.console.views.SchemaExportAction.doRun(SchemaExportAction.java:48)

at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:47)

at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:167)

at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:555)

at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:505)

at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:419)

at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)

at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833)

at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2803)

at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2448)

at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1569)

at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1540)

at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:285)

at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144)

at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:102)

at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:220)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at org.eclipse.core.launcher.Main.basicRun(Main.java:185)

at org.eclipse.core.launcher.Main.run(Main.java:710)

at org.eclipse.core.launcher.Main.main(Main.java:694)


Top
 Profile  
 
 Post subject: Problme with Hibernate and Oracle in Weblogic
PostPosted: Mon Mar 20, 2006 7:40 am 
Newbie

Joined: Mon Mar 20, 2006 7:26 am
Posts: 1
HI ,
As i was going thru the Hibernate forum for an issue that im facing with in my environment, i fortunetly came across the issue that u have faced and posted some days back...

Did u find any soultion for the problmes that u have faced...
Could you pls help me out solving the issue by sharing ur knowledge.
Thanks in advance...and here are the exceptions...

----------------------------------------------------------------------------------
java.sql.SQLException: ORA-00942: table or view does not exist

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:420)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:894)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:452)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:984)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2885)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:2926)
at weblogic.jdbc.wrapper.PreparedStatement.executeQuery(PreparedStatement.java:124)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
------------------------------------------------------------------------------------


Top
 Profile  
 
 Post subject: Table or view does not exist
PostPosted: Wed Jul 23, 2008 11:11 am 
Newbie

Joined: Tue Jun 24, 2008 12:17 pm
Posts: 6
This is a rather old posting, however, I seem to face the same issues today. Perhaps my post can help others who are in my situation:

The reason you are getting this exception (table does not exist) is because it does not.

When SchemaExport exports the schema it also creates it in the database (default behavior).

The generated schema is generic and allows you to use it (run it as an sql script) over and over, even after the tables were created and populated with dat.

Hence, the first SQL statements in the schema would be the drop statements:
drop TABLE MY_TABLE;
create TABLE MY_RABLE(....);

That is the SchemaExport behavior by default.
There is a way to turn the drop off - please read the SchemaExport API.

If you use an ant task for schema exportation, you can set the drop attribute to false. Don't forget to set the export attribute to true though (drop means create a script for only dropping db items).

About the such unique or primary key already exists in the table error - I am battling this one too. However, I hope my posting was of some help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 3:38 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Image

Quote:
The SchemaExport Create Method

You will notice that the create method of the SchemaExport object takes two boolean parameters. The first boolean value indicates whether or not you want the generated database creation script to be printed out to the log file. The second parameter indicates whether you want the generated script to be executed against the underlying database. Passing two true values to the create method will cause the database generation scripts to be printed out to the log files, while also triggering the execution of the database creation scripts, which would mean dropping the existing tables in the database, and subsequently recreating them.

public void create(boolean script, boolean export)

Run the schema creation script.

Parameters:

script - print the DDL to the console

export - export the script to the database

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.