• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating a table using hibernate 5

 
Greenhorn
Posts: 4
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

This is my first day learning hibernate and I am trying to create a table using hibernate 5. Iam getting the below error which seems to be because SchemaExport is deprecated in hibernate 5. Is there any other way I can create a table using hibernate 5? I browsed a bit and found that using hibernate.hbm2ddl.auto in hibernate.cfg.xml file can help but don't exactly know how to do it. Really need some help. My code as below.

Error:
Exception in thread "main" java.lang.UnsupportedOperationException: Attempt to use unsupported SchemaExport constructor accepting org.hibernate.cfg.Configuration; one of the forms accepting org.hibernate.boot.spi.MetadataImplementor should be used instead
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:250)
at com.examscam.model.User.main(User.java:33)

hibernate.cfg.xml:



User.java:


Many Thanks,
Varun
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to Javaranch!

As a first advice, I would recommend you to take a look here on how to ask a question! https://coderanch.com/t/660146/Wiki/Questions-Java-Ranch

Now, for your question. Try having a look at this post to see if that helps: http://mrbool.com/how-to-create-database-table-using-hibernate/28269
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Varun B Rao,

First of all, a warm welcome to CodeRanch!

Varun B Rao wrote:This is my first day learning hibernate and I am trying to create a table using hibernate 5. Iam getting the below error which seems to be because SchemaExport is deprecated in hibernate 5. Is there any other way I can create a table using hibernate 5? I browsed a bit and found that using hibernate.hbm2ddl.auto in hibernate.cfg.xml file can help but don't exactly know how to do it. Really need some help. My code as below.


Here you'll find a very concise tutorial to generate database schemas with JPA 2.1. Definitely worth reading as well.

Hope it helps!
Kind regards,
Roel

PS. Always use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information. Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers. Jeanne already added the code tags for you. See how much easier the code is to read?
 
Varun B Rao
Greenhorn
Posts: 4
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joe and Roel,

Thanks alot for the very helpful links they really helped me correct my code. I am finally able to create a table using hibernate.

Thanks again,
Varun
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic