1 package org.apache.maven.hibernate.beans;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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.SchemaExport;
25
26 /**
27 *
28 * The Bean which serves as Proxy To Hibernate API
29 * <br/>
30 *
31 * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
32 * @version $Id: SchemaExportBean.java 170200 2005-05-15 06:24:19Z brett $
33 */
34 public class SchemaExportBean extends SchemaBeanBase
35 {
36
37 private boolean drop = false;
38
39 /**
40 * @return
41 */
42 public boolean isDrop()
43 {
44 return drop;
45 }
46
47 /**
48 * @param b
49 */
50 public void setDrop(boolean b)
51 {
52 drop = b;
53 }
54
55 protected void executeSchema(Configuration cfg) throws Exception {
56 SchemaExport schemaExport = null;
57 if (getProperties() == null)
58 {
59 schemaExport = new SchemaExport(cfg);
60 }
61 else
62 {
63 Properties properties = new Properties();
64 properties.load(new FileInputStream(getProperties()));
65 schemaExport = new SchemaExport(cfg, properties);
66 }
67 LOG.debug("Output file:" + getOutputFile());
68 schemaExport.setOutputFile(getOutputFile());
69 schemaExport.setDelimiter(getDelimiter());
70 if (isDrop())
71 {
72 schemaExport.drop(!getQuiet(), !getText());
73 }
74 else
75 {
76 schemaExport.create(!getQuiet(), !getText());
77 }
78 }
79
80 }