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.  [ 2 posts ] 
Author Message
 Post subject: Qeruy over exised database
PostPosted: Sun Apr 22, 2007 10:33 am 
Newbie

Joined: Sun Apr 22, 2007 10:26 am
Posts: 1
Hi, everybody:
I'm quite new to hibernate. Now i just want to use Hibernate as a query tool over the existed database. (in MYSQL)

I also donn't need anything from the database's table, only a few column is needed.

I defined the necessary mapping file and the hibernate configuration file. But when i execute:
session.createQuery("from PortBean").list();
not only nothing return, but also my existed table is erased with all its datas. It looks like a new table is created with only those columns mapping defined. And also, no data in that table.

Can anyone show some light for me? I thought this much be a basic question, but i just donn't know how to solve. In which case, the hibernate will erase all the data and create a new table?

In addition: i notice the hibernate output, after i change the table to a view(portview):
ERROR SchemaExport:274 - Unsuccessful: create table portview .
ERROR SchemaExport:275 - Table 'portview' already exists

it looks like hibernate try to create the table first before query.

cheers,
Warren


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 12:27 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,
Just verify the value for property "hbm2ddl.auto". ( hibernate.cfg.xml )

Looks like, in your case, it has the value "create".

You can comment out that option. ( or not set that if you are doing it programatically )

http://www.hibernate.org/hib_docs/v3/re ... n-optional

----------------------------------------------------------------------
Rate the reply if you find it helpful


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.