• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

new to hibernate need sample

 
Sundar Murthi
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i am new to hibernate. My PL tolled me we can able to create table using .hbm.xml in any database. with out logging in to the db console.

is it possible through hibernate.

can any one give me the sample.

I need very urgent help on this.
thanks in advance


 
Theodore Casser
Ranch Hand
Posts: 1902
Hibernate Netbeans IDE PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it is true to some extent - you do give Hibernate the information to build objects and tables that correspond to those objects in a good many DB platforms. There's an Ant task it comes with to do that, if you install everything.

If it helps at all, I found "Hibernate: A Developer's Notebook" from O'Reilly to be a good starting point for learning quickly - it's hardly the definative resource, but it's still a good way to get your feet wet quickly.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

is it possible through hibernate.

Yes indirectly. Hibernate itself is just an ORM and provides only really ORM functionality. However tools built on Hibernate can do this - in particular you should look at the SchemaExport/SchemaUpdate tools (check out Hibernate's site for this.
[ September 28, 2004: Message edited by: Paul Sturrock ]
 
Madhu Kumar Vatts
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question:
i am new to hibernate. My PL tolled me we can able to create table using .hbm.xml in any database. with out logging in to the db console.

is it possible through hibernate.

My Answer : Yes You can do that
Download Middlegen Software supplied.

there will be a build.xml file provided with it which has the code used to create tables, and generate lot of java/j2ee stuff. I have used it to connect to sybase table and create hbm.xml files. This can be achieved very easily, you just need to add the following lines in the build.xml file.

<!DOCTYPE project [
<!ENTITY database SYSTEM "file:./config/database/sybase.xml">

what this does is you are pointing to sybase table, the sybase.xml file has the necessary properties for the sybase database..sample sybase.xml file:
<!-- =================================================================== -->
<!-- ant properties/targets for mysql -->
<!-- note: this is not a proper xml file (there is no root element) -->
<!-- it is intended to be imported from a *real* xml file -->
<!-- =================================================================== -->


<property name="database.driver.file" value="${lib.dir}/jconn2.jar"/>
<property name="database.driver.classpath" value="${database.driver.file}"/>
<property name="database.driver" value="com.sybase.jdbc2.jdbc.SybDriver"/>
<property name="database.url" value="jdbc:sybase:Tds:enter your database name here "/>
<property name="database.userid" value="useid"/>
<property name="database.password" value="pwd"/>
<property name="database.schema" value="dbo1"/>
<property name="database.catalog" value="p22"/>

<property name="jboss.datasource.mapping" value="Sybase"/>


Once you have this set up you just need to run the build script which will provide you a GUI from where you can select the proper table and click generate which will generate the hbm.xml files for you in the hibernate directory.
If you still have doubts about let me know.

The following links will help you in downloading the software and how to work with them, If you still have problesm let me know.

http://boss.bekk.no/boss/middlegen/getstarted/index.html
http://www.hibernate.org/98.html
http://www.mjwall.com/node/view/138
http://boss.bekk.no/boss/middlegen/getstarted/

let me tell you this is a terrific tool which saves you a lot of time.
 
Sundar Murthi
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks kumar.
i am created tabels using the ant script in oracle, mysql and sybase with out db console.
 
sajin sachidanandan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what isthis
 
sajin sachidanandan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes it is possible.
for tht you should need a xml file for mapping the table items.
use this link for further details
www.gloegl.de/15.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic