From: <cs...@us...> - 2002-11-04 00:55:33
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate In directory usw-pr-cvs1:/tmp/cvs-serv31063/cirrus/hibernate Modified Files: Datastore.java Log Message: dynamic schema update Index: Datastore.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/Datastore.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Datastore.java 18 Oct 2002 11:02:19 -0000 1.30 --- Datastore.java 4 Nov 2002 00:55:30 -0000 1.31 *************** *** 1 **** ! //$Id$ package cirrus.hibernate; import java.io.InputStream; import java.util.Properties; import org.w3c.dom.Document; import cirrus.hibernate.sql.Dialect; /** An instance of <tt>Datastore</tt> represents an entire mapping from a set of Java classes to a relational model. Usually an application will configure a single instance of <tt>Datastore</tt>, obtain a single instance of <tt>SessionFactory</tt> and then instantiate <tt>Session</tt>s in threads servicing client requests. The <tt>Datastore</tt> is meant as a configuration-time object.<br> <br> New instances are provided by the factory method <tt>Hibernate.createDatastore()</tt><br> <br> It is not intended that implementors be threadsafe. @see SessionFactory @see Hibernate#createDatastore() */ public interface Datastore { /** Obtain a factory for <tt>Session</tt>s. Connections may be provided by the application or according to System properties. @return SessionFactory @throws HibernateException */ public SessionFactory buildSessionFactory() throws HibernateException; /** Obtain a factory for <tt>Session</tt>s. Connections may be provided by the application or according to the given <tt>Properties</tt>. @param connectionProps connection properties @return SessionFactory @throws HibernateException */ public SessionFactory buildSessionFactory(Properties connectionProps) throws HibernateException; /** Obtain a factory for <tt>Session</tt>s, specifying an <tt>Interceptor</tt>. Connections may be provided by the application or according to System properties. @return SessionFactory @param interceptor a factory-scoped interceptor @throws HibernateException */ public SessionFactory buildSessionFactory(Interceptor interceptor) throws HibernateException; /** Obtain a factory for <tt>Session</tt>s, specifying an <tt>Interceptor</tt>. Connections may be provided by the application or according to the given <tt>Properties</tt>. @param connectionProps connection properties @param interceptor intercepts important session events @return SessionFactory @throws HibernateException */ public SessionFactory buildSessionFactory(Properties connectionProps, Interceptor interceptor) throws HibernateException; /** Load persistence mappings from an XML file. @param xmlFile the filename @return Datastore @throws MappingException */ public Datastore storeFile(String xmlFile) throws MappingException; /** Load persistence mappings from an XML file, using <tt>getResourceAsStream()</tt>. @param path the resource path @param classLoader the <tt>ClassLoader</tt> to use @return Datastore @throws MappingException */ public Datastore storeResource(String path, ClassLoader classLoader) throws MappingException; /** Load persistence mappings from an input stream containing XML. @param xmlInputStream an input stream containing XML data @return Datastore @throws MappingException */ public Datastore storeInputStream(InputStream xmlInputStream) throws MappingException; /** Load persistence mappings from a string containing XML. @param xml @return Datastore @throws MappingException */ public Datastore storeXML(String xml) throws MappingException; /** Load persistence mappings from a parsed XML document. @param doc @return Datastore @throws MappingException */ public Datastore storeDocument(Document doc) throws MappingException; /** Look for a mapping file for the given class using a naming convention. <tt>storeClass(eg.Foo.class)</tt> looks for <tt>eg/Foo.hbm.xml</tt> in the classpath. @param persistentClass the mapped persistent class @return Datastore @throws MappingException */ public Datastore storeClass(Class persistentClass) throws MappingException; /** Look for mapping files in a jar. Any files with names ending in <tt>.hbm.xml</tt> will be assumed to be mapping documents. @param resource the .jar file @return Datastore @throws MappingException */ public Datastore storeJar(String resource) throws MappingException; /** Generates a list of SQL statements that may be used to create the tables needed by this Datastore. @param dialect the script SQL dialect */ public String[] generateSchemaCreationScript(Dialect dialect) throws HibernateException; /** Generates a list of SQL statements that may be used to drop the tables needed by this Datastore. @param dialect the script SQL dialect */ public String[] generateDropSchemaScript(Dialect dialect) throws HibernateException; } \ No newline at end of file --- 1,157 ---- ! //$Id$ ! package cirrus.hibernate; ! ! import java.io.InputStream; ! import java.util.Properties; ! ! import org.w3c.dom.Document; ! import cirrus.hibernate.sql.Dialect; ! ! /** ! An instance of <tt>Datastore</tt> represents an entire mapping from a set of ! Java classes to a relational model. Usually an application will configure a ! single instance of <tt>Datastore</tt>, obtain a single instance of ! <tt>SessionFactory</tt> and then instantiate <tt>Session</tt>s in ! threads servicing client requests. The <tt>Datastore</tt> is meant as a ! configuration-time object.<br> ! <br> ! New instances are provided by the factory method ! <tt>Hibernate.createDatastore()</tt><br> ! <br> ! It is not intended that implementors be threadsafe. ! ! @see SessionFactory ! @see Hibernate#createDatastore() ! */ ! public interface Datastore { ! ! /** ! Obtain a factory for <tt>Session</tt>s. Connections may be provided by the application ! or according to System properties. ! ! @return SessionFactory ! @throws HibernateException ! */ ! public SessionFactory buildSessionFactory() throws HibernateException; ! ! /** ! Obtain a factory for <tt>Session</tt>s. Connections may be provided by the application ! or according to the given <tt>Properties</tt>. ! ! @param connectionProps connection properties ! @return SessionFactory ! @throws HibernateException ! */ ! public SessionFactory buildSessionFactory(Properties connectionProps) ! throws HibernateException; ! ! /** ! Obtain a factory for <tt>Session</tt>s, specifying an <tt>Interceptor</tt>. Connections ! may be provided by the application or according to System properties. ! ! @return SessionFactory ! @param interceptor a factory-scoped interceptor ! @throws HibernateException ! */ ! public SessionFactory buildSessionFactory(Interceptor interceptor) throws HibernateException; ! ! /** ! Obtain a factory for <tt>Session</tt>s, specifying an <tt>Interceptor</tt>. Connections ! may be provided by the application or according to the given <tt>Properties</tt>. ! ! @param connectionProps connection properties ! @param interceptor intercepts important session events ! @return SessionFactory ! @throws HibernateException ! */ ! public SessionFactory buildSessionFactory(Properties connectionProps, Interceptor interceptor) ! throws HibernateException; ! ! /** ! Load persistence mappings from an XML file. ! ! @param xmlFile the filename ! @return Datastore ! @throws MappingException ! */ ! public Datastore storeFile(String xmlFile) throws MappingException; ! ! /** ! Load persistence mappings from an XML file, using <tt>getResourceAsStream()</tt>. ! ! @param path the resource path ! @param classLoader the <tt>ClassLoader</tt> to use ! @return Datastore ! @throws MappingException ! */ ! public Datastore storeResource(String path, ClassLoader classLoader) ! throws MappingException; ! /** ! Load persistence mappings from an input stream containing XML. ! ! @param xmlInputStream an input stream containing XML data ! @return Datastore ! @throws MappingException ! */ ! public Datastore storeInputStream(InputStream xmlInputStream) ! throws MappingException; ! ! /** ! Load persistence mappings from a string containing XML. ! ! @param xml ! @return Datastore ! @throws MappingException ! */ ! public Datastore storeXML(String xml) throws MappingException; ! ! /** ! Load persistence mappings from a parsed XML document. ! ! @param doc ! @return Datastore ! @throws MappingException ! */ ! public Datastore storeDocument(Document doc) throws MappingException; ! ! /** ! Look for a mapping file for the given class using a naming convention. ! <tt>storeClass(eg.Foo.class)</tt> looks for <tt>eg/Foo.hbm.xml</tt> in ! the classpath. ! ! @param persistentClass the mapped persistent class ! @return Datastore ! @throws MappingException ! */ ! public Datastore storeClass(Class persistentClass) throws MappingException; ! ! /** ! Look for mapping files in a jar. Any files with names ending in <tt>.hbm.xml</tt> ! will be assumed to be mapping documents. ! ! @param resource the .jar file ! @return Datastore ! @throws MappingException ! */ ! public Datastore storeJar(String resource) throws MappingException; ! ! /** ! Generates a list of SQL statements that may be used to create the tables ! needed by this Datastore. ! ! @param dialect the script SQL dialect ! */ ! public String[] generateSchemaCreationScript(Dialect dialect) ! throws HibernateException; ! ! /** ! Generates a list of SQL statements that may be used to drop the tables ! needed by this Datastore. ! ! @param dialect the script SQL dialect ! */ ! public String[] generateDropSchemaScript(Dialect dialect) ! throws HibernateException; ! String[] generateSchemaUpdateScript(Dialect dialect, java.util.Map tableColumnInfo) throws HibernateException; ! ! } |