| Author |
new to hibernate need sample
|
Sundar Murthi
Ranch Hand
Joined: Mar 05, 2004
Posts: 209
|
|
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
Joined: Mar 14, 2001
Posts: 1902
|
|
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.
|
Theodore Jonathan Casser
SCJP/SCSNI/SCBCD/SCWCD/SCDJWS/SCMAD/SCEA/MCTS/MCPD... and so many more letters than you can shake a stick at!
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
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 ]
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Madhu Kumar Vatts
Ranch Hand
Joined: Apr 01, 2004
Posts: 67
|
|
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.
|
Oracle Certified Enterprise Architect (Part 1)
SUN Certified Programmer,
SUN Certified Business Component Developer
SUN Certified Web Component Developer
Oracle Certified WebServices Developer
Oracle Certified Java Persistence API Developer
Oracle Certified SQL Expert
IBM Certified XML Solution Developer
|
 |
Sundar Murthi
Ranch Hand
Joined: Mar 05, 2004
Posts: 209
|
|
thanks kumar. i am created tabels using the ant script in oracle, mysql and sybase with out db console.
|
 |
sajin sachidanandan
Greenhorn
Joined: Sep 28, 2004
Posts: 11
|
|
|
what isthis
|
 |
sajin sachidanandan
Greenhorn
Joined: Sep 28, 2004
Posts: 11
|
|
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
|
 |
 |
|
|
subject: new to hibernate need sample
|
|
|