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:
- how application automatically create table member in database?
- where schema information?
- why , how 'import.sql' atomically executed once application running?
the answers questions, in order:
- how application automatically create
member
table in database?
executingcreate table
statement. - where schema information?
entities/entity configurations. - why , how
import.sql
automically executed once application running?
how: hibernate automatically try importimport.sql
file root of classpath ifhibernate.hbm2ddl.auto
property setcreate
(files imported can further specified usinghibernate.hbm2ddl.import_files
property).
why: can guess, i'm guessing hibernate team thought might convenient feature?
Comments
Post a Comment