Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating a table using hibernate 5

 
Varun B Rao
Greenhorn
Posts: 4
1
  • Mark post as helpful
  • send pies
  • 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
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • 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! http://www.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
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic