comparison flys-backend/src/main/java/de/intevation/flys/App.java @ 174:249390dd24e7

Added foreign key constraint annotations to model classes. flys-backend/trunk@1473 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 15 Mar 2011 14:49:56 +0000
parents 7929f4144d2f
children bc3747a371cc
comparison
equal deleted inserted replaced
173:8e2f2ddc507f 174:249390dd24e7
2 2
3 import org.hibernate.cfg.Configuration; 3 import org.hibernate.cfg.Configuration;
4 4
5 import org.hibernate.SessionFactory; 5 import org.hibernate.SessionFactory;
6 6
7 import de.intevation.flys.model.Annotation;
8 import de.intevation.flys.model.Attribute;
9 import de.intevation.flys.model.DischargeTable;
10 import de.intevation.flys.model.DischargeTableValue;
11 import de.intevation.flys.model.Gauge;
12 import de.intevation.flys.model.MainValueType;
13 import de.intevation.flys.model.NamedMainValues;
14 import de.intevation.flys.model.Position;
15 import de.intevation.flys.model.Range;
7 import de.intevation.flys.model.River; 16 import de.intevation.flys.model.River;
17 import de.intevation.flys.model.TimeInterval;
18 import de.intevation.flys.model.WstColumn;
19 import de.intevation.flys.model.WstColumnQRange;
20 import de.intevation.flys.model.WstColumnValue;
21 import de.intevation.flys.model.Wst;
22 import de.intevation.flys.model.WstQRange;
8 23
9 import org.hibernate.dialect.resolver.DialectFactory; 24 import org.hibernate.dialect.resolver.DialectFactory;
10 25
11 import java.util.Properties; 26 import java.util.Properties;
12 27
20 System.getProperty("flys.user", "flys"); 35 System.getProperty("flys.user", "flys");
21 36
22 private static final String PASS = 37 private static final String PASS =
23 System.getProperty("flys.pass", "flys"); 38 System.getProperty("flys.pass", "flys");
24 39
25 public static void main(String [] args) 40 public static void dumpSchema(Configuration cfg) {
26 throws Exception 41 System.out.println("BEGIN;");
27 {
28 Configuration cfg = new Configuration();
29
30 cfg.addAnnotatedClass(River.class);
31 42
32 String [] setupScript = cfg.generateSchemaCreationScript( 43 String [] setupScript = cfg.generateSchemaCreationScript(
33 DialectFactory.constructDialect( 44 DialectFactory.constructDialect(
34 "org.hibernate.dialect.PostgreSQLDialect")); 45 "org.hibernate.dialect.PostgreSQLDialect"));
35 46
36 for (String line: setupScript) { 47 for (String line: setupScript) {
37 System.out.println(line); 48 System.out.println(line + ";");
38 } 49 }
39 50
51 System.out.println("COMMIT;");
52 }
53
54 public static void main(String [] args)
55 throws Exception
56 {
57 Configuration cfg = new Configuration();
58
59 cfg.addAnnotatedClass(Annotation.class);
60 cfg.addAnnotatedClass(Attribute.class);
61 cfg.addAnnotatedClass(DischargeTable.class);
62 cfg.addAnnotatedClass(DischargeTableValue.class);
63 cfg.addAnnotatedClass(Gauge.class);
64 cfg.addAnnotatedClass(MainValueType.class);
65 cfg.addAnnotatedClass(NamedMainValues.class);
66 cfg.addAnnotatedClass(Position.class);
67 cfg.addAnnotatedClass(Range.class);
68 cfg.addAnnotatedClass(River.class);
69 cfg.addAnnotatedClass(TimeInterval.class);
70 cfg.addAnnotatedClass(WstColumn.class);
71 cfg.addAnnotatedClass(WstColumnQRange.class);
72 cfg.addAnnotatedClass(WstColumnValue.class);
73 cfg.addAnnotatedClass(Wst.class);
74 cfg.addAnnotatedClass(WstQRange.class);
40 Properties props = new Properties(); 75 Properties props = new Properties();
76
77 dumpSchema(cfg);
41 78
42 props.setProperty( 79 props.setProperty(
43 Environment.DIALECT, 80 Environment.DIALECT,
44 "org.hibernate.dialect.PostgreSQLDialect"); 81 "org.hibernate.dialect.PostgreSQLDialect");
45 82

http://dive4elements.wald.intevation.org