• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Entities and JPA

 
Jim Petersson
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Do I need to manually create the tables in my database (corresponding to my entities)? I thought they would be created automatically, but when trying to persist one of my entities I get this:

"Table 'mydatabase.myentity' doesn't exist"

Thanks, Jim
 
Scott Selikoff
author
Saloon Keeper
Posts: 4031
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find its better to, although there is support to create the tables, assuming you have this feature turned on (probably in a server xml file). Either way this sounds like an issue for the object relational mapping forum...
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can configure your hibernate.cfg.xml file to create the database when the configuration object is configured, or you can just run the following code snippet to have you database tables created for you:



It's the SchemaExport class that's doing all the heavy lifting here.



-Cameron McKenzie
 
Ramesh Srinivasan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Cameron Wallace McKenzie:
You can configure your hibernate.cfg.xml file to create the database when the configuration object is configured, or you can just run the following code snippet to have you database tables created for you:



It's the SchemaExport class that's doing all the heavy lifting here.



-Cameron McKenzie


Hi McKenzie,

I have one small doubt here, Are you talking about "BOTTOM APPROACH" of creating database at the time of creating my Hibernate Session Factory?

Please clarify me, If I am wrong.

Ramesh
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using a SchemaExport create would be considered a top down creation of database tables.

You do indeed need to have those database tables!

-Cameron McKenzie
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic