View Javadoc

1   package org.apache.maven.hibernate.beans;
2   
3   /* ====================================================================
4    *   Copyright 2004 The Apache Software Foundation.
5    *
6    *   Licensed under the Apache License, Version 2.0 (the "License");
7    *   you may not use this file except in compliance with the License.
8    *   You may obtain a copy of the License at
9    *
10   *       http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing, software
13   *   distributed under the License is distributed on an "AS IS" BASIS,
14   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *   See the License for the specific language governing permissions and
16   *   limitations under the License.
17   * ====================================================================
18   */
19  
20  import java.io.FileInputStream;
21  import java.util.Properties;
22  
23  import net.sf.hibernate.cfg.Configuration;
24  import net.sf.hibernate.tool.hbm2ddl.SchemaUpdate;
25  
26  /**
27   * 
28   * The Bean which serves as Proxy To Hibernate SchemaUpdate 
29   * <br/>
30   *   
31   * @author <a href="maven@felipeal.net">Felipe Leme</a> 
32   * @version $Id: SchemaUpdateBean.java 170200 2005-05-15 06:24:19Z brett $
33   */
34  public class SchemaUpdateBean extends SchemaBeanBase
35  {
36     
37     protected void executeSchema(Configuration cfg) throws Exception {
38        SchemaUpdate schemaUpdate = null;
39        if (getProperties() == null)
40        {
41           schemaUpdate = new SchemaUpdate(cfg);
42        }
43        else
44        {
45           Properties properties = new Properties();
46           properties.load(new FileInputStream(getProperties()));
47           schemaUpdate = new SchemaUpdate(cfg, properties);
48        }
49        schemaUpdate.execute( !getQuiet(), !getText() );
50      }
51     
52  }