Source Code Cross Referenced for SchemaCreator.java in  » Web-Framework » webonswing » net » ar » webonswing » petstore » persistence » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » webonswing » net.ar.webonswing.petstore.persistence 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.ar.webonswing.petstore.persistence;
002:
003:        import net.ar.webonswing.petstore.model.*;
004:        import net.sf.hibernate.*;
005:        import net.sf.hibernate.cfg.*;
006:        import net.sf.hibernate.tool.hbm2ddl.*;
007:
008:        public class SchemaCreator {
009:            public static void main(String[] args) throws HibernateException {
010:                Configuration cfg = new Configuration()
011:                        .configure("/hibernate/config/hibernate.cfg.xml");
012:                SessionFactory sessionFactory = cfg.buildSessionFactory();
013:                new SchemaExport(cfg).create(true, true);
014:                Session session = sessionFactory.openSession();
015:                Transaction transaction = session.beginTransaction();
016:
017:                session.save(createFishCategory());
018:                session.save(createDogsCategory());
019:                session.save(createReptilesCategory());
020:                session.save(createCatsCategory());
021:                session.save(createBirdsCategory());
022:
023:                transaction.commit();
024:
025:                session.close();
026:                sessionFactory.close();
027:            }
028:
029:            protected static Category createBirdsCategory() {
030:                Category category5 = new Category("Birds",
031:                        "description of BIRDS");
032:                Product product15 = new Product("AV-CB-01", "Amazon Parrot",
033:                        "Great companion for up to 75 years");
034:                product15.addItem(new Item("EST-25", "Male Adult", 348.50,
035:                        120.00, "bird1"));
036:                product15.addItem(new Item("EST-26", "Female Adult", 348.50,
037:                        120.00, "bird2"));
038:                Product product16 = new Product("AV-SB-02", "Finch",
039:                        "Great stress reliever");
040:                category5.addProduct(product15);
041:                category5.addProduct(product16);
042:                return category5;
043:            }
044:
045:            protected static Category createCatsCategory() {
046:                Category category4 = new Category("Cats", "description of CATS");
047:                Product product13 = new Product("FL-DSH-01", "Manx",
048:                        "Great for reducing mouse populations");
049:                product13.addItem(new Item("EST-23", "Male Adult", 348.50,
050:                        120.00, "cat1"));
051:                product13.addItem(new Item("EST-24", "Female Adult", 348.50,
052:                        120.00, "cat2"));
053:                Product product14 = new Product("FL-DLH-02", "Persian",
054:                        "Friendly house cat, doubles as a princess");
055:                category4.addProduct(product13);
056:                category4.addProduct(product14);
057:                return category4;
058:            }
059:
060:            protected static Category createReptilesCategory() {
061:                Category category3 = new Category("Reptiles",
062:                        "description of REPTILES");
063:                Product product11 = new Product("RP-SN-01", "Rattlesnake",
064:                        "Doubles as a watch dog");
065:                product11.addItem(new Item("EST-21", "Female Adult", 48.50,
066:                        20.00, "lizard1"));
067:                product11.addItem(new Item("EST-22", "Male Adult", 48.50,
068:                        20.00, "lizard2"));
069:                Product product12 = new Product("RP-LI-02", "Iguana",
070:                        "Friendly green friend");
071:                product12.addItem(new Item("EST-221", "Female Adult", 48.50,
072:                        20.00, "lizard3"));
073:                category3.addProduct(product11);
074:                category3.addProduct(product12);
075:                return category3;
076:            }
077:
078:            protected static Category createDogsCategory() {
079:                Category category2 = new Category("Dogs", "description of DOGS");
080:                Product product5 = new Product("K9-BD-01", "Bulldog",
081:                        "Friendly dog from England");
082:                product5.addItem(new Item("EST-9", "Spotless Male Puppy",
083:                        28.50, 22.00, "dog1"));
084:                product5.addItem(new Item("EST-10", "Spotless Female Puppy",
085:                        28.50, 22.00, "dog2"));
086:                Product product6 = new Product("K9-PO-02", "Poodle",
087:                        "Cute dog from France");
088:                product6.addItem(new Item("EST-11", "Spotted Male Puppy",
089:                        48.50, 32.00, "dog3"));
090:                product6.addItem(new Item("EST-12", "Spotted Female Puppy",
091:                        58.50, 32.00, "dog4"));
092:                Product product7 = new Product("K9-DL-01", "Dalmation",
093:                        "Great dog for a fire station");
094:                product7.addItem(new Item("EST-13", "Tailed", 108.50, 62.00,
095:                        "dog5"));
096:                product7.addItem(new Item("EST-14", "Tailless", 108.50, 62.00,
097:                        "dog6"));
098:                Product product8 = new Product("K9-RT-01", "Golden Retriever",
099:                        "Great family dog");
100:                product8.addItem(new Item("EST-15", "Tailed", 158.50, 82.00,
101:                        "dog4"));
102:                product8.addItem(new Item("EST-16", "Tailless", 158.50, 82.00,
103:                        "dog4"));
104:                Product product9 = new Product("K9-RT-02",
105:                        "Labrador Retriever", "Great hunting dog");
106:                product9.addItem(new Item("EST-17", "Tailed", 258.50, 100.00,
107:                        "dog5"));
108:                product9.addItem(new Item("EST-18", "Tailless", 258.50, 100.00,
109:                        "dog5"));
110:                Product product10 = new Product("K9-CW-01", "Chihuahua",
111:                        "Great companion dog");
112:                product10.addItem(new Item("EST-19", "Female Adult", 208.50,
113:                        100.00, "dog6"));
114:                product10.addItem(new Item("EST-20", "Female Adult", 208.50,
115:                        100.00, "dog6"));
116:                category2.addProduct(product5);
117:                category2.addProduct(product6);
118:                category2.addProduct(product7);
119:                category2.addProduct(product8);
120:                category2.addProduct(product9);
121:                category2.addProduct(product10);
122:                return category2;
123:            }
124:
125:            protected static Category createFishCategory() {
126:                Category category1 = new Category("Fish", "description of FISH");
127:                Product product1 = new Product("FI-SW-01", "Angelfish",
128:                        "Saltwater fish from Australia");
129:                product1.addItem(new Item("EST-1", "Large", 16.50, 10.00,
130:                        "fish1"));
131:                product1.addItem(new Item("EST-2", "Thootless", 16.50, 10.00,
132:                        "fish2"));
133:                Product product2 = new Product("FI-SW-02", "Tiger Shark",
134:                        "Saltwater fish from Australia");
135:                product2.addItem(new Item("EST-3", "Spotted", 18.50, 12.00,
136:                        "fish3"));
137:                product2.addItem(new Item("EST-4", "Spotless", 18.50, 12.00,
138:                        "fish4"));
139:                Product product3 = new Product("FI-FW-01", "Koi",
140:                        "Freshwater fish from Japan");
141:                product3.addItem(new Item("EST-5", "Male Adult", 18.50, 12.00,
142:                        "fish3"));
143:                product3.addItem(new Item("EST-6", "Female Adult", 18.50,
144:                        12.00, "fish3"));
145:                Product product4 = new Product("FI-FW-02", "Goldfish",
146:                        "Freshwater fish from China");
147:                product4.addItem(new Item("EST-7", "Male Puppy", 18.50, 12.00,
148:                        "fish4"));
149:                product4.addItem(new Item("EST-8", "Female Puppy", 18.50,
150:                        12.00, "fish4"));
151:                category1.addProduct(product1);
152:                category1.addProduct(product2);
153:                category1.addProduct(product3);
154:                category1.addProduct(product4);
155:
156:                return category1;
157:            }
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.