• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

How can Hibernate create Tables in DB without commiting?

 
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How can Hibernate create Tables in DB without commiting ie calling save?
Problem stated is I want to have tables generated without any data in the database and without my calling save etc on Entities when the application gets started. Is there any class in Hibernate that can be used?

Thanks,

Maki Jav
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Maki Jav wrote:How can Hibernate create Tables in DB without commiting ie calling save?
Problem stated is I want to have tables generated without any data in the database and without my calling save etc on Entities when the application gets started. Is there any class in Hibernate that can be used?


I think you are looking for the hibernate.hbm2ddl.auto property. Another option is generating database schemas using JPA 2.1.
 
Maki Jav
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

The link you gave hints at the code:

Persistence.generateSchema("sampleJPALoadScriptSourcePU", null);


I have downloaded jpa 2.1 and then jpa 3.0 but I cannot use that method as I have not find any.

Thanks
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Maki Jav wrote:I have downloaded jpa 2.1 and then jpa 3.0 but I cannot use that method as I have not find any.


So I assume your issue is not resolved yet

Let me first ask another question: why would you want Hibernate to create the tables in the database? Why not manually execute some DDL statements?
 
Maki Jav
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason is because the last software house I worked for, they had a framework that used to do that using Hibernate. I just did something similar ,that is,developed an application using their "QT" to make two entities i.e., User and Role. It was not allowing me to use those names at application run time as it already had those built-in entities. So I used a bit different names like hcmuser and hcmrole and just ran that Tomcat based web application and BINGO!
I had those two table and others were created too. I did not wanted those though.

I have been able to create entities from Entity Diagram saved from their "QT". I compiled them in isolation.

I think that I will look into their code. It is complex anyway.

Thanks,

Maki Jav
 
Maki Jav
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell me what unreal word I used?

Thanks
 
Maki Jav
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mr Roel,


I was able to create tables from those two entities after tweaking that application code. You were right in saying that I should create it using DDL. That application is fetching all entities and creating sqls for the job based on those entities. That is how I am getting those tables.

Thank you for replying to me
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Maki Jav wrote:Can you tell me what unreal word I used?


What's "QT" in your previous post?
 
Maki Jav
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
QT is a Java swing based software of my software house that is used for entity diagrams for a project in addition to other things
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Maki Jav wrote:QT is a Java swing based software of my software house


So it's a proprietary application of the company you work for. It is not available to the general public?
 
Maki Jav
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it is not but you may use some other tools for drawing Entity Diagrams
 
You got style baby! More than this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!