com.j256.ormlite.spring
Class TableCreator

java.lang.Object
  extended by com.j256.ormlite.spring.TableCreator

public class TableCreator
extends Object

Spring bean that auto-creates any tables that it finds DAOs for if the property name in TableCreator.AUTO_CREATE_TABLES property has been set to true. It will also auto-drop any tables that were auto-created if the property name in TableCreator.AUTO_DROP_TABLES property has been set to true.

NOTE: If you are using the Spring type wiring in Java, initialize() should be called after all of the set methods. In Spring XML, init-method="initialize" should be used.

Here is an example of spring wiring.

 <!-- our database type factory-bean -->
 <bean id="tableCreator" class="com.j256.ormlite.spring.TableCreator" init-method="initialize">
        <property name="connectionSource" ref="connectionSource" />
        <property name="configuredDaos">
                <list>
                        <ref bean="accountDao" />
                        <ref bean="orderDao" />
                </list>
        </property>
 </bean>
 

Author:
graywatson

Field Summary
static String AUTO_CREATE_TABLES
           
static String AUTO_DROP_TABLES
           
 
Constructor Summary
TableCreator()
           
TableCreator(com.j256.ormlite.support.ConnectionSource connectionSource, List<com.j256.ormlite.dao.Dao<?,?>> configuredDaos)
           
 
Method Summary
 void destroy()
           
 void initialize()
          If you are using the Spring type wiring, this should be called after all of the set methods.
 void maybeCreateTables()
          Possibly create the tables is the AUTO_CREATE_TABLES system property is set to "true".
 void maybeDropTables()
          Possibly drop the tables that were previously created if the AUTO_DROP_TABLES system property is set to "true".
 void setConfiguredDaos(List<com.j256.ormlite.dao.Dao<?,?>> configuredDaos)
           
 void setConnectionSource(com.j256.ormlite.support.ConnectionSource dataSource)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUTO_CREATE_TABLES

public static final String AUTO_CREATE_TABLES
See Also:
Constant Field Values

AUTO_DROP_TABLES

public static final String AUTO_DROP_TABLES
See Also:
Constant Field Values
Constructor Detail

TableCreator

public TableCreator()

TableCreator

public TableCreator(com.j256.ormlite.support.ConnectionSource connectionSource,
                    List<com.j256.ormlite.dao.Dao<?,?>> configuredDaos)
Method Detail

maybeCreateTables

public void maybeCreateTables()
                       throws SQLException
Possibly create the tables is the AUTO_CREATE_TABLES system property is set to "true".

Throws:
SQLException

initialize

public void initialize()
                throws SQLException
If you are using the Spring type wiring, this should be called after all of the set methods.

Throws:
SQLException

maybeDropTables

public void maybeDropTables()
                     throws SQLException
Possibly drop the tables that were previously created if the AUTO_DROP_TABLES system property is set to "true".

Throws:
SQLException

destroy

public void destroy()
             throws SQLException
Throws:
SQLException

setConnectionSource

public void setConnectionSource(com.j256.ormlite.support.ConnectionSource dataSource)

setConfiguredDaos

public void setConfiguredDaos(List<com.j256.ormlite.dao.Dao<?,?>> configuredDaos)


This content is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.