jpa - How does Hibernate hbm2ddl automatically create table? -


i reading example of java ee (jboss) application, , learning basics of hibernate in java ee. under src/main/resources/meta-inf/persistence.xml:

      <jta-data-source>java:jboss/datasources/memberds</jta-data-source>       <properties>          <!-- properties hibernate -->          <property name="hibernate.hbm2ddl.auto" value="create" />          <property name="hibernate.show_sql" value="false" />       </properties>    </persistence-unit> 

under src/main/resources/import.sql:

insert member (id, name, email, password, phone_number) values (0, 'john smith', 'john.smith@mailinator.com', 'password', '2125551212') 

under model package, has member class.

my questions:

  1. how application automatically create table member in database?
  2. where schema information?
  3. why , how 'import.sql' atomically executed once application running?

the answers questions, in order:

  1. how application automatically create member table in database?
    executing create table statement.
  2. where schema information?
    entities/entity configurations.
  3. why , how import.sql automically executed once application running?
    how: hibernate automatically try import import.sql file root of classpath if hibernate.hbm2ddl.auto property set create (files imported can further specified using hibernate.hbm2ddl.import_files property).
    why: can guess, i'm guessing hibernate team thought might convenient feature?

Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -