Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy isn't hibernate creating my tables from hbm.xmls?
    primarykey
    data
    text
    <p>I have several .hbm.xml mapping files set up in Spring, and I can tell from the logs that Spring sees them and does something with them, but no tables are created in the DB.</p> <p><strong>Bean setup:</strong></p> <pre><code> &lt;beans:bean id="dataSourceEmbedded" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt; &lt;beans:property name="driverClassName" value="org.h2.Driver" /&gt; &lt;beans:property name="url" value="jdbc:h2:~/myDbName" /&gt; &lt;beans:property name="username" value="sa" /&gt; &lt;beans:property name="password" value="" /&gt; &lt;/beans:bean&gt; &lt;beans:bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" p:dataSource-ref="dataSourceEmbedded"&gt; &lt;beans:property name="mappingLocations"&gt; &lt;beans:list&gt; &lt;beans:value&gt;classpath:path/to/schemas/Page.hbm.xml&lt;/beans:value&gt; &lt;beans:value&gt;classpath:path/to/schemas/Navigation.hbm.xml&lt;/beans:value&gt; &lt;/beans:list&gt; &lt;/beans:property&gt; &lt;beans:property name="hibernateProperties"&gt; &lt;beans:value&gt; hibernate.show_sql=true hibernate.dialect=${hibernate.dialect} hibernate.hbmToDdlAuto=create &lt;/beans:value&gt; &lt;/beans:property&gt; &lt;/beans:bean&gt; </code></pre> <p>I know that the path to the Page and Navigation mapping files is correct - an error is thrown if it's not, and I can see the fields being mapped during the tomcat startup: </p> <pre><code>DEBUG: org.hibernate.cfg.Configuration - Processing hbm.xml files INFO : org.hibernate.cfg.HbmBinder - Mapping class: Page -&gt; pages DEBUG: org.hibernate.cfg.HbmBinder - Mapped property: Page ID -&gt; pageid DEBUG: org.hibernate.cfg.HbmBinder - Mapped property: title -&gt; title </code></pre> <p>Similarly, the database is clearly accessed / locked while tomcat is loading, so <em>something</em> is happening in there! But once it's loaded and I try to query it or inspect it, no tables exist.</p> <p><strong>Question:</strong> Why aren't my tables being created / what have I done wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload